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] |
template<class T>
void byte_to_symbol |
( |
T & |
dest, |
|
|
ub1_t |
x | |
|
) |
| | [inline] |
void* check_pointer |
( |
void * |
ptr |
) |
[inline] |
checks ptr on null and throw exception
- Parameters:
-
ptr |
pointer to allocated memory |
Definition at line 61 of file common.hpp.
References exception::_throw().
Referenced by xml_document::add_attribute(), xml_document::add_cdata(), xml_document::add_comment(), xml_document::add_element(), xml_document::add_element_desc(), xml_document::add_entity_desc(), xml_document::add_notation_desc(), xml_document::add_pi(), xml_document::add_text(), binder::allocate_value(), dfa_token::assign(), dtd_processor::checkRepeation(), binder::clone(), xml_grammar::copy(), copy_value(), parse_value(), dtd_processor::parseChildren(), dtd_processor::parseMixed(), persist_value(), orcl_dbserver::v_bind_one_column(), odbc_dbserver::v_bind_one_column(), mysql_dbserver::v_bind_one_column(), orcl_dbserver::v_bind_one_param(), odbc_dbserver::v_bind_one_param(), mysql_dbserver::v_bind_one_param(), orcl_dbserver::v_convert_one_value(), odbc_dbserver::v_convert_one_value(), mysql_dbserver::v_convert_one_value(), odbc_dbserver::v_get_one_column_info(), orcl_dbserver::v_rebind_one_param(), odbc_dbserver::v_rebind_one_param(), mysql_dbserver::v_rebind_one_param(), orcl_dbserver::v_replace_quote(), odbc_dbserver::v_replace_quote(), mysql_dbserver::v_replace_quote(), and xml_document::validate_children().
compares the two terimber_xml_value values of the same type with additional restrictions
- Parameters:
-
type |
value type |
first |
first value |
second |
second value |
use_hash |
using hash for string |
case_insensitive |
compare strings low case |
Definition at line 476 of file common.hpp.
References _terimber_xml_value_::boolVal, _terimber_xml_value_::bufVal, _terimber_xml_value_::bVal, _terimber_xml_value_::cVal, _terimber_xml_value_::dblVal, _terimber_xml_value_::fltVal, _terimber_xml_value_::guidVal, _terimber_xml_value_::intVal, _terimber_xml_value_::iVal, _terimber_xml_value_::lVal, memory_compare(), memory_compare_binary(), os_minus_one, simple_compare(), simple_compare_ptr(), str_template::strcmp(), str_template::strnocasecmp(), _terimber_xml_value_::strVal, _terimber_xml_value_::uintVal, _terimber_xml_value_::uiVal, _terimber_xml_value_::ulVal, vt_binary, vt_bool, vt_date, vt_double, vt_empty, vt_float, vt_guid, vt_null, vt_sb1, vt_sb2, vt_sb4, vt_sb8, vt_string, vt_ub1, vt_ub2, vt_ub4, vt_ub8, vt_wstring, and _terimber_xml_value_::wstrVal.
Referenced by compare_db_value(), and xml_document::validate_attributes().
template<class T>
T* copy_string |
( |
const T * |
x, |
|
|
byte_allocator & |
_allocator, |
|
|
size_t |
len | |
|
) |
| | [inline] |
copies terimber_xml_value using external allocator
- Parameters:
-
type |
value type |
x |
input value |
_allocator |
external allocator |
Definition at line 533 of file common.hpp.
References byte_allocator::allocate(), _terimber_xml_value_::bufVal, check_pointer(), copy_string(), _terimber_xml_value_::dblVal, _terimber_xml_value_::guidVal, _terimber_xml_value_::intVal, os_minus_one, _terimber_xml_value_::strVal, _terimber_xml_value_::uintVal, vt_binary, vt_bool, vt_date, vt_decimal, vt_double, vt_empty, vt_float, vt_guid, vt_null, vt_numeric, vt_sb1, vt_sb2, vt_sb4, vt_sb8, vt_string, vt_ub1, vt_ub2, vt_ub4, vt_ub8, vt_wstring, and _terimber_xml_value_::wstrVal.
template<class T>
size_t do_hash |
( |
const T * |
x, |
|
|
size_t |
len | |
|
) |
| | [inline] |
produces hash
- Parameters:
-
x |
input pointer to array |
len |
the length of input array |
Definition at line 85 of file common.hpp.
References get16bits(), get8bits(), os_minus_one, and str_template::strlen().
Referenced by xml_grammar::add_attribute_decl(), xml_grammar::add_element_decl(), xml_grammar::add_entity_decl(), xml_grammar::add_notation_decl(), xml_grammar::add_pi_decl(), xml_grammar::add_reference_decl(), do_hash(), xml_grammar::find_attribute_decl(), xml_grammar::find_element_decl(), xml_grammar::find_entity_decl(), xml_grammar::find_notation_decl(), xml_grammar::find_pi_decl(), and xml_grammar::find_reference_decl().
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:
-
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] |
template<class T>
bool hex_to_binary |
( |
ub1_t * |
dest, |
|
|
const T * |
x, |
|
|
size_t |
len | |
|
) |
| | [inline] |
template<class T>
int memory_compare |
( |
const T & |
v1, |
|
|
const T & |
v2 | |
|
) |
| | [inline] |
int memory_compare_binary |
( |
const size_t * |
v1, |
|
|
const size_t * |
v2 | |
|
) |
| | [inline] |
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] |
template<class T>
int simple_compare_ptr |
( |
const T * |
v1, |
|
|
const T * |
v2 | |
|
) |
| | [inline] |
template<class T, class F>
int string_compare |
( |
const T & |
v1, |
|
|
const T & |
v2, |
|
|
F |
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 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
|
|