Public Member Functions | Public Attributes

cmn_FastZeroRecSearch Class Reference
[G_new_group]

This is a class for fast search of zeroes through buffer. More...

#include <cmn_FastSearch.h>

Inheritance diagram for cmn_FastZeroRecSearch:
Inheritance graph
[legend]
Collaboration diagram for cmn_FastZeroRecSearch:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 cmn_FastZeroRecSearch (int a_numberOfZeroes)
 cmn_FastZeroRecSearch (const char *const a_buffer_p, const int a_bufLen, int a_numberOfZeroes)
virtual ~cmn_FastZeroRecSearch ()
void SetPattern (const string &a_pattern)
 set new search pattern, just to implement virtual method
void SetNumberOfZeroes (const int a_num)
Int32_t Find ()
 NOTE! if return value is grater than buffer then string was not found the return value is willing handled in this way, because of using same algorithem with merging buffers.

Public Attributes

 log_CLASSID_m
 Macro to add class name member s_className.

Detailed Description

This is a class for fast search of zeroes through buffer.

Definition at line 232 of file cmn_FastSearch.h.


Constructor & Destructor Documentation

cmn_FastZeroRecSearch::cmn_FastZeroRecSearch ( int  a_numberOfZeroes  ) 

Definition at line 320 of file cmn_FastSearch.cpp.

References log_FUNC_m.

cmn_FastZeroRecSearch::cmn_FastZeroRecSearch ( const char *const   a_buffer_p,
const int  a_bufLen,
int  a_numberOfZeroes 
)

Definition at line 331 of file cmn_FastSearch.cpp.

References log_FUNC_m.

            :
            cmn_FastZeroSearch(a_buffer_p, a_bufLen, a_recLen)
{
    log_FUNC_m(cmn_FastZeroRecSearch);
    //Empty
}

virtual cmn_FastZeroRecSearch::~cmn_FastZeroRecSearch (  )  [inline, virtual]

Definition at line 243 of file cmn_FastSearch.h.

{};


Member Function Documentation

Int32_t cmn_FastZeroRecSearch::Find (  )  [virtual]

NOTE! if return value is grater than buffer then string was not found the return value is willing handled in this way, because of using same algorithem with merging buffers.

It's known how much buffer is need to be merged at front of next buffer.

Reimplemented from cmn_FastZeroSearch.

Definition at line 344 of file cmn_FastSearch.cpp.

References log_FUNC_m, cmn_FastSearch::m_buffer_p, cmn_FastSearch::m_bufLen, cmn_FastZeroSearch::m_numberOfZeroes, and zero.

                                    {
    log_FUNC_m(Find);

    register UInt32_t   patLen   = m_numberOfZeroes;
    register UInt32_t   patLen_1 = patLen - 1;

    register const char *p    = m_buffer_p + patLen_1;
    register const char *s    = m_buffer_p;

    register char    zero = 0;

    const char          *buff = m_buffer_p;

    const char *limit = buff + m_bufLen;
    while (p < limit) {                           
       while (*p == zero) {
           if (p == s) {
              return static_cast<Int32_t>(p - buff);
           }
           p--;
       }
       p = patLen_1 + (s += patLen);  // s = start of next rec and p = end of next record
    }
    return static_cast<Int32_t>( (p - buff - m_bufLen) - patLen );  // NOTE! if return value is negative then string was not found
}

void cmn_FastZeroRecSearch::SetNumberOfZeroes ( const int  a_num  )  [inline]

Reimplemented from cmn_FastZeroSearch.

Definition at line 257 of file cmn_FastSearch.h.

{m_numberOfZeroes = a_num;};

void cmn_FastZeroRecSearch::SetPattern ( const string &  a_pattern  )  [inline, virtual]

set new search pattern, just to implement virtual method

Reimplemented from cmn_FastZeroSearch.

Definition at line 253 of file cmn_FastSearch.h.

                                                     {
        m_numberOfZeroes = static_cast<UInt32_t>(a_pattern.length());
    };


Member Data Documentation

Macro to add class name member s_className.

Reimplemented from cmn_FastZeroSearch.

Definition at line 243 of file cmn_FastSearch.h.


The documentation for this class was generated from the following files: