Inherits YGP::AttributValue.
Public Member Functions | |
ANumeric () | |
ANumeric (const ANumeric &other) | |
ANumeric (const unsigned int val) | |
ANumeric (const unsigned long val) | |
ANumeric (const int val) | |
ANumeric (const long val) | |
ANumeric (const char *pValue) throw (std::invalid_argument) | |
ANumeric (const std::string &str) throw (std::invalid_argument) | |
virtual | ~ANumeric () |
virtual void | define () |
virtual std::string | toString () const |
virtual std::string | toUnformattedString () const |
virtual void | readFromStream (std::istream &in) throw (std::invalid_argument) |
Assignment methods | |
ANumeric & | operator= (const int val) |
ANumeric & | operator= (const unsigned int val) |
ANumeric & | operator= (const unsigned long val) |
ANumeric & | operator= (const long val) |
ANumeric & | operator= (const std::string &value) throw (std::invalid_argument) |
ANumeric & | operator= (const char *pValue) throw (std::invalid_argument) |
ANumeric & | operator= (const ANumeric &other) |
Comparison | |
bool | operator== (const ANumeric &other) const |
bool | operator!= (const ANumeric &other) const |
bool | operator< (const ANumeric &other) const |
bool | operator> (const ANumeric &other) const |
bool | operator<= (const ANumeric &other) const |
bool | operator>= (const ANumeric &other) const |
int | compare (const ANumeric &other) const |
bool | operator== (int other) const |
bool | operator!= (int other) const |
bool | operator< (int other) const |
bool | operator> (int other) const |
bool | operator<= (int other) const |
bool | operator>= (int other) const |
Convertion | |
operator long int () const | |
operator unsigned long int () const | |
operator int () const | |
operator unsigned int () const | |
operator short int () const | |
operator unsigned short int () const | |
static std::string | toString (int value) |
static std::string | toString (unsigned int value) |
static std::string | toString (short value) |
static std::string | toString (unsigned short value) |
static std::string | toString (long value) |
static std::string | toString (unsigned long value) |
Calculation | |
ANumeric & | operator+= (const ANumeric &rhs) |
ANumeric & | operator-= (const ANumeric &rhs) |
ANumeric & | operator*= (const ANumeric &rhs) |
ANumeric & | operator/= (const ANumeric &rhs) |
ANumeric | operator+ (const ANumeric &lhs, const ANumeric &rhs) |
ANumeric | operator- (const ANumeric &lhs, const ANumeric &rhs) |
ANumeric | operator* (const ANumeric &lhs, const ANumeric &rhs) |
ANumeric | operator/ (const ANumeric &lhs, const ANumeric &rhs) |
As every AttributValue is supports undefined values.
Furthermore the range is unlimitted (thanks to GNUs Multi Precission library. That also means, that if this library is not available, only longs (or long longs, if they are supported) are used!)
YGP::ANumeric::ANumeric | ( | ) | [inline] |
Default constructor; creates an undefined number.
YGP::ANumeric::ANumeric | ( | const ANumeric & | other | ) | [inline] |
Copy constructor.
YGP::ANumeric::ANumeric | ( | const unsigned int | val | ) | [inline] |
Constructor; initializes the object with the passed value and defines it.
YGP::ANumeric::ANumeric | ( | const unsigned long | val | ) | [inline] |
Constructor; initializes the object with the passed value and defines it.
YGP::ANumeric::ANumeric | ( | const int | val | ) | [inline] |
Constructor; initializes the object with the passed value and defines it.
YGP::ANumeric::ANumeric | ( | const long | val | ) | [inline] |
Constructor; initializes the object with the passed value and defines it.
YGP::ANumeric::ANumeric | ( | const char * | pValue | ) | throw (std::invalid_argument) [inline] |
Constructor; initializes the object from the passed text and defines it.
YGP::ANumeric::ANumeric | ( | const std::string & | str | ) | throw (std::invalid_argument) [inline] |
Constructor; initializes the object from the passed text and defines it.
YGP::ANumeric::~ANumeric | ( | ) | [virtual] |
Destructor.
int YGP::ANumeric::compare | ( | const ANumeric & | other | ) | const |
Returns -1 if this is less then other, 0 if they are equal or 1 if this is larger.
Undefined values are considered as larger than any number for this comparison (so that defined values are sorted before undefined ones); if both values are undefined they are considered as equal.
other | Object to compare |
void YGP::ANumeric::define | ( | ) | [virtual] |
YGP::ANumeric::operator int | ( | ) | const [inline] |
Convertion to a number.
YGP::ANumeric::operator long int | ( | ) | const [inline] |
Convertion to a number.
YGP::ANumeric::operator short int | ( | ) | const [inline] |
Convertion to a number.
YGP::ANumeric::operator unsigned int | ( | ) | const [inline] |
Convertion to a number.
YGP::ANumeric::operator unsigned long int | ( | ) | const [inline] |
Convertion to a number.
YGP::ANumeric::operator unsigned short int | ( | ) | const [inline] |
Convertion to a number.
bool YGP::ANumeric::operator!= | ( | int | other | ) | const [inline] |
Checks if two objects are not equal. See compare() for details.
bool YGP::ANumeric::operator!= | ( | const ANumeric & | other | ) | const [inline] |
Checks if two objects are not equal. See compare() for details.
Multiplies another number-object to this object.
An undefined number is treated as "1"; so only if both objects are undefined, the result is (remains) undefined.
rhs | Value to multiply |
Adds another number-object to this object.
An undefined number is treated as "0"; so only if both objects are undefined, the result is (remains) undefined.
rhs | Value to add |
Substracts another number-object from this object.
An undefined number is treated as "0"; so only if both objects are undefined, the result is (remains) undefined.
rhs | Value to substract |
Divides this by another number-object.
An undefined number is treated as "1"; so only if both objects are undefined, the result is (remains) undefined.
rhs | Value to divide with |
bool YGP::ANumeric::operator< | ( | int | other | ) | const [inline] |
Checks if one object is smaller than another. See compare() for details.
bool YGP::ANumeric::operator< | ( | const ANumeric & | other | ) | const [inline] |
Checks if one object is smaller than another. See compare() for details.
bool YGP::ANumeric::operator<= | ( | int | other | ) | const [inline] |
Checks if one object is smaller than or equan to another. See compare() for details.
bool YGP::ANumeric::operator<= | ( | const ANumeric & | other | ) | const [inline] |
Checks if one object is smaller than or equan to another. See compare() for details.
ANumeric & YGP::ANumeric::operator= | ( | const char * | pValue | ) | throw (std::invalid_argument) |
Assignmentoperator; tries to extract an integer-value from the passed value.
pValue must not be a NULL-pointer, may have leading white-spaces which may follow a sign (plus (+) or minus (-)) followed by numeric characters and a zero-characer (\0).
Any locale-related separaters are stripped out.
If pValue has a different format an excpetion is thrown.
pValue | Pointer to ASCIIZ-string containing numeric value to assign |
invalid_argument | in case of an exception |
pValue
a valid ASCIIZ-string ANumeric& YGP::ANumeric::operator= | ( | const std::string & | value | ) | throw (std::invalid_argument) [inline] |
Assign the value from the passed text.
ANumeric& YGP::ANumeric::operator= | ( | const long | val | ) | [inline] |
Assigning from a value
ANumeric& YGP::ANumeric::operator= | ( | const unsigned long | val | ) | [inline] |
Assigning from a value
ANumeric& YGP::ANumeric::operator= | ( | const unsigned int | val | ) | [inline] |
Assigning from a value
ANumeric& YGP::ANumeric::operator= | ( | const int | val | ) | [inline] |
Assigning from a value.
bool YGP::ANumeric::operator== | ( | int | other | ) | const [inline] |
Checks if two objects are equal. See compare() for details.
bool YGP::ANumeric::operator== | ( | const ANumeric & | other | ) | const [inline] |
Checks if two objects are equal. See compare() for details.
bool YGP::ANumeric::operator> | ( | int | other | ) | const [inline] |
Checks if one object is bigger than another. See compare() for details.
bool YGP::ANumeric::operator> | ( | const ANumeric & | other | ) | const [inline] |
Checks if one object is bigger than another. See compare() for details.
bool YGP::ANumeric::operator>= | ( | int | other | ) | const [inline] |
Checks if one object is bigger than or equan to another. See compare() for details.
bool YGP::ANumeric::operator>= | ( | const ANumeric & | other | ) | const [inline] |
Checks if one object is bigger than or equan to another. See compare() for details.
void YGP::ANumeric::readFromStream | ( | std::istream & | in | ) | throw (std::invalid_argument) [virtual] |
Reads a numeric value from a stream.
If the input is not valid, an excpetion is thrown.
in | Stream to parse |
Implements YGP::AttributValue.
static std::string YGP::ANumeric::toString | ( | unsigned long | value | ) | [inline, static] |
Convertion to a std::string
static std::string YGP::ANumeric::toString | ( | long | value | ) | [inline, static] |
Convertion to a std::string
static std::string YGP::ANumeric::toString | ( | unsigned short | value | ) | [inline, static] |
Convertion to a std::string
static std::string YGP::ANumeric::toString | ( | short | value | ) | [inline, static] |
Convertion to a std::string
static std::string YGP::ANumeric::toString | ( | unsigned int | value | ) | [inline, static] |
Convertion to a std::string
static std::string YGP::ANumeric::toString | ( | int | value | ) | [inline, static] |
Convertion to a std::string
std::string YGP::ANumeric::toString | ( | ) | const [virtual] |
Converts the number into a string, in the format specified by the current locale.
Reimplemented from YGP::AttributValue.
std::string YGP::ANumeric::toUnformattedString | ( | ) | const [virtual] |
Converts the number into a string without any formatting.
Reimplemented from YGP::AttributValue.
Multiplies rhs and lhs and returns the result.
If one object is defined, the other is treated as "1"; so only if both objects are undefined, the result is undefined.
lhs | Left-hand-side of mulitplication | |
rhs | Right-hand-side of mulitplication |
Adds lhs and rhs and returns the result.
If one object is defined, the other object is treated as "0"; so only if both objects are undefined, the result is undefined.
lhs | Left-hand-side of addition | |
rhs | Right-hand-side of addition |
Substracts rhs from lhs and returns the result.
If one object is defined, the other is is treated as "0"; so only if both objects are undefined, the result is undefined.
lhs | Left-hand-side of substraction | |
rhs | Right-hand-side of substraction |
Divides this by another number-object.
If only one object is defined, the other is treated as "1"; so only if both objects are undefined, the result is undefined.
lhs | Left-hand-side of division | |
rhs | Right-hand-side of division |