cgul_substring_cxx Class Reference

C++ bindings for cgul_substring More...

#include <cgul_substring_cxx.h>

Collaboration diagram for cgul_substring_cxx:
Collaboration graph

Public Member Functions

 cgul_substring_cxx ()
 
 cgul_substring_cxx (const char *substring)
 
 cgul_substring_cxx (const char *substring, size_t length)
 
 cgul_substring_cxx (const cgul_substring_cxx &rhs)
 
virtual ~cgul_substring_cxx ()
 
virtual cgul_substring_cxxoperator= (const cgul_substring_cxx &rhs)
 
virtual cgul_substring_cxxoperator= (const char *rhs)
 
virtual const char * get_value () const
 
virtual void set_value (const char *substring)
 
virtual void set_value (const char *substring, size_t length)
 
virtual size_t get_length () const
 
virtual const char * search (const char *s)
 
virtual const char * search (const char *block, size_t length)
 

Static Public Member Functions

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)
 

Detailed Description

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.

Constructor & Destructor Documentation

§ 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]substringc-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]substringbinary substring
[in]lengthlength of substring

References cgul_substring__new_from_bstring().

§ cgul_substring_cxx() [4/4]

cgul_substring_cxx::cgul_substring_cxx ( const cgul_substring_cxx rhs)
inline

Copy constructor that creates a new instance by copying the value from rhs. If an error occurs, an exception is thrown.

Parameters
[in]rhsright-hand side

References cgul_substring__new_from_bstring(), get_length(), and get_value().

§ ~cgul_substring_cxx()

virtual cgul_substring_cxx::~cgul_substring_cxx ( )
inlinevirtual

Destructor.

References cgul_substring__delete().

Member Function Documentation

§ 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]ssc-style substring
[in]sc-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]ssbinary substring
[in]ss_lengthsubstring length in bytes
[in]blockblock of binary data to search
[in]block_lengthblock length in bytes
Returns
pointer to first match or NULL if no match

References cgul_substring__search_ez().

§ operator=() [1/2]

virtual cgul_substring_cxx& cgul_substring_cxx::operator= ( const cgul_substring_cxx rhs)
inlinevirtual

Assign the value from rhs to this object and return this object.

Parameters
[in]rhsright-hand side
Returns
*this

References cgul_substring__set_value(), get_length(), and get_value().

§ operator=() [2/2]

virtual cgul_substring_cxx& cgul_substring_cxx::operator= ( const char *  rhs)
inlinevirtual

Assign the value from rhs to this object and return this object.

Parameters
[in]rhsright-hand side
Returns
*this

References cgul_substring__set_value().

§ get_value()

virtual const char* cgul_substring_cxx::get_value ( ) const
inlinevirtual

Get the value used as the substring in subsequent searches. The value can be set by calling set_value(). If the value is not set, NULL is returned.

Returns
value used as the substring in subsequent searches

References cgul_substring__get_value().

Referenced by cgul_substring_cxx(), and operator=().

§ 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]substringc-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]substringbinary substring
[in]lengthlength of substring

References cgul_substring__set_value().

§ get_length()

virtual size_t cgul_substring_cxx::get_length ( ) const
inlinevirtual

Get the length of the substring that will be used in subsequent searches. The substring can be set by calling set_value(). If the substring is not set, 0 is returned.

Returns
length of the substring that will be used in subsequent searches

References cgul_substring__get_length().

Referenced by cgul_substring_cxx(), and operator=().

§ 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
[in]sc-style string
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]blockblock of binary data to search
[in]lengthblock 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: