/indra/llmessage/llmessagetemplateparser.h

https://bitbucket.org/lindenlab/viewer-beta/ · C++ Header · 80 lines · 43 code · 12 blank · 25 comment · 0 complexity · ab8e18a94f6aa6faf347167ceba45550 MD5 · raw file

  1. /**
  2. * @file llmessagetemplateparser.h
  3. * @brief Classes to parse message template.
  4. *
  5. * $LicenseInfo:firstyear=2000&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_MESSAGETEMPLATEPARSER_H
  27. #define LL_MESSAGETEMPLATEPARSER_H
  28. #include <string>
  29. #include "llmessagetemplate.h"
  30. class LLTemplateTokenizer
  31. {
  32. public:
  33. LLTemplateTokenizer(const std::string & contents);
  34. U32 line() const;
  35. bool atEOF() const;
  36. std::string next();
  37. bool want(const std::string & token);
  38. bool wantEOF();
  39. private:
  40. void inc();
  41. void dec();
  42. std::string get() const;
  43. void error(std::string message = "generic") const;
  44. struct positioned_token
  45. {
  46. std::string str;
  47. U32 line;
  48. };
  49. bool mStarted;
  50. std::list<positioned_token> mTokens;
  51. std::list<positioned_token>::const_iterator mCurrent;
  52. };
  53. class LLTemplateParser
  54. {
  55. public:
  56. typedef std::list<LLMessageTemplate *>::const_iterator message_iterator;
  57. static LLMessageTemplate * parseMessage(LLTemplateTokenizer & tokens);
  58. static LLMessageBlock * parseBlock(LLTemplateTokenizer & tokens);
  59. static LLMessageVariable * parseVariable(LLTemplateTokenizer & tokens);
  60. LLTemplateParser(LLTemplateTokenizer & tokens);
  61. message_iterator getMessagesBegin() const;
  62. message_iterator getMessagesEnd() const;
  63. F32 getVersion() const;
  64. private:
  65. F32 mVersion;
  66. std::list<LLMessageTemplate *> mMessages;
  67. };
  68. #endif