gwnavruntime/blob/blobfieldstring.h Source File

blobfieldstring.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 
8 // primary contact: GUAL - secondary contact: NOBODY
9 #ifndef Navigation_BlobFieldString_H
10 #define Navigation_BlobFieldString_H
11 
12 
19 
20 
21 namespace Kaim
22 {
23 
24 
25 class BlobFieldString
26 {
27  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
28 public:
29  BlobArray<char> m_name;
30  BlobArray<char> m_value;
31 };
32 
33 inline void SwapEndianness(Endianness::Target e, BlobFieldString& self)
34 {
35  SwapEndianness(e, self.m_name);
36  SwapEndianness(e, self.m_value);
37 }
38 
39 
40 class BlobFieldStringMapping
41 {
42  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
43 public:
44  BlobFieldStringMapping() : m_name(KY_NULL), m_string(KY_NULL), m_guid(KY_NULL) {}
45 
46  BlobFieldStringMapping(const char* name, String* string_) :
47  m_name(name), m_string(string_), m_guid(KY_NULL)
48  {}
49 
50  BlobFieldStringMapping(const char* name, KyGuid* guid) :
51  m_name(name), m_string(KY_NULL), m_guid(guid)
52  {}
53 
54 public:
55  const char* m_name;
56  String* m_string;
57  KyGuid* m_guid;
58 };
59 
60 template <class OSTREAM>
61 inline OSTREAM& operator<<(OSTREAM& os, BlobFieldStringMapping& mapping)
62 {
63  os << mapping.m_name << " : " << mapping.m_string->ToCStr() << Endl;
64  return os;
65 }
66 
67 
68 class BlobFieldStringBuilder : public BaseBlobBuilder<BlobFieldString>
69 {
70 public:
71  BlobFieldStringBuilder(BlobFieldStringMapping& mapping) : m_mapping(&mapping) {}
72 
73 private:
74  virtual void DoBuild()
75  {
76  String str;
77  if (m_mapping->m_string != KY_NULL)
78  {
79  str = *m_mapping->m_string;
80  }
81  else
82  {
83  char guidChars[37];
84  m_mapping->m_guid->ToString(guidChars);
85  str = guidChars;
86  }
87 
88  BLOB_STRING(m_blob->m_name, m_mapping->m_name);
89  BLOB_STRING(m_blob->m_value, str.ToCStr());
90  }
91 
92  BlobFieldStringMapping* m_mapping;
93 };
94 
95 
96 }
97 
98 
99 #endif
100 
#define KY_NULL
Null value.
Definition: types.h:247
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
#define BLOB_STRING(str, src)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:179