llmessagebuilder.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /**
  2. * @file llmessagebuilder.h
  3. * @brief Declaration of LLMessageBuilder class.
  4. *
  5. * $LicenseInfo:firstyear=2007&license=viewergpl$
  6. *
  7. * Copyright (c) 2007-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLMESSAGEBUILDER_H
  33. #define LL_LLMESSAGEBUILDER_H
  34. #include <string>
  35. #include "stdtypes.h"
  36. class LLMsgData;
  37. class LLQuaternion;
  38. class LLSD;
  39. class LLUUID;
  40. class LLVector3;
  41. class LLVector3d;
  42. class LLVector4;
  43. class LLMessageBuilder
  44. {
  45. protected:
  46. LOG_CLASS(LLMessageBuilder);
  47. public:
  48. virtual ~LLMessageBuilder() = default;
  49. virtual void newMessage(const char* name) = 0;
  50. virtual void nextBlock(const char* blockname) = 0;
  51. // *TODO: Babbage: remove this horror...
  52. virtual bool removeLastBlock() = 0;
  53. /** All add* methods expect pointers to canonical strings. */
  54. virtual void addBinaryData(const char* varname, const void* data,
  55. S32 size) = 0;
  56. virtual void addBool(const char* varname, bool b) = 0;
  57. virtual void addS8(const char* varname, S8 s) = 0;
  58. virtual void addU8(const char* varname, U8 u) = 0;
  59. virtual void addS16(const char* varname, S16 i) = 0;
  60. virtual void addU16(const char* varname, U16 i) = 0;
  61. virtual void addF32(const char* varname, F32 f) = 0;
  62. virtual void addS32(const char* varname, S32 s) = 0;
  63. virtual void addU32(const char* varname, U32 u) = 0;
  64. virtual void addU64(const char* varname, U64 lu) = 0;
  65. virtual void addF64(const char* varname, F64 d) = 0;
  66. virtual void addVector3(const char* varname, const LLVector3& vec) = 0;
  67. virtual void addVector4(const char* varname, const LLVector4& vec) = 0;
  68. virtual void addVector3d(const char* varname, const LLVector3d& vec) = 0;
  69. virtual void addQuat(const char* varname, const LLQuaternion& quat) = 0;
  70. virtual void addUUID(const char* varname, const LLUUID& uuid) = 0;
  71. virtual void addIPAddr(const char* varname, U32 ip) = 0;
  72. virtual void addIPPort(const char* varname, U16 port) = 0;
  73. virtual void addString(const char* varname, const char* s) = 0;
  74. virtual void addString(const char* varname, const std::string& s) = 0;
  75. virtual bool isMessageFull(const char* blockname) const = 0;
  76. virtual void compressMessage(U8*& buf_ptr, U32& buffer_length) = 0;
  77. virtual S32 getMessageSize() = 0;
  78. virtual bool isBuilt() const = 0;
  79. virtual bool isClear() const = 0;
  80. // Returns the built message size
  81. virtual U32 buildMessage(U8* buffer, U32 buffer_size,
  82. U8 offset_to_data) = 0;
  83. virtual void clearMessage() = 0;
  84. // *TODO: Babbage: remove this horror
  85. virtual void setBuilt(bool b) = 0;
  86. virtual const char* getMessageName() const = 0;
  87. virtual void copyFromMessageData(const LLMsgData& data) = 0;
  88. virtual void copyFromLLSD(const LLSD& data) = 0;
  89. };
  90. typedef enum e_message_variable_type
  91. {
  92. MVT_NULL,
  93. MVT_FIXED,
  94. MVT_VARIABLE,
  95. MVT_U8,
  96. MVT_U16,
  97. MVT_U32,
  98. MVT_U64,
  99. MVT_S8,
  100. MVT_S16,
  101. MVT_S32,
  102. MVT_S64,
  103. MVT_F32,
  104. MVT_F64,
  105. MVT_LLVector3,
  106. MVT_LLVector3d,
  107. MVT_LLVector4,
  108. MVT_LLQuaternion,
  109. MVT_LLUUID,
  110. MVT_BOOL,
  111. MVT_IP_ADDR,
  112. MVT_IP_PORT,
  113. MVT_U16Vec3,
  114. MVT_U16Quat,
  115. MVT_S16Array,
  116. MVT_EOL
  117. } EMsgVariableType;
  118. #endif // LL_LLMESSAGEBUILDER_H