7 #ifndef _REGULAR_EXPRESSION_HELPER_CLASS_HEADER_
8 #define _REGULAR_EXPRESSION_HELPER_CLASS_HEADER_
53 ptr_(i_oOther.GetPtr()),
54 length_(i_oOther.GetSize())
65 if (
this != &i_oOther)
92 , length_(static_cast<
tInt>(str.GetLength()))
190 if ((
nullptr != buffer)
193 ptr_ =
reinterpret_cast<const tChar*
>(buffer);
265 return !(*
this == x);
268 #define STRINGPIECE_BINARY_PREDICATE(cmp,auxcmp)\
269 tBool operator cmp (const cStringPiece& x) const {\
270 tInt r = cMemoryBlock::MemCmp(ptr_, x.ptr_, length_ < x.length_ ? length_ : x.length_);\
271 return ((r auxcmp 0) || ((r == 0) && (length_ cmp x.length_)));\
301 #undef STRINGPIECE_BINARY_PREDICATE
334 if (
nullptr == GetPtr())
339 CopyToString(&strTmp);
352 if ((
nullptr != ptr_) &&
355 target->
Set(ptr_, length_);
369 if ((
nullptr == GetPtr())
370 || (
nullptr == x.
GetPtr()))
383 template<
bool B,
class T =
void>
437 #define AEVREGEXP_DECLARE_INTEGER_PARSER(name)\
439 static tBool parse_ ## name(const tChar* str, tInt n, tVoid* dest);\
440 static tBool parse_ ## name ## _radix(\
441 const tChar* str, tInt n, tVoid* dest, tInt radix);\
443 static tBool parse_ ## name ## _hex(const tChar* str, tInt n, tVoid* dest);\
444 static tBool parse_ ## name ## _octal(const tChar* str, tInt n, tVoid* dest);\
445 static tBool parse_ ## name ## _cradix(const tChar* str, tInt n, tVoid* dest)
447 AEVREGEXP_DECLARE_INTEGER_PARSER(
tInt8);
448 AEVREGEXP_DECLARE_INTEGER_PARSER(
tUInt8);
449 AEVREGEXP_DECLARE_INTEGER_PARSER(
tInt16);
450 AEVREGEXP_DECLARE_INTEGER_PARSER(
tUInt16);
451 AEVREGEXP_DECLARE_INTEGER_PARSER(
tInt32);
452 AEVREGEXP_DECLARE_INTEGER_PARSER(
tUInt32);
453 AEVREGEXP_DECLARE_INTEGER_PARSER(
tInt64);
454 AEVREGEXP_DECLARE_INTEGER_PARSER(
tUInt64);
456 #undef AEVREGEXP_DECLARE_INTEGER_PARSER
505 #define REG_EXP_CONST_INTEGER(size, name) \
507 cRegularExpressionArg(T* pRef, fnRegExpParser parser = name, \
508 typename a_utils_enable_if<std::numeric_limits<T>::is_integer, T>::type* = nullptr, \
509 typename a_utils_enable_if<std::numeric_limits<T>::is_signed, T>::type* = nullptr, \
510 typename a_utils_enable_if<a_utils_size_of_helper<T>::nSize == size, T>::type* = nullptr) \
511 : arg_(pRef), parser_(parser) {}
513 #define REG_EXP_CONST_UNSIGNED_INTEGER(size, name) \
515 cRegularExpressionArg(T* pRef, fnRegExpParser parser = name, \
516 typename a_utils_enable_if<std::numeric_limits<T>::is_integer, T>::type* = nullptr, \
517 typename a_utils_enable_if<!std::numeric_limits<T>::is_signed, T>::type* = nullptr, \
518 typename a_utils_enable_if<a_utils_size_of_helper<T>::nSize == size, T>::type* = nullptr) \
519 : arg_(pRef), parser_(parser) {}
521 #define REG_EXP_CONST_FLOAT(size, name) \
523 cRegularExpressionArg(T* pRef, fnRegExpParser parser = name, \
524 typename a_utils_enable_if<!std::numeric_limits<T>::is_integer, T>::type* = nullptr, \
525 typename a_utils_enable_if<a_utils_size_of_helper<T>::nSize == size, T>::type* = nullptr) \
526 : arg_(pRef), parser_(parser) {}
528 REG_EXP_CONST_INTEGER(1, parse_tInt8)
529 REG_EXP_CONST_UNSIGNED_INTEGER(1, parse_tUInt8)
530 REG_EXP_CONST_INTEGER(2, parse_tInt16)
531 REG_EXP_CONST_UNSIGNED_INTEGER(2, parse_tUInt16)
532 REG_EXP_CONST_INTEGER(4, parse_tInt32)
533 REG_EXP_CONST_UNSIGNED_INTEGER(4, parse_tUInt32)
534 REG_EXP_CONST_INTEGER(8, parse_tInt64)
535 REG_EXP_CONST_UNSIGNED_INTEGER(8, parse_tUInt64)
537 REG_EXP_CONST_FLOAT(4, parse_tFloat32)
538 REG_EXP_CONST_FLOAT(8, parse_tFloat64)
568 #undef REG_EXP_CONST_FLOAT
569 #undef REG_EXP_CONST_UNSIGNED_INTEGER
570 #undef REG_EXP_CONST_INTEGER
582 return (*parser_)(str, n, arg_);
587 #define A_UTILS_MAKE_INTEGER_PARSER_HELPER(size, parser, func, parser_name) \
589 inline cRegularExpressionArg func(T* pArg, \
590 typename a_utils_enable_if<std::numeric_limits<T>::is_integer, T>::type* = nullptr, \
591 typename a_utils_enable_if<std::numeric_limits<T>::is_signed, T>::type* = nullptr, \
592 typename a_utils_enable_if<a_utils_size_of_helper<T>::nSize == size, T>::type* = nullptr) \
594 return cRegularExpressionArg(pArg, cRegularExpressionArg::parse_tInt ## parser ## parser_name); \
597 #define A_UTILS_MAKE_INTEGER_PARSER(size, parser) \
598 A_UTILS_MAKE_INTEGER_PARSER_HELPER(size, parser, Hex, _hex) \
599 A_UTILS_MAKE_INTEGER_PARSER_HELPER(size, parser, Octal, _octal) \
600 A_UTILS_MAKE_INTEGER_PARSER_HELPER(size, parser, CRadix, _cradix)
602 #define A_UTILS_MAKE_UNSIGNED_INTEGER_PARSER_HELPER(size, parser, func, parser_name) \
604 inline cRegularExpressionArg func(T* pArg, \
605 typename a_utils_enable_if<std::numeric_limits<T>::is_integer, T>::type* = nullptr, \
606 typename a_utils_enable_if<!std::numeric_limits<T>::is_signed, T>::type* = nullptr, \
607 typename a_utils_enable_if<a_utils_size_of_helper<T>::nSize == size, T>::type* = nullptr) \
609 return cRegularExpressionArg(pArg, cRegularExpressionArg::parse_tUInt ## parser ## parser_name); \
612 #define A_UTILS_MAKE_UNSIGNED_INTEGER_PARSER(size, parser) \
613 A_UTILS_MAKE_UNSIGNED_INTEGER_PARSER_HELPER(size, parser, Hex, _hex) \
614 A_UTILS_MAKE_UNSIGNED_INTEGER_PARSER_HELPER(size, parser, Octal, _octal) \
615 A_UTILS_MAKE_UNSIGNED_INTEGER_PARSER_HELPER(size, parser, CRadix, _cradix)
618 A_UTILS_MAKE_INTEGER_PARSER(1, 8)
619 A_UTILS_MAKE_UNSIGNED_INTEGER_PARSER(1, 8)
620 A_UTILS_MAKE_INTEGER_PARSER(2, 16)
621 A_UTILS_MAKE_UNSIGNED_INTEGER_PARSER(2, 16)
622 A_UTILS_MAKE_INTEGER_PARSER(4, 32)
623 A_UTILS_MAKE_UNSIGNED_INTEGER_PARSER(4, 32)
624 A_UTILS_MAKE_INTEGER_PARSER(8, 64)
625 A_UTILS_MAKE_UNSIGNED_INTEGER_PARSER(8, 64)
628 #undef A_UTILS_MAKE_INTEGER_PARSER
629 #undef A_UTILS_MAKE_INTEGER_PARSER_HELPER
630 #undef A_UTILS_MAKE_UNSIGNED_INTEGER_PARSER
631 #undef A_UTILS_MAKE_UNSIGNED_INTEGER_PARSER_HELPER
uint8_t tUInt8
type definition for unsigned integer values (8bit) (platform and compiler independent type).
char tChar
The tChar defines the type for platform character set (platform and compiler dependent type).
int64_t tInt64
type definition for signed integer values (64bit) (platform and compiler independent type).
int16_t tInt16
type definition for signed integer values (16bit) (platform and compiler independent type).
int32_t tInt32
type definition for signed integer values (32bit) (platform and compiler independent type).
void tVoid
The tVoid is always the definition for the void (non-type).
uint16_t tUInt16
type definition for unsigned integer values (16bit) (platform and compiler independent type).
int tInt
type definition for signed integer value (platform and compiler dependent type).
bool tBool
The tBool defines the type for the Values tTrue and tFalse (platform and compiler dependent).
uint32_t tUInt32
type definition for unsigned integer values (32bit) (platform and compiler independent type).
size_t tSize
type definition for a array size values, map size values etc.
int8_t tInt8
type definition for signed integer values (8bit) (platform and compiler independent type).
uint64_t tUInt64
type definition for unsigned integer values (64bit) (platform and compiler independent type).
static tInt MemCmp(const tVoid *pMem1, const tVoid *pMem2, tSize nCount)
Compares the data bytes of two memory buffers.
Regular expression argument class.
fnRegExpParser GetParser() const
Retrieve the parser.
tVoid Set(fnRegExpParser pParser, tVoid *pData)
Assign parser and data.
cRegularExpressionArg(tVoid *pRef)
CTR.
cRegularExpressionArg(fnRegExpParser pParser, tVoid *pData)
Copy constructor.
cRegularExpressionArg(cStringPiece *p)
CTR.
cRegularExpressionArg(cString *p)
CTR.
cRegularExpressionArg()
Empty constructor so we can declare arrays of cRegularExpressionArg.
tBool Parse(const tChar *str, tInt n) const
Parse the given string.
tVoid * GetData() const
Retrieve arguments.
Class that represents string pieces.
tVoid RemovePrefix(tInt n)
Remove prefix of given length.
tVoid CopyToString(cString *target) const
Return string piece as standard string.
tInt length_
Length of string.
tInt Compare(const cStringPiece &x) const
Compare two string pieces.
STRINGPIECE_BINARY_PREDICATE(<,<)
Compare two string pieces.
tBool operator==(const cStringPiece &x) const
Compare two string pieces for equality.
STRINGPIECE_BINARY_PREDICATE(>, >)
Compare two string pieces.
const tChar * GetPtr() const
Retrieve character pointer.
tVoid RemoveSuffix(tInt n)
Remove suffix of given length.
cStringPiece(const cString &str)
Constructor.
STRINGPIECE_BINARY_PREDICATE(<=,<)
Compare two string pieces.
const tChar * ptr_
Character pointer.
tBool StartsWith(const cStringPiece &x) const
Check if this string piece starts with the given string piece.
tChar operator[](tInt i) const
Retrieve character at the given position.
cStringPiece()
Default constructor.
tVoid Set(const tChar *str)
Assigns the string to the string piece.
cString AsString() const
Return string piece as standard string.
tVoid Clear()
Clears the string piece.
cStringPiece(const tChar *str)
Constructor.
tVoid Set(const tChar *buffer, tInt len)
Assigns the buffer to the string piece.
STRINGPIECE_BINARY_PREDICATE(>=, >)
Compare two string pieces.
tBool IsEmpty() const
Check if string piece is empty.
cStringPiece(const tChar *offset, tInt len)
Constructor.
cStringPiece(const cStringPiece &i_oOther)
Copy constructor.
tInt GetSize() const
Retrieve the size of the string piece.
tVoid Set(const tVoid *buffer, tInt len)
Assigns the buffer to the string piece.
tBool operator!=(const cStringPiece &x) const
Compare two string pieces for inequality.
static tSize GetLength(const tChar *pcStr)
Returns the length of the string.
Template to implement the Private class of the global d_pointer definitions.
_myType & Set(const _myType &strStringToSet, tSize nLength=InvalidPos)
Assigns a new value to a cStringA object.
static const _myType Empty
Internally used empty string.
#define tFalse
Value for tBool.
#define A_UTILS_DEPRECATED(_func_)
Mark a function or variable as deprecated.
#define A_UTILS_D(__pclassname_)
Helper macro for d-pattern definitions.
ADTF A_UTIL Namespace - Within adtf this is used as adtf::util or adtf_util.
tBool(* fnRegExpParser)(const tChar *str, tInt n, tVoid *dest)
Type of regular expression parser function.
T type
type of template class
template for SFINAE selection of the right constructor
template for handling sizeof(void) in SFINAE below (required for Visual Studio)
static const tSize nSize
the size of template class