diff --git a/src/Pig.cpp b/src/Pig.cpp index 283c1eae..a8fe63fd 100644 --- a/src/Pig.cpp +++ b/src/Pig.cpp @@ -38,6 +38,24 @@ Pig::Pig (const std::string& text) { } +//////////////////////////////////////////////////////////////////////////////// +bool Pig::skipN (const int quantity) +{ + auto save = _cursor; + + auto count = 0; + while (count++ < quantity) + { + if (! utf8_next_char (_text, _cursor)) + { + _cursor = save; + return false; + } + } + + return true; +} + //////////////////////////////////////////////////////////////////////////////// bool Pig::skipWS () { diff --git a/src/Pig.h b/src/Pig.h index 0886e6e3..8bb51781 100644 --- a/src/Pig.h +++ b/src/Pig.h @@ -34,6 +34,7 @@ class Pig public: Pig (const std::string&); + bool skipN (const int quantity = 1); bool skipWS (); bool getDigit (int&);