mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 14:01:25 +12:00
Moved the input stream, together with line/column info, into its own class, which allowed some other stuff just to pass the stream, and not have to be a member of Scanner.
This commit is contained in:
parent
0d5a97bffe
commit
ff99f85a6d
13 changed files with 162 additions and 142 deletions
43
stream.cpp
Normal file
43
stream.cpp
Normal file
|
@ -0,0 +1,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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue