stream.cpp 729 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "stream.h"

namespace YAML
{
	// GetChar
	// . Extracts a character from the stream and updates our position
	char Stream::GetChar()
	{
		char ch = input.get();
		column++;
		if(ch == '\n') {
			column = 0;
			line++;
		}
		return ch;
	}

	// GetChar
	// . Extracts 'n' characters from the stream and updates our position
	std::string Stream::GetChar(int n)
	{
		std::string ret;
		for(int i=0;i<n;i++)
			ret += GetChar();
		return ret;
	}

	// Eat
	// . Eats 'n' characters and updates our position.
	void Stream::Eat(int n)
	{
		for(int i=0;i<n;i++)
			GetChar();
	}

	// GetLineBreak
	// . Eats with no checking
	void Stream::EatLineBreak()
	{
		Eat(1);
		column = 0;
	}
}