PageRenderTime 54ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llmessage/llsdmessagebuilder.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 126 lines | 60 code | 20 blank | 46 comment | 0 complexity | d4cbe5e10dc25b00c1a5e8ea3a3c5620 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llsdmessagebuilder.h
  3. * @brief Declaration of LLSDMessageBuilder 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_LLSDMESSAGEBUILDER_H
  27. #define LL_LLSDMESSAGEBUILDER_H
  28. #include <map>
  29. #include "llmessagebuilder.h"
  30. #include "llmsgvariabletype.h"
  31. #include "llsd.h"
  32. class LLMessageTemplate;
  33. class LLMsgData;
  34. class LLSDMessageBuilder : public LLMessageBuilder
  35. {
  36. public:
  37. //CLASS_LOG_TYPE(LLSDMessageBuilder);
  38. LLSDMessageBuilder();
  39. virtual ~LLSDMessageBuilder();
  40. virtual void newMessage(const char* name);
  41. virtual void nextBlock(const char* blockname);
  42. virtual BOOL removeLastBlock(); // TODO: babbage: remove this horror...
  43. /** All add* methods expect pointers to canonical varname strings. */
  44. virtual void addBinaryData(
  45. const char* varname,
  46. const void* data,
  47. S32 size);
  48. virtual void addBOOL(const char* varname, BOOL b);
  49. virtual void addS8(const char* varname, S8 s);
  50. virtual void addU8(const char* varname, U8 u);
  51. virtual void addS16(const char* varname, S16 i);
  52. virtual void addU16(const char* varname, U16 i);
  53. virtual void addF32(const char* varname, F32 f);
  54. virtual void addS32(const char* varname, S32 s);
  55. virtual void addU32(const char* varname, U32 u);
  56. virtual void addU64(const char* varname, U64 lu);
  57. virtual void addF64(const char* varname, F64 d);
  58. virtual void addVector3(const char* varname, const LLVector3& vec);
  59. virtual void addVector4(const char* varname, const LLVector4& vec);
  60. virtual void addVector3d(const char* varname, const LLVector3d& vec);
  61. virtual void addQuat(const char* varname, const LLQuaternion& quat);
  62. virtual void addUUID(const char* varname, const LLUUID& uuid);
  63. virtual void addIPAddr(const char* varname, const U32 ip);
  64. virtual void addIPPort(const char* varname, const U16 port);
  65. virtual void addString(const char* varname, const char* s);
  66. virtual void addString(const char* varname, const std::string& s);
  67. virtual BOOL isMessageFull(const char* blockname) const;
  68. virtual void compressMessage(U8*& buf_ptr, U32& buffer_length);
  69. virtual BOOL isBuilt() const;
  70. virtual BOOL isClear() const;
  71. virtual U32 buildMessage(U8* buffer, U32 buffer_size, U8 offset_to_data);
  72. /**< Null implementation which returns 0. */
  73. virtual void clearMessage();
  74. // TODO: babbage: remove this horror.
  75. virtual void setBuilt(BOOL b);
  76. virtual S32 getMessageSize();
  77. virtual const char* getMessageName() const;
  78. virtual void copyFromMessageData(const LLMsgData& data);
  79. virtual void copyFromLLSD(const LLSD& msg);
  80. const LLSD& getMessage() const;
  81. private:
  82. /* mCurrentMessage is of the following format:
  83. mCurrentMessage = { 'block_name1' : [ { 'block1_field1' : 'b1f1_data',
  84. 'block1_field2' : 'b1f2_data',
  85. ...
  86. 'block1_fieldn' : 'b1fn_data'},
  87. { 'block2_field1' : 'b2f1_data',
  88. 'block2_field2' : 'b2f2_data',
  89. ...
  90. 'block2_fieldn' : 'b2fn_data'},
  91. ...
  92. { 'blockm_field1' : 'bmf1_data',
  93. 'blockm_field2' : 'bmf2_data',
  94. ...
  95. 'blockm_fieldn' : 'bmfn_data'} ],
  96. 'block_name2' : ...,
  97. ...
  98. 'block_namem' } */
  99. LLSD mCurrentMessage;
  100. LLSD* mCurrentBlock;
  101. std::string mCurrentMessageName;
  102. std::string mCurrentBlockName;
  103. BOOL mbSBuilt;
  104. BOOL mbSClear;
  105. };
  106. #endif // LL_LLSDMESSAGEBUILDER_H