Pig: Added ::getNumber(double&)

This commit is contained in:
Paul Beckingham 2015-12-30 10:07:01 -05:00
parent 836cffbc35
commit 691b481ee6
2 changed files with 15 additions and 0 deletions

View file

@ -30,6 +30,7 @@
#include <utf8.h>
#include <sstream>
#include <cinttypes>
#include <cstdlib>
////////////////////////////////////////////////////////////////////////////////
Pig::Pig (const std::string& text)
@ -236,6 +237,19 @@ bool Pig::getNumber (std::string& result)
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool Pig::getNumber (double& result)
{
std::string s;
if (getNumber (s))
{
result = std::strtof (s.c_str (), NULL);
return true;
}
return false;
}
////////////////////////////////////////////////////////////////////////////////
bool Pig::getRemainder (std::string& result)
{

View file

@ -42,6 +42,7 @@ public:
bool getDigit (int&);
bool getDigits (int&);
bool getNumber (std::string&);
bool getNumber (double&);
bool getRemainder (std::string&);
bool eos () const;