|
Home / Open source / Terimber 2.0
numeric Class Referencefloat number without restrictions on precision and scale
More...
#include <numeric.h>
List of all members.
|
Public Member Functions |
| | numeric (byte_allocator *allocator_=0) |
| | default constructor
|
| | ~numeric () |
| | destructor
|
| | numeric (sb8_t x, byte_allocator *allocator_=0) |
| | constructor
|
| | numeric (sb4_t x, byte_allocator *allocator_=0) |
| | constructor
|
| | numeric (float x, byte_allocator *allocator_=0) |
| | constructor
|
| | numeric (double x, byte_allocator *allocator_=0) |
| | constructor
|
| | numeric (const char *x, size_t len, numeric_radix radix=RADIX10, byte_allocator *allocator_=0) |
| | constructor
|
| | numeric (const char *x, size_t len, char delimeter, byte_allocator *allocator_=0) |
| | constructor
|
| | numeric (const wchar_t *x, size_t len, wchar_t delimeter, byte_allocator *allocator_=0) |
| | constructor
|
| | numeric (const numeric &x) |
| | copy constructor
|
| numeric & | operator= (const numeric &x) |
| | assign operator
|
| numeric & | operator++ () |
| | operator++
|
| numeric | operator++ (int) |
| | operator++(int)
|
| numeric & | operator-- () |
| | operator--
|
| numeric | operator-- (int) |
| | operator--(int)
|
| numeric & | operator+= (const numeric &x) |
| | operator+=
|
| numeric & | operator-= (const numeric &x) |
| | operator-=
|
| numeric & | operator*= (const numeric &x) |
| | operator *=
|
| numeric & | operator/= (const numeric &x) |
| | operator /=
|
| numeric & | operator%= (const numeric &x) |
| | operator =
|
| bool | operator== (const numeric &x) |
| | equal operator
|
| bool | operator!= (const numeric &x) |
| | non equal operator
|
| bool | operator< (const numeric &x) |
| | operator<
|
| bool | operator<= (const numeric &x) |
| | operator <=
|
| bool | operator> (const numeric &x) |
| | operator>
|
| bool | operator>= (const numeric &x) |
| | operator >=
|
| bool | sign () const |
| | get sign, return true for negative numbers
|
| size_t | scale () const |
| | get scale
|
| bool | is_zero () const |
| | check if number is zero
|
| size_t | precision () const |
| | get precision
|
| bool | format (char *buf, char delimeter= '.') const |
| | output numeric using provided buffer and delimeter buffer has to have enough room to accomodate all bytes precision + 1 (delimeter) + 1 (sign) + 1 (leading zero)
|
| bool | persist (ub1_t *buf, size_t size) const |
| | output numeric in binary format
|
| bool | parse (const ub1_t *buf) |
| | parses binary buffer extracting numeric
|
| bool | persist_orcl (ub1_t *buf) const |
| | outputs numeric in binary oracle like format NUMERIC type
|
| bool | parse_orcl (const ub1_t *buf) |
| | parses external oracle like binary buffer extracting numeric
|
| bool | persist_sql (ub1_t &sign, ub1_t *buf, ub1_t &precision, sb1_t &scale) const |
| | outputs numeric in binary ms sql like format SQL_NUMERIC type
|
| bool | parse_sql (ub1_t sign, const ub1_t *buf, ub1_t precision, sb1_t scale) |
| | parses external ms sql like binary buffer extracting numeric
|
| size_t | orcl_len () const |
| | gets the minimum length for oracle output
|
Static Public Member Functions |
| static const numeric & | zero () |
| | static zero
|
| static const numeric & | one () |
| | static one
|
| static int | compare_orcl (const ub1_t *x, const ub1_t *y) |
| | compares binaries in oracle format
|
Static Public Attributes |
| static const numeric_radix | _radix = RADIX10 |
| | radix 10
|
Private Member Functions |
| | numeric (ub1_t x, size_t length, byte_allocator *allocator_=0) |
| | private constructor
|
| | numeric (const ub1_t *x, size_t length, byte_allocator *allocator_=0) |
| | private constructor
|
| numeric & | negative () |
| | makes numeric negative
|
| numeric & | cutjunk () |
| | removes unused tailing or leading zeroes
|
| numeric & | round (size_t scale_) |
| | rounds up to the scale
|
| numeric & | operator<< (int shift) |
| | shifts buffer to the left
|
| numeric & | operator>> (int shift) |
| | shifts buffer to the right
|
| numeric & | scan (const char *x, size_t len, char delimeter) |
| | scans external string with specified delimeter
|
| numeric & | scan (const wchar_t *x, size_t len, wchar_t delimeter) |
| | scans external wide string with specified delimeter
|
Static Private Member Functions |
| static numeric & | plus (numeric &res, const numeric &x, const numeric &y) |
| | returns x+y
|
| static numeric & | minus (numeric &res, const numeric &x, const numeric &y) |
| | returns x-y
|
| static numeric & | multiply (numeric &res, const numeric &x, const numeric &y) |
| | returns x*y
|
| static numeric & | divide (numeric &res, numeric &reminder, const numeric ÷nd, const numeric ÷r) |
| | returns x/y
|
| static int | compare (const numeric &x, const numeric &y) |
| | compares x, y
|
Private Attributes |
| room_array< ub1_t > | _vec |
| | internal buffer
|
| size_t | _scale |
| | scale
|
| size_t | _precision |
| | precision
|
| bool | _sign |
| | sign, true means negative
|
Friends |
| numeric | operator+ (const numeric &x, const numeric &y) |
| | operator+
|
| numeric | operator- (const numeric &x, const numeric &y) |
| | operator-
|
| numeric | operator* (const numeric &x, const numeric &y) |
| | operator*
|
| numeric | operator/ (const numeric &x, const numeric &y) |
| | operator/
|
| numeric | operator% (const numeric &x, const numeric &y) |
| | operator%
|
Detailed Description
float number without restrictions on precision and scale
Definition at line 39 of file numeric.h.
Constructor & Destructor Documentation
| numeric::numeric |
( |
float |
x, |
|
|
byte_allocator * |
allocator_ = 0 | |
|
) |
| | [explicit] |
| numeric::numeric |
( |
double |
x, |
|
|
byte_allocator * |
allocator_ = 0 | |
|
) |
| | [explicit] |
| numeric::numeric |
( |
const char * |
x, |
|
|
size_t |
len, |
|
|
char |
delimeter, |
|
|
byte_allocator * |
allocator_ = 0 | |
|
) |
| | [explicit] |
constructor
- Parameters:
-
| x |
input string |
| len |
string length |
| delimeter |
delimeter '.', ',', etc |
| allocator_ |
optional external allocator |
Definition at line 149 of file numeric.cpp.
References scan().
constructor
- Parameters:
-
| x |
input wide string |
| len |
string length |
| delimeter |
delimeter L'.', L',', etc |
| allocator_ |
optional external allocator |
Definition at line 155 of file numeric.cpp.
References scan().
| numeric::numeric |
( |
const numeric & |
x |
) |
|
private constructor
- Parameters:
-
| x |
input value |
| length |
reserved length |
| allocator_ |
optional external allocator |
Definition at line 62 of file numeric.cpp.
References _vec.
private constructor
- Parameters:
-
| x |
input buffer |
| length |
buffer length |
| allocator_ |
optional external allocator |
Definition at line 68 of file numeric.cpp.
References _vec.
Member Function Documentation
| numeric numeric::operator++ |
( |
int |
|
) |
|
| numeric numeric::operator-- |
( |
int |
|
) |
|
| bool numeric::operator== |
( |
const numeric & |
x |
) |
|
| bool numeric::operator!= |
( |
const numeric & |
x |
) |
|
| bool numeric::operator< |
( |
const numeric & |
x |
) |
|
| bool numeric::operator<= |
( |
const numeric & |
x |
) |
|
| bool numeric::operator> |
( |
const numeric & |
x |
) |
|
| bool numeric::operator>= |
( |
const numeric & |
x |
) |
|
| bool numeric::sign |
( |
|
) |
const |
| size_t numeric::scale |
( |
|
) |
const |
| bool numeric::is_zero |
( |
|
) |
const |
| size_t numeric::precision |
( |
|
) |
const |
| bool numeric::format |
( |
char * |
buf, |
|
|
char |
delimeter = '.' | |
|
) |
| | const |
output numeric using provided buffer and delimeter buffer has to have enough room to accomodate all bytes precision + 1 (delimeter) + 1 (sign) + 1 (leading zero)
Definition at line 162 of file numeric.cpp.
References _precision, _scale, _sign, _vec, byte_to_symbol(), compare(), and zero().
Referenced by dbserver_impl::get_param_as_numeric(), memlookup::get_value_as_numeric(), terimber_db_value_vector_impl::get_value_as_numeric(), dbserver_impl::get_value_as_numeric(), persist_value(), odbc_dbserver::v_bind_one_param(), and mysql_dbserver::v_bind_one_param().
| bool numeric::persist |
( |
ub1_t * |
buf, |
|
|
size_t |
size | |
|
) |
| | const |
| bool numeric::parse |
( |
const ub1_t * |
buf |
) |
|
| bool numeric::persist_orcl |
( |
ub1_t * |
buf |
) |
const |
outputs numeric in binary oracle like format NUMERIC type
Definition at line 482 of file numeric.cpp.
References _precision, _scale, _vec, is_zero(), and sign().
Referenced by variant_factory::clone(), copy_db_row(), parse_value(), binder::set_as_decimal(), binder::set_as_numeric(), orcl_dbserver::v_bind_one_param(), orcl_dbserver::v_convert_one_value(), odbc_dbserver::v_convert_one_value(), mysql_dbserver::v_convert_one_value(), orcl_dbserver::v_rebind_one_param(), odbc_dbserver::v_rebind_one_param(), and mysql_dbserver::v_rebind_one_param().
| bool numeric::parse_orcl |
( |
const ub1_t * |
buf |
) |
|
parses external oracle like binary buffer extracting numeric
Definition at line 276 of file numeric.cpp.
References _vec, negative(), numeric(), and zero().
Referenced by variant_factory::clone(), binder::clone(), dbserver_impl::get_param_as_numeric(), memlookup::get_value_as_numeric(), terimber_db_value_vector_impl::get_value_as_numeric(), dbserver_impl::get_value_as_numeric(), persist_value(), binder::set_as_decimal(), binder::set_as_numeric(), orcl_dbserver::v_bind_one_param(), odbc_dbserver::v_bind_one_param(), mysql_dbserver::v_bind_one_param(), orcl_dbserver::v_convert_one_value(), and orcl_dbserver::v_rebind_one_param().
| size_t numeric::orcl_len |
( |
|
) |
const |
gets the minimum length for oracle output
Definition at line 589 of file numeric.cpp.
References _precision, _scale, is_zero(), precision(), and scale().
Referenced by variant_factory::clone(), binder::clone(), copy_db_row(), parse_value(), binder::set_as_decimal(), binder::set_as_numeric(), orcl_dbserver::v_bind_one_param(), orcl_dbserver::v_convert_one_value(), odbc_dbserver::v_convert_one_value(), mysql_dbserver::v_convert_one_value(), orcl_dbserver::v_rebind_one_param(), odbc_dbserver::v_rebind_one_param(), and mysql_dbserver::v_rebind_one_param().
| const numeric & numeric::zero |
( |
|
) |
[static] |
| const numeric & numeric::one |
( |
|
) |
[static] |
| int numeric::compare_orcl |
( |
const ub1_t * |
x, |
|
|
const ub1_t * |
y | |
|
) |
| | [static] |
compares binaries in oracle format
- Parameters:
-
| x |
first argument |
| y |
second argument |
Definition at line 352 of file numeric.cpp.
Referenced by operator_less().
| int numeric::compare |
( |
const numeric & |
x, |
|
|
const numeric & |
y | |
|
) |
| | [static, private] |
| numeric & numeric::negative |
( |
|
) |
[private] |
| numeric & numeric::cutjunk |
( |
|
) |
[private] |
removes unused tailing or leading zeroes
Definition at line 851 of file numeric.cpp.
References _precision, _scale, and _vec.
Referenced by divide(), operator%(), operator%=(), operator*(), operator*=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), and scan().
| numeric& numeric::round |
( |
size_t |
scale_ |
) |
[private] |
rounds up to the scale
- Parameters:
-
| numeric & numeric::operator<< |
( |
int |
shift |
) |
[private] |
| numeric & numeric::operator>> |
( |
int |
shift |
) |
[private] |
| numeric & numeric::scan |
( |
const char * |
x, |
|
|
size_t |
len, |
|
|
char |
delimeter | |
|
) |
| | [private] |
Friends And Related Function Documentation
operator+
- Parameters:
-
| x |
first argument |
| y |
second argument |
Definition at line 1268 of file numeric.cpp.
operator-
- Parameters:
-
| x |
first argument |
| y |
second argument |
Definition at line 1275 of file numeric.cpp.
operator*
- Parameters:
-
| x |
first argument |
| y |
second argument |
Definition at line 1282 of file numeric.cpp.
operator/
- Parameters:
-
| x |
first argument |
| y |
second argument |
Definition at line 1289 of file numeric.cpp.
operator%
- Parameters:
-
| x |
first argument |
| y |
second argument |
Definition at line 1296 of file numeric.cpp.
Member Data Documentation
internal buffer
Definition at line 253 of file numeric.h.
Referenced by compare(), cutjunk(), divide(), format(), is_zero(), minus(), multiply(), numeric(), operator%=(), operator*=(), operator+=(), operator-=(), operator/=(), operator<<(), operator=(), operator>>(), parse(), parse_orcl(), persist(), persist_orcl(), persist_sql(), plus(), and scan().
scale
Definition at line 254 of file numeric.h.
Referenced by compare(), cutjunk(), divide(), format(), minus(), multiply(), operator<<(), operator=(), operator>>(), orcl_len(), parse(), parse_sql(), persist(), persist_orcl(), persist_sql(), plus(), scale(), and scan().
precision
Definition at line 255 of file numeric.h.
Referenced by compare(), cutjunk(), divide(), format(), is_zero(), minus(), multiply(), numeric(), operator<<(), operator=(), operator>>(), orcl_len(), parse(), persist(), persist_orcl(), persist_sql(), plus(), precision(), and scan().
sign, true means negative
Definition at line 256 of file numeric.h.
Referenced by format(), negative(), numeric(), operator%=(), operator*=(), operator+=(), operator-=(), operator/=(), operator<(), operator<=(), operator=(), operator==(), parse(), parse_sql(), persist(), persist_sql(), scan(), and sign().
The documentation for this class was generated from the following files:
|
|