OCILIB (C and C++ Driver for Oracle)  4.7.7
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 (const Interval &other)
 For value types, overrides HandleHolder copy constructor to perform assignment rather than ref counting management.
 
Intervaloperator= (const Interval &other) noexcept
 For value types, overrides HandleHolder assignment operator to perform assignment rather than ref counting management.
 
 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.
 
int GetNanoSeconds () const
 Return the interval nano seconds value.
 
void SetNanoSeconds (int value)
 Set the interval nano seconds value.
 
void GetDaySecond (int &day, int &hour, int &min, int &sec, int &nsec) const
 Extract the date / second parts from the interval value.
 
void SetDaySecond (int day, int hour, int min, int sec, int nsec)
 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 3171 of file types.hpp.

Member Typedef Documentation

◆ IntervalType

Interval types.

Possible values are Interval::IntervalTypeValues

Definition at line 3203 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 3188 of file types.hpp.

Constructor & Destructor Documentation

◆ Interval() [1/4]

ocilib::Interval::Interval ( )
inline

Create an empty null Interval instance.

Definition at line 31 of file Interval.hpp.

◆ Interval() [2/4]

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.

◆ Interval() [3/4]

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

For value types, overrides HandleHolder copy constructor to perform assignment rather than ref counting management.

Parameters
other- value to assign

Definition at line 40 of file Interval.hpp.

◆ Interval() [4/4]

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 60 of file Interval.hpp.

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

Member Function Documentation

◆ operator=()

Interval & ocilib::Interval::operator= ( const Interval other)
inlinenoexcept

For value types, overrides HandleHolder assignment operator to perform assignment rather than ref counting management.

Parameters
other- value to assign

Definition at line 45 of file Interval.hpp.

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

◆ GetType()

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

Return the type of the given interval object.

Definition at line 99 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 104 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 109 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 118 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 126 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 135 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 143 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 152 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 160 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 169 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 177 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 186 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 194 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 203 of file Interval.hpp.

References GetDaySecond(), and SetDaySecond().

◆ GetMilliSeconds()

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

Return the interval seconds value.

Definition at line 211 of file Interval.hpp.

References GetDaySecond().

◆ SetMilliSeconds()

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

Set the interval milliseconds value.

Definition at line 220 of file Interval.hpp.

References GetDaySecond(), and SetDaySecond().

◆ GetNanoSeconds()

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

Return the interval nano seconds value.

Definition at line 228 of file Interval.hpp.

References GetDaySecond().

◆ SetNanoSeconds()

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

Set the interval nano seconds value.

Definition at line 237 of file Interval.hpp.

References GetDaySecond(), and SetDaySecond().

◆ GetDaySecond()

void ocilib::Interval::GetDaySecond ( int &  day,
int &  hour,
int &  min,
int &  sec,
int &  nsec 
) 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
nsec- Place holder for NanoSeconds value
Warning
this call is only permitted if the current interval type is Interval::DaySecond

Definition at line 245 of file Interval.hpp.

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

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

◆ SetDaySecond()

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

Set the Day / Second parts.

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

Definition at line 250 of file Interval.hpp.

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

Referenced by SetDay(), SetHours(), SetMilliSeconds(), SetMinutes(), SetNanoSeconds(), 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 255 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 259 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 264 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 269 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 274 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 290 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 85 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 295 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 301 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 307 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 313 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 319 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 324 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 329 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 334 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 339 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 346 of file Interval.hpp.