mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-09 04:41:16 +00:00
Fixed several bugs from the new file i/o setup.
In particular: 1. Windows CR/LF weren't read properly (issue #11) 2. Scanning wasn't reading EOF properly 3. Documents may be empty (this was old, I think) Also fixed some VS2008 warnings on /W4.
This commit is contained in:
15
src/stream.h
15
src/stream.h
@@ -5,6 +5,19 @@
|
||||
|
||||
namespace YAML
|
||||
{
|
||||
// a simple buffer wrapper that knows how big it is
|
||||
struct Buffer {
|
||||
Buffer(char *b, int s): buffer(b), size(s) {}
|
||||
|
||||
operator bool() const { return size > 0; }
|
||||
bool operator !() const { return !static_cast <bool> (*this); }
|
||||
char operator [] (int i) const { return buffer[i]; }
|
||||
const Buffer operator + (int offset) const { return Buffer(buffer + offset, size - offset); }
|
||||
|
||||
char *buffer;
|
||||
int size;
|
||||
};
|
||||
|
||||
class Stream
|
||||
{
|
||||
public:
|
||||
@@ -14,7 +27,7 @@ namespace YAML
|
||||
operator bool() const;
|
||||
bool operator !() const { return !static_cast <bool>(*this); }
|
||||
|
||||
const char *current() const { return buffer + pos; }
|
||||
const Buffer current() const { return Buffer(buffer + pos, size - pos); }
|
||||
char peek();
|
||||
char get();
|
||||
std::string get(int n);
|
||||
|
Reference in New Issue
Block a user