Redesigned how server commands work. The "plugins" command will be back soon.
1 #ifndef _INCLUDE_SOURCEMOD_TRANSLATOR_H_
2 #define _INCLUDE_SOURCEMOD_TRANSLATOR_H_
7 #include "sm_globals.h"
8 #include "sm_memtable.h"
9 #include "ITextParsers.h"
11 #define MAX_TRANSLATE_PARAMS 32
13 /* :TODO: write a templatized version of tries? */
15 using namespace SourceHook;
39 class CPhraseFile : public ITextListener_SMC
42 CPhraseFile(CTranslator *pTranslator, const char *file);
46 const char *GetFilename();
47 const char *GetTranslation(const Translation *pTrans, int **fmt_order, unsigned int *fmt_count);
48 public: //ITextListener_SMC
49 void ReadSMC_ParseStart();
50 void ReadSMC_ParseEnd(bool halted, bool failed);
51 SMCParseResult ReadSMC_NewSection(const char *name, bool opt_quotes);
52 SMCParseResult ReadSMC_KeyValue(const char *key, const char *value, bool key_quotes, bool value_quotes);
53 SMCParseResult ReadSMC_LeavingSection();
54 SMCParseResult ReadSMC_RawLine(const char *line, unsigned int curline);
56 void ParseError(const char *message, ...);
57 void ParseWarning(const char *message, ...);
59 Trie *m_pPhraseLookup;
61 CTranslator *m_pTranslator;
62 PhraseParseState m_ParseState;
64 BaseMemTable *m_pMemory;
65 BaseStringTable *m_pStringTab;
66 unsigned int m_LangCount;
68 String m_LastPhraseString;
69 unsigned int m_CurLine;
73 class CTranslator : public ITextListener_SMC
78 public: //ITextListener_SMC
79 void ReadSMC_ParseStart();
80 SMCParseResult ReadSMC_NewSection(const char *name, bool opt_quotes);
81 SMCParseResult ReadSMC_KeyValue(const char *key, const char *value, bool key_quotes, bool value_quotes);
82 SMCParseResult ReadSMC_LeavingSection();
84 void RebuildLanguageDatabase(const char *lang_header_file);
85 unsigned int FindOrAddPhraseFile(const char *phrase_file);
86 BaseStringTable *GetStringTable();
87 unsigned int GetLanguageCount();
88 bool GetLanguageByCode(const char *code, unsigned int *index);
89 size_t Translate(char *buffer, size_t maxlength, const Translation *pTrans);
91 CVector<Language *> m_Languages;
92 CVector<CPhraseFile *> m_Files;
93 BaseStringTable *m_pStringTab;
95 bool m_InLanguageSection;
99 extern CTranslator g_Translator;
101 #endif //_INCLUDE_SOURCEMOD_TRANSLATOR_H_