OCILIB (C and C++ Driver for Oracle)  4.7.5
Open source and cross platform Oracle Driver delivering efficient access to Oracle databases.
Loading...
Searching...
No Matches
ocilib::Interval Class Reference

Object identifying the SQL data type INTERVAL. More...

#include <types.hpp>

Inherits ocilib::core::HandleHolder< OCI_Interval * >, and ocilib::core::Streamable.

Public Types

enum  IntervalTypeValues { YearMonth = OCI_INTERVAL_YM , DaySecond = OCI_INTERVAL_DS }
 Interval types enumerated values. More...
 
typedef core::Enum< IntervalTypeValuesIntervalType
 Interval types.
 

Public Member Functions

 Interval ()
 Create an empty null Interval instance.
 
 Interval (IntervalType type)
 Create a new instance of the given type.
 
 Interval (IntervalType type, const ostring &data)
 Create an interval object with the value provided by the input interval string.
 
IntervalType GetType () const
 Return the type of the given interval object.
 
bool IsValid () const
 Check if the given interval is valid.
 
int GetYear () const
 Return the interval year value.
 
void SetYear (int value)
 Set the interval year value.
 
int GetMonth () const
 Return the interval month value.
 
void SetMonth (int value)
 Set the interval month value.
 
int GetDay () const
 Return the interval day value.
 
void SetDay (int value)
 Set the interval day value.
 
int GetHours () const
 Return the interval hours value.
 
void SetHours (int value)
 Set the interval hours value.
 
int GetMinutes () const
 Return the interval minutes value.
 
void SetMinutes (int value)
 Set the interval minutes value.
 
int GetSeconds () const
 Return the interval seconds value.
 
void SetSeconds (int value)
 Set the interval seconds value.
 
int GetMilliSeconds () const
 Return the interval seconds value.
 
void SetMilliSeconds (int value)
 Set the interval milliseconds value.
 
void GetDaySecond (int &day, int &hour, int &min, int &sec, int &fsec) const
 Extract the date / second parts from the interval value.
 
void SetDaySecond (int day, int hour, int min, int sec, int fsec)
 Set the Day / Second parts.
 
void GetYearMonth (int &year, int &month) const
 Extract the year / month parts from the interval value.
 
void SetYearMonth (int year, int month)
 Set the Year / Month parts.
 
void UpdateTimeZone (const ostring &timeZone)
 Update the interval value with the given time zone.
 
void FromString (const ostring &data)
 Assign to the interval object the value provided by the input interval string.
 
ostring ToString (int leadingPrecision, int fractionPrecision) const
 Convert the interval value to a string using the given precisions.
 
ostring ToString () const override
 Convert the interval value to a string using the default precisions of 10.
 
Interval Clone () const
 Clone the current instance to a new one performing deep copy.
 
Interval operator+ (const Interval &other) const
 Return a new Interval holding the sum of the current Interval value and the given Interval value.
 
Interval operator- (const Interval &other) const
 Return a new Interval holding the difference of the current Interval value and the given Interval value.
 
Intervaloperator+= (const Interval &other)
 Increment the current Value with the given Interval value.
 
Intervaloperator-= (const Interval &other)
 Decrement the current Value with the given Interval value.
 
bool operator== (const Interval &other) const
 Indicates if the current Interval value is equal to the given Interval value.
 
bool operator!= (const Interval &other) const
 Indicates if the current Interval value is not equal the given Interval value.
 
bool operator> (const Interval &other) const
 Indicates if the current Interval value is superior to the given Interval value.
 
bool operator< (const Interval &other) const
 Indicates if the current Interval value is inferior to the given Interval value.
 
bool operator>= (const Interval &other) const
 Indicates if the current Interval value is superior or equal to the given Interval value.
 
bool operator<= (const Interval &other) const
 Indicates if the current Interval value is inferior or equal to the given Interval value.
 

Detailed Description

Object identifying the SQL data type INTERVAL.

This class wraps the OCILIB object handle OCI_Interval and its related methods

Definition at line 3110 of file types.hpp.

Member Typedef Documentation

◆ IntervalType

Interval types.

Possible values are Interval::IntervalTypeValues

Definition at line 3142 of file types.hpp.

Member Enumeration Documentation

◆ IntervalTypeValues

Interval types enumerated values.

Enumerator
YearMonth 

Interval unit range is months -> years

DaySecond 

Interval unit range is seconds -> days

Definition at line 3127 of file types.hpp.

Constructor & Destructor Documentation

◆ Interval() [1/3]

ocilib::Interval::Interval ( )
inline

Create an empty null Interval instance.

Definition at line 31 of file Interval.hpp.

◆ Interval() [2/3]

ocilib::Interval::Interval ( IntervalType  type)
inline

Create a new instance of the given type.

Parameters
type- Interval type to create

Definition at line 35 of file Interval.hpp.

References ocilib::core::Check(), and OCI_IntervalCreate().

◆ Interval() [3/3]

ocilib::Interval::Interval ( IntervalType  type,
const ostring data 
)
inline

Create an interval object with the value provided by the input interval string.

Parameters
type- Interval type to create
data- String interval
Note
For interval format, refer to the Oracle SQL documentation

Definition at line 44 of file Interval.hpp.

References ocilib::core::Check(), FromString(), and OCI_IntervalCreate().

Member Function Documentation

◆ GetType()

Interval::IntervalType ocilib::Interval::GetType ( ) const
inline

Return the type of the given interval object.

Definition at line 74 of file Interval.hpp.

References ocilib::core::Check(), and OCI_IntervalGetType().

Referenced by Clone().

◆ IsValid()

bool ocilib::Interval::IsValid ( ) const
inline

Check if the given interval is valid.

Definition at line 79 of file Interval.hpp.

References ocilib::core::Check(), and OCI_IntervalCheck().

◆ GetYear()

int ocilib::Interval::GetYear ( ) const
inline

Return the interval year value.

Warning
this call is only permitted if the current interval type is Interval::YearMonth

Definition at line 84 of file Interval.hpp.

References GetYearMonth().

◆ SetYear()

void ocilib::Interval::SetYear ( int  value)
inline

Set the interval year value.

Warning
this call is only permitted if the current interval type is Interval::YearMonth

Definition at line 93 of file Interval.hpp.

References GetYearMonth(), and SetYearMonth().

◆ GetMonth()

int ocilib::Interval::GetMonth ( ) const
inline

Return the interval month value.

Warning
this call is only permitted if the current interval type is Interval::YearMonth

Definition at line 101 of file Interval.hpp.

References GetYearMonth().

◆ SetMonth()

void ocilib::Interval::SetMonth ( int  value)
inline

Set the interval month value.

Warning
this call is only permitted if the current interval type is Interval::YearMonth

Definition at line 110 of file Interval.hpp.

References GetYearMonth(), and SetYearMonth().

◆ GetDay()

int ocilib::Interval::GetDay ( ) const
inline

Return the interval day value.

Warning
this call is only permitted if the current interval type is Interval::DaySecond

Definition at line 118 of file Interval.hpp.

References GetDaySecond().

◆ SetDay()

void ocilib::Interval::SetDay ( int  value)
inline

Set the interval day value.

Warning
this call is only permitted if the current interval type is Interval::DaySecond

Definition at line 127 of file Interval.hpp.

References GetDaySecond(), and SetDaySecond().

Referenced by ocilib::Timestamp::operator+(), ocilib::Timestamp::operator+=(), ocilib::Timestamp::operator-(), and ocilib::Timestamp::operator-=().

◆ GetHours()

int ocilib::Interval::GetHours ( ) const
inline

Return the interval hours value.

Warning
this call is only permitted if the current interval type is Interval::DaySecond

Definition at line 135 of file Interval.hpp.

References GetDaySecond().

◆ SetHours()

void ocilib::Interval::SetHours ( int  value)
inline

Set the interval hours value.

Warning
this call is only permitted if the current interval type is Interval::DaySecond

Definition at line 144 of file Interval.hpp.

References GetDaySecond(), and SetDaySecond().

◆ GetMinutes()

int ocilib::Interval::GetMinutes ( ) const
inline

Return the interval minutes value.

Warning
this call is only permitted if the current interval type is Interval::DaySecond

Definition at line 152 of file Interval.hpp.

References GetDaySecond().

◆ SetMinutes()

void ocilib::Interval::SetMinutes ( int  value)
inline

Set the interval minutes value.

Warning
this call is only permitted if the current interval type is Interval::DaySecond

Definition at line 161 of file Interval.hpp.

References GetDaySecond(), and SetDaySecond().

◆ GetSeconds()

int ocilib::Interval::GetSeconds ( ) const
inline

Return the interval seconds value.

Warning
this call is only permitted if the current interval type is Interval::DaySecond

Definition at line 169 of file Interval.hpp.

References GetDaySecond().

◆ SetSeconds()

void ocilib::Interval::SetSeconds ( int  value)
inline

Set the interval seconds value.

Warning
this call is only permitted if the current interval type is Interval::DaySecond

Definition at line 178 of file Interval.hpp.

References GetDaySecond(), and SetDaySecond().

◆ GetMilliSeconds()

int ocilib::Interval::GetMilliSeconds ( ) const
inline

Return the interval seconds value.

Definition at line 186 of file Interval.hpp.

References GetDaySecond().

◆ SetMilliSeconds()

void ocilib::Interval::SetMilliSeconds ( int  value)
inline

Set the interval milliseconds value.

Definition at line 195 of file Interval.hpp.

References GetDaySecond(), and SetDaySecond().

◆ GetDaySecond()

void ocilib::Interval::GetDaySecond ( int &  day,
int &  hour,
int &  min,
int &  sec,
int &  fsec 
) const
inline

Extract the date / second parts from the interval value.

Parameters
day- Place holder for Day value
hour- Place holder for Hour value
min- Place holder for Minutes value
sec- Place holder for Seconds value
fsec- Place holder for Milliseconds value
Warning
this call is only permitted if the current interval type is Interval::DaySecond

Definition at line 203 of file Interval.hpp.

References ocilib::core::Check(), and OCI_IntervalGetDaySecond().

Referenced by GetDay(), GetHours(), GetMilliSeconds(), GetMinutes(), GetSeconds(), SetDay(), SetHours(), SetMilliSeconds(), SetMinutes(), and SetSeconds().

◆ SetDaySecond()

void ocilib::Interval::SetDaySecond ( int  day,
int  hour,
int  min,
int  sec,
int  fsec 
)
inline

Set the Day / Second parts.

Parameters
day- Day value
hour- Hour value
min- Minutes value
sec- Seconds value
fsec- Milliseconds value
Warning
this call is only permitted if the current interval type is Interval::DaySecond

Definition at line 208 of file Interval.hpp.

References ocilib::core::Check(), and OCI_IntervalSetDaySecond().

Referenced by SetDay(), SetHours(), SetMilliSeconds(), SetMinutes(), and SetSeconds().

◆ GetYearMonth()

void ocilib::Interval::GetYearMonth ( int &  year,
int &  month 
) const
inline

Extract the year / month parts from the interval value.

Parameters
year- Place holder for year value
month- Place holder for month value
Warning
this call is only permitted if the current interval type is Interval::YearMonth

Definition at line 213 of file Interval.hpp.

References ocilib::core::Check(), and OCI_IntervalGetYearMonth().

Referenced by GetMonth(), GetYear(), SetMonth(), and SetYear().

◆ SetYearMonth()

void ocilib::Interval::SetYearMonth ( int  year,
int  month 
)
inline

Set the Year / Month parts.

Parameters
year- Year value
month- Month value
Warning
this call is only permitted if the current interval type is Interval::YearMonth

Definition at line 217 of file Interval.hpp.

References ocilib::core::Check(), and OCI_IntervalSetYearMonth().

Referenced by SetMonth(), and SetYear().

◆ UpdateTimeZone()

void ocilib::Interval::UpdateTimeZone ( const ostring timeZone)
inline

Update the interval value with the given time zone.

Parameters
timeZone- Time zone name

Definition at line 222 of file Interval.hpp.

References ocilib::core::Check(), and OCI_IntervalFromTimeZone().

◆ FromString()

void ocilib::Interval::FromString ( const ostring data)
inline

Assign to the interval object the value provided by the input interval string.

Parameters
data- String interval
Note
For interval format, refer to the Oracle SQL documentation

Definition at line 227 of file Interval.hpp.

References ocilib::core::Check(), and OCI_IntervalFromText().

Referenced by Interval().

◆ ToString() [1/2]

ostring ocilib::Interval::ToString ( int  leadingPrecision,
int  fractionPrecision 
) const
inline

Convert the interval value to a string using the given precisions.

Parameters
leadingPrecision- leading precision
fractionPrecision- fraction precision

Definition at line 232 of file Interval.hpp.

References ocilib::core::Check(), ocilib::core::MakeString(), and OCI_IntervalToText().

◆ ToString() [2/2]

ostring ocilib::Interval::ToString ( ) const
inlineoverridevirtual

Convert the interval value to a string using the default precisions of 10.

Implements ocilib::core::Streamable.

Definition at line 248 of file Interval.hpp.

References ToString().

Referenced by ToString().

◆ Clone()

Interval ocilib::Interval::Clone ( ) const
inline

Clone the current instance to a new one performing deep copy.

Definition at line 60 of file Interval.hpp.

References ocilib::core::Check(), GetType(), and OCI_IntervalAssign().

Referenced by operator+(), and operator-().

◆ operator+()

Interval ocilib::Interval::operator+ ( const Interval other) const
inline

Return a new Interval holding the sum of the current Interval value and the given Interval value.

Definition at line 253 of file Interval.hpp.

References Clone().

◆ operator-()

Interval ocilib::Interval::operator- ( const Interval other) const
inline

Return a new Interval holding the difference of the current Interval value and the given Interval value.

Definition at line 259 of file Interval.hpp.

References Clone().

◆ operator+=()

Interval & ocilib::Interval::operator+= ( const Interval other)
inline

Increment the current Value with the given Interval value.

Definition at line 265 of file Interval.hpp.

References ocilib::core::Check(), and OCI_IntervalAdd().

◆ operator-=()

Interval & ocilib::Interval::operator-= ( const Interval other)
inline

Decrement the current Value with the given Interval value.

Definition at line 271 of file Interval.hpp.

References ocilib::core::Check(), and OCI_IntervalSubtract().

◆ operator==()

bool ocilib::Interval::operator== ( const Interval other) const
inline

Indicates if the current Interval value is equal to the given Interval value.

Definition at line 277 of file Interval.hpp.

◆ operator!=()

bool ocilib::Interval::operator!= ( const Interval other) const
inline

Indicates if the current Interval value is not equal the given Interval value.

Definition at line 282 of file Interval.hpp.

◆ operator>()

bool ocilib::Interval::operator> ( const Interval other) const
inline

Indicates if the current Interval value is superior to the given Interval value.

Definition at line 287 of file Interval.hpp.

◆ operator<()

bool ocilib::Interval::operator< ( const Interval other) const
inline

Indicates if the current Interval value is inferior to the given Interval value.

Definition at line 292 of file Interval.hpp.

◆ operator>=()

bool ocilib::Interval::operator>= ( const Interval other) const
inline

Indicates if the current Interval value is superior or equal to the given Interval value.

Definition at line 297 of file Interval.hpp.

◆ operator<=()

bool ocilib::Interval::operator<= ( const Interval other) const
inline

Indicates if the current Interval value is inferior or equal to the given Interval value.

Definition at line 304 of file Interval.hpp.