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

common.hpp File Reference

#include "base/common.h"
#include "base/except.h"
#include "base/string.hpp"

Go to the source code of this file.

Functions

void * check_pointer (void *ptr)
 checks ptr on null and throw exception
size_t get8bits (unsigned char x)
 transforms byte to lower case size_t
size_t get16bits (const unsigned char *x)
 transforms 2 byte word to lower case size_t
template<class T>
size_t do_hash (const T *x, size_t len)
 produces hash
template<class T>
T * copy_string (const T *x, byte_allocator &_allocator, size_t len)
 makes a copy of string using allocator memory
template<class T>
bool hex_to_binary (ub1_t *dest, const T *x, size_t len)
 converts heximal string to preallocated binary array
template<class T>
bool symbol_to_byte (ub1_t &dest, T x, numeric_radix radix_)
 converts one radix symbol to byte
template<class T>
bool hex_to_byte (ub1_t &dest, const T *x, numeric_radix radix_)
 converts radix symbols to byte
template<class T>
void binary_to_hex (T *dest, const ub1_t *x)
 converts binary array to preallocated heximal string
template<class T>
void byte_to_symbol (T &dest, ub1_t x)
 converts byte to symbol
template<class T>
void byte_to_hex (T *dest, ub1_t x)
 converts byte to preallocated heximal string
template<class T>
T * guid_to_string (T *dest, const guid_t &x)
 converts guid to string - no dashes or curly brackets, just heximal 16 bytes representation
template<class T>
bool string_to_guid (guid_t &dest, const T *x)
 converts string to guid - no dashes or curly brackets, just heximal 16 bytes representation
template<class T>
int simple_compare (const T &v1, const T &v2)
 compares the two values where comparision operators are defined
template<class T>
int memory_compare (const T &v1, const T &v2)
 binary compare
int memory_compare_binary (const size_t *v1, const size_t *v2)
template<class T>
int simple_compare_ptr (const T *v1, const T *v2)
 compares simple values by pointers
template<class T, class F>
int string_compare (const T &v1, const T &v2, F fn)
 strings using external function
size_t do_hash (vt_types type, const terimber_xml_value &x)
 produces hash value for terimber_xml_value enum
int compare_value (vt_types type, const terimber_xml_value &first, const terimber_xml_value &second, bool use_hash, bool case_insensitive)
 compares the two terimber_xml_value values of the same type with additional restrictions
terimber_xml_value copy_value (vt_types type, const terimber_xml_value &x, byte_allocator &_allocator)
 copies terimber_xml_value using external allocator
bool operator== (const guid_t &first, const guid_t &second)
 equal operator
bool operator!= (const guid_t &first, const guid_t &second)
 non equal operator
bool operator< (const guid_t &first, const guid_t &second)
 less operator
bool operator> (const guid_t &first, const guid_t &second)
 greater operator

Variables

BEGIN_TERIMBER_NAMESPACE const
ub1_t 
_ch_period = '.'
 period char
const ub1_t _ch0 = '0'
 0 char
const ub1_t _ch1 = '1'
 1 char
const ub1_t _ch7 = '7'
 7 char
const ub1_t _ch9 = '9'
 9 char
const ub1_t _chA = 'A'
 A char.
const ub1_t _cha = 'a'
 a char
const ub1_t _chF = 'F'
 F char.
const ub1_t _chf = 'f'
 f char


Function Documentation

template<class T>
void binary_to_hex ( T *  dest,
const ub1_t x 
) [inline]

converts binary array to preallocated heximal string

Parameters:
dest  [out] preallocated string
x  input array of bytes - internal format

Definition at line 274 of file common.hpp.

References byte_to_hex().

Referenced by persist_value().

template<class T>
void byte_to_hex ( T *  dest,
ub1_t  x 
) [inline]

converts byte to preallocated heximal string

Parameters:
dest  [out] preallocated string
x  input byte

Definition at line 305 of file common.hpp.

References byte_to_symbol().

Referenced by binary_to_hex(), and guid_to_string().

template<class T>
void byte_to_symbol ( T &  dest,
ub1_t  x 
) [inline]

converts byte to symbol

Parameters:
dest  [out] char
x  input byte

Definition at line 297 of file common.hpp.

References _ch0, and _chA.

Referenced by byte_to_hex(), and numeric::format().

template<class T>
T* copy_string ( const T *  x,
byte_allocator _allocator,
size_t  len 
) [inline]

makes a copy of string using allocator memory

Parameters:
x  input string
_allocator  external allocator
len  the length of input string

Definition at line 142 of file common.hpp.

References byte_allocator::allocate(), os_minus_one, and str_template::strlen().

Referenced by xml_document::assign_attribute_value(), copy_db_row(), copy_value(), vardatabase::fill_schema(), binder::set_name(), tokenValues(), and xml_designer_impl::update_value().

size_t do_hash ( vt_types  type,
const terimber_xml_value x 
) [inline]

produces hash value for terimber_xml_value enum

Parameters:
type  value type
x  input value

Definition at line 448 of file common.hpp.

References _terimber_xml_value_::bufVal, do_hash(), os_minus_one, _terimber_xml_value_::strVal, vt_binary, vt_string, vt_wstring, and _terimber_xml_value_::wstrVal.

size_t get16bits ( const unsigned char *  x  )  [inline]

transforms 2 byte word to lower case size_t

Parameters:
x  input pointer to array of bytes

Definition at line 77 of file common.hpp.

Referenced by do_hash().

size_t get8bits ( unsigned char  x  )  [inline]

transforms byte to lower case size_t

Parameters:
x  input byte

Definition at line 70 of file common.hpp.

Referenced by do_hash().

template<class T>
T* guid_to_string ( T *  dest,
const guid_t x 
) [inline]

converts guid to string - no dashes or curly brackets, just heximal 16 bytes representation

Parameters:
dest  [out] preallocated string
x  guid

Definition at line 316 of file common.hpp.

References byte_to_hex(), _terimber_guid_::Data1, _terimber_guid_::Data2, _terimber_guid_::Data3, and _terimber_guid_::Data4.

Referenced by msg_communicator::log_msg(), and persist_value().

template<class T>
bool hex_to_binary ( ub1_t dest,
const T *  x,
size_t  len 
) [inline]

converts heximal string to preallocated binary array

Parameters:
dest  [out] array of bytes
x  input string
len  the length of input string

Definition at line 162 of file common.hpp.

References hex_to_byte(), os_minus_one, RADIX16, and str_template::strlen().

Referenced by parse_value().

template<class T>
bool hex_to_byte ( ub1_t dest,
const T *  x,
numeric_radix  radix_ 
) [inline]

converts radix symbols to byte

Parameters:
dest  [out] byte
x  input string
radix_  radix

Definition at line 235 of file common.hpp.

References RADIX10, RADIX16, RADIX2, RADIX8, and symbol_to_byte().

Referenced by hex_to_binary(), and string_to_guid().

template<class T>
int memory_compare ( const T &  v1,
const T &  v2 
) [inline]

binary compare

Parameters:
v1  first value
v2  second value

Definition at line 418 of file common.hpp.

Referenced by compare_value().

int memory_compare_binary ( const size_t *  v1,
const size_t *  v2 
) [inline]

Definition at line 425 of file common.hpp.

bool operator!= ( const guid_t first,
const guid_t second 
) [inline]

non equal operator

Parameters:
first  first value
second  second value

Definition at line 639 of file common.hpp.

bool operator< ( const guid_t first,
const guid_t second 
) [inline]

less operator

Parameters:
first  first value
second  second value

Definition at line 646 of file common.hpp.

bool operator== ( const guid_t first,
const guid_t second 
) [inline]

equal operator

Parameters:
first  first value
second  second value

Definition at line 632 of file common.hpp.

bool operator> ( const guid_t first,
const guid_t second 
) [inline]

greater operator

Parameters:
first  first value
second  second value

Definition at line 651 of file common.hpp.

template<class T>
int simple_compare ( const T &  v1,
const T &  v2 
) [inline]

compares the two values where comparision operators are defined

Parameters:
v1  first value
v2  second value

Definition at line 410 of file common.hpp.

Referenced by compare_value(), and simple_compare_ptr().

template<class T>
int simple_compare_ptr ( const T *  v1,
const T *  v2 
) [inline]

compares simple values by pointers

Parameters:
v1  first value
v2  second value

Definition at line 433 of file common.hpp.

References simple_compare().

Referenced by compare_value().

template<class T, class F>
int string_compare ( const T &  v1,
const T &  v2,
fn 
) [inline]

strings using external function

Parameters:
v1  first value
v2  second value
fn  comaprision function

Definition at line 441 of file common.hpp.

template<class T>
bool string_to_guid ( guid_t dest,
const T *  x 
) [inline]

converts string to guid - no dashes or curly brackets, just heximal 16 bytes representation

Parameters:
dest  [out] guid
x  input string

Definition at line 353 of file common.hpp.

References _terimber_guid_::Data1, _terimber_guid_::Data2, _terimber_guid_::Data3, _terimber_guid_::Data4, hex_to_byte(), and RADIX16.

Referenced by msg_communicator::init(), msg_communicator::parse_connection(), msg_communicator::parse_listener(), and parse_value().

template<class T>
bool symbol_to_byte ( ub1_t dest,
x,
numeric_radix  radix_ 
) [inline]

converts one radix symbol to byte

Parameters:
dest  [out] byte
x  input char
radix_  radix

Definition at line 195 of file common.hpp.

References _ch0, _ch1, _ch7, _ch9, _cha, _chA, _chf, _chF, RADIX10, RADIX16, RADIX2, and RADIX8.

Referenced by hex_to_byte(), numeric::numeric(), and numeric::scan().


Variable Documentation

const ub1_t _ch0 = '0'

0 char

Definition at line 42 of file common.hpp.

Referenced by byte_to_symbol(), persist_value(), and symbol_to_byte().

const ub1_t _ch1 = '1'

1 char

Definition at line 44 of file common.hpp.

Referenced by persist_value(), and symbol_to_byte().

const ub1_t _ch7 = '7'

7 char

Definition at line 46 of file common.hpp.

Referenced by symbol_to_byte().

const ub1_t _ch9 = '9'

9 char

Definition at line 48 of file common.hpp.

Referenced by symbol_to_byte().

BEGIN_TERIMBER_NAMESPACE const ub1_t _ch_period = '.'

period char

Definition at line 40 of file common.hpp.

Referenced by parse_value(), and persist_value().

const ub1_t _cha = 'a'

a char

Definition at line 52 of file common.hpp.

Referenced by symbol_to_byte().

const ub1_t _chA = 'A'

A char.

Definition at line 50 of file common.hpp.

Referenced by byte_to_symbol(), and symbol_to_byte().

const ub1_t _chf = 'f'

f char

Definition at line 56 of file common.hpp.

Referenced by symbol_to_byte().

const ub1_t _chF = 'F'

F char.

Definition at line 54 of file common.hpp.

Referenced by symbol_to_byte().



© Copyright Terimber 2003-.