PageRenderTime 32ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llmessage/llnamevalue.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 183 lines | 112 code | 32 blank | 39 comment | 0 complexity | 1063f04dc447b045b2878757f8bbfcd6 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llnamevalue.h
  3. * @brief class for defining name value pairs.
  4. *
  5. * $LicenseInfo:firstyear=2001&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_LLNAMEVALUE_H
  27. #define LL_LLNAMEVALUE_H
  28. // As of January 2008, I believe we only use the following name-value
  29. // pairs. This is hard to prove because they are initialized from
  30. // strings. JC
  31. //
  32. // FirstName STRING
  33. // LastName STRING
  34. // AttachPt U32
  35. // AttachmentItemId STRING
  36. // Title STRING
  37. // AttachmentOffset VEC3
  38. // AttachmentOrientation VEC3
  39. // SitObject STRING
  40. // SitPosition VEC3
  41. #include "string_table.h"
  42. #include "llmath.h"
  43. #include "v3math.h"
  44. #include "lldbstrings.h"
  45. class LLNameValue;
  46. class LLStringTable;
  47. typedef enum e_name_value_types
  48. {
  49. NVT_NULL,
  50. NVT_STRING,
  51. NVT_F32,
  52. NVT_S32,
  53. NVT_VEC3,
  54. NVT_U32,
  55. NVT_CAMERA, // Deprecated, but leaving in case removing this will cause problems
  56. NVT_ASSET,
  57. NVT_U64,
  58. NVT_EOF
  59. } ENameValueType;
  60. typedef enum e_name_value_class
  61. {
  62. NVC_NULL,
  63. NVC_READ_ONLY,
  64. NVC_READ_WRITE,
  65. NVC_EOF
  66. } ENameValueClass;
  67. typedef enum e_name_value_sento
  68. {
  69. NVS_NULL,
  70. NVS_SIM,
  71. NVS_DATA_SIM,
  72. NVS_SIM_VIEWER,
  73. NVS_DATA_SIM_VIEWER,
  74. NVS_EOF
  75. } ENameValueSendto;
  76. // NameValues can always be "printed" into a buffer of this length.
  77. const U32 NAME_VALUE_BUF_SIZE = 1024;
  78. const U32 NAME_VALUE_TYPE_STRING_LENGTH = 8;
  79. const U32 NAME_VALUE_CLASS_STRING_LENGTH = 16;
  80. const U32 NAME_VALUE_SENDTO_STRING_LENGTH = 18;
  81. const U32 NAME_VALUE_DATA_SIZE =
  82. NAME_VALUE_BUF_SIZE -
  83. ( DB_NV_NAME_BUF_SIZE +
  84. NAME_VALUE_TYPE_STRING_LENGTH +
  85. NAME_VALUE_CLASS_STRING_LENGTH +
  86. NAME_VALUE_SENDTO_STRING_LENGTH );
  87. extern char NameValueTypeStrings[NVT_EOF][NAME_VALUE_TYPE_STRING_LENGTH]; /* Flawfinder: Ignore */
  88. extern char NameValueClassStrings[NVC_EOF][NAME_VALUE_CLASS_STRING_LENGTH]; /* Flawfinder: Ignore */
  89. extern char NameValueSendtoStrings[NVS_EOF][NAME_VALUE_SENDTO_STRING_LENGTH]; /* Flawfinder: Ignore */
  90. typedef union u_name_value_reference
  91. {
  92. char *string;
  93. F32 *f32;
  94. S32 *s32;
  95. LLVector3 *vec3;
  96. U32 *u32;
  97. U64 *u64;
  98. } UNameValueReference;
  99. class LLNameValue
  100. {
  101. public:
  102. void baseInit();
  103. void init(const char *name, const char *data, const char *type, const char *nvclass, const char *nvsendto );
  104. LLNameValue();
  105. LLNameValue(const char *data);
  106. LLNameValue(const char *name, const char *type, const char *nvclass );
  107. LLNameValue(const char *name, const char *data, const char *type, const char *nvclass );
  108. LLNameValue(const char *name, const char *data, const char *type, const char *nvclass, const char *nvsendto );
  109. ~LLNameValue();
  110. char *getString();
  111. const char *getAsset() const;
  112. F32 *getF32();
  113. S32 *getS32();
  114. void getVec3(LLVector3 &vec);
  115. LLVector3 *getVec3();
  116. U32 *getU32();
  117. U64 *getU64();
  118. const char *getType() const { return mStringType; }
  119. const char *getClass() const { return mStringClass; }
  120. const char *getSendto() const { return mStringSendto; }
  121. BOOL sendToData() const;
  122. BOOL sendToViewer() const;
  123. void callCallback();
  124. std::string printNameValue() const;
  125. std::string printData() const;
  126. ENameValueType getTypeEnum() const { return mType; }
  127. ENameValueClass getClassEnum() const { return mClass; }
  128. ENameValueSendto getSendtoEnum() const { return mSendto; }
  129. LLNameValue &operator=(const LLNameValue &a);
  130. void setString(const char *a);
  131. void setAsset(const char *a);
  132. void setF32(const F32 a);
  133. void setS32(const S32 a);
  134. void setVec3(const LLVector3 &a);
  135. void setU32(const U32 a);
  136. friend std::ostream& operator<<(std::ostream& s, const LLNameValue &a);
  137. private:
  138. void printNameValue(std::ostream& s);
  139. public:
  140. char *mName;
  141. char *mStringType;
  142. ENameValueType mType;
  143. char *mStringClass;
  144. ENameValueClass mClass;
  145. char *mStringSendto;
  146. ENameValueSendto mSendto;
  147. UNameValueReference mNameValueReference;
  148. LLStringTable *mNVNameTable;
  149. };
  150. extern LLStringTable gNVNameTable;
  151. #endif