summaryrefslogtreecommitdiff
path: root/indra/llmessage/llmessagetemplateparser.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llmessage/llmessagetemplateparser.h')
-rw-r--r--indra/llmessage/llmessagetemplateparser.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/indra/llmessage/llmessagetemplateparser.h b/indra/llmessage/llmessagetemplateparser.h
new file mode 100644
index 0000000000..0fba42bc41
--- /dev/null
+++ b/indra/llmessage/llmessagetemplateparser.h
@@ -0,0 +1,62 @@
+/**
+ * @file llmessagetemplateparser.h
+ * @brief Classes to parse message template.
+ *
+ * Copyright (c) 2000-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#ifndef LL_MESSAGETEMPLATEPARSER_H
+#define LL_MESSAGETEMPLATEPARSER_H
+
+#include <string>
+#include "llmessagetemplate.h"
+
+class LLTemplateTokenizer
+{
+public:
+ LLTemplateTokenizer(const std::string & contents);
+
+ U32 line() const;
+ bool atEOF() const;
+ std::string next();
+
+ bool want(const std::string & token);
+ bool wantEOF();
+private:
+ void inc();
+ void dec();
+ std::string get() const;
+ void error(std::string message = "generic") const;
+
+ struct positioned_token
+ {
+ std::string str;
+ U32 line;
+ };
+
+ bool mStarted;
+ std::list<positioned_token> mTokens;
+ std::list<positioned_token>::const_iterator mCurrent;
+};
+
+class LLTemplateParser
+{
+public:
+ typedef std::list<LLMessageTemplate *>::const_iterator message_iterator;
+
+ static LLMessageTemplate * parseMessage(LLTemplateTokenizer & tokens);
+ static LLMessageBlock * parseBlock(LLTemplateTokenizer & tokens);
+ static LLMessageVariable * parseVariable(LLTemplateTokenizer & tokens);
+
+ LLTemplateParser(LLTemplateTokenizer & tokens);
+ message_iterator getMessagesBegin() const;
+ message_iterator getMessagesEnd() const;
+ F32 getVersion() const;
+
+private:
+ F32 mVersion;
+ std::list<LLMessageTemplate *> mMessages;
+};
+
+#endif