Open GoogleCodeExporter opened 9 years ago
You're right, this is the current behavior of the library - you should only use
one parser on a given stream, and use GetNextDocument to iterate through the
documents.
That said, it's not a bad idea to have a parser only read one document at a
time from a stream. I'm not sure when I can get to this, but I'll keep it in
mind.
Original comment by jbe...@gmail.com
on 23 Jan 2012 at 6:15
Original comment by jbe...@gmail.com
on 18 May 2012 at 6:32
Original comment by jbe...@gmail.com
on 19 May 2012 at 9:08
Issue 160 has been merged into this issue.
Original comment by jbe...@gmail.com
on 27 May 2012 at 7:14
As people use Yaml more and more, you're going to see people running into this
bug more and more.
The reason is simple - people want to use Yaml to communicate, between
processes or between network node. One of my applications uses socket
connections to send packets of Yaml information up and down the wire. In
another, a Python application sends commands to a C++ subprocess as packets of
Yaml data.
Yaml was clearly designed for streaming - the existence of the --- and ...
lines should make that clear, but if you try to read the entire "document"
before it starts it can't stream!
An interesting note is that at least one other Yaml parser, pyyaml/libyaml, has
a different but related issue that also causes trouble. It doesn't actually
greedily suck down the entirely stream, but what it does do is not to write the
separating --- string until the *next* packet appears. This means of course
that the last packet in any stream hangs up the parser, because it never sees
the ---...
All their work seems to be thinking of parsing documents, too, but these days,
I have fewer documents and a lot more "requests through the internet."
Original comment by tom.ritc...@gmail.com
on 11 Apr 2013 at 8:07
But what I came here really to say was that a workaround to this is very simple
in user code.
You just send and receive one chunk of Yaml at a time and synthesize your own
--- markers. You need to search for exactly \n--- on the incoming stream
(some Yaml parsers don't write the closing \n for that --- line), chunk the
input, and send those chunks to your parsing code, and similarly for the
reverse direction.
Original comment by tom.ritc...@gmail.com
on 11 Apr 2013 at 8:11
Issue 206 has been merged into this issue.
Original comment by jbe...@gmail.com
on 6 Jun 2013 at 3:52
I attach a small patch against stream.cpp and singledocparser.cpp, which makes
possible to call YAML::Load(std::istream&) multiple times on the same input, so
that each document is returned as soon as it is complete.
The modifications are:
- make Stream::GetNextByte read only the available number of character from the
source istream(buf);
- make SingleDocParser::HandleDocument eat stray DOC_END tokens at the
beginning of its execution.
I did not test this patch extensively, but send it anyway just in case someone
finds it useful.
Original comment by pin...@gmail.com
on 14 Aug 2014 at 3:14
Attachments:
... here is a better patch against version 0.5.1.
The Loader class allows to read multiple documents from the same input stream
(tested using std::cin and a std::ifstream)
Original comment by pin...@gmail.com
on 18 Aug 2014 at 2:25
Attachments:
Original issue reported on code.google.com by
phil.s.s...@gmail.com
on 23 Jan 2012 at 12:08Attachments: