mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
Pig: Added ::getNumber(double&)
This commit is contained in:
parent
836cffbc35
commit
691b481ee6
2 changed files with 15 additions and 0 deletions
14
src/Pig.cpp
14
src/Pig.cpp
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue