mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Pit: Added ::save, ::restore
This commit is contained in:
parent
8db517528f
commit
da072c17d4
2 changed files with 18 additions and 0 deletions
15
src/Pig.cpp
15
src/Pig.cpp
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue