cmn_FastFileSearch Class Reference
[Classes for large file i/o, relative file, and DataBase]

#include <cmn_FastFileSearch.h>

Collaboration diagram for cmn_FastFileSearch:

Collaboration graph
[legend]

List of all members.


Detailed Description

<Description:> A more elaborate class description that describes all aspects of class usage etc.

Author:
Dejan Volk Lupo, HERMES SoftLab
See also:
<reference>

Definition at line 32 of file cmn_FastFileSearch.h.


Public Member Functions

 cmn_FastFileSearch (cmn_FastSearch *a_fastSearch_p, cmn_File *a_file_p, ivd_FileBufSize_t a_buffSize=4096)
virtual ~cmn_FastFileSearch ()
ivd_FilePosition_t Find (ivd_FilePosition_t a_start)
void SetFile (cmn_File *a_file_p)

Public Attributes

 log_CLASSID_m
 Description of a class member.

Private Attributes

cmn_FastSearchm_fastSearch_p
 pointer to fast search instance
cmn_Filem_file_p
 file that need to be searched
ivd_FileBufSize_t m_buffSize
 size of buffer where search is perform
char * m_buffer_p

Constructor & Destructor Documentation

cmn_FastFileSearch::cmn_FastFileSearch ( cmn_FastSearch a_fastSearch_p,
cmn_File a_file_p,
ivd_FileBufSize_t  a_buffSize = 4096 
)

Definition at line 39 of file cmn_FastFileSearch.cpp.

References cmn_Num2Str(), ivd_NULLCHK_m, m_buffer_p, m_buffSize, and cmn_FastSearch::SetBuffer().

00043                     :
00044                     m_fastSearch_p(a_fastSearch_p),
00045                     m_file_p(a_file_p),
00046                     m_buffSize(a_buffSize)
00047 {
00048     m_buffer_p = new char[m_buffSize];
00049     ivd_NULLCHK_m(m_buffer_p, "void[" + cmn_Num2Str(m_buffSize) + "]");
00050 
00051     a_fastSearch_p->SetBuffer(m_buffer_p, m_buffSize);
00052 }
//============================================================================//

Here is the call graph for this function:

cmn_FastFileSearch::~cmn_FastFileSearch (  )  [virtual]

Definition at line 56 of file cmn_FastFileSearch.cpp.

References m_buffer_p.

00056                                         {
00057     //TODO who will delete m_fastSearch_p
00058     // DO not delete m_file_p 
00059     delete [] m_buffer_p;
00060 }


Member Function Documentation

ivd_FilePosition_t cmn_FastFileSearch::Find ( ivd_FilePosition_t  a_start  ) 

Definition at line 65 of file cmn_FastFileSearch.cpp.

References cmn_FastSearch::Find(), m_buffer_p, m_buffSize, m_fastSearch_p, m_file_p, cmn_File::ReadF(), cmn_File::SeekF(), and cmn_FastSearch::SetBuffer().

Referenced by fio_StartTransaction_t::FindStart().

00066                                                 {
00067 
00068     ivd_FilePosition_t p = a_start;
00069 
00070     m_file_p->SeekF(a_start);
00071 
00072     int   left = 0;
00073     char *d    = m_buffer_p;
00074 
00075     ivd_FileBufSize_t byteToRead = m_buffSize;
00076     ivd_FileBufSize_t read       = m_file_p->ReadF(d, byteToRead);
00077 
00078 
00079     while (read == byteToRead) {
00080         left = m_fastSearch_p->Find();
00081         if (left >= 0) {
00082             return p + left; // the pattern is found
00083         }
00084         left *= -1; // make it positive
00085         byteToRead = m_buffSize - left;
00086         memcpy(d, d + byteToRead, left);  // copy from the end of the buffer what was not checked
00087         p += byteToRead; // first byte in buffer represent this file offset
00088         read = m_file_p->ReadF(d + left, byteToRead); // read next amount of data
00089     }
00090     // check rest data, buffer is shorter now
00091     m_fastSearch_p->SetBuffer(m_buffer_p, read + left); 
00092     left = m_fastSearch_p->Find();
00093     if (left >= 0) {
00094         return p + left; // the pattern is found
00095     }
00096     return -1;
00097 }

Here is the call graph for this function:

Here is the caller graph for this function:

void cmn_FastFileSearch::SetFile ( cmn_File a_file_p  )  [inline]

Definition at line 68 of file cmn_FastFileSearch.h.

00068 { m_file_p = a_file_p; };


Member Data Documentation

pointer to fast search instance

Definition at line 43 of file cmn_FastFileSearch.h.

Referenced by Find().

file that need to be searched

Definition at line 46 of file cmn_FastFileSearch.h.

Referenced by Find().

size of buffer where search is perform

Definition at line 49 of file cmn_FastFileSearch.h.

Referenced by cmn_FastFileSearch(), and Find().

Definition at line 51 of file cmn_FastFileSearch.h.

Referenced by cmn_FastFileSearch(), Find(), and ~cmn_FastFileSearch().

Description of a class member.

See also:
<reference>

<reference> Macro to add class name member s_className.

Definition at line 63 of file cmn_FastFileSearch.h.


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

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