Present  0.9
 All Classes Files Functions Variables Typedefs Friends Macros Pages
MonthDelta Struct Reference

Class or struct representing a positive or negative delta of a number of months or years. More...

Public Member Functions

int_month_delta months () const
 Get the number of months represented by a MonthDelta. More...
 
int_year_delta years () const
 Get the number of years represented by a MonthDelta. More...
 
double years_decimal () const
 Get the number of years represented by a MonthDelta, with a fractional part if necessary. More...
 
bool is_negative () const
 Determine whether a MonthDelta is negative. More...
 
void negate ()
 Negate a MonthDelta, making it negative if it was positive or positive if it was negative. More...
 
MonthDelta operator- () const
 Return the negated version of this MonthDelta. More...
 
MonthDeltaoperator++ ()
 Add one month to the MonthDelta. More...
 
MonthDelta operator++ (int)
 Add one month to the MonthDelta. More...
 
MonthDeltaoperator-- ()
 Subtract one month from the MonthDelta. More...
 
MonthDelta operator-- (int)
 Subtract one month from the MonthDelta. More...
 
MonthDeltaoperator*= (const long &scale_factor)
 Scale a MonthDelta by multiplying it by a scale factor. More...
 
MonthDeltaoperator/= (const long &scale_factor)
 Scale a MonthDelta by dividing it by a scale factor. More...
 
MonthDeltaoperator+= (const MonthDelta &other)
 Add another MonthDelta to a MonthDelta. More...
 
MonthDeltaoperator-= (const MonthDelta &other)
 Subtract another MonthDelta from a MonthDelta. More...
 

Static Public Member Functions

static MonthDelta from_months (int_month_delta months)
 Create a new MonthDelta based on a positive or negative number of months. More...
 
static MonthDelta from_years (int_year_delta years)
 Create a new MonthDelta based on a positive or negative number of years. More...
 
static MonthDelta zero ()
 Create a new MonthDelta initialized to zero months. More...
 
static short compare (const MonthDelta &lhs, const MonthDelta &rhs)
 Compare two MonthDelta instances. More...
 

Public Attributes

struct PresentMonthDeltaData data_
 

Friends

const MonthDelta operator* (const MonthDelta &delta, const long &scale_factor)
 
const MonthDelta operator/ (const MonthDelta &delta, const long &scale_factor)
 
const MonthDelta operator+ (const MonthDelta &lhs, const MonthDelta &rhs)
 
const MonthDelta operator- (const MonthDelta &lhs, const MonthDelta &rhs)
 
bool operator== (const MonthDelta &, const MonthDelta &rhs)
 Determine whether two MonthDelta instances are equal (lhs == rhs). More...
 
bool operator!= (const MonthDelta &, const MonthDelta &rhs)
 
bool operator< (const MonthDelta &lhs, const MonthDelta &rhs)
 Determine whether a MonthDelta is less than another MonthDelta (lhs < rhs). More...
 
bool operator<= (const MonthDelta &lhs, const MonthDelta &rhs)
 Determine whether a MonthDelta is less than or equal to another MonthDelta (lhs <= rhs). More...
 
bool operator> (const MonthDelta &lhs, const MonthDelta &rhs)
 Determine whether a MonthDelta is greater than another MonthDelta (lhs > rhs). More...
 
bool operator>= (const MonthDelta &lhs, const MonthDelta &rhs)
 Determine whether a MonthDelta is greater than or equal to another MonthDelta (lhs >= rhs). More...
 

Detailed Description

Class or struct representing a positive or negative delta of a number of months or years.

Member Function Documentation

static MonthDelta MonthDelta::from_months ( int_month_delta  months)
static

Create a new MonthDelta based on a positive or negative number of months.

static MonthDelta MonthDelta::from_years ( int_year_delta  years)
static

Create a new MonthDelta based on a positive or negative number of years.

static MonthDelta MonthDelta::zero ( )
static

Create a new MonthDelta initialized to zero months.

int_month_delta MonthDelta::months ( ) const

Get the number of months represented by a MonthDelta.

int_year_delta MonthDelta::years ( ) const

Get the number of years represented by a MonthDelta.

If the MonthDelta does not represent an exact number of years, the number of years will be truncated.

double MonthDelta::years_decimal ( ) const

Get the number of years represented by a MonthDelta, with a fractional part if necessary.

bool MonthDelta::is_negative ( ) const

Determine whether a MonthDelta is negative.

void MonthDelta::negate ( )

Negate a MonthDelta, making it negative if it was positive or positive if it was negative.

MonthDelta MonthDelta::operator- ( ) const

Return the negated version of this MonthDelta.

See Also
MonthDelta::negate
MonthDelta& MonthDelta::operator++ ( )

Add one month to the MonthDelta.

MonthDelta MonthDelta::operator++ ( int  )

Add one month to the MonthDelta.

MonthDelta& MonthDelta::operator-- ( )

Subtract one month from the MonthDelta.

MonthDelta MonthDelta::operator-- ( int  )

Subtract one month from the MonthDelta.

MonthDelta& MonthDelta::operator*= ( const long &  scale_factor)

Scale a MonthDelta by multiplying it by a scale factor.

MonthDelta& MonthDelta::operator/= ( const long &  scale_factor)

Scale a MonthDelta by dividing it by a scale factor.

MonthDelta& MonthDelta::operator+= ( const MonthDelta other)

Add another MonthDelta to a MonthDelta.

The second MonthDelta parameter is added to the first.

MonthDelta& MonthDelta::operator-= ( const MonthDelta other)

Subtract another MonthDelta from a MonthDelta.

The second MonthDelta parameter is subtracted from the first.

static short MonthDelta::compare ( const MonthDelta lhs,
const MonthDelta rhs 
)
static

Compare two MonthDelta instances.

  • If lhs < rhs, then a negative integer will be returned.
  • If lhs == rhs, then 0 will be returned.
  • If lhs > rhs, then a positive integer will be returned.

Friends And Related Function Documentation

const MonthDelta operator* ( const MonthDelta delta,
const long &  scale_factor 
)
friend
const MonthDelta operator/ ( const MonthDelta delta,
const long &  scale_factor 
)
friend
const MonthDelta operator+ ( const MonthDelta lhs,
const MonthDelta rhs 
)
friend
const MonthDelta operator- ( const MonthDelta lhs,
const MonthDelta rhs 
)
friend
bool operator== ( const MonthDelta ,
const MonthDelta rhs 
)
friend

Determine whether two MonthDelta instances are equal (lhs == rhs).

bool operator!= ( const MonthDelta ,
const MonthDelta rhs 
)
friend
bool operator< ( const MonthDelta lhs,
const MonthDelta rhs 
)
friend

Determine whether a MonthDelta is less than another MonthDelta (lhs < rhs).

bool operator<= ( const MonthDelta lhs,
const MonthDelta rhs 
)
friend

Determine whether a MonthDelta is less than or equal to another MonthDelta (lhs <= rhs).

bool operator> ( const MonthDelta lhs,
const MonthDelta rhs 
)
friend

Determine whether a MonthDelta is greater than another MonthDelta (lhs > rhs).

bool operator>= ( const MonthDelta lhs,
const MonthDelta rhs 
)
friend

Determine whether a MonthDelta is greater than or equal to another MonthDelta (lhs >= rhs).

Member Data Documentation

struct PresentMonthDeltaData MonthDelta::data_

The documentation for this struct was generated from the following file: