Thread portable class


Gate portable class


Timer class


Pool class


Terimber 2.0


About C++


Downloads Products & Services Support Clients Open Source About



Home / Open source / Terimber 2.0

numeric Class Reference

float 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
numericoperator= (const numeric &x)
 assign operator
numericoperator++ ()
 operator++
numeric operator++ (int)
 operator++(int)
numericoperator-- ()
 operator--
numeric operator-- (int)
 operator--(int)
numericoperator+= (const numeric &x)
 operator+=
numericoperator-= (const numeric &x)
 operator-=
numericoperator*= (const numeric &x)
 operator *=
numericoperator/= (const numeric &x)
 operator /=
numericoperator%= (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 numericzero ()
 static zero
static const numericone ()
 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
numericnegative ()
 makes numeric negative
numericcutjunk ()
 removes unused tailing or leading zeroes
numericround (size_t scale_)
 rounds up to the scale
numericoperator<< (int shift)
 shifts buffer to the left
numericoperator>> (int shift)
 shifts buffer to the right
numericscan (const char *x, size_t len, char delimeter)
 scans external string with specified delimeter
numericscan (const wchar_t *x, size_t len, wchar_t delimeter)
 scans external wide string with specified delimeter

Static Private Member Functions

static numericplus (numeric &res, const numeric &x, const numeric &y)
 returns x+y
static numericminus (numeric &res, const numeric &x, const numeric &y)
 returns x-y
static numericmultiply (numeric &res, const numeric &x, const numeric &y)
 returns x*y
static numericdivide (numeric &res, numeric &reminder, const numeric &dividend, const numeric &divider)
 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 ( byte_allocator allocator_ = 0  ) 

default constructor

Parameters:
allocator_  optional external allocator

Definition at line 52 of file numeric.cpp.

References _vec.

Referenced by numeric(), parse_orcl(), parse_sql(), and scan().

numeric::~numeric (  ) 

destructor

Definition at line 58 of file numeric.cpp.

numeric::numeric ( sb8_t  x,
byte_allocator allocator_ = 0 
) [explicit]

constructor

Parameters:
x  64 bits integer
allocator_  optional external allocator

Definition at line 87 of file numeric.cpp.

References _vec, I64d, scan(), and str_template::strprint().

numeric::numeric ( sb4_t  x,
byte_allocator allocator_ = 0 
) [explicit]

constructor

Parameters:
x  32 bits integer
allocator_  optional external allocator

Definition at line 74 of file numeric.cpp.

References _precision, _radix, _sign, and _vec.

numeric::numeric ( float  x,
byte_allocator allocator_ = 0 
) [explicit]

constructor

Parameters:
x  32 bits float
allocator_  optional external allocator

Definition at line 96 of file numeric.cpp.

References _vec, scan(), and str_template::strprint().

numeric::numeric ( double  x,
byte_allocator allocator_ = 0 
) [explicit]

constructor

Parameters:
x  64 bits float
allocator_  optional external allocator

Definition at line 106 of file numeric.cpp.

References _vec, scan(), and str_template::strprint().

numeric::numeric ( const char *  x,
size_t  len,
numeric_radix  radix = RADIX10,
byte_allocator allocator_ = 0 
) [explicit]

constructor

Parameters:
x  input string, no delimeters
len  string length
radix  radix
allocator_  optional external allocator

Definition at line 116 of file numeric.cpp.

References _sign, _vec, numeric(), os_minus_one, RADIX10, RADIX16, str_template::strlen(), and symbol_to_byte().

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().

numeric::numeric ( const wchar_t x,
size_t  len,
wchar_t  delimeter,
byte_allocator allocator_ = 0 
) [explicit]

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  ) 

copy constructor

Definition at line 832 of file numeric.cpp.

numeric::numeric ( ub1_t  x,
size_t  length,
byte_allocator allocator_ = 0 
) [private]

private constructor

Parameters:
x  input value
length  reserved length
allocator_  optional external allocator

Definition at line 62 of file numeric.cpp.

References _vec.

numeric::numeric ( const ub1_t x,
size_t  length,
byte_allocator allocator_ = 0 
) [private]

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= ( const numeric x  ) 

assign operator

Definition at line 838 of file numeric.cpp.

References _precision, _scale, _sign, and _vec.

numeric & numeric::operator++ (  ) 

operator++

Definition at line 707 of file numeric.cpp.

References one().

numeric numeric::operator++ ( int   ) 

operator++(int)

Definition at line 713 of file numeric.cpp.

References one().

numeric & numeric::operator-- (  ) 

operator--

Definition at line 721 of file numeric.cpp.

References one().

numeric numeric::operator-- ( int   ) 

operator--(int)

Definition at line 727 of file numeric.cpp.

References one().

numeric & numeric::operator+= ( const numeric x  ) 

operator+=

Definition at line 735 of file numeric.cpp.

References _sign, _vec, compare(), cutjunk(), minus(), and plus().

numeric & numeric::operator-= ( const numeric x  ) 

operator-=

Definition at line 769 of file numeric.cpp.

References _sign, _vec, compare(), cutjunk(), minus(), and plus().

numeric & numeric::operator*= ( const numeric x  ) 

operator *=

Definition at line 803 of file numeric.cpp.

References _sign, _vec, cutjunk(), and multiply().

numeric & numeric::operator/= ( const numeric x  ) 

operator /=

Definition at line 812 of file numeric.cpp.

References _sign, _vec, cutjunk(), and divide().

numeric & numeric::operator%= ( const numeric x  ) 

operator =

Definition at line 822 of file numeric.cpp.

References _sign, _vec, cutjunk(), and divide().

bool numeric::operator== ( const numeric x  ) 

equal operator

Definition at line 923 of file numeric.cpp.

References _sign, and compare().

bool numeric::operator!= ( const numeric x  ) 

non equal operator

Definition at line 929 of file numeric.cpp.

bool numeric::operator< ( const numeric x  ) 

operator<

Definition at line 935 of file numeric.cpp.

References _sign, and compare().

bool numeric::operator<= ( const numeric x  ) 

operator <=

Definition at line 941 of file numeric.cpp.

References _sign, and compare().

bool numeric::operator> ( const numeric x  ) 

operator>

Definition at line 947 of file numeric.cpp.

bool numeric::operator>= ( const numeric x  ) 

operator >=

Definition at line 953 of file numeric.cpp.

bool numeric::sign (  )  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

output numeric in binary format

Definition at line 193 of file numeric.cpp.

References _precision, _scale, _sign, and _vec.

bool numeric::parse ( const ub1_t buf  ) 

parses binary buffer extracting numeric

Definition at line 215 of file numeric.cpp.

References _precision, _scale, _sign, and _vec.

bool numeric::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

Definition at line 607 of file numeric.cpp.

References _precision, _scale, _sign, _vec, and is_zero().

bool numeric::parse_sql ( ub1_t  sign,
const ub1_t buf,
ub1_t  precision,
sb1_t  scale 
)

parses external ms sql like binary buffer extracting numeric

Definition at line 631 of file numeric.cpp.

References _scale, _sign, numeric(), and zero().

const numeric & numeric::zero (  )  [static]

static zero

Definition at line 682 of file numeric.cpp.

Referenced by divide(), format(), parse_orcl(), and parse_sql().

const numeric & numeric::one (  )  [static]

static one

Definition at line 690 of file numeric.cpp.

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

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().

numeric & numeric::plus ( numeric res,
const numeric x,
const numeric y 
) [static, private]

returns x+y

Parameters:
res  result
x  first argument
y  second argument

Definition at line 962 of file numeric.cpp.

References _precision, _radix, _scale, _vec, precision(), and scale().

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

numeric & numeric::minus ( numeric res,
const numeric x,
const numeric y 
) [static, private]

returns x-y

Parameters:
res  result
x  first argument
y  second argument

Definition at line 1016 of file numeric.cpp.

References _precision, _radix, _scale, _vec, precision(), and scale().

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

numeric & numeric::multiply ( numeric res,
const numeric x,
const numeric y 
) [static, private]

returns x*y

Parameters:
res  result
x  first argument
y  second argument

Definition at line 1069 of file numeric.cpp.

References _precision, _radix, _scale, and _vec.

Referenced by operator*=().

numeric & numeric::divide ( numeric res,
numeric reminder,
const numeric dividend,
const numeric divider 
) [static, private]

returns x/y

Parameters:
res  result
reminder  reminder
dividend  dividend
divider  divider

Definition at line 1130 of file numeric.cpp.

References _precision, _scale, exception::_throw(), _vec, compare(), cutjunk(), is_zero(), and zero().

Referenced by operator%=(), and operator/=().

int numeric::compare ( const numeric x,
const numeric y 
) [static, private]

compares x, y

Parameters:
x  first argument
y  second argument

Definition at line 1228 of file numeric.cpp.

References _precision, _scale, and _vec.

Referenced by divide(), format(), operator+=(), operator-=(), operator<(), operator<=(), and operator==().

numeric & numeric::negative (  )  [private]

makes numeric negative

Definition at line 656 of file numeric.cpp.

References _sign.

Referenced by parse_orcl().

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:
scale_  scale

numeric & numeric::operator<< ( int  shift  )  [private]

shifts buffer to the left

Definition at line 879 of file numeric.cpp.

References _precision, _scale, and _vec.

numeric & numeric::operator>> ( int  shift  )  [private]

shifts buffer to the right

Definition at line 902 of file numeric.cpp.

References _precision, _scale, and _vec.

numeric & numeric::scan ( const char *  x,
size_t  len,
char  delimeter 
) [private]

scans external string with specified delimeter

Parameters:
x  input string
len  string length
delimeter  delimeter

Definition at line 1305 of file numeric.cpp.

References _precision, _scale, _sign, _vec, cutjunk(), numeric(), RADIX16, and symbol_to_byte().

Referenced by numeric().

numeric & numeric::scan ( const wchar_t x,
size_t  len,
wchar_t  delimeter 
) [private]

scans external wide string with specified delimeter

Parameters:
x  input wide string
len  string length
delimeter  delimeter

Definition at line 1355 of file numeric.cpp.

References _precision, _scale, _sign, _vec, numeric(), RADIX16, and symbol_to_byte().


Friends And Related Function Documentation

numeric operator+ ( const numeric x,
const numeric y 
) [friend]

operator+

Parameters:
x  first argument
y  second argument

Definition at line 1268 of file numeric.cpp.

numeric operator- ( const numeric x,
const numeric y 
) [friend]

operator-

Parameters:
x  first argument
y  second argument

Definition at line 1275 of file numeric.cpp.

numeric operator* ( const numeric x,
const numeric y 
) [friend]

operator*

Parameters:
x  first argument
y  second argument

Definition at line 1282 of file numeric.cpp.

numeric operator/ ( const numeric x,
const numeric y 
) [friend]

operator/

Parameters:
x  first argument
y  second argument

Definition at line 1289 of file numeric.cpp.

numeric operator% ( const numeric x,
const numeric y 
) [friend]

operator%

Parameters:
x  first argument
y  second argument

Definition at line 1296 of file numeric.cpp.


Member Data Documentation

const numeric_radix numeric::_radix = RADIX10 [static]

radix 10

Definition at line 250 of file numeric.h.

Referenced by minus(), multiply(), numeric(), plus(), and room_count().


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


© Copyright Terimber 2003-.