llmessagereader.h 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /**
  2. * @file llmessagereader.h
  3. * @brief Declaration of LLMessageReader 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_LLMESSAGEREADER_H
  33. #define LL_LLMESSAGEREADER_H
  34. #include "stdtypes.h"
  35. class LLHost;
  36. class LLMessageBuilder;
  37. class LLMsgData;
  38. class LLQuaternion;
  39. class LLUUID;
  40. class LLVector3;
  41. class LLVector3d;
  42. class LLVector4;
  43. // Error return values for getSize() functions
  44. constexpr S32 LL_BLOCK_NOT_IN_MESSAGE = -1;
  45. constexpr S32 LL_VARIABLE_NOT_IN_BLOCK = -2;
  46. constexpr S32 LL_MESSAGE_ERROR = -3;
  47. class LLMessageReader
  48. {
  49. public:
  50. virtual ~LLMessageReader() = default;
  51. // All get* methods expect pointers to canonical strings.
  52. virtual void getBinaryData(const char* blockname, const char* varname, void* datap, S32 size, S32 blocknum = 0, S32 max_size = S32_MAX) = 0;
  53. virtual void getBool(const char* block, const char* var, bool& data, S32 blocknum = 0) = 0;
  54. virtual void getS8(const char* block, const char* var, S8& data, S32 blocknum = 0) = 0;
  55. virtual void getU8(const char* block, const char* var, U8& data, S32 blocknum = 0) = 0;
  56. virtual void getS16(const char* block, const char* var, S16& data, S32 blocknum = 0) = 0;
  57. virtual void getU16(const char* block, const char* var, U16& data, S32 blocknum = 0) = 0;
  58. virtual void getS32(const char* block, const char* var, S32& data, S32 blocknum = 0) = 0;
  59. virtual void getF32(const char* block, const char* var, F32& data, S32 blocknum = 0) = 0;
  60. virtual void getU32(const char* block, const char* var, U32& data, S32 blocknum = 0) = 0;
  61. virtual void getU64(const char* block, const char* var, U64& data, S32 blocknum = 0) = 0;
  62. virtual void getF64(const char* block, const char* var, F64& data, S32 blocknum = 0) = 0;
  63. virtual void getVector3(const char* block, const char* var, LLVector3& vec, S32 blocknum = 0) = 0;
  64. virtual void getVector4(const char* block, const char* var, LLVector4& vec, S32 blocknum = 0) = 0;
  65. virtual void getVector3d(const char* block, const char* var, LLVector3d& vec, S32 blocknum = 0) = 0;
  66. virtual void getQuat(const char* block, const char* var, LLQuaternion& q, S32 blocknum = 0) = 0;
  67. virtual void getUUID(const char* block, const char* var, LLUUID& uuid, S32 blocknum = 0) = 0;
  68. virtual void getIPAddr(const char* block, const char* var, U32& ip, S32 blocknum = 0) = 0;
  69. virtual void getIPPort(const char* block, const char* var, U16& port, S32 blocknum = 0) = 0;
  70. virtual void getString(const char* block, const char* var, S32 buffer_size, char* buffer, S32 blocknum = 0) = 0;
  71. virtual void getString(const char* block, const char* var, std::string& outstr, S32 blocknum = 0) = 0;
  72. virtual S32 getNumberOfBlocks(const char* blockname) = 0;
  73. virtual S32 getSize(const char* blockname, const char* varname) = 0;
  74. virtual S32 getSize(const char* blockname, S32 blocknum, const char* varname) = 0;
  75. virtual void clearMessage() = 0;
  76. // Returns pointer to canonical (prehashed) string.
  77. virtual const char* getMessageName() const = 0;
  78. virtual S32 getMessageSize() const = 0;
  79. virtual void copyToBuilder(LLMessageBuilder&) const = 0;
  80. static void setTimeDecodes(bool b);
  81. static bool getTimeDecodes();
  82. static void setTimeDecodesSpamThreshold(F32 seconds);
  83. static F32 getTimeDecodesSpamThreshold();
  84. };
  85. #endif // LL_LLMESSAGEREADER_H