00001
00032 #ifndef LL_LLNAMEVALUE_H
00033 #define LL_LLNAMEVALUE_H
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #include "string_table.h"
00050 #include "llmath.h"
00051 #include "v3math.h"
00052 #include "lldbstrings.h"
00053
00054 class LLNameValue;
00055 class LLStringTable;
00056
00057 typedef enum e_name_value_types
00058 {
00059 NVT_NULL,
00060 NVT_STRING,
00061 NVT_F32,
00062 NVT_S32,
00063 NVT_VEC3,
00064 NVT_U32,
00065 NVT_CAMERA,
00066 NVT_ASSET,
00067 NVT_U64,
00068 NVT_EOF
00069 } ENameValueType;
00070
00071 typedef enum e_name_value_class
00072 {
00073 NVC_NULL,
00074 NVC_READ_ONLY,
00075 NVC_READ_WRITE,
00076 NVC_EOF
00077 } ENameValueClass;
00078
00079 typedef enum e_name_value_sento
00080 {
00081 NVS_NULL,
00082 NVS_SIM,
00083 NVS_DATA_SIM,
00084 NVS_SIM_VIEWER,
00085 NVS_DATA_SIM_VIEWER,
00086 NVS_EOF
00087 } ENameValueSendto;
00088
00089
00090
00091 const U32 NAME_VALUE_BUF_SIZE = 1024;
00092
00093
00094 const U32 NAME_VALUE_TYPE_STRING_LENGTH = 8;
00095 const U32 NAME_VALUE_CLASS_STRING_LENGTH = 16;
00096 const U32 NAME_VALUE_SENDTO_STRING_LENGTH = 18;
00097 const U32 NAME_VALUE_DATA_SIZE =
00098 NAME_VALUE_BUF_SIZE -
00099 ( DB_NV_NAME_BUF_SIZE +
00100 NAME_VALUE_TYPE_STRING_LENGTH +
00101 NAME_VALUE_CLASS_STRING_LENGTH +
00102 NAME_VALUE_SENDTO_STRING_LENGTH );
00103
00104
00105 extern char NameValueTypeStrings[NVT_EOF][NAME_VALUE_TYPE_STRING_LENGTH];
00106 extern char NameValueClassStrings[NVC_EOF][NAME_VALUE_CLASS_STRING_LENGTH];
00107 extern char NameValueSendtoStrings[NVS_EOF][NAME_VALUE_SENDTO_STRING_LENGTH];
00108
00109 typedef union u_name_value_reference
00110 {
00111 char *string;
00112 F32 *f32;
00113 S32 *s32;
00114 LLVector3 *vec3;
00115 U32 *u32;
00116 U64 *u64;
00117 } UNameValueReference;
00118
00119
00120 class LLNameValue
00121 {
00122 public:
00123 void baseInit();
00124 void init(const char *name, const char *data, const char *type, const char *nvclass, const char *nvsendto );
00125
00126 LLNameValue();
00127 LLNameValue(const char *data);
00128 LLNameValue(const char *name, const char *type, const char *nvclass );
00129 LLNameValue(const char *name, const char *data, const char *type, const char *nvclass );
00130 LLNameValue(const char *name, const char *data, const char *type, const char *nvclass, const char *nvsendto );
00131
00132 ~LLNameValue();
00133
00134 char *getString();
00135 const char *getAsset() const;
00136 F32 *getF32();
00137 S32 *getS32();
00138 void getVec3(LLVector3 &vec);
00139 LLVector3 *getVec3();
00140 U32 *getU32();
00141 U64 *getU64();
00142
00143 const char *getType() const { return mStringType; }
00144 const char *getClass() const { return mStringClass; }
00145 const char *getSendto() const { return mStringSendto; }
00146
00147 BOOL sendToData() const;
00148 BOOL sendToViewer() const;
00149
00150 void callCallback();
00151 std::string printNameValue();
00152 std::string printData();
00153
00154 ENameValueType getTypeEnum() const { return mType; }
00155 ENameValueClass getClassEnum() const { return mClass; }
00156 ENameValueSendto getSendtoEnum() const { return mSendto; }
00157
00158 LLNameValue &operator=(const LLNameValue &a);
00159 void setString(const char *a);
00160 void setAsset(const char *a);
00161 void setF32(const F32 a);
00162 void setS32(const S32 a);
00163 void setVec3(const LLVector3 &a);
00164 void setU32(const U32 a);
00165
00166 friend std::ostream& operator<<(std::ostream& s, const LLNameValue &a);
00167
00168 private:
00169 void printNameValue(std::ostream& s);
00170
00171 public:
00172 char *mName;
00173
00174 char *mStringType;
00175 ENameValueType mType;
00176 char *mStringClass;
00177 ENameValueClass mClass;
00178 char *mStringSendto;
00179 ENameValueSendto mSendto;
00180
00181 UNameValueReference mNameValueReference;
00182 LLStringTable *mNVNameTable;
00183 };
00184
00185 extern LLStringTable gNVNameTable;
00186
00187
00188 #endif