📄 rpgtextparse.h
字号:
//RPGcHAT.h
/*/////////////////////////////////////////////////////////////////
李亦
liease@163.com 4040719
2006-7-18
/*/////////////////////////////////////////////////////////////////
#ifndef _RPG__RPGTEXTPARSE_H_
#define _RPG__RPGTEXTPARSE_H_
#ifndef _RPG__RPGOBJECT_H_
#include "RPGObject.h"
#endif
#ifndef _RPG__RPGDEFINE_H_
#include "RPGDefine.h"
#endif
#ifndef _TNAMEDICTIONARY_H_
#include "rpg/core/tNameDictionary.h"
#endif
#ifndef _COLOR_H_
#include "core/color.h"
#endif
#ifndef _STRINGSTACK_H_
#include "console/stringStack.h"
#endif
namespace RPG
{
/////////////////////////////////////////////////////////////////
/// RPG错误代码管理
class RPGTextParse : public RPGObject
{
typedef RPGObject Parent;
enum RPGTextParseConstants
{
HASHSIZE = 32,
SECTION_NUM = 32,
COLORSTACK_NUM = 8,
LEVEL_MAX = 10
};
public:
struct TextEntry
{
StringTableEntry pIDName;
ERPGTextParseTypes dwType;
union
{
StringTableEntry pData;
StringTableEntry pVar;
StringTableEntry pColor;
StringTableEntry pField;
StringTableEntry pTag;
StringTableEntry pFilename;
};
};
protected:
struct TextSection
{
CSTR pSection;
int nLen;
CSTR pParams;
int nParamsLen;
};
protected:
StringStack m_textPool;
NameDictionary<TextEntry> m_arEntrys;
StringTableEntry m_pExpsPath;
Vector<TextSection> m_arSections;
Vector<TextEntry*> m_arColorStack;
U32 m_nBufSize;
U32 m_nLevelNum;//深度控制,防止自循环
//U32 m_dwColor;
StringTableEntry m_sClrTag;
U32 m_nClrTagLen;
public:
//构造/析构函数
RPGTextParse();
~RPGTextParse();
public:
static void Initialize(CSTR pScriptName);
static void Destroy();
static void initPersistFields();
//static void consoleInit();
public:
void RegEntry(StringTableEntry pIDName,ERPGTextParseTypes type, StringTableEntry pData);
void UnregEntry(StringTableEntry pIDName);
ERPGTextParseTypes GetEntryType(StringTableEntry pIDName);
CSTR ParseTextF(CSTR sText,...);
CSTR ParseText(CSTR sText,S32 nLevel=-1);
BOOL ClearParse();
inline BOOL BeginParse(){return ClearParse();}
inline CSTR GetParseText(){return ConcatSections(m_nBufSize);}
RPGTextParse& operator << (CSTR str);
RPGTextParse& operator << (S8 n);
RPGTextParse& operator << (S32 n);
RPGTextParse& operator << (F32 n);
protected:
CSTR ConcatSections(U32 nBufSize);
U32 ParseEntry(StringTableEntry sIDName,CSTR pParams, U32 nParamsLen,S32 nLevel);
public:
DECLARE_CONOBJECT(RPGTextParse);
};//class RPGTextParse
///////////////////////////////////////////////////
inline RPGTextParse& RPGTextParse::operator << (S32 n)
{
char* szBuf = m_textPool.getStrBuffer(64);
dSprintf(szBuf,64,"%d",n);
return operator << (szBuf);
}
inline RPGTextParse& RPGTextParse::operator << (F32 n)
{
char* szBuf = m_textPool.getStrBuffer(64);
dSprintf(szBuf,64,"%g",n);
return operator << (szBuf);
}
inline RPGTextParse& RPGTextParse::operator << (S8 n)
{
char* szBuf = m_textPool.getStrBuffer(8);
dSprintf(szBuf,8,"%c",n);
return operator << (szBuf);
}
inline void RPGTextParse::UnregEntry(StringTableEntry pIDName)
{
if(!pIDName || !pIDName[0])
return;
m_arEntrys.Remove(pIDName);
}
inline ERPGTextParseTypes RPGTextParse::GetEntryType(StringTableEntry pIDName)
{
if(!pIDName || !pIDName[0])
return TXTT_NULL;
TextEntry* pEntry = m_arEntrys.Get(pIDName);
if(pEntry)
return pEntry->dwType;
return TXTT_NULL;
}
///////////////////////////////////////////////////
extern RPGTextParse* g_pRPGTextParse;
};//namespace RPG
//#endif//#ifdef TGE_RPGCLIENT
#endif //_RPG__RPGTEXTPARSE_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -