PageRenderTime 199ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llmessage/lltemplatemessagebuilder.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 115 lines | 67 code | 20 blank | 28 comment | 0 complexity | 447efcd697c10ff3cba0d8d8a4cd912f MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lltemplatemessagebuilder.h
  3. * @brief Declaration of LLTemplateMessageBuilder class.
  4. *
  5. * $LicenseInfo:firstyear=2007&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_LLTEMPLATEMESSAGEBUILDER_H
  27. #define LL_LLTEMPLATEMESSAGEBUILDER_H
  28. #include <map>
  29. #include "llmessagebuilder.h"
  30. #include "llmsgvariabletype.h"
  31. class LLMsgData;
  32. class LLMessageTemplate;
  33. class LLMsgBlkData;
  34. class LLMessageTemplate;
  35. class LLTemplateMessageBuilder : public LLMessageBuilder
  36. {
  37. public:
  38. typedef std::map<const char* , LLMessageTemplate*> message_template_name_map_t;
  39. LLTemplateMessageBuilder(const message_template_name_map_t&);
  40. virtual ~LLTemplateMessageBuilder();
  41. virtual void newMessage(const char* name);
  42. virtual void nextBlock(const char* blockname);
  43. virtual BOOL removeLastBlock(); // TODO: babbage: remove this horror...
  44. /** All add* methods expect pointers to canonical varname strings. */
  45. virtual void addBinaryData(const char *varname, const void *data,
  46. S32 size);
  47. virtual void addBOOL(const char* varname, BOOL b);
  48. virtual void addS8(const char* varname, S8 s);
  49. virtual void addU8(const char* varname, U8 u);
  50. virtual void addS16(const char* varname, S16 i);
  51. virtual void addU16(const char* varname, U16 i);
  52. virtual void addF32(const char* varname, F32 f);
  53. virtual void addS32(const char* varname, S32 s);
  54. virtual void addU32(const char* varname, U32 u);
  55. virtual void addU64(const char* varname, U64 lu);
  56. virtual void addF64(const char* varname, F64 d);
  57. virtual void addVector3(const char* varname, const LLVector3& vec);
  58. virtual void addVector4(const char* varname, const LLVector4& vec);
  59. virtual void addVector3d(const char* varname, const LLVector3d& vec);
  60. virtual void addQuat(const char* varname, const LLQuaternion& quat);
  61. virtual void addUUID(const char* varname, const LLUUID& uuid);
  62. virtual void addIPAddr(const char* varname, const U32 ip);
  63. virtual void addIPPort(const char* varname, const U16 port);
  64. virtual void addString(const char* varname, const char* s);
  65. virtual void addString(const char* varname, const std::string& s);
  66. virtual BOOL isMessageFull(const char* blockname) const;
  67. virtual void compressMessage(U8*& buf_ptr, U32& buffer_length);
  68. virtual BOOL isBuilt() const;
  69. virtual BOOL isClear() const;
  70. virtual U32 buildMessage(U8* buffer, U32 buffer_size, U8 offset_to_data);
  71. /**< Return built message size */
  72. virtual void clearMessage();
  73. // TODO: babbage: remove this horror.
  74. virtual void setBuilt(BOOL b);
  75. virtual S32 getMessageSize();
  76. virtual const char* getMessageName() const;
  77. virtual void copyFromMessageData(const LLMsgData& data);
  78. virtual void copyFromLLSD(const LLSD&);
  79. LLMsgData* getCurrentMessage() const { return mCurrentSMessageData; }
  80. private:
  81. void addData(const char* varname, const void* data,
  82. EMsgVariableType type, S32 size);
  83. void addData(const char* varname, const void* data,
  84. EMsgVariableType type);
  85. LLMsgData* mCurrentSMessageData;
  86. const LLMessageTemplate* mCurrentSMessageTemplate;
  87. LLMsgBlkData* mCurrentSDataBlock;
  88. char* mCurrentSMessageName;
  89. char* mCurrentSBlockName;
  90. BOOL mbSBuilt;
  91. BOOL mbSClear;
  92. S32 mCurrentSendTotal;
  93. const message_template_name_map_t& mMessageTemplates;
  94. };
  95. #endif // LL_LLTEMPLATEMESSAGEBUILDER_H