Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
mie::local Namespace Reference

Classes

struct  addsubmul
 
struct  comparable
 
struct  dividable
 
struct  Empty
 
class  FixedBuffer
 
struct  hasNegative
 
struct  inversible
 
struct  PrimitiveFunction
 
struct  shiftable
 
class  VariableBuffer
 

Functions

std::istream & getDigits (std::istream &is, std::string &str, bool allowNegative=false)
 

Function Documentation

◆ getDigits()

std::istream & mie::local::getDigits ( std::istream & is,
std::string & str,
bool allowNegative = false )
inline

Definition at line 84 of file zm.h.

85{
86 std::ios_base::fmtflags keep = is.flags();
87 size_t pos = 0;
88 char c;
89 while (is >> c) {
90 if (('0' <= c && c <= '9') /* digits */
91 || (pos == 1 && (str[0] == '0' && c == 'x')) /* 0x.. */
92 || ('a' <= c && c <= 'f') /* lowercase hex */
93 || ('A' <= c && c <= 'F') /* uppercase hex */
94 || (allowNegative && pos == 0 && c == '-')) { /* -digits */
95 str.push_back(c);
96 if (pos == 0) {
97 is >> std::noskipws;
98 }
99 pos++;
100 } else {
101 is.unget();
102 break;
103 }
104 }
105 is.flags(keep);
106 return is;
107}