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:
Jesse Beder
2009-02-07 07:57:13 +00:00
parent f9c0725684
commit 9d0e0c6a48
13 changed files with 85 additions and 63 deletions

View File

@@ -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);