00001 00032 #ifndef LL_MESSAGETEMPLATEPARSER_H 00033 #define LL_MESSAGETEMPLATEPARSER_H 00034 00035 #include <string> 00036 #include "llmessagetemplate.h" 00037 00038 class LLTemplateTokenizer 00039 { 00040 public: 00041 LLTemplateTokenizer(const std::string & contents); 00042 00043 U32 line() const; 00044 bool atEOF() const; 00045 std::string next(); 00046 00047 bool want(const std::string & token); 00048 bool wantEOF(); 00049 private: 00050 void inc(); 00051 void dec(); 00052 std::string get() const; 00053 void error(std::string message = "generic") const; 00054 00055 struct positioned_token 00056 { 00057 std::string str; 00058 U32 line; 00059 }; 00060 00061 bool mStarted; 00062 std::list<positioned_token> mTokens; 00063 std::list<positioned_token>::const_iterator mCurrent; 00064 }; 00065 00066 class LLTemplateParser 00067 { 00068 public: 00069 typedef std::list<LLMessageTemplate *>::const_iterator message_iterator; 00070 00071 static LLMessageTemplate * parseMessage(LLTemplateTokenizer & tokens); 00072 static LLMessageBlock * parseBlock(LLTemplateTokenizer & tokens); 00073 static LLMessageVariable * parseVariable(LLTemplateTokenizer & tokens); 00074 00075 LLTemplateParser(LLTemplateTokenizer & tokens); 00076 message_iterator getMessagesBegin() const; 00077 message_iterator getMessagesEnd() const; 00078 F32 getVersion() const; 00079 00080 private: 00081 F32 mVersion; 00082 std::list<LLMessageTemplate *> mMessages; 00083 }; 00084 00085 #endif