cmn_FastZeroSearch Class Reference
[G_new_group]

#include <cmn_FastSearch.h>

Inheritance diagram for cmn_FastZeroSearch:

Inheritance graph
[legend]
Collaboration diagram for cmn_FastZeroSearch:

Collaboration graph
[legend]

List of all members.


Detailed Description

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

Definition at line 174 of file cmn_FastSearch.h.


Public Member Functions

 cmn_FastZeroSearch (int a_numberOfZeroes)
 cmn_FastZeroSearch (const char *const a_buffer_p, const int a_bufLen, int a_numberOfZeroes)
virtual ~cmn_FastZeroSearch ()
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.

Protected Attributes

UInt32_t m_numberOfZeroes
 number of sequenced zeroes to find

Constructor & Destructor Documentation

cmn_FastZeroSearch::cmn_FastZeroSearch ( int  a_numberOfZeroes  ) 

Definition at line 248 of file cmn_FastSearch.cpp.

References log_FUNC_m.

00250             :
00251             cmn_FastSearch(NULL, 0),
00252             m_numberOfZeroes(a_numberOfZeroes)
00253 {
00254     log_FUNC_m(cmn_FastZeroSearch);
00255 
00256 } 
//============================================================================//

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

Definition at line 260 of file cmn_FastSearch.cpp.

References log_FUNC_m.

00264             :
00265             cmn_FastSearch(a_buffer_p, a_bufLen),
00266             m_numberOfZeroes(a_numberOfZeroes)
00267 {
00268     log_FUNC_m(cmn_FastZeroSearch);
00269     //Empty
00270 }
//============================================================================//

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

Definition at line 185 of file cmn_FastSearch.h.

00185 {};


Member Function Documentation

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

set new search pattern, just to implement virtual method

Implements cmn_FastSearch.

Reimplemented in cmn_FastZeroRecSearch.

Definition at line 198 of file cmn_FastSearch.h.

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

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

Reimplemented in cmn_FastZeroRecSearch.

Definition at line 202 of file cmn_FastSearch.h.

00202 {m_numberOfZeroes = a_num;};

Int32_t cmn_FastZeroSearch::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.

Implements cmn_FastSearch.

Reimplemented in cmn_FastZeroRecSearch.

Definition at line 274 of file cmn_FastSearch.cpp.

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

00274                                  {
00275     log_FUNC_m(Find);
00276 
00277     UInt32_t    patLen   = m_numberOfZeroes;
00278     UInt32_t    patLen_1 = patLen - 1;
00279 
00280     register const char *p    = m_buffer_p + patLen_1;
00281     register const char *s    = m_buffer_p;
00282 
00283     register char    zero = 0;
00284 
00285     const char          *buff = m_buffer_p;
00286 
00287     const char *limit = buff + m_bufLen;
00288     while (p < limit) {   // this is optimized not readable code  it si 14% faster
00289                            // see below in comment for original code 
00290 //       register const char *r = p;
00291        while (*p == zero) {
00292            if (p == s) {
00293               return static_cast<Int32_t>(p - buff);
00294            }
00295            p--;
00296        };
00297        s  = p + 1;
00298        p += patLen;
00299     }
00300     return static_cast<Int32_t>( (p - buff - m_bufLen) - patLen );  // NOTE! if return value is negative then string was not found
00301 
00302 }


Member Data Documentation

number of sequenced zeroes to find

Definition at line 185 of file cmn_FastSearch.h.

Referenced by cmn_FastZeroRecSearch::Find(), and Find().

Macro to add class name member s_className.

Reimplemented from cmn_FastSearch.

Reimplemented in cmn_FastZeroRecSearch.

Definition at line 193 of file cmn_FastSearch.h.


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

Generated on Mon Feb 27 19:04:29 2012 for OPENARCHIVE by  doxygen 1.5.6