Drizzled Public API Documentation

drizzled::TemporalInterval Class Reference

Stores time interval for date/time manipulation. More...

#include <temporal_interval.h>

List of all members.

Public Member Functions

 TemporalInterval (uint32_t in_year, uint32_t in_month, uint32_t in_day, uint32_t in_hour, uint64_t in_minute, uint64_t in_second, uint64_t in_second_part, bool in_neg)
void setNegative (bool in_neg=true)
void toggleNegative ()
bool getNegative () const
uint32_t get_year () const
void set_year (uint32_t new_year)
uint32_t get_month () const
void set_month (uint32_t new_month)
uint32_t get_day () const
void set_day (uint32_t new_day)
uint32_t get_hour () const
void set_hour (uint32_t new_hour)
uint64_t get_minute () const
void set_minute (uint32_t new_minute)
uint64_t get_second () const
void set_second (uint32_t new_second)
uint64_t get_second_part () const
void set_second_part (uint32_t new_second_part)
bool initFromItem (Item *args, interval_type int_type, String *str_value)
bool addDate (type::Time *ltime, interval_type int_type)

Private Member Functions

bool getIntervalFromString (const char *str, uint32_t length, const charset_info_st *const cs, uint32_t count, uint64_t *values, bool transform_msec)

Private Attributes

uint32_t year
uint32_t month
uint32_t day
uint32_t hour
uint64_t minute
uint64_t second
uint64_t second_part
bool neg

Static Private Attributes

static const uint32_t MAX_STRING_ELEMENTS = 5
static const uint32_t NUM_YEAR_MONTH_STRING_ELEMENTS = 2
static const uint32_t NUM_DAY_HOUR_STRING_ELEMENTS = 2
static const uint32_t NUM_DAY_MICROSECOND_STRING_ELEMENTS = 5
static const uint32_t NUM_DAY_MINUTE_STRING_ELEMENTS = 3
static const uint32_t NUM_DAY_SECOND_STRING_ELEMENTS = 4
static const uint32_t NUM_HOUR_MICROSECOND_STRING_ELEMENTS = 4
static const uint32_t NUM_HOUR_MINUTE_STRING_ELEMENTS = 2
static const uint32_t NUM_HOUR_SECOND_STRING_ELEMENTS = 3
static const uint32_t NUM_MINUTE_MICROSECOND_STRING_ELEMENTS = 3
static const uint32_t NUM_MINUTE_SECOND_STRING_ELEMENTS = 2
static const uint32_t NUM_SECOND_MICROSECOND_STRING_ELEMENTS = 2

Detailed Description

Stores time interval for date/time manipulation.

Definition at line 36 of file temporal_interval.h.


Member Function Documentation

bool drizzled::TemporalInterval::addDate ( type::Time ltime,
interval_type  int_type 
)

Adds this interval to a DRIZZLE_LTIME structure

Parameters:
[in,out]ltimethe interval will be added to ltime directly in the ltime structure
[in]int_typethe type of interval requested
Return values:
truedate was added and value stored properly
falseresult of addition is a null value

Definition at line 190 of file temporal_interval.cc.

Referenced by drizzled::Item_date_add_interval::get_date().

bool drizzled::TemporalInterval::getIntervalFromString ( const char *  str,
uint32_t  length,
const charset_info_st *const  cs,
uint32_t  count,
uint64_t *  values,
bool  transform_msec 
)
private

Get a array of positive numbers from a string object. Each number is separated by 1 non digit character Return error if there is too many numbers. If there is too few numbers, assume that the numbers are left out from the high end. This allows one to give: DAY_TO_SECOND as "D MM:HH:SS", "MM:HH:SS" "HH:SS" or as seconds.

Parameters:
[in]length,:length of str
[in]cs,:charset of str
[out]values,:array of results
[out]count,:count of elements in result array
transform_msec,:if value is true we suppose that the last part of string value is microseconds and we should transform value to six digit value. For example, '1.1' -> '1.100000'

Definition at line 296 of file temporal_interval.cc.

Referenced by initFromItem().

bool drizzled::TemporalInterval::getNegative ( ) const
inline
Return values:
truethis is a negative temporal interval
falsethis is a positive temporal interval

Definition at line 90 of file temporal_interval.h.

bool drizzled::TemporalInterval::initFromItem ( Item args,
interval_type  int_type,
String str_value 
)

Populate this TemporalInterval from a string value

To make code easy, allow interval objects without separators.

Parameters:
argsargument Item structure
int_typetype of interval to create
str_valueString pointer to the input value
Returns:
true if the string would result in a null interval

Definition at line 33 of file temporal_interval.cc.

References getIntervalFromString(), MAX_STRING_ELEMENTS, drizzled::Item::null_value, NUM_YEAR_MONTH_STRING_ELEMENTS, drizzled::Item::val_int(), and drizzled::Item::val_str().

Referenced by drizzled::Item_date_add_interval::get_date().

void drizzled::TemporalInterval::setNegative ( bool  in_neg = true)
inline

Sets whether or not this object specifies a negative interval

Parameters:
[in]in_negtrue if this is a negative interval, false if not

Definition at line 73 of file temporal_interval.h.

void drizzled::TemporalInterval::toggleNegative ( )
inline

reverse boolean value of the negative flag

Definition at line 81 of file temporal_interval.h.

Referenced by drizzled::Item_date_add_interval::get_date().


Member Data Documentation

const uint32_t drizzled::TemporalInterval::MAX_STRING_ELEMENTS = 5
staticprivate

The maximum number of text elements to extract into a temporal interval

Definition at line 144 of file temporal_interval.h.

Referenced by initFromItem().

const uint32_t drizzled::TemporalInterval::NUM_YEAR_MONTH_STRING_ELEMENTS = 2
staticprivate

Each of these corresponds to an 'interval_type'

Definition at line 149 of file temporal_interval.h.

Referenced by initFromItem().


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