gwnavruntime/blob/blobfieldstring.h Source File

blobfieldstring.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 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 #pragma once
9 
10 
17 
18 
19 namespace Kaim
20 {
21 
22 
23 class BlobFieldString
24 {
25  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
26 public:
27  BlobArray<char> m_name;
28  BlobArray<char> m_value;
29 };
30 
31 inline void SwapEndianness(Endianness::Target e, BlobFieldString& self)
32 {
33  SwapEndianness(e, self.m_name);
34  SwapEndianness(e, self.m_value);
35 }
36 
37 
38 class BlobFieldStringMapping
39 {
40  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
41 public:
42  BlobFieldStringMapping() : m_name(nullptr), m_string(nullptr), m_guid(nullptr) {}
43 
44  BlobFieldStringMapping(const char* name, String* string_) :
45  m_name(name), m_string(string_), m_guid(nullptr)
46  {}
47 
48  BlobFieldStringMapping(const char* name, KyGuid* guid) :
49  m_name(name), m_string(nullptr), m_guid(guid)
50  {}
51 
52 public:
53  const char* m_name;
54  String* m_string;
55  KyGuid* m_guid;
56 };
57 
58 template <class OSTREAM>
59 inline OSTREAM& operator<<(OSTREAM& os, BlobFieldStringMapping& mapping)
60 {
61  os << mapping.m_name << " : " << mapping.m_string->ToCStr() << Endl;
62  return os;
63 }
64 
65 
66 class BlobFieldStringBuilder : public BaseBlobBuilder<BlobFieldString>
67 {
68 public:
69  BlobFieldStringBuilder(BlobFieldStringMapping& mapping) : m_mapping(&mapping) {}
70 
71 private:
72  virtual void DoBuild()
73  {
74  String str;
75  if (m_mapping->m_string != nullptr)
76  {
77  str = *m_mapping->m_string;
78  }
79  else
80  {
81  char guidChars[37];
82  m_mapping->m_guid->ToString(guidChars);
83  str = guidChars;
84  }
85 
86  BLOB_STRING(m_blob->m_name, m_mapping->m_name);
87  BLOB_STRING(m_blob->m_value, str.ToCStr());
88  }
89 
90  BlobFieldStringMapping* m_mapping;
91 };
92 
93 
94 }
95 
96 
97 
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
#define BLOB_STRING(str, src)
Use this macro only in implementations of BaseBlobBuilder::DoBuild().
Definition: baseblobbuilder.h:166