Pit: Added ::save, ::restore

This commit is contained in:
Paul Beckingham 2015-12-30 10:37:07 -05:00
parent 8db517528f
commit da072c17d4
2 changed files with 18 additions and 0 deletions

View file

@ -36,6 +36,7 @@
Pig::Pig (const std::string& text)
: _text (text)
, _cursor (0)
, _saved (0)
{
}
@ -287,6 +288,20 @@ std::string Pig::peek (const int quantity) const
return "";
}
////////////////////////////////////////////////////////////////////////////////
// Note: never called internally, otherwise the client cannot rely on iṫ.
std::string::size_type Pig::save ()
{
return _saved = _cursor;
}
////////////////////////////////////////////////////////////////////////////////
// Note: never called internally, otherwise the client cannot rely on iṫ.
std::string::size_type Pig::restore ()
{
return _cursor = _saved;
}
////////////////////////////////////////////////////////////////////////////////
std::string Pig::dump () const
{

View file

@ -48,12 +48,15 @@ public:
bool eos () const;
int peek () const;
std::string peek (const int) const;
std::string::size_type save ();
std::string::size_type restore ();
std::string dump () const;
private:
const std::string& _text;
std::string::size_type _cursor;
std::string::size_type _saved;
};
#endif