/*********************************************************************
Copyright (C) 2001 by
Alexander Berthold, alexander-berthold@web.de.
Hoegestr. 54
79108 Freiburg i. Breisgau
Germany
-- This file is part of cxAnalyzer --
"cxAnalyzer" is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or any later version.
"cxAnalyzer" is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with "cxAnalyzer"; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
---------------------------------------------------------------
If you find any bugs or if you make other corrections/
enhancements, i'd appreciate if you'd let me know about
that. My email is
alexander-berthold@web.de
If you share this code, do not remove this text.
---------------------------------------------------------------
Class: cxAnalyzerTypeMap
Author: Alexander Berthold
Copyright: Alexander Berthold
Date: 2001/06/12
Version: 0.1.07
Purpose: Stores metadata for the analyzer token / rule IDs.
Version history:
- 2001/05/19
Released the version 0.1.05
- 2001/06/01
Added #DEFINE's for the subtypes ATM_SUBT_RULE_FINITE and
ATM_SUBT_RULE_OPEN (for closed rules / open rules)
- 2001/06/12
Current source labeled version 0.1.07
*********************************************************************/
// cxAnalyzerTypeMap.h: interface for the cxAnalyzerTypeMap class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_CXANALYZERTYPEMAP_H__0FAC41ED_07D2_4FD8_9514_34B34370D8B8__INCLUDED_)
#define AFX_CXANALYZERTYPEMAP_H__0FAC41ED_07D2_4FD8_9514_34B34370D8B8__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Forward references
class cxTokenizerMap;
class cxTokenizerMapData;
class cxTokenizerTokenRule;
#define ATM_ID_INVALID 0
#define ATM_ID_LITERAL -1
#define ATM_ID_MATCHALL -2
#define ATM_ID_SUBBRANCH -3
#define ATM_ID_NIL -4
#define ATM_MTYPE_TOKEN 0
#define ATM_MTYPE_COMP_TOKEN 1
#define ATM_MTYPE_RULE 2
#define ATM_SUBT_RULE_UNDEF -1
#define ATM_SUBT_RULE_FINITE 0
#define ATM_SUBT_RULE_OPEN 1
#define IDVALUE_NULL_TOKEN -3
#define IDVALUE_REORDER -2
class cxAnalyzerTypeInfo
{
// Construction
public:
cxAnalyzerTypeInfo(int nAtmType, int nMType, int nSubType)
{
m_nAtmType =nAtmType;
m_nMType =nMType;
m_nSubType =nSubType;
}
~cxAnalyzerTypeInfo()
{
}
// Attributes
protected:
int m_nAtmType;
int m_nMType;
int m_nSubType;
void *m_pvData;
// Operations
public:
int nGetAtmType() const
{ return m_nAtmType; };
int nGetMType() const
{ return m_nMType; };
int nGetSubType() const
{ return m_nSubType; };
void* pvGetData()
{ return m_pvData; };
const void* pvGetData() const
{ return m_pvData; };
void* pvSetData(void* pvNewData)
{ void *pvTemp = m_pvData; m_pvData = pvNewData; return pvTemp; };
void vSetSubType(int nSubType)
{ m_nSubType = nSubType; };
};
class cxAnalyzerTypeMap
{
// Construction
public:
cxAnalyzerTypeMap();
virtual ~cxAnalyzerTypeMap();
// Attributes
protected:
int m_nNextID;
typedef std::map<std::tstring,int>
strmap_type;
typedef std::map<DWORD,int>
dwmap_type;
typedef std::map<int,cxAnalyzerTypeInfo*>
atmmap_type;
typedef std::map<int,int>
atm_to_id_map_type;
// Mapping from string identifiers to ID's
strmap_type m_mapStr;
// Mapping from DWORD(cooLexxerTokenRule*) to ID's
dwmap_type m_mapDW;
// Mapping from AtmID to cxAnalyzerTypeInfo
atmmap_type m_mapAtmInfo;
// Mapping from CustID to AtmID
atm_to_id_map_type m_mapCustIDtoAtmID;
// Protected operations
protected:
void vInitFromTokenizerMapData(const cxTokenizerMapData* plmdRules);
// Operations
public:
virtual bool fCheckValid() const { return true; };
void vInitFromTokenizerMap(const cxTokenizerMap* pmInit);
void vSetCustIDToAtmMapping(int nCustID, int nAtmID);
int nGetIDFor(const cxTokenizerTokenRule* pltrRule) const;
int nGetIDFor(const std::tstring& str, bool fCreate = true);
int nGetIDFor(LPCTSTR lpszString, bool fCreate = true);
int nGetIDFor(int nCustID) const;
cxAnalyzerTypeInfo*
patiGetTypeInfo(int nAtmID);
const cxAnalyzerTypeInfo*
patiGetTypeInfo(int nAtmID) const
{ return patiGetTypeInfo(nAtmID); };
cxAnalyzerTypeInfo*
patiSetTypeInfo(int nID, int nMType, int nSubType);
// For testing purposes only
std::tstring strGetStringForID(int nID);
DWORD dwGetDWORDForID(int nID);
void vDump();
};
#endif // !defined(AFX_CXANALYZERTYPEMAP_H__0FAC41ED_07D2_4FD8_9514_34B34370D8B8__INCLUDED_)