C++ bindings for cgul_substring
More...
#include <cgul_substring_cxx.h>
|
static const char * | search_ez (const char *ss, const char *s) |
|
static const char * | search_ez (const char *ss, size_t ss_length, const char *block, size_t block_length) |
|
This class provides the C++ bindings for cgul_substring
. The main purpose of this class is to convert the C-style function calls and exception handling in cgul_substring
into C++-style function calls and exception handling.
§ cgul_substring_cxx() [1/4]
cgul_substring_cxx::cgul_substring_cxx |
( |
| ) |
|
|
inline |
Default constructor that creates a new instance with an undefined substring. If an error occurs, an exception is thrown.
References cgul_substring__new().
§ cgul_substring_cxx() [2/4]
cgul_substring_cxx::cgul_substring_cxx |
( |
const char * |
substring | ) |
|
|
inline |
Construct a new instance initialized from the C-style substring substring
. If an error occurs, an exception is thrown.
- Parameters
-
[in] | substring | c-style substring |
References cgul_substring__new_from_cstring().
§ cgul_substring_cxx() [3/4]
cgul_substring_cxx::cgul_substring_cxx |
( |
const char * |
substring, |
|
|
size_t |
length |
|
) |
| |
|
inline |
Construct a new instance initialized from the binary substring substring
that extends for length
bytes. If an error occurs, an exception is thrown.
- Parameters
-
[in] | substring | binary substring |
[in] | length | length of substring |
References cgul_substring__new_from_bstring().
§ cgul_substring_cxx() [4/4]
§ ~cgul_substring_cxx()
virtual cgul_substring_cxx::~cgul_substring_cxx |
( |
| ) |
|
|
inlinevirtual |
§ search_ez() [1/2]
static const char* cgul_substring_cxx::search_ez |
( |
const char * |
ss, |
|
|
const char * |
s |
|
) |
| |
|
inlinestatic |
This function is the easy way to search because it does not require the user to allocate a cgul_substring
instance. Instead, just pass in the c-style substring ss
along with the c-style string s
to search. If the substring is found, a pointer to the first matching character of the substring in s
is returned; otherwise, NULL
is returned.
If you are only going to search s
once, in addition to being easier to use, this function will be faster than search()
because this function does not copy the substring.
- Parameters
-
[in] | ss | c-style substring |
[in] | s | c-style string to search |
- Returns
- pointer to first match or
NULL
if no match
References cgul_substring__search_ez().
§ search_ez() [2/2]
static const char* cgul_substring_cxx::search_ez |
( |
const char * |
ss, |
|
|
size_t |
ss_length, |
|
|
const char * |
block, |
|
|
size_t |
block_length |
|
) |
| |
|
inlinestatic |
This function is the easy way to search because it does not require the user to allocate a cgul_substring
instance. Instead, just pass in the binary substring ss
and its length ss_length
in bytes along with the binary block block
to search and its length block_length
in bytes. If the substring is found, a pointer to the first matching character of the substring in block
is returned; otherwise, NULL
is returned.
If you are only going to search block
once, in addition to being easier to use, this function will be faster than search()
because this function does not copy the substring.
- Parameters
-
[in] | ss | binary substring |
[in] | ss_length | substring length in bytes |
[in] | block | block of binary data to search |
[in] | block_length | block length in bytes |
- Returns
- pointer to first match or
NULL
if no match
References cgul_substring__search_ez().
§ operator=() [1/2]
§ operator=() [2/2]
§ get_value()
virtual const char* cgul_substring_cxx::get_value |
( |
| ) |
const |
|
inlinevirtual |
§ set_value() [1/2]
virtual void cgul_substring_cxx::set_value |
( |
const char * |
substring | ) |
|
|
inlinevirtual |
Set the value to use as the substring in subsequent searches from the C-style substring substring
. This function must be called before calling search()
. It caches the pre-computations based on the substring so that subsequent searches for the same substring will not have to recompute the same values. If an error occurs, an exception is thrown.
In addition to caching the pre-computed values, this function also caches a copy of substring
for use with search()
. Because search_ez()
does not copy the substring, it is not always clear whether search()
or search_ez()
will run faster.
- Parameters
-
[in] | substring | c-style substring |
References cgul_substring__set_value().
§ set_value() [2/2]
virtual void cgul_substring_cxx::set_value |
( |
const char * |
substring, |
|
|
size_t |
length |
|
) |
| |
|
inlinevirtual |
Set the value to use as the substring in subsequent searches. This function must be called before calling search()
. It caches the pre-computations based on the substring so that subsequent searches for the same substring will not have to recompute the same values. If an error occurs, an exception is thrown.
In addition to caching the pre-computed values, this function also caches a copy of substring
for use with search()
. Because search_ez()
does not copy the substring, it is not always clear whether search()
or search_ez()
will run faster.
- Parameters
-
[in] | substring | binary substring |
[in] | length | length of substring |
References cgul_substring__set_value().
§ get_length()
virtual size_t cgul_substring_cxx::get_length |
( |
| ) |
const |
|
inlinevirtual |
§ search() [1/2]
virtual const char* cgul_substring_cxx::search |
( |
const char * |
s | ) |
|
|
inlinevirtual |
Search the c-style string s
for the substring set by the most recent call to set_value()
. If the substring is found, a pointer to the first matching character in block
is returned; otherwise, NULL
is returned.
- Parameters
-
- Returns
- pointer to first match or
NULL
if no match
References cgul_substring__search().
§ search() [2/2]
virtual const char* cgul_substring_cxx::search |
( |
const char * |
block, |
|
|
size_t |
length |
|
) |
| |
|
inlinevirtual |
Search the first length
bytes of block block
for the substring set by the most recent call to set_value()
. If the substring is found, a pointer to the first matching character in block
is returned; otherwise, NULL
is returned.
- Parameters
-
[in] | block | block of binary data to search |
[in] | length | block length in bytes |
- Returns
- pointer to first match or
NULL
if no match
References cgul_substring__search().
The documentation for this class was generated from the following file: