YGP::AYear Class Reference

Class for year attributes. More...

Inherits YGP::AttributValue.

Inherited by YGP::ADate.

List of all members.

Public Member Functions

 AYear ()
 AYear (const AYear &other)
 AYear (int Year)
 AYear (const char *pYear) throw (std::invalid_argument)
 AYear (const std::string &year) throw (std::invalid_argument)
virtual ~AYear ()
virtual void define ()
Assignment methods
AYearoperator= (const std::string &year) throw (std::invalid_argument)
AYearoperator= (const AYear &other)
AYearoperator= (const char *pValue) throw (std::invalid_argument)
AYearoperator= (int Year)
virtual void readFromStream (std::istream &in) throw (std::invalid_argument)
Query methods
 operator int () const
Convertion
virtual std::string toUnformattedString () const
Comparison
bool operator== (const AYear &other) const
bool operator!= (const AYear &other) const
bool operator< (const AYear &other) const
bool operator> (const AYear &other) const
bool operator<= (const AYear &other) const
bool operator>= (const AYear &other) const
long compare (const AYear &other) const

Protected Attributes

int year

Calculation

AYearoperator+= (const AYear &rhs)
AYearoperator-= (const AYear &rhs)
AYear operator+ (const AYear &lhs, const AYear &rhs)
AYear operator- (const AYear &lhs, const AYear &rhs)

Usefull utility-functions

bool isLeapYear () const
static bool isLeapYear (int year)


Detailed Description

Class for year attributes.

As every AttributValue is supports undefined values.


Constructor & Destructor Documentation

YGP::AYear::AYear (  )  [inline]

Default constructor; creates an undefined object.

YGP::AYear::AYear ( const AYear other  )  [inline]

Copy constructor from another year object.

YGP::AYear::AYear ( int  Year  )  [inline]

Parameters:
Year Constructor; sets the passed year

YGP::AYear::AYear ( const char *  pYear  )  throw (std::invalid_argument) [inline]

Constructor from a text.

YGP::AYear::AYear ( const std::string &  year  )  throw (std::invalid_argument) [inline]

Constructor from a text.

YGP::AYear::~AYear (  )  [virtual]

Destructor.


Member Function Documentation

long YGP::AYear::compare ( const AYear other  )  const

Returns the (approximated) difference in days between two years.

"Younger years" (closer to the past) are considered bigger than "older years" (further in the past; that means the numeric value of the year is compared (e.g.: "last year" < "this year" < "next year").

If both years are undefined, their difference is "0", if only this is undefined the result is -1; if other is undefined 1 is returned.

Parameters:
other Object to compare
Returns:
long >0 if this "younger" other; 0 if this == other; <0 else

virtual void YGP::AYear::define (  )  [inline, virtual]

Defining the object; setting it to a default value (of 1900).

Implements YGP::AttributValue.

Reimplemented in YGP::ADate, and YGP::ATimestamp.

bool YGP::AYear::isLeapYear (  )  const [inline]

Tests, if the actual year is a leap year

bool YGP::AYear::isLeapYear ( int  year  )  [static]

Returns the maximal day of the specified month (in the passed year).

Checks if the passed year is a leap-year (years which can be divided by 4; except if it is also divideable by 100).

Parameters:
year Year to check
Returns:
bool True, if leap-year

YGP::AYear::operator int (  )  const [inline]

Casting to an int.

bool YGP::AYear::operator!= ( const AYear other  )  const [inline]

Compares if two objects are not equal

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

Adds another year-value to the year-object.

An undefined year is treated as 0.0.0; so only if both objects are undefined, the result is (remains) undefined. Overflows (of day or month) are corrected.

Parameters:
rhs Value to add
Returns:
AYear& Self

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

Substracts another year-value from the year-object.

An undefined year is treated as 0.0.0; the result is (remains) undefined if both objects are undefined. Underflows (of day or month) are corrected.

Parameters:
rhs Value to substract
Returns:
AYear& Self

bool YGP::AYear::operator< ( const AYear other  )  const [inline]

Checks if one object is "younger" than the other. See compare() for details.

bool YGP::AYear::operator<= ( const AYear other  )  const [inline]

Checks if one object is "younger" than or equal to the other. See compare() for details.

AYear& YGP::AYear::operator= ( int  Year  )  [inline]

Assignment operator from an (unformatted) text.

AYear & YGP::AYear::operator= ( const char *  pValue  )  throw (std::invalid_argument)

Assignment-operator from a const char-pointer.

The year must be passed as Y[Y...]. If the buffer does not represent a valid year, an exception is thrown.

Parameters:
pValue Character array holding year to assign
Returns:
AYear& Reference to self
Exceptions:
std::invalid_argument if the characters don't represent a valid year

Reimplemented in YGP::ADate, and YGP::ATimestamp.

AYear & YGP::AYear::operator= ( const AYear other  ) 

Assignment-operator.

Parameters:
other Object to assign
Returns:
AYear& Reference to self

AYear& YGP::AYear::operator= ( const std::string &  year  )  throw (std::invalid_argument) [inline]

Assignment operator from an (unformatted) text.

Reimplemented in YGP::ADate, and YGP::ATimestamp.

bool YGP::AYear::operator== ( const AYear other  )  const [inline]

Compares two objects for equalnesss

bool YGP::AYear::operator> ( const AYear other  )  const [inline]

Checks if one object is "older" than the other. See compare() for details.

bool YGP::AYear::operator>= ( const AYear other  )  const [inline]

Checks if one object is "older" than or equal to the other. See compare() for details.

void YGP::AYear::readFromStream ( std::istream &  in  )  throw (std::invalid_argument) [virtual]

Reads a year as DDMMY[Y.

..] from a stream. If the input is not valid, an exception is thrown.

Parameters:
in Stream to parse
Exceptions:
std::invalid_argument in case of an invalid input

Implements YGP::AttributValue.

Reimplemented in YGP::ADate, and YGP::ATimestamp.

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

Converts the year into a string, in the format DDMMYYYY[.

..]; each entry is filled up with zeros.

Returns:
std::string String-representation of AYear

Reimplemented from YGP::AttributValue.

Reimplemented in YGP::ADate, and YGP::ATimestamp.


Friends And Related Function Documentation

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

Adds two year-values and returns the result.

An undefined year is treated as "0.0.0"; the result is (remains) undefined if both objects are undefined. Overflows (of day or month) are corrected.

Parameters:
lhs Left-hand-side of addition
rhs Right-hand-side of addition
Returns:
AYear Result of additon

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

Substracts two year-values and returns the result.

An undefined year is treated as "0.0.0"; the result is (remains) undefined if both objects are undefined. Overflows (of day or month) are corrected.

Parameters:
lhs Left-hand-side of substraction
rhs Right-hand-side of substraction
Returns:
AYear Result of substraction


Member Data Documentation

int YGP::AYear::year [protected]

Stores the year.


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