YGP::ANumeric Class Reference

Class for numeric attributes. More...

Inherits YGP::AttributValue.

List of all members.

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
ANumericoperator= (const int val)
ANumericoperator= (const unsigned int val)
ANumericoperator= (const unsigned long val)
ANumericoperator= (const long val)
ANumericoperator= (const std::string &value) throw (std::invalid_argument)
ANumericoperator= (const char *pValue) throw (std::invalid_argument)
ANumericoperator= (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

ANumericoperator+= (const ANumeric &rhs)
ANumericoperator-= (const ANumeric &rhs)
ANumericoperator*= (const ANumeric &rhs)
ANumericoperator/= (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)


Detailed Description

Class for numeric attributes.

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!)


Constructor & Destructor Documentation

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.


Member Function Documentation

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.

Parameters:
other Object to compare
Returns:
1 if this > other; 0 if this == other; -1 else

void YGP::ANumeric::define (  )  [virtual]

Defines the object and sets the value to 0.

Implements YGP::AttributValue.

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.

ANumeric & YGP::ANumeric::operator*= ( const ANumeric rhs  ) 

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.

Parameters:
rhs Value to multiply
Returns:
ANumeric& Self

ANumeric & YGP::ANumeric::operator+= ( const ANumeric rhs  ) 

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.

Parameters:
rhs Value to add
Returns:
ANumeric& Self

ANumeric & YGP::ANumeric::operator-= ( const ANumeric rhs  ) 

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.

Parameters:
rhs Value to substract
Returns:
ANumeric& Self

ANumeric & YGP::ANumeric::operator/= ( const ANumeric rhs  ) 

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.

Parameters:
rhs Value to divide with
Returns:
ANumeric& Self
Remarks:
If rhs is not defined this is not changed; if this is not defined, it is set to 1/rhs

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 ANumeric other  ) 

Assignment-operator from another ANumeric object.

Parameters:
other Object to copy
Returns:
ANumeric& Reference to self

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.

Parameters:
pValue Pointer to ASCIIZ-string containing numeric value to assign
Exceptions:
invalid_argument in case of an exception
Precondition:
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.

Parameters:
in Stream to parse
Remarks:
  • Leading whitespaces in the stream are skipped.
  • Parsing is stopped at EOF or at any non-digit.

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.

Returns:
std::string String-representation of ANumeric
Remarks:
Initializes the locale-definition (if not already done)

Reimplemented from YGP::AttributValue.

std::string YGP::ANumeric::toUnformattedString (  )  const [virtual]

Converts the number into a string without any formatting.

Returns:
std::string String-representation of ANumeric

Reimplemented from YGP::AttributValue.


Friends And Related Function Documentation

ANumeric operator* ( const ANumeric lhs,
const ANumeric rhs 
) [friend]

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.

Parameters:
lhs Left-hand-side of mulitplication
rhs Right-hand-side of mulitplication
Returns:
ANumeric Result of mulitplication

ANumeric operator+ ( const ANumeric lhs,
const ANumeric rhs 
) [friend]

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.

Parameters:
lhs Left-hand-side of addition
rhs Right-hand-side of addition
Returns:
ANumeric Result of additon Note : Undefined values are ignored

ANumeric operator- ( const ANumeric lhs,
const ANumeric rhs 
) [friend]

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.

Parameters:
lhs Left-hand-side of substraction
rhs Right-hand-side of substraction
Returns:
ANumeric Result of substraction Note : Undefined values are ignored

ANumeric operator/ ( const ANumeric lhs,
const ANumeric rhs 
) [friend]

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.

Parameters:
lhs Left-hand-side of division
rhs Right-hand-side of division
Returns:
ANumeric Result of division


The documentation for this class was generated from the following files:

YGP Version 0.9.31 - Generated on Wed Nov 18 11:25:27 2009 by doxygen 1.5.8