OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
StdAdaptors.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
5  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
6  *
7  * Distributed under the terms of the ISC license; see accompanying file
8  * "COPYING" for details.
9  *
10  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
11  * See accompanying file "TRADEMARK" for details.
12  *
13  * To redistribute this file separately, substitute the full license texts
14  * for the above references.
15  */
16 #ifndef STDADAPTORS_H
17 #define STDADAPTORS_H
18 
19 #include "lib/Standard.h"
20 #include "lib/StdCompiler.h"
21 
22 // * Wrappers for C4Compiler-types
23 
24 // Whole-line string, automatic size deduction (C4Compiler-String)
25 #define toC4CStr(szString) mkStringAdaptMA(szString)
26 #define toC4CStrBuf(rBuf) mkParAdapt(rBuf, StdCompiler::RCT_All)
27 
28 // Integer-array with default 0, automatic size deduction
29 #define toC4CArr(rArr) mkArrayAdaptDM(rArr, 0)
30 #define toC4CArrU(rArr) mkArrayAdaptDM(rArr, 0u)
31 
32 // * Null Adaptor
33 // Doesn't compile anything
35 {
36  inline void CompileFunc(StdCompiler *pComp) const { }
37 };
38 
39 // * Defaulting Adaptor
40 // Sets default if CompileFunc fails with a Exception of type NotFoundException
41 template <class T, class D>
43 {
44  T &rValue; const D &rDefault;
45  StdDefaultAdapt(T &rValue, const D &rDefault) : rValue(rValue), rDefault(rDefault) { }
46  inline void CompileFunc(StdCompiler *pComp) const
47  {
48  try
49  {
50 #ifdef STDCOMPILER_EXCEPTION_WORKAROUND
51  if (!pComp->ValueSafe(rValue))
52  rValue = rDefault;
53 #else
54  pComp->Value(rValue);
55 #endif
56  }
58  {
59  rValue = rDefault;
60  delete pEx;
61  }
62  }
63 };
64 template <class T, class D>
65 inline StdDefaultAdapt<T, D> mkDefaultAdapt(T &&rValue, const D &rDefault) { return StdDefaultAdapt<T, D>(rValue, rDefault); }
66 
67 // * Naming Adaptor
68 // Embeds a value into a named section, failsafe
69 // (use for values that do defaulting themselves - e.g. objects using naming)
70 template <class T>
72 {
73  T &rValue; const char *szName;
74  StdNamingAdapt(T &rValue, const char *szName) : rValue(rValue), szName(szName) { }
75  inline void CompileFunc(StdCompiler *pComp) const
76  {
77  pComp->Name(szName);
78  try
79  {
80  pComp->Value(rValue);
81  }
82  catch (StdCompiler::Exception *)
83  {
84  pComp->NameEnd(true);
85  throw;
86  }
87  pComp->NameEnd();
88  }
89  template <class D> inline bool operator == (const D &nValue) const { return rValue == nValue; }
90  template <class D> inline StdNamingAdapt &operator = (const D &nValue) { rValue = nValue; return *this; }
91 };
92 template <class T>
93 inline StdNamingAdapt<T> mkNamingAdapt(T &&rValue, const char *szName) { return StdNamingAdapt<T>(rValue, szName); }
94 
95 // * Naming Adaptor (defaulting)
96 // Embeds a value into a named section, sets default on fail
97 template <class T, class D>
99 {
100  T &rValue; const char *szName; const D &rDefault; bool fPrefillDefault; bool fStoreDefault;
101  StdNamingDefaultAdapt(T &rValue, const char *szName, const D &rDefault, bool fPrefillDefault, bool fStoreDefault) : rValue(rValue), szName(szName), rDefault(rDefault), fPrefillDefault(fPrefillDefault), fStoreDefault(fStoreDefault) { }
102  inline void CompileFunc(StdCompiler *pComp) const
103  {
104  // Default check
105  if (pComp->hasNaming() && pComp->isSerializer() && rValue == rDefault && !fStoreDefault)
106  {
107  if (pComp->Default(szName)) return;
108  }
109  try
110  {
111  // Search named section, set default if not found
112  if (pComp->Name(szName))
113  {
114  if (fPrefillDefault && pComp->isDeserializer()) rValue = rDefault; // default prefill if desired
115  pComp->Value(mkDefaultAdapt(rValue, rDefault));
116  }
117  else
118  rValue = rDefault;
119  }
120  catch (StdCompiler::Exception *)
121  {
122  pComp->NameEnd(true);
123  throw;
124  }
125  // End section
126  pComp->NameEnd();
127  }
128 };
129 template <class T, class D>
130 inline StdNamingDefaultAdapt<T,D> mkNamingAdapt(T &&rValue, const char *szName, const D &rDefault, bool fPrefillDefault=false, bool fStoreDefault=false) { return StdNamingDefaultAdapt<T,D>(rValue, szName, rDefault, fPrefillDefault, fStoreDefault); }
131 
132 // * Decompiling Adaptor
133 // Allows to use const objects if the compiler won't change the targets
134 template <class T>
136 {
137  const T &rValue;
138  explicit StdDecompileAdapt(const T &rValue) : rValue(rValue) { }
139  inline void CompileFunc(StdCompiler *pComp) const
140  {
141  assert(pComp->isSerializer());
142  pComp->Value(const_cast<T &>(rValue));
143  }
144 
145  // make this work with in combination with StdParameterAdapt
146  template<typename ... P>
147  inline void CompileFunc(StdCompiler* pComp, P && ... pars) const
148  {
149  assert(pComp->isSerializer());
150  pComp->Value(mkParAdapt(const_cast<T &>(rValue), std::forward<P>(pars)...));
151  }
152 };
153 template <class T>
154 inline StdDecompileAdapt<T> mkDecompileAdapt(const T& rValue) { return StdDecompileAdapt<T>(rValue); }
155 
156 // * Runtime value Adaptor
157 // Allows the C4ValueSetCompiler to set the value
158 template <class T>
160 {
161  T &rValue;
162  explicit StdRuntimeValueAdapt(T &rValue) : rValue(rValue) { }
163  inline void CompileFunc(StdCompiler *pComp) const
164  {
165  pComp->setRuntimeWritesAllowed(+1);
166  pComp->Value(rValue);
167  pComp->setRuntimeWritesAllowed(-1);
168  }
169  template <class D> inline bool operator == (const D &nValue) const { return rValue == nValue; }
170  template <class D> inline StdRuntimeValueAdapt<T> &operator = (const D &nValue) { rValue = nValue; return *this; }
171 };
172 template <class T>
174 
175 // * String adaptor
177 {
179  StdStringAdapt(char *szString, int iMaxLength, StdCompiler::RawCompileType eRawType = StdCompiler::RCT_Escaped)
180  : szString(szString), iMaxLength(iMaxLength), eRawType(eRawType) { }
181  inline void CompileFunc(StdCompiler *pComp) const
182  {
183  pComp->String(szString, iMaxLength, eRawType);
184  }
185  inline bool operator == (const char *szDefault) const { return SEqual(szString, szDefault); }
186  inline StdStringAdapt &operator = (const char *szDefault) { SCopy(szDefault, szString, iMaxLength); return *this; }
187 };
188 inline StdStringAdapt mkStringAdapt(char *szString, int iMaxLength, StdCompiler::RawCompileType eRawType = StdCompiler::RCT_Escaped)
189 { return StdStringAdapt(szString, iMaxLength, eRawType); }
190 #define mkStringAdaptM(szString) mkStringAdapt(szString, (sizeof(szString) / sizeof(*szString)) - 1)
191 #define mkStringAdaptMA(szString) mkStringAdapt(szString, (sizeof(szString) / sizeof(*szString)) - 1, StdCompiler::RCT_All)
192 #define mkStringAdaptMI(szString) mkStringAdapt(szString, (sizeof(szString) / sizeof(*szString)) - 1, StdCompiler::RCT_Idtf)
193 #define mkStringAdaptMIE(szString) mkStringAdapt(szString, (sizeof(szString) / sizeof(*szString)) - 1, StdCompiler::RCT_IdtfAllowEmpty)
194 
195 // * Raw adaptor
197 {
199  StdRawAdapt(void *pData, size_t iSize, StdCompiler::RawCompileType eRawType = StdCompiler::RCT_Escaped)
200  : pData(pData), iSize(iSize), eRawType(eRawType) { }
201  inline void CompileFunc(StdCompiler *pComp) const
202  {
203  pComp->Raw(pData, iSize, eRawType);
204  }
205  inline bool operator == (const void *pDefault) const { return !memcmp(pDefault, pData, iSize); }
206  inline StdRawAdapt &operator = (const void *pDefault) { memcpy(pData, pDefault, iSize); return *this; }
207 };
209 { return StdRawAdapt(pData, iSize, eRawType); }
210 #define mkRawAdaptM(X) mkRawAdapt(&X, sizeof(X))
211 
212 // * Integer Adaptor
213 // Stores Integer-like datatypes (Enumerations)
214 template <class T, class int_t = int32_t>
216 {
217  T &rValue;
218  explicit StdIntAdapt(T &rValue) : rValue(rValue) { }
219  inline void CompileFunc(StdCompiler *pComp) const
220  {
221  // Cast
222  int_t iVal = int_t(rValue);
223  pComp->Value(iVal);
224  rValue = T(iVal);
225  }
226  // Operators for default checking/setting
227  template <class D> inline bool operator == (const D &nValue) const { return rValue == nValue; }
228  template <class D> inline StdIntAdapt &operator = (const D &nValue) { rValue = nValue; return *this; }
229 };
230 template <class T> inline StdIntAdapt<T> mkIntAdapt(T &rValue) { return StdIntAdapt<T>(rValue); }
231 template <class int_t, class T> StdIntAdapt<T, int_t> mkIntAdaptT(T &rValue) { return StdIntAdapt<T, int_t>(rValue); }
232 
233 // * Casting Adaptor
234 // Does a reinterprete_cast
235 template <class T, class to_t>
237 {
238  T &rValue;
239  explicit StdCastAdapt(T &rValue) : rValue(rValue) { }
240  inline void CompileFunc(StdCompiler *pComp) const
241  {
242  // Cast
243  assert(sizeof(to_t) == sizeof(T));
244  to_t vVal = *reinterpret_cast<to_t *>(&rValue);
245  pComp->Value(vVal);
246  rValue = *reinterpret_cast<T *>(&vVal);
247  }
248  // Operators for default checking/setting
249  template <class D> inline bool operator == (const D &nValue) const { return rValue == nValue; }
250  template <class D> inline StdCastAdapt &operator = (const D &nValue) { rValue = nValue; return *this; }
251 };
252 template <class to_t, class T> StdCastAdapt<T, to_t> mkCastAdapt(T &rValue) { return StdCastAdapt<T, to_t>(rValue); }
253 template <class T> StdCastAdapt<T, int32_t> mkCastIntAdapt(T &rValue) { return StdCastAdapt<T, int32_t>(rValue); }
254 
255 // Helper: Identity function class
256 template <class T>
258 {
259  T &operator ()(T &rValue) const { return rValue; }
260 };
261 
262 // * Array Adaptor
263 // Stores a separated list
264 template <class T, class M = _IdFuncClass<T> >
266 {
267  StdArrayAdapt(T *pArray, int iSize, M && map = M())
268  : pArray(pArray), iSize(iSize), map(std::forward<M>(map))
269  { }
270  T *pArray; int iSize; M && map;
271  inline void CompileFunc(StdCompiler *pComp) const
272  {
273  for (int i = 0; i < iSize; i++)
274  {
275  if (i) pComp->Separator(StdCompiler::SEP_SEP);
276  pComp->Value(map(pArray[i]));
277  }
278  }
279  // Operators for default checking/setting
280  inline bool operator == (const T &rDefault) const
281  {
282  for (int i = 0; i < iSize; i++)
283  if (pArray[i] != rDefault)
284  return false;
285  return true;
286  }
287  inline StdArrayAdapt &operator = (const T &rDefault)
288  {
289  for (int i = 0; i < iSize; i++)
290  pArray[i] = rDefault;
291  return *this;
292  }
293  inline bool operator == (const T *pDefaults) const
294  {
295  for (int i = 0; i < iSize; i++)
296  if (pArray[i] != pDefaults[i])
297  return false;
298  return true;
299  }
300  inline StdArrayAdapt &operator = (const T *pDefaults)
301  {
302  for (int i = 0; i < iSize; i++)
303  pArray[i] = pDefaults[i];
304  return *this;
305  }
306 };
307 template <class T>
308 inline StdArrayAdapt<T> mkArrayAdapt(T *pArray, int iSize) { return StdArrayAdapt<T>(pArray, iSize); }
309 #define mkArrayAdaptM(A) mkArrayAdapt(A, sizeof(A) / sizeof(*(A)))
310 template <class T, class M>
311 inline StdArrayAdapt<T, M> mkArrayAdaptMap(T *pArray, int iSize, M && map) { return StdArrayAdapt<T, M>(pArray, iSize, std::forward<M>(map)); }
312 #define mkArrayAdaptMapM(A, M) mkArrayAdaptMap(A, sizeof(A) / sizeof(*(A)), M)
313 
314 // * Array Adaptor (defaulting)
315 // Stores a separated list, sets defaults if a value or separator is missing.
316 template <class T, class D, class M = _IdFuncClass<T> >
318 {
319  StdArrayDefaultAdapt(T *pArray, size_t iSize, const D &rDefault, const M &map = M())
320  : pArray(pArray), iSize(iSize), rDefault(rDefault), map(map)
321  { }
322  T *pArray; size_t iSize; const D &rDefault; const M map;
323  inline void CompileFunc(StdCompiler *pComp) const
324  {
325  size_t i, iWrite = iSize;
326  bool deserializing = pComp->isDeserializer();
327  // Decompiling: Omit defaults
328  if (!deserializing && pComp->hasNaming())
329  while (iWrite > 0 && pArray[iWrite - 1] == rDefault)
330  iWrite--;
331  // Read/write values
332  for (i = 0; i < iWrite; i++)
333  {
334  // Separator?
335  if (i) if (!pComp->Separator(StdCompiler::SEP_SEP)) break;
336  // Expect a value. Default if not found.
337  pComp->Value(mkDefaultAdapt(map(pArray[i]), rDefault));
338  }
339  // Fill rest of array
340  if (deserializing)
341  for (; i < iSize; i++)
342  pArray[i] = rDefault;
343  }
344  // Additional defaulting (whole array)
345  inline bool operator == (const T *pDefaults) const
346  {
347  for (size_t i = 0; i < iSize; i++)
348  if (pArray[i] != pDefaults[i])
349  return false;
350  return true;
351  }
352  inline StdArrayDefaultAdapt &operator = (const T *pDefaults)
353  {
354  for (size_t i = 0; i < iSize; i++)
355  pArray[i] = pDefaults[i];
356  return *this;
357  }
358 };
359 template <class T, class D>
360 inline StdArrayDefaultAdapt<T, D> mkArrayAdapt(T *pArray, size_t iSize, const D &rDefault) { return StdArrayDefaultAdapt<T, D>(pArray, iSize, rDefault); }
361 #define mkArrayAdaptDM(A, D) mkArrayAdapt(A, sizeof(A) / sizeof(*(A)), D)
362 template <class T, class D, class M>
363 inline StdArrayDefaultAdapt<T, D, M> mkArrayAdaptMap(T *pArray, size_t iSize, const D &rDefault, M map) { return StdArrayDefaultAdapt<T, D, M>(pArray, iSize, rDefault, map); }
364 #define mkArrayAdaptMapDM(A, D, M) mkArrayAdaptMap(A, sizeof(A) / sizeof(*(A)), D, M)
365 
366 // * Array Adaptor (defaulting to another array)
367 // Stores a separated list, sets defaults if a value or separator is missing.
368 template <class T, class D, class M = _IdFuncClass<T> >
370 {
371  StdArrayDefaultArrayAdapt(T *pArray, size_t iSize, const D &rDefault, const M &map = M())
372  : pArray(pArray), iSize(iSize), rDefault(rDefault), map(map)
373  { }
374  T *pArray; size_t iSize; const D &rDefault; const M map;
375  inline void CompileFunc(StdCompiler *pComp) const
376  {
377  size_t i, iWrite = iSize;
378  bool deserializing = pComp->isDeserializer();
379  // Decompiling: Omit defaults
380  if (!deserializing && pComp->hasNaming())
381  while (iWrite > 0 && pArray[iWrite - 1] == rDefault[iWrite - 1])
382  iWrite--;
383  // Read/write values
384  for (i = 0; i < iWrite; i++)
385  {
386  // Separator?
387  if (i) if (!pComp->Separator(StdCompiler::SEP_SEP)) break;
388  // Expect a value. Default if not found.
389  pComp->Value(mkDefaultAdapt(map(pArray[i]), rDefault[i]));
390  }
391  // Fill rest of array
392  if (deserializing)
393  for (; i < iSize; i++)
394  pArray[i] = rDefault[i];
395  }
396  // Additional defaulting (whole array)
397  inline bool operator == (const T *pDefaults) const
398  {
399  for (size_t i = 0; i < iSize; i++)
400  if (pArray[i] != pDefaults[i])
401  return false;
402  return true;
403  }
404  inline StdArrayDefaultArrayAdapt &operator = (const T *pDefaults)
405  {
406  for (size_t i = 0; i < iSize; i++)
407  pArray[i] = pDefaults[i];
408  return *this;
409  }
410 };
411 template <class T, class D>
412 inline StdArrayDefaultArrayAdapt<T, D> mkArrayAdaptDefArr(T *pArray, size_t iSize, const D &rDefault) { return StdArrayDefaultArrayAdapt<T, D>(pArray, iSize, rDefault); }
413 #define mkArrayAdaptDMA(A, D) mkArrayAdaptDefArr(A, sizeof(A) / sizeof(*(A)), D)
414 template <class T, class D, class M>
415 inline StdArrayDefaultArrayAdapt<T, D, M> mkArrayAdaptDefArrMap(T *pArray, size_t iSize, const D &rDefault, const M &map) { return StdArrayDefaultArrayAdapt<T, D, M>(pArray, iSize, rDefault, map); }
416 #define mkArrayAdaptDMAM(A, D, M) mkArrayAdaptDefArrMap(A, sizeof(A) / sizeof(*(A)), D, M)
417 
418 // * Insertion Adaptor
419 // Compile a value before / after another
420 template <class T, class I>
422 {
423  StdInsertAdapt(T &rObj, I &rIns, bool fBefore = true)
424  : rObj(rObj), rIns(rIns), fBefore(fBefore)
425  { }
426  T &rObj; I &rIns; bool fBefore;
427  void CompileFunc(StdCompiler *pComp) const
428  {
429  if (fBefore) pComp->Value(rIns);
430  pComp->Value(rObj);
431  if (!fBefore) pComp->Value(rIns);
432  }
433 };
434 template <class T, class I>
435 inline StdInsertAdapt<T, I> mkInsertAdapt(T &&rObj, I &&rIns, bool fBefore = true) { return StdInsertAdapt<T,I>(rObj, rIns, fBefore); }
436 
437 // * Parameter Adaptor
438 // Specify a second parameter for the CompileFunc
439 template <class T, class P>
441 {
442  StdParameterAdapt(T && rObj, P && rPar) : rObj(std::forward<T>(rObj)), Par(std::forward<P>(rPar)) { }
443  T && rObj; P && Par;
444  void CompileFunc(StdCompiler *pComp) const
445  {
446  std::forward<T>(rObj).CompileFunc(pComp, std::forward<P>(Par));
447  }
448  // Operators for default checking/setting
449  template <class D> inline bool operator == (const D &nValue) const { return rObj == nValue; }
450  template <class D> inline StdParameterAdapt &operator = (const D &nValue) { rObj = nValue; return *this; }
451 
452  // getting value
453  inline T && GetObj() { return std::forward<T>(rObj); }
454 };
455 template <class T, class P>
456 inline StdParameterAdapt<T, P> mkParAdapt(T && rObj, P && rPar)
457 { return StdParameterAdapt<T, P>(std::forward<T>(rObj), std::forward<P>(rPar)); }
458 
459 // for mkArrayAdaptMap
460 template <class P>
462 {
463  P && Par;
464  StdParameterAdaptMaker(P && rPar) : Par(std::forward<P>(rPar)) { }
465  template <class T>
466  StdParameterAdapt<T, P> operator ()(T && rObj) const { return StdParameterAdapt<T, P>(std::forward<T>(rObj), std::forward<P>(Par)); }
467 };
468 template <class P>
469 inline StdParameterAdaptMaker<P> mkParAdaptMaker(P && rPar) { return StdParameterAdaptMaker<P>(std::forward<P>(rPar)); }
470 
471 // * Parameter Adaptor 2
472 // Specify a second and a third parameter for the CompileFunc
473 template <class T, class P1, class P2>
475 {
476  StdParameter2Adapt(T && rObj, P1 && rPar1, P2 && rPar2) :
477  rObj(std::forward<T>(rObj)), rPar1(std::forward<P1>(rPar1)), rPar2(std::forward<P2>(rPar2)) { }
478  T && rObj; P1 && rPar1; P2 && rPar2;
479  void CompileFunc(StdCompiler *pComp) const
480  {
481  std::forward<T>(rObj).CompileFunc(pComp, std::forward<P1>(rPar1), std::forward<P2>(rPar2));
482  }
483  // Operators for default checking/setting
484  template <class D> inline bool operator == (const D &nValue) const { return rObj == nValue; }
485  template <class D> inline StdParameter2Adapt &operator = (const D &nValue) { rObj = nValue; return *this; }
486 };
487 template <class T, class P1, class P2>
488 inline StdParameter2Adapt<T, P1, P2> mkParAdapt(T && rObj, P1 && rPar1, P2 && rPar2)
489 { return StdParameter2Adapt<T, P1, P2>(std::forward<T>(rObj), std::forward<P1>(rPar1), std::forward<P2>(rPar2)); }
490 
491 template <class T>
493 {
494  StdBasicPtrAdapt(T *&rpObj, bool fAllowNull = true, const char *szNaming = "Data")
495  : rpObj(rpObj), fAllowNull(fAllowNull), szNaming(szNaming) {}
496  T *&rpObj; bool fAllowNull; const char *szNaming;
497 
498  // Operators for default checking/setting
499  inline bool operator == (const T &nValue) const { return rpObj && *rpObj == nValue; }
500  inline StdBasicPtrAdapt &operator = (const T &nValue) { delete rpObj; rpObj = new T(nValue); return *this; }
501  inline bool operator == (const T *pValue) const { return rpObj == pValue; }
502  inline StdBasicPtrAdapt &operator = (const T *pValue) { delete rpObj; rpObj = pValue; return *this; }
503 };
504 
505 // * Store pointer (contents)
506 // Defaults to null
507 template <class T>
509 {
510  StdPtrAdapt(T *&rpObj, bool fAllowNull = true, const char *szNaming = "Data")
511  : StdBasicPtrAdapt<T>(rpObj, fAllowNull, szNaming)
512  { }
513 
514  void CompileFunc(StdCompiler *pComp) const
515  {
516  StdPtrAdaptCompileFunc(pComp, *this);
517  }
518 
519  // For use with StdParAdapt
520  template<typename ... P>
521  void CompileFunc(StdCompiler *pComp, P && ...pars)
522  {
523  StdPtrAdaptCompileFunc(pComp, *this, std::forward<P>(pars)...);
524  }
525 };
526 
527 template <class T, class ContextT>
529 {
530  StdContextPtrAdapt(T *&rpObj, const ContextT& rCtx, bool fAllowNull = true, const char *szNaming = "Data")
531  : StdBasicPtrAdapt<T>(rpObj, fAllowNull, szNaming), pCtx(&rCtx)
532  { }
533 
534  const ContextT* pCtx;
535 
536  void CompileFunc(StdCompiler *pComp) const
537  {
538  StdPtrAdaptCompileFunc(pComp, *this);
539  }
540 
541  // For use with StdParAdapt
542  template<class P>
543  void CompileFunc(StdCompiler *pComp, const P& p)
544  {
545  StdPtrAdaptCompileFunc(pComp, *this, p);
546  }
547 };
548 
549 template <class T, typename ... P>
550 void StdPtrAdaptCompileFunc(StdCompiler* pComp, const T& adapt, P && ...pars)
551 {
552  bool deserializing = pComp->isDeserializer(),
553  fNaming = pComp->hasNaming();
554  // Compiling? Clear object before
555  if(deserializing) { delete adapt.rpObj; adapt.rpObj = nullptr; }
556  // Null checks - different with naming support.
557  if(adapt.fAllowNull)
558  if(fNaming)
559  {
560  // Null check: just omit when writing
561  if(!deserializing && !adapt.rpObj) return;
562  // Set up naming
563  if(!pComp->Name(adapt.szNaming)) { assert(deserializing); pComp->NameEnd(); return; }
564  }
565  else
566  {
567  bool fNull = !! adapt.rpObj;
568  pComp->Value(fNull);
569  // Null? Nothing further to do
570  if(fNull) return;
571  }
572  else if(!deserializing)
573  assert(adapt.rpObj);
574  // Compile value
575  if(deserializing)
576  StdPtrAdaptCompileNewFunc(adapt, pComp, std::forward<P>(pars)...);
577  else
578  StdPtrAdaptDecompileNewFunc(adapt, pComp, std::forward<P>(pars)...);
579 
580  // Close naming
581  if(adapt.fAllowNull && fNaming) pComp->NameEnd();
582 }
583 
584 
585 template <class T, typename ... P>
586 void StdPtrAdaptCompileNewFunc(const StdPtrAdapt<T>& adapt, StdCompiler* pComp, P && ...pars) { CompileNewFunc(adapt.rpObj, pComp, std::forward<P>(pars)...); }
587 template <class T, class ContextT, typename ... P>
588 void StdPtrAdaptCompileNewFunc(const StdContextPtrAdapt<T, ContextT>& adapt, StdCompiler* pComp, P && ...pars) { CompileNewFuncCtx(adapt.rpObj, pComp, *adapt.pCtx, std::forward<P>(pars)...); }
589 
590 template <class T>
591 void StdPtrAdaptDecompileNewFunc(const StdPtrAdapt<T>& adapt, StdCompiler* pComp) { pComp->Value(mkDecompileAdapt(*adapt.rpObj)); }
592 template <class T, class ContextT>
594 template <class T, typename ... P>
595 void StdPtrAdaptDecompileNewFunc(const StdPtrAdapt<T>& adapt, StdCompiler* pComp, P && ...pars) { pComp->Value(mkParAdapt(mkDecompileAdapt(*adapt.rpObj), std::forward<P>(pars)...)); }
596 template <class T, class ContextT, typename ... P>
597 void StdPtrAdaptDecompileNewFunc(const StdContextPtrAdapt<T, ContextT>& adapt, StdCompiler* pComp, P && ...pars) { pComp->Value(mkParAdapt(mkDecompileAdapt(*adapt.rpObj), std::forward<P>(pars)...)); }
598 
599 template <class T>
600 inline StdPtrAdapt<T> mkPtrAdapt(T *&rpObj, bool fAllowNull = true) { return StdPtrAdapt<T>(rpObj, fAllowNull); }
601 template <class T>
602 inline StdPtrAdapt<T> mkNamingPtrAdapt(T *&rpObj, const char *szNaming) { return StdPtrAdapt<T>(rpObj, true, szNaming); }
603 template <class T>
604 inline StdPtrAdapt<T> mkPtrAdaptNoNull(T *&rpObj) { return mkPtrAdapt<T>(rpObj, false); }
605 
606 template <class T, class ContextT>
607 inline StdContextPtrAdapt<T, ContextT> mkContextPtrAdapt(T *&rpObj, const ContextT& ctx, bool fAllowNull = true) { return StdContextPtrAdapt<T, ContextT>(rpObj, ctx, fAllowNull); }
608 template <class T, class ContextT>
609 inline StdContextPtrAdapt<T, ContextT> mkNamingContextPtrAdapt(T *&rpObj, const ContextT& ctx, const char* szNaming) { return StdContextPtrAdapt<T, ContextT>(rpObj, ctx, true, szNaming); }
610 template <class T, class ContextT>
611 inline StdContextPtrAdapt<T, ContextT> mkContextPtrAdaptNoNull(T *&rpObj, const ContextT& ctx) { return mkContextPtrAdapt<T, ContextT>(rpObj, ctx, false); }
612 
613 // * Adaptor for STL containers
614 // Writes a comma-separated list for compilers that support it. Otherwise, the size is calculated and safed.
615 // The defaulting uses the standard STL operators (full match)
616 template <class C>
618 {
620  : rStruct(rStruct), eSep(eSep) { }
622  inline void CompileFunc(StdCompiler *pComp) const
623  {
624  typedef typename C::value_type T;
625  // Get compiler specs
626  bool deserializing = pComp->isDeserializer();
627  bool fNaming = pComp->hasNaming();
628  // Decompiling?
629  if (!deserializing)
630  {
631  // Write size (binary only)
632  if (!fNaming)
633  {
634  int32_t iSize = rStruct.size();
635  pComp->Value(iSize);
636  }
637  // Write all entries
638  for (typename C::const_iterator i = rStruct.begin(); i != rStruct.end(); ++i)
639  {
640  if (i != rStruct.begin() && eSep) pComp->Separator(eSep);
641  pComp->Value(const_cast<T &>(*i));
642  }
643  }
644  else
645  {
646  // Compiling: Empty previous
647  rStruct.clear();
648  // Read size (binary only)
649  uint32_t iSize;
650  if (!fNaming) pComp->Value(iSize);
651  // Read new
652  do
653  {
654  // No entries left to read?
655  if (!fNaming && !iSize--)
656  break;
657  // Read entries
658  try
659  {
660  T val;
661  pComp->Value(val);
662  rStruct.push_back(val);
663  }
664  catch (StdCompiler::NotFoundException *pEx)
665  {
666  // No value found: Stop reading loop
667  delete pEx;
668  break;
669  }
670  }
671  while (!eSep || pComp->Separator(eSep));
672  }
673  }
674  // Operators for default checking/setting
675  inline bool operator == (const C &nValue) const { return rStruct == nValue; }
676  inline StdSTLContainerAdapt &operator = (const C &nValue) { rStruct = nValue; return *this; }
677 };
678 template <class C>
680 
681 // Write an integer that is supposed to be small most of the time. The adaptor writes it in
682 // 7-bit-pieces, bit 8 being a continuation marker: If it's set, more data is following, if not,
683 // all following bits are 0.
684 // Code lengths for uint32_t:
685 // 0x00000000 (0) - 0x0000007F (127) : 1 byte
686 // 0x00000080 (128) - 0x00003FFF (16383) : 2 byte
687 // 0x00004000 (16384) - 0x001FFFFF (2097151) : 3 byte
688 // 0x00200000 (2097152) - 0x0FFFFFFF (268435456) : 4 byte
689 // 0x10000000 (268435456) - 0xFFFFFFFF (4294967295) : 5 byte
690 // So this sort of packing is always useful when the integer in question is almost impossible to
691 // grow bigger than 2,097,151.
692 template <class T>
694 {
695  StdIntPackAdapt(T &rVal) : rVal(rVal) { }
696  T &rVal;
697 
698  inline T clearUpper(T x) const
699  {
700  const int CLEARBITS = 8 * sizeof(T) - 7;
701  return (x << CLEARBITS) >> CLEARBITS;
702  }
703 
704  void CompileFunc(StdCompiler *pComp) const
705  {
706  // simply write for textual compilers
707  if (pComp->hasNaming())
708  {
709  pComp->Value(rVal);
710  return;
711  }
712  T val; uint8_t tmp;
713  // writing?
714  if (!pComp->isDeserializer())
715  {
716  val = rVal;
717  for (;;)
718  {
719  tmp = uint8_t(clearUpper(val));
720  // last byte?
721  if (clearUpper(val) == val)
722  break;
723  // write byte
724  tmp ^= 0x80; pComp->Value(tmp);
725  // advance
726  val >>= 7;
727  }
728  // write last byte
729  pComp->Value(tmp);
730  }
731  // reading?
732  else
733  {
734  // read first byte
735  pComp->Value(tmp);
736  val = clearUpper(T(tmp));
737  // read remaining bytes
738  int i = 7; T data = val;
739  while ( uint8_t(data) != tmp )
740  {
741  // read byte
742  pComp->Value(tmp);
743  // add to value
744  data = clearUpper(T(tmp));
745  val = (data << i) | (val & ((1 << i) - 1));
746  // next byte
747  i+=7;
748  }
749  // write
750  rVal = val;
751  }
752  }
753  template <class D> inline bool operator == (const D &nValue) const { return rVal == nValue; }
754  template <class D> inline StdIntPackAdapt &operator = (const D &nValue) { rVal = nValue; return *this; }
755 };
756 template <class T>
758 
759 template <class T>
761 {
762  const char *Name;
763  T Val;
764 };
765 
766 // Enumeration: For text compilers, write a given name for a value.
767 // For everything else, just write an integer of given type.
768 template <class T, class int_t = int32_t>
770 {
772 
773  StdEnumAdapt(T &rVal, const Entry *pNames) : rVal(rVal), pNames(pNames) { assert(pNames); }
774  T &rVal; const Entry *pNames;
775 
776  void CompileFunc(StdCompiler *pComp) const
777  {
778  // Write as int
779  if (!pComp->isVerbose())
780  {
781  pComp->Value(mkIntAdaptT<int_t>(rVal));
782  return;
783  }
784  // writing?
785  if (!pComp->isDeserializer())
786  {
787  // Find value
788  const Entry *pName = pNames;
789  for (; pName->Name; pName++)
790  if (pName->Val == rVal)
791  {
792  // Put name
793  pComp->String(const_cast<char **>(&pName->Name), StdCompiler::RCT_Idtf);
794  break;
795  }
796  // No name found?
797  if (!pName->Name)
798  // Put value as integer
799  pComp->Value(mkIntAdaptT<int_t>(rVal));
800  }
801  // reading?
802  else
803  {
804  int_t val = 0;
805 #ifdef STDCOMPILER_EXCEPTION_WORKAROUND
806  // Try to read as number
807  if (!pComp->ValueSafe(val))
808  {
809  rVal = T(val);
810 #else
811  // Try to read as number
812  try
813  {
814  pComp->Value(val);
815  rVal = T(val);
816  }
817  catch (StdCompiler::NotFoundException *pEx)
818  {
819  delete pEx;
820 #endif
821  // Try to read as string
822  StdStrBuf Name;
823  pComp->Value(mkParAdapt(Name, StdCompiler::RCT_Idtf));
824  // Search in name list
825  const Entry *pName = pNames;
826  for (; pName->Name; pName++)
827  if (Name == pName->Name)
828  {
829  rVal = pName->Val;
830  break;
831  }
832  // Not found? Warn
833  if (!pName->Name)
834  pComp->Warn("Unknown bit name: %s", Name.getData());
835  }
836  }
837  }
838 
839  template <class D> inline bool operator == (const D &nValue) const { return rVal == nValue; }
840  template <class D> inline StdEnumAdapt<T, int_t> &operator = (const D &nValue) { rVal = nValue; return *this; }
841 };
842 template <class T, class int_t>
844 template <class int_t, class T>
846 
847 template <class T>
849 {
850  const char *Name;
851  T Val;
852 };
853 
854 // Convert a bitfield into/from something like "foo | bar | baz", where "foo", "bar" and "baz" are given constants.
855 template <class T>
857 {
859 
860  StdBitfieldAdapt(T &rVal, const Entry *pNames) : rVal(rVal), pNames(pNames) { assert(pNames); }
861  T &rVal; const Entry *pNames;
862 
863  void CompileFunc(StdCompiler *pComp) const
864  {
865  // simply write for non-verbose compilers
866  if (!pComp->isVerbose())
867  {
868  pComp->Value(rVal);
869  return;
870  }
871  // writing?
872  if (!pComp->isDeserializer())
873  {
874  T val = rVal, orig_val = rVal;
875  // Write until value is comsumed
876  bool fFirst = true;
877  for (const Entry *pName = pNames; pName->Name; pName++)
878  if ((pName->Val & val) == pName->Val)
879  {
880  // Avoid writing meaningless none-values (e.g. Category=C4D_None|C4D_Object)
881  if (orig_val && !pName->Val) continue;
882  // Put "|"
883  if (!fFirst) pComp->Separator(StdCompiler::SEP_VLINE);
884  // Put name
885  pComp->String(const_cast<char **>(&pName->Name), StdCompiler::RCT_Idtf);
886  fFirst = false;
887  // Remove bits
888  val &= ~pName->Val;
889  }
890  // Anything left is written as number, or a simple 0 in case no default was used
891  if (val || fFirst)
892  {
893  // Put "|"
894  if (!fFirst) pComp->Separator(StdCompiler::SEP_VLINE);
895  // Put value
896  pComp->Value(val);
897  }
898  }
899  // reading?
900  else
901  {
902  T val = 0;
903  // Read
904  do
905  {
906 #ifdef STDCOMPILER_EXCEPTION_WORKAROUND
907  T tmp;
908  // Try to read as number
909  if (pComp->ValueSafe(tmp))
910  val |= tmp;
911  else
912  {
913 #else
914  // Try to read as number
915  try
916  {
917  T tmp;
918  pComp->Value(tmp);
919  val |= tmp;
920  }
921  catch (StdCompiler::NotFoundException *pEx)
922  {
923  delete pEx;
924 #endif
925  // Try to read as string
926  StdStrBuf Name;
927  pComp->Value(mkParAdapt(Name, StdCompiler::RCT_Idtf));
928  // Search in name list
929  const Entry *pName = pNames;
930  for (; pName->Name; pName++)
931  if (Name == pName->Name)
932  {
933  val |= pName->Val;
934  break;
935  }
936  // Not found? Warn
937  if (!pName->Name)
938  pComp->Warn("Unknown bit name: %s", Name.getData());
939  }
940  // Expect separation
941  } while (pComp->Separator(StdCompiler::SEP_VLINE));
942  // Write value back
943  rVal = val;
944  }
945  }
946 
947  template <class D> inline bool operator == (const D &nValue) const { return rVal == nValue; }
948  template <class D> inline StdBitfieldAdapt<T> &operator = (const D &nValue) { rVal = nValue; return *this; }
949 };
950 template <class T>
952 
953 // * Name count adapter
954 // For compilers without name support, this just compiles the given value. Otherwise, the count
955 // of given namings is returned on compiling, and nothing is done for decompiling (The caller
956 // has to make sure that an appropriate number of namings will be created)
957 template <class int_t>
959 {
960  int_t &iCount; const char *szName;
961  StdNamingCountAdapt(int_t &iCount, const char *szName) : iCount(iCount), szName(szName) { }
962  inline void CompileFunc(StdCompiler *pComp) const
963  {
964  if (pComp->hasNaming())
965  {
966  if (pComp->isDeserializer())
967  iCount = pComp->NameCount(szName);
968  }
969  else
970  pComp->Value(mkIntPackAdapt(iCount));
971  }
972 };
973 template <class int_t>
974 inline StdNamingCountAdapt<int_t> mkNamingCountAdapt(int_t &iCount, const char *szName) { return StdNamingCountAdapt<int_t>(iCount, szName); }
975 
976 // * Hex adapter
977 // Writes raw binary data in hexadecimal
979 {
980  void *pData; size_t iSize;
981 public:
982  StdHexAdapt(void *pData, size_t iSize) : pData(pData), iSize(iSize) { }
983  inline void CompileFunc(StdCompiler *pComp) const
984  {
985  if (!pComp->isVerbose())
986  pComp->Raw(pData, iSize);
987  char szData[2+1]; bool deserializing = pComp->isDeserializer();
988  for (size_t i = 0; i < iSize; i++)
989  {
990  uint8_t *pByte = reinterpret_cast<uint8_t *>(pData) + i;
991  if (!deserializing) sprintf(szData, "%02x", *pByte);
992  pComp->String(szData, 2, StdCompiler::RCT_Idtf);
993  if (deserializing)
994  {
995  unsigned int b;
996  if (sscanf(szData, "%02x", &b) != 1)
997  pComp->excNotFound(i ? "hexadecimal data: bytes missing!" : "hexadecimal data missing!");
998  *pByte = b;
999  }
1000  }
1001  }
1002 };
1003 inline StdHexAdapt mkHexAdapt(void *pData, size_t iSize) { return StdHexAdapt(pData, iSize); }
1004 template <class T>
1005 inline StdHexAdapt mkHexAdapt(T &rData) { return StdHexAdapt(&rData, sizeof(rData)); }
1006 
1007 
1008 #endif //STDADAPTORS_H
const char * getData() const
Definition: StdBuf.h:450
T & operator()(T &rValue) const
Definition: StdAdaptors.h:259
StdRuntimeValueAdapt< T > mkRuntimeValueAdapt(T &&rValue)
Definition: StdAdaptors.h:173
StdStringAdapt mkStringAdapt(char *szString, int iMaxLength, StdCompiler::RawCompileType eRawType=StdCompiler::RCT_Escaped)
Definition: StdAdaptors.h:188
virtual bool Separator(Sep eSep=SEP_SEP)
Definition: StdCompiler.h:129
bool operator==(const D &nValue) const
Definition: StdAdaptors.h:753
StdIntPackAdapt(T &rVal)
Definition: StdAdaptors.h:695
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:479
StdNamingAdapt(T &rValue, const char *szName)
Definition: StdAdaptors.h:74
StdCastAdapt & operator=(const D &nValue)
Definition: StdAdaptors.h:250
virtual bool hasNaming()
Definition: StdCompiler.h:68
Definition: StdAdaptors.h:848
bool operator==(const D &nValue) const
Definition: StdAdaptors.h:227
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:122
bool operator==(const T &nValue) const
Definition: StdAdaptors.h:499
void CompileFunc(StdCompiler *pComp, const P &p)
Definition: StdAdaptors.h:543
Definition: StdAdaptors.h:760
StdNamingCountAdapt< int_t > mkNamingCountAdapt(int_t &iCount, const char *szName)
Definition: StdAdaptors.h:974
StdIntAdapt & operator=(const D &nValue)
Definition: StdAdaptors.h:228
StdRawAdapt mkRawAdapt(void *pData, size_t iSize, StdCompiler::RawCompileType eRawType=StdCompiler::RCT_Escaped)
Definition: StdAdaptors.h:208
const char * szName
Definition: StdAdaptors.h:73
StdIntAdapt< T, int_t > mkIntAdaptT(T &rValue)
Definition: StdAdaptors.h:231
StdNamingCountAdapt(int_t &iCount, const char *szName)
Definition: StdAdaptors.h:961
StdParameterAdapt< T, P > operator()(T &&rObj) const
Definition: StdAdaptors.h:466
bool operator==(const void *pDefault) const
Definition: StdAdaptors.h:205
void CompileFunc(StdCompiler *pComp, P &&...pars)
Definition: StdAdaptors.h:521
#define b
#define sprintf
Definition: Standard.h:171
const T & rValue
Definition: StdAdaptors.h:137
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:139
void StdPtrAdaptCompileFunc(StdCompiler *pComp, const T &adapt, P &&...pars)
Definition: StdAdaptors.h:550
StdInsertAdapt(T &rObj, I &rIns, bool fBefore=true)
Definition: StdAdaptors.h:423
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:181
StdEnumAdapt< T, int_t > & operator=(const D &nValue)
Definition: StdAdaptors.h:840
const D & rDefault
Definition: StdAdaptors.h:44
StdArrayDefaultArrayAdapt< T, D, M > mkArrayAdaptDefArrMap(T *pArray, size_t iSize, const D &rDefault, const M &map)
Definition: StdAdaptors.h:415
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:622
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:514
StdContextPtrAdapt< T, ContextT > mkNamingContextPtrAdapt(T *&rpObj, const ContextT &ctx, const char *szNaming)
Definition: StdAdaptors.h:609
StdSTLContainerAdapt & operator=(const C &nValue)
Definition: StdAdaptors.h:676
bool operator==(const D &nValue) const
Definition: StdAdaptors.h:249
virtual bool Name(const char *szName)
Definition: StdCompiler.h:87
virtual void Raw(void *pData, size_t iSize, RawCompileType eType=RCT_Escaped)=0
StdArrayDefaultAdapt & operator=(const T *pDefaults)
Definition: StdAdaptors.h:352
StdParameterAdaptMaker< P > mkParAdaptMaker(P &&rPar)
Definition: StdAdaptors.h:469
StdNamingDefaultAdapt(T &rValue, const char *szName, const D &rDefault, bool fPrefillDefault, bool fStoreDefault)
Definition: StdAdaptors.h:101
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:704
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:97
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:271
StdCastAdapt< T, to_t > mkCastAdapt(T &rValue)
Definition: StdAdaptors.h:252
StdCastAdapt< T, int32_t > mkCastIntAdapt(T &rValue)
Definition: StdAdaptors.h:253
StdParameterAdaptMaker(P &&rPar)
Definition: StdAdaptors.h:464
bool operator==(const D &nValue) const
Definition: StdAdaptors.h:169
virtual void String(char *szString, size_t iMaxLength, RawCompileType eType=RCT_Escaped)=0
bool operator==(const D &nValue) const
Definition: StdAdaptors.h:449
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:93
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:444
StdBitfieldAdapt(T &rVal, const Entry *pNames)
Definition: StdAdaptors.h:860
StdArrayAdapt & operator=(const T &rDefault)
Definition: StdAdaptors.h:287
bool isSerializer()
Definition: StdCompiler.h:64
bool operator==(const D &nValue) const
Definition: StdAdaptors.h:839
StdSTLContainerAdapt(C &rStruct, StdCompiler::Sep eSep=StdCompiler::SEP_SEP)
Definition: StdAdaptors.h:619
StdNamingAdapt & operator=(const D &nValue)
Definition: StdAdaptors.h:90
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:163
virtual bool isVerbose()
Definition: StdCompiler.h:72
size_t iSize
Definition: StdAdaptors.h:198
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:75
void * pData
Definition: StdAdaptors.h:198
StdParameterAdapt & operator=(const D &nValue)
Definition: StdAdaptors.h:450
StdIntAdapt(T &rValue)
Definition: StdAdaptors.h:218
StdCompiler::RawCompileType eRawType
Definition: StdAdaptors.h:178
StdArrayAdapt< T > mkArrayAdapt(T *pArray, int iSize)
Definition: StdAdaptors.h:308
StdBitfieldAdapt< T > mkBitfieldAdapt(T &rVal, const StdBitfieldEntry< T > *pNames)
Definition: StdAdaptors.h:951
StdDecompileAdapt< T > mkDecompileAdapt(const T &rValue)
Definition: StdAdaptors.h:154
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:983
void CompileFunc(StdCompiler *pComp, P &&...pars) const
Definition: StdAdaptors.h:147
bool operator==(const T *pDefaults) const
Definition: StdAdaptors.h:345
StdPtrAdapt< T > mkPtrAdaptNoNull(T *&rpObj)
Definition: StdAdaptors.h:604
StdRawAdapt(void *pData, size_t iSize, StdCompiler::RawCompileType eRawType=StdCompiler::RCT_Escaped)
Definition: StdAdaptors.h:199
bool operator==(const char *szDefault) const
Definition: StdAdaptors.h:185
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:962
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:536
StdParameter2Adapt & operator=(const D &nValue)
Definition: StdAdaptors.h:485
StdRuntimeValueAdapt(T &rValue)
Definition: StdAdaptors.h:162
StdArrayDefaultArrayAdapt & operator=(const T *pDefaults)
Definition: StdAdaptors.h:404
T clearUpper(T x) const
Definition: StdAdaptors.h:698
void excNotFound(const char *szMessage,...)
Definition: StdCompiler.h:242
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:776
StdInsertAdapt< T, I > mkInsertAdapt(T &&rObj, I &&rIns, bool fBefore=true)
Definition: StdAdaptors.h:435
StdCastAdapt(T &rValue)
Definition: StdAdaptors.h:239
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:427
bool operator==(const D &nValue) const
Definition: StdAdaptors.h:484
const char * szName
Definition: StdAdaptors.h:100
StdParameter2Adapt(T &&rObj, P1 &&rPar1, P2 &&rPar2)
Definition: StdAdaptors.h:476
void Value(const T &rStruct)
Definition: StdCompiler.h:170
StdBasicPtrAdapt & operator=(const T &nValue)
Definition: StdAdaptors.h:500
StdParameterAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:442
bool operator==(const T *pDefaults) const
Definition: StdAdaptors.h:397
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:219
StdRawAdapt & operator=(const void *pDefault)
Definition: StdAdaptors.h:206
const char * szNaming
Definition: StdAdaptors.h:496
const char * Name
Definition: StdAdaptors.h:762
virtual bool isDeserializer()
Definition: StdCompiler.h:63
const Entry * pNames
Definition: StdAdaptors.h:774
StdStringAdapt & operator=(const char *szDefault)
Definition: StdAdaptors.h:186
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:102
StdContextPtrAdapt(T *&rpObj, const ContextT &rCtx, bool fAllowNull=true, const char *szNaming="Data")
Definition: StdAdaptors.h:530
StdEnumAdapt< T, int_t > mkEnumAdapt(T &rVal, const StdEnumEntry< T > *pNames)
Definition: StdAdaptors.h:843
StdIntPackAdapt< T > mkIntPackAdapt(T &rVal)
Definition: StdAdaptors.h:757
StdDecompileAdapt(const T &rValue)
Definition: StdAdaptors.h:138
StdBitfieldEntry< T > Entry
Definition: StdAdaptors.h:858
StdHexAdapt mkHexAdapt(void *pData, size_t iSize)
Definition: StdAdaptors.h:1003
StdStringAdapt(char *szString, int iMaxLength, StdCompiler::RawCompileType eRawType=StdCompiler::RCT_Escaped)
Definition: StdAdaptors.h:179
void StdPtrAdaptCompileNewFunc(const StdPtrAdapt< T > &adapt, StdCompiler *pComp, P &&...pars)
Definition: StdAdaptors.h:586
StdContextPtrAdapt< T, ContextT > mkContextPtrAdaptNoNull(T *&rpObj, const ContextT &ctx)
Definition: StdAdaptors.h:611
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:201
StdSTLContainerAdapt< C > mkSTLContainerAdapt(C &rTarget, StdCompiler::Sep eSep=StdCompiler::SEP_SEP)
Definition: StdAdaptors.h:679
void Warn(const char *szWarning,...)
Definition: StdCompiler.cpp:26
StdDefaultAdapt(T &rValue, const D &rDefault)
Definition: StdAdaptors.h:45
void StdPtrAdaptDecompileNewFunc(const StdPtrAdapt< T > &adapt, StdCompiler *pComp)
Definition: StdAdaptors.h:591
virtual void setRuntimeWritesAllowed(int32_t iChange)
Definition: StdCompiler.h:78
const ContextT * pCtx
Definition: StdAdaptors.h:534
virtual int NameCount(const char *szName=nullptr)
Definition: StdCompiler.h:101
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:240
virtual bool Default(const char *szName)
Definition: StdCompiler.h:98
StdArrayDefaultAdapt(T *pArray, size_t iSize, const D &rDefault, const M &map=M())
Definition: StdAdaptors.h:319
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:456
StdEnumAdapt< T, int_t > mkEnumAdaptT(T &rVal, const StdEnumEntry< T > *pNames)
Definition: StdAdaptors.h:845
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:323
StdHexAdapt(void *pData, size_t iSize)
Definition: StdAdaptors.h:982
void CompileNewFuncCtx(T *&pStruct, StdCompiler *pComp, const ContextT &rCtx)
Definition: StdCompiler.h:351
StdPtrAdapt< T > mkNamingPtrAdapt(T *&rpObj, const char *szNaming)
Definition: StdAdaptors.h:602
StdEnumEntry< T > Entry
Definition: StdAdaptors.h:771
bool operator==(const T &rDefault) const
Definition: StdAdaptors.h:280
bool operator==(const D &nValue) const
Definition: StdAdaptors.h:89
StdIntPackAdapt & operator=(const D &nValue)
Definition: StdAdaptors.h:754
const char * Name
Definition: StdAdaptors.h:850
StdArrayAdapt(T *pArray, int iSize, M &&map=M())
Definition: StdAdaptors.h:267
StdDefaultAdapt< T, D > mkDefaultAdapt(T &&rValue, const D &rDefault)
Definition: StdAdaptors.h:65
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:46
StdArrayAdapt< T, M > mkArrayAdaptMap(T *pArray, int iSize, M &&map)
Definition: StdAdaptors.h:311
bool operator==(const C &nValue) const
Definition: StdAdaptors.h:675
StdCompiler::RawCompileType eRawType
Definition: StdAdaptors.h:198
StdBasicPtrAdapt(T *&rpObj, bool fAllowNull=true, const char *szNaming="Data")
Definition: StdAdaptors.h:494
StdRuntimeValueAdapt< T > & operator=(const D &nValue)
Definition: StdAdaptors.h:170
StdPtrAdapt< T > mkPtrAdapt(T *&rpObj, bool fAllowNull=true)
Definition: StdAdaptors.h:600
virtual void NameEnd(bool fBreak=false)
Definition: StdCompiler.h:88
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:36
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:863
StdContextPtrAdapt< T, ContextT > mkContextPtrAdapt(T *&rpObj, const ContextT &ctx, bool fAllowNull=true)
Definition: StdAdaptors.h:607
StdIntAdapt< T > mkIntAdapt(T &rValue)
Definition: StdAdaptors.h:230
StdPtrAdapt(T *&rpObj, bool fAllowNull=true, const char *szNaming="Data")
Definition: StdAdaptors.h:510
StdEnumAdapt(T &rVal, const Entry *pNames)
Definition: StdAdaptors.h:773
StdArrayDefaultArrayAdapt(T *pArray, size_t iSize, const D &rDefault, const M &map=M())
Definition: StdAdaptors.h:371
void CompileNewFunc(T *&pStruct, StdCompiler *pComp)
Definition: StdCompiler.h:323
int iSize
Definition: TstC4NetIO.cpp:35
const StdCompiler::Sep eSep
Definition: StdAdaptors.h:621
const char * szName
Definition: StdAdaptors.h:960
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:375
StdArrayDefaultArrayAdapt< T, D > mkArrayAdaptDefArr(T *pArray, size_t iSize, const D &rDefault)
Definition: StdAdaptors.h:412