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_t > | paged_vector_t |
| vector of bytes
|
typedef _list< paged_vector_t > | paged_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
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] |
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().
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 = os_minus_one | |
|
) |
| | [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>
int memory_compare |
( |
const T & |
v1, |
|
|
const T & |
v2 | |
|
) |
| | [inline] |
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.
converts string representation to terimber_xml_value using external allocator
- Parameters:
-
type |
value type |
x |
input string |
len_ |
input string length |
allocator_ |
external allocator |
Definition at line 41 of file common.cpp.
References _ch_period, byte_allocator::allocate(), _terimber_xml_value_::boolVal, _terimber_xml_value_::bufVal, _terimber_xml_value_::bVal, check_pointer(), _terimber_xml_value_::cVal, _terimber_xml_value_::dblVal, _terimber_xml_value_::fltVal, _terimber_xml_value_::guidVal, hex_to_binary(), I64d, I64u, _terimber_xml_value_::intVal, _terimber_xml_value_::iVal, _terimber_xml_value_::lVal, str_template::multibyte_to_unicode(), numeric::orcl_len(), os_minus_one, numeric::persist_orcl(), str_template::strcmp(), str_template::strcpy(), string_to_guid(), str_template::strlen(), str_template::strscan(), _terimber_xml_value_::strVal, _terimber_xml_value_::uintVal, _terimber_xml_value_::uiVal, _terimber_xml_value_::ulVal, 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.
Referenced by xml_document::assign_attribute_value(), dbserver_impl::get_param_as_value(), memlookup::get_value_as_value(), terimber_db_value_vector_impl::get_value_as_value(), dbserver_impl::get_value_as_value(), var_object_repository::process_condition(), and var_object_repository::process_values().
converts terimber_xml_value to string representation using external allocator
- Parameters:
-
type |
value type |
x |
input value |
allocator_ |
external allocator |
Definition at line 177 of file common.cpp.
References _ch0, _ch1, _ch_period, byte_allocator::allocate(), binary_to_hex(), _terimber_xml_value_::boolVal, _terimber_xml_value_::bufVal, _terimber_xml_value_::bVal, check_pointer(), _terimber_xml_value_::cVal, _terimber_xml_value_::dblVal, _terimber_xml_value_::fltVal, numeric::format(), date::get_date(), guid_to_string(), _terimber_xml_value_::guidVal, I64d, I64u, _terimber_xml_value_::intVal, _terimber_xml_value_::iVal, _terimber_xml_value_::lVal, numeric::parse_orcl(), numeric::precision(), str_template::strprint(), _terimber_xml_value_::strVal, _terimber_xml_value_::uintVal, _terimber_xml_value_::uiVal, _terimber_xml_value_::ulVal, str_template::unicode_to_multibyte(), 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.
Referenced by dbserver_impl::get_param_as_value(), xml_designer_impl::get_value(), memlookup::get_value_as_value(), terimber_db_value_vector_impl::get_value_as_value(), dbserver_impl::get_value_as_value(), attributeDecl::persist_attribute(), and var_object_repository::process_query().
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().
|
|