23 #include "ocilibcpp/types.hpp" 38 Acquire(pNumber,
nullptr,
nullptr, parent);
55 inline void Number::Allocate()
69 const size_t size = OCI_SIZE_BUFFER;
78 return OCI_STRING_NULL;
98 AnyPointer Number::GetNativeValue(
const T& value)
100 return reinterpret_cast<AnyPointer>(
const_cast<T*
>(&value));
109 inline int Number::Compare(
const Number& other)
const 115 T Number::GetValue()
const 125 Number& Number::SetValue(
const T &value)
138 void Number::Add(
const T &value)
144 void Number::Sub(
const T &value)
150 void Number::Multiply(
const T &value)
156 void Number::Divide(
const T &value)
163 Acquire(lhs, reinterpret_cast<HandleFreeFunc>(
OCI_NumberFree),
nullptr,
nullptr);
167 template<class T, typename core::SupportedNumeric<T>::Type::type*>
168 Number& Number::operator = (
const T &lhs)
174 template<class T, typename core::SupportedNumeric<T>::Type::type*>
175 Number::operator T()
const 177 return GetValue<T>();
180 template<class T, typename core::SupportedNumeric<T>::Type::type*>
181 Number Number::operator + (
const T &value)
188 template<class T, typename core::SupportedNumeric<T>::Type::type*>
189 Number Number::operator - (
const T &value)
196 template<class T, typename core::SupportedNumeric<T>::Type::type*>
197 Number Number::operator * (
const T &value)
200 result.Multiply(value);
204 template<class T, typename core::SupportedNumeric<T>::Type::type*>
205 Number Number::operator / (
const T &value)
208 result.Divide(value);
212 template<class T, typename core::SupportedNumeric<T>::Type::type*>
213 Number& Number::operator += (
const T &value)
219 template<class T, typename core::SupportedNumeric<T>::Type::type*>
220 Number& Number::operator -= (
const T &value)
226 template<class T, typename core::SupportedNumeric<T>::Type::type*>
227 Number& Number::operator *= (
const T &value)
233 template<class T, typename core::SupportedNumeric<T>::Type::type*>
234 Number& Number::operator /= (
const T &value)
240 inline Number& Number::operator ++ ()
245 inline Number& Number::operator -- ()
250 inline Number Number::operator ++ (
int)
255 inline Number Number::operator -- (
int)
260 inline bool Number::operator == (
const Number& other)
const 262 return Compare(other) == 0;
265 inline bool Number::operator != (
const Number& other)
const 267 return !(*
this == other);
270 inline bool Number::operator > (
const Number& other)
const 272 return Compare(other) > 0;
275 inline bool Number::operator < (
const Number& other)
const 277 return Compare(other) < 0;
280 inline bool Number::operator >= (
const Number& other)
const 282 const int res = Compare(other);
284 return res == 0 || res < 0;
287 inline bool Number::operator <= (
const Number& other)
const 289 const int res = Compare(other);
291 return res == 0 || res > 0;
Internal usage. Interface for handling ownership and relationship of a C API handle.
void FromString(const ostring &str, const ostring &format=OTEXT("")) const
Assign to the number object the value provided by the input number time string.
OCI_SYM_PUBLIC boolean OCI_API OCI_NumberSub(OCI_Number *number, unsigned int type, void *value)
Subtract the value of a native C numeric type to the given number.
OCI_SYM_PUBLIC boolean OCI_API OCI_NumberAdd(OCI_Number *number, unsigned int type, void *value)
Add the value of a native C numeric type to the given number.
static ostring GetFormat(FormatType formatType)
Return the format string for implicit string conversions of the given type.
OCI_SYM_PUBLIC int OCI_API OCI_NumberAssign(OCI_Number *number, OCI_Number *number_src)
Assign the value of a number handle to another one.
Allow resolving a the C API numeric enumerated type from a C++ type.
static T Check(T result)
Internal usage. Checks if the last OCILIB function call has raised an error. If so, it raises a C++ exception using the retrieved error handle.
OCI_SYM_PUBLIC boolean OCI_API OCI_NumberGetValue(OCI_Number *number, unsigned int type, void *value)
Assign the number value to a native C numeric type.
OCI_SYM_PUBLIC boolean OCI_API OCI_NumberSetValue(OCI_Number *number, unsigned int type, void *value)
Assign the number value with the value of a native C numeric type.
OCI_SYM_PUBLIC boolean OCI_API OCI_NumberToText(OCI_Number *number, const otext *fmt, int size, otext *str)
Convert a number value from the given number handle to a string.
Number Clone() const
Clone the current instance to a new one performing deep copy.
OCI_SYM_PUBLIC unsigned char *OCI_API OCI_NumberGetContent(OCI_Number *number)
Return the number value content.
ostring MakeString(const otext *result, int size=-1)
Internal usage. Constructs a C++ string object from the given OCILIB string pointer.
void * AnyPointer
Alias for the generic void pointer.
OCI_SYM_PUBLIC boolean OCI_API OCI_NumberDivide(OCI_Number *number, unsigned int type, void *value)
Divide the given number with the value of a native C numeric.
OCI_SYM_PUBLIC boolean OCI_API OCI_NumberFree(OCI_Number *number)
Free a number object.
OCI_SYM_PUBLIC boolean OCI_API OCI_NumberFromText(OCI_Number *number, const otext *str, const otext *fmt)
Convert a string to a number and store it in the given number handle.
OCI_SYM_PUBLIC OCI_Number *OCI_API OCI_NumberCreate(OCI_Connection *con)
Create a local number object.
Internal usage. Provide a buffer class with RAII capabilities.
ostring ToString() const override
Convert the number value to a string using default format OCI_STRING_FORMAT_NUMERIC.
OCI_SYM_PUBLIC boolean OCI_API OCI_NumberMultiply(OCI_Number *number, unsigned int type, void *value)
Multiply the given number with the value of a native C numeric.
OCI_SYM_PUBLIC int OCI_API OCI_NumberCompare(OCI_Number *number1, OCI_Number *number2)
Compares two number handles.
struct OCI_Number OCI_Number
Oracle NUMBER representation.
Object identifying the SQL data type NUMBER.
Number(bool create=false)
Create an empty null number object.
std::basic_string< otext, std::char_traits< otext >, std::allocator< otext > > ostring
string class wrapping the OCILIB otext * type and OTEXT() macros ( see Character sets ) ...