-
Notifications
You must be signed in to change notification settings - Fork 64
SL-18330: Send binary LLSD to LEAP plugins; extend LLSD compatibility. #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
abe62c2
42e0787
b180e4d
2f557cd
761d833
590e158
6ef3df5
aec39a0
224667e
292bb39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -513,3 +513,29 @@ std::istream& operator>>(std::istream& str, const char *tocheck) | |
} | ||
return str; | ||
} | ||
|
||
int cat_streambuf::underflow() | ||
{ | ||
if (gptr() == egptr()) | ||
{ | ||
// here because our buffer is empty | ||
std::streamsize size = 0; | ||
// Until we've run out of mInputs, try reading the first of them | ||
// into mBuffer. If that fetches some characters, break the loop. | ||
while (! mInputs.empty() | ||
&& ! (size = mInputs.front()->sgetn(mBuffer.data(), mBuffer.size()))) | ||
{ | ||
// We tried to read mInputs.front() but got zero characters. | ||
// Discard the first streambuf and try the next one. | ||
mInputs.pop_front(); | ||
} | ||
// Either we ran out of mInputs or we succeeded in reading some | ||
// characters, that is, size != 0. Tell base class what we have. | ||
setg(mBuffer.data(), mBuffer.data(), mBuffer.data() + size); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well spotted. Will fix. |
||
} | ||
// If we fell out of the above loop with mBuffer still empty, return | ||
// eof(), otherwise return the next character. | ||
return (gptr() == egptr()) | ||
? std::char_traits<char>::eof() | ||
: std::char_traits<char>::to_int_type(*gptr()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is possible to have more than one '\n' or '\r' right at the end, right? This only deletes on of them. It seems to me you would want to delete them all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a really excellent point! I'm glad you raised it.
erase(iterator)
calls the overload that erases only a single character.erase(size_type)
calls the(size_type, count)
overload whose defaultcount
erases to the end of the string. That's what I intend, and that's what I'm calling here, becausefind_last_not_of()
returnssize_type
.But the confusion is perfectly natural given that I declared
auto lastchar = ...
In order to distinguish theerase()
overloads, the reader must either remember or look up the type returned byfind_last_not_of()
.I will (a) declare
size_type
explicitly, and (b) add a comment explaining whicherase()
overload that invokes.