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.h File Reference

#include "base/string.h"
#include "base/template.h"
#include "base/vector.h"
#include "base/date.h"

Go to the source code of this file.

Classes

class  paged_buffer
 high-performance resizable buffer of bytes More...

Typedefs

typedef pool
< byte_allocator_creator
mem_pool_t
 memory pool of allocators
typedef _vector< ub1_tpaged_vector_t
 vector of bytes
typedef _list< paged_vector_tpaged_store_t
 list of pages

Enumerations

enum  numeric_radix { RADIX2 = 2, RADIX8 = 8, RADIX10 = 10, RADIX16 = 16 }
 radix enum More...

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=os_minus_one)
 produces hash
template<class T>
T * copy_string (const T *x, byte_allocator &_allocator, size_t length=os_minus_one)
 makes a copy of string using allocator memory
template<class T>
bool hex_to_binary (ub1_t *dest, const T *x, size_t len=os_minus_one)
 converts heximal string to preallocated binary array
template<class T>
bool symbol_to_byte (ub1_t &dest, T x, numeric_radix radix_=RADIX16)
 converts one radix symbol to byte
template<class T>
bool hex_to_byte (ub1_t &dest, const T *x, numeric_radix radix_=RADIX16)
 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_hex (T *dest, ub1_t x)
 converts byte to preallocated heximal string
template<class T>
void byte_to_symbol (T &dest, ub1_t x)
 converts byte to symbol
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 ub1_t *v1, const ub1_t *v2)
 compares Terimber binaries - internal format
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
terimber_xml_value parse_value (vt_types type, const char *x, size_t len_=os_minus_one, byte_allocator *allocator_=0)
 converts string representation to terimber_xml_value using external allocator
const char * persist_value (vt_types type, const terimber_xml_value &x, byte_allocator *allocator_)
 converts terimber_xml_value to string representation 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


Typedef Documentation

memory pool of allocators

Definition at line 211 of file common.h.

list of pages

Definition at line 246 of file common.h.

vector of bytes

Definition at line 243 of file common.h.


Enumeration Type Documentation

radix enum

Enumerator:
RADIX2  base 2 - binary
RADIX8  base 2 - octet
RADIX10  base 10 - decimal
RADIX16  base 16 - heximal

Definition at line 41 of file common.h.


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  length = os_minus_one 
) [inline]

makes a copy of string using allocator memory

Parameters:
x  input string
_allocator  external allocator
length  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 = os_minus_one 
) [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_ = RADIX16 
) [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 ub1_t v1,
const ub1_t v2 
) [inline]

compares Terimber binaries - internal format

Parameters:
v1  first value
v2  second value

Referenced by compare_value().

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.

terimber_xml_value parse_value ( vt_types  type,
const char *  x,
size_t  len_ = os_minus_one,
byte_allocator allocator_ = 0 
)

const char* persist_value ( vt_types  type,
const terimber_xml_value x,
byte_allocator allocator_ 
)

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_ = RADIX16 
) [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().



© Copyright Terimber 2003-.