|
/********************************************************************\
created: 2001/03/04
created: 4:3:2001 12:51
filename: Parser\prsBase.h
file path: .\Parser
file base: prsBase
file ext: h
author: Alex Kucherenko
purpose:
\********************************************************************/
#ifndef _PARSER_TODO_BASE_CLASSES_H_
#define _PARSER_TODO_BASE_CLASSES_H_
#pragma once
#ifndef PURE
#define PURE =0
#endif
//////////////////////////////////////////////////////////////////////////
// Template used for defining typical classes iterator functions
template < class T >
class CToDoIterator
{
public:
typedef T::iterator It;
typedef T::key_type Base;
It* First( void )
{
if( m_lCounter == 0 ) throw CToDoNoElements();
m_mapIter = m_mapStore.begin();
return &m_mapIter;
};
It* Next( void )
{
if( m_lCounter == 0 ) throw CToDoNoElements();
if( m_mapIter == m_mapStore.end() ) throw CToDoLastRiched();
m_mapIter++;
return &m_mapIter;
};
It* Prev( void )
{
if( m_lCounter == 0 ) throw CToDoNoElements();
if( m_mapIter == m_mapStore.begin() ) throw CToDoFirstRiched();
m_mapIter--;
return &m_mapIter;
};
It* Last( void )
{
if( m_lCounter == 0 ) throw CToDoNoElements();
m_mapIter = m_mapStore.end();
return &m_mapIter;
};
It* Find( Base &base_type )
{
m_mapFindIter = m_mapStore.find( base_type );
if( m_mapFindIter == m_mapStore.end() ) throw CToDoNoElements();
return &m_mapFindIter;
}
protected:
It m_mapFindIter;
It m_mapIter;
T m_mapStore;
long m_lCounter;
};
//////////////////////////////////////////////////////////////////////////
// Base class of Parser Engine
class CToDoBaseParser
{
public:
// default constructor
CToDoBaseParser() { };
// destructor
virtual ~CToDoBaseParser( ) { };
// Constructor which set FileName var
CToDoBaseParser( const string &FileName ) : m_strFileName( FileName ) { };
// Function starts parsing procedure in class
virtual long StartParsing()
{
long tmpRet = 0;
ClearAllElements();
try { tmpRet = ParseEngine(); }
catch( CToDoException ex ) { };
return tmpRet;
};
// Function return FileName of file which will be parsed
const string &GetFileName( void )
{
return m_strFileName;
}
// Fuction set FileName of file which will be parsed
void SetFileName( const string &FileName )
{
m_strFileName = FileName;
};
// Function clear all element in map
virtual void ClearAllElements( void ) PURE;
protected:
// Parsing Engine which do main job in class
virtual long ParseEngine( ) PURE;
private:
// File name of file for parsing
string m_strFileName;
};
#endif /* _PARSER_TODO_BASE_CLASSES_H_ */
//:> end of file
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.