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  static_assert(sizeof(to_t) == sizeof(T), "CastAdapt sanity: sizes match");
244  static_assert(std::is_pod<to_t>::value, "CastAdapt sanity: to-type is POD");
245  static_assert(std::is_pod<T>::value, "CastAdapt sanity: from-type is POD");
246  to_t vVal;
247  std::memcpy(&vVal, &rValue, sizeof(to_t));
248  pComp->Value(vVal);
249  std::memcpy(&rValue, &vVal, sizeof(T));
250  }
251  // Operators for default checking/setting
252  template <class D> inline bool operator == (const D &nValue) const { return rValue == nValue; }
253  template <class D> inline StdCastAdapt &operator = (const D &nValue) { rValue = nValue; return *this; }
254 };
255 template <class to_t, class T> StdCastAdapt<T, to_t> mkCastAdapt(T &rValue) { return StdCastAdapt<T, to_t>(rValue); }
256 template <class T> StdCastAdapt<T, int32_t> mkCastIntAdapt(T &rValue) { return StdCastAdapt<T, int32_t>(rValue); }
257 
258 // Helper: Identity function class
259 template <class T>
261 {
262  T &operator ()(T &rValue) const { return rValue; }
263 };
264 
265 // * Array Adaptor
266 // Stores a separated list
267 template <class T, class M = _IdFuncClass<T> >
269 {
270  StdArrayAdapt(T *pArray, int iSize, M && map = M())
271  : pArray(pArray), iSize(iSize), map(std::forward<M>(map))
272  { }
273  T *pArray; int iSize; M && map;
274  inline void CompileFunc(StdCompiler *pComp) const
275  {
276  for (int i = 0; i < iSize; i++)
277  {
278  if (i) pComp->Separator(StdCompiler::SEP_SEP);
279  pComp->Value(map(pArray[i]));
280  }
281  }
282  // Operators for default checking/setting
283  inline bool operator == (const T &rDefault) const
284  {
285  for (int i = 0; i < iSize; i++)
286  if (pArray[i] != rDefault)
287  return false;
288  return true;
289  }
290  inline StdArrayAdapt &operator = (const T &rDefault)
291  {
292  for (int i = 0; i < iSize; i++)
293  pArray[i] = rDefault;
294  return *this;
295  }
296  inline bool operator == (const T *pDefaults) const
297  {
298  for (int i = 0; i < iSize; i++)
299  if (pArray[i] != pDefaults[i])
300  return false;
301  return true;
302  }
303  inline StdArrayAdapt &operator = (const T *pDefaults)
304  {
305  for (int i = 0; i < iSize; i++)
306  pArray[i] = pDefaults[i];
307  return *this;
308  }
309 };
310 template <class T>
311 inline StdArrayAdapt<T> mkArrayAdapt(T *pArray, int iSize) { return StdArrayAdapt<T>(pArray, iSize); }
312 #define mkArrayAdaptM(A) mkArrayAdapt(A, sizeof(A) / sizeof(*(A)))
313 template <class T, class M>
314 inline StdArrayAdapt<T, M> mkArrayAdaptMap(T *pArray, int iSize, M && map) { return StdArrayAdapt<T, M>(pArray, iSize, std::forward<M>(map)); }
315 #define mkArrayAdaptMapM(A, M) mkArrayAdaptMap(A, sizeof(A) / sizeof(*(A)), M)
316 
317 // * Array Adaptor (defaulting)
318 // Stores a separated list, sets defaults if a value or separator is missing.
319 template <class T, class D, class M = _IdFuncClass<T> >
321 {
322  StdArrayDefaultAdapt(T *pArray, size_t iSize, const D &rDefault, const M &map = M())
323  : pArray(pArray), iSize(iSize), rDefault(rDefault), map(map)
324  { }
325  T *pArray; size_t iSize; const D &rDefault; const M map;
326  inline void CompileFunc(StdCompiler *pComp) const
327  {
328  size_t i, iWrite = iSize;
329  bool deserializing = pComp->isDeserializer();
330  // Decompiling: Omit defaults
331  if (!deserializing && pComp->hasNaming())
332  while (iWrite > 0 && pArray[iWrite - 1] == rDefault)
333  iWrite--;
334  // Read/write values
335  for (i = 0; i < iWrite; i++)
336  {
337  // Separator?
338  if (i) if (!pComp->Separator(StdCompiler::SEP_SEP)) break;
339  // Expect a value. Default if not found.
340  pComp->Value(mkDefaultAdapt(map(pArray[i]), rDefault));
341  }
342  // Fill rest of array
343  if (deserializing)
344  for (; i < iSize; i++)
345  pArray[i] = rDefault;
346  }
347  // Additional defaulting (whole array)
348  inline bool operator == (const T *pDefaults) const
349  {
350  for (size_t i = 0; i < iSize; i++)
351  if (pArray[i] != pDefaults[i])
352  return false;
353  return true;
354  }
355  inline StdArrayDefaultAdapt &operator = (const T *pDefaults)
356  {
357  for (size_t i = 0; i < iSize; i++)
358  pArray[i] = pDefaults[i];
359  return *this;
360  }
361 };
362 template <class T, class D>
363 inline StdArrayDefaultAdapt<T, D> mkArrayAdapt(T *pArray, size_t iSize, const D &rDefault) { return StdArrayDefaultAdapt<T, D>(pArray, iSize, rDefault); }
364 #define mkArrayAdaptDM(A, D) mkArrayAdapt(A, sizeof(A) / sizeof(*(A)), D)
365 template <class T, class D, class M>
366 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); }
367 #define mkArrayAdaptMapDM(A, D, M) mkArrayAdaptMap(A, sizeof(A) / sizeof(*(A)), D, M)
368 
369 // * Array Adaptor (defaulting to another array)
370 // Stores a separated list, sets defaults if a value or separator is missing.
371 template <class T, class D, class M = _IdFuncClass<T> >
373 {
374  StdArrayDefaultArrayAdapt(T *pArray, size_t iSize, const D &rDefault, const M &map = M())
375  : pArray(pArray), iSize(iSize), rDefault(rDefault), map(map)
376  { }
377  T *pArray; size_t iSize; const D &rDefault; const M map;
378  inline void CompileFunc(StdCompiler *pComp) const
379  {
380  size_t i, iWrite = iSize;
381  bool deserializing = pComp->isDeserializer();
382  // Decompiling: Omit defaults
383  if (!deserializing && pComp->hasNaming())
384  while (iWrite > 0 && pArray[iWrite - 1] == rDefault[iWrite - 1])
385  iWrite--;
386  // Read/write values
387  for (i = 0; i < iWrite; i++)
388  {
389  // Separator?
390  if (i) if (!pComp->Separator(StdCompiler::SEP_SEP)) break;
391  // Expect a value. Default if not found.
392  pComp->Value(mkDefaultAdapt(map(pArray[i]), rDefault[i]));
393  }
394  // Fill rest of array
395  if (deserializing)
396  for (; i < iSize; i++)
397  pArray[i] = rDefault[i];
398  }
399  // Additional defaulting (whole array)
400  inline bool operator == (const T *pDefaults) const
401  {
402  for (size_t i = 0; i < iSize; i++)
403  if (pArray[i] != pDefaults[i])
404  return false;
405  return true;
406  }
407  inline StdArrayDefaultArrayAdapt &operator = (const T *pDefaults)
408  {
409  for (size_t i = 0; i < iSize; i++)
410  pArray[i] = pDefaults[i];
411  return *this;
412  }
413 };
414 template <class T, class D>
415 inline StdArrayDefaultArrayAdapt<T, D> mkArrayAdaptDefArr(T *pArray, size_t iSize, const D &rDefault) { return StdArrayDefaultArrayAdapt<T, D>(pArray, iSize, rDefault); }
416 #define mkArrayAdaptDMA(A, D) mkArrayAdaptDefArr(A, sizeof(A) / sizeof(*(A)), D)
417 template <class T, class D, class M>
418 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); }
419 #define mkArrayAdaptDMAM(A, D, M) mkArrayAdaptDefArrMap(A, sizeof(A) / sizeof(*(A)), D, M)
420 
421 // * Insertion Adaptor
422 // Compile a value before / after another
423 template <class T, class I>
425 {
426  StdInsertAdapt(T &rObj, I &rIns, bool fBefore = true)
427  : rObj(rObj), rIns(rIns), fBefore(fBefore)
428  { }
429  T &rObj; I &rIns; bool fBefore;
430  void CompileFunc(StdCompiler *pComp) const
431  {
432  if (fBefore) pComp->Value(rIns);
433  pComp->Value(rObj);
434  if (!fBefore) pComp->Value(rIns);
435  }
436 };
437 template <class T, class I>
438 inline StdInsertAdapt<T, I> mkInsertAdapt(T &&rObj, I &&rIns, bool fBefore = true) { return StdInsertAdapt<T,I>(rObj, rIns, fBefore); }
439 
440 // * Parameter Adaptor
441 // Specify a second parameter for the CompileFunc
442 template <class T, class P>
444 {
445  StdParameterAdapt(T && rObj, P && rPar) : rObj(std::forward<T>(rObj)), Par(std::forward<P>(rPar)) { }
446  T && rObj; P && Par;
447  void CompileFunc(StdCompiler *pComp) const
448  {
449  std::forward<T>(rObj).CompileFunc(pComp, std::forward<P>(Par));
450  }
451  // Operators for default checking/setting
452  template <class D> inline bool operator == (const D &nValue) const { return rObj == nValue; }
453  template <class D> inline StdParameterAdapt &operator = (const D &nValue) { rObj = nValue; return *this; }
454 
455  // getting value
456  inline T && GetObj() { return std::forward<T>(rObj); }
457 };
458 template <class T, class P>
459 inline StdParameterAdapt<T, P> mkParAdapt(T && rObj, P && rPar)
460 { return StdParameterAdapt<T, P>(std::forward<T>(rObj), std::forward<P>(rPar)); }
461 
462 // for mkArrayAdaptMap
463 template <class P>
465 {
466  P && Par;
467  StdParameterAdaptMaker(P && rPar) : Par(std::forward<P>(rPar)) { }
468  template <class T>
469  StdParameterAdapt<T, P> operator ()(T && rObj) const { return StdParameterAdapt<T, P>(std::forward<T>(rObj), std::forward<P>(Par)); }
470 };
471 template <class P>
472 inline StdParameterAdaptMaker<P> mkParAdaptMaker(P && rPar) { return StdParameterAdaptMaker<P>(std::forward<P>(rPar)); }
473 
474 // * Parameter Adaptor 2
475 // Specify a second and a third parameter for the CompileFunc
476 template <class T, class P1, class P2>
478 {
479  StdParameter2Adapt(T && rObj, P1 && rPar1, P2 && rPar2) :
480  rObj(std::forward<T>(rObj)), rPar1(std::forward<P1>(rPar1)), rPar2(std::forward<P2>(rPar2)) { }
481  T && rObj; P1 && rPar1; P2 && rPar2;
482  void CompileFunc(StdCompiler *pComp) const
483  {
484  std::forward<T>(rObj).CompileFunc(pComp, std::forward<P1>(rPar1), std::forward<P2>(rPar2));
485  }
486  // Operators for default checking/setting
487  template <class D> inline bool operator == (const D &nValue) const { return rObj == nValue; }
488  template <class D> inline StdParameter2Adapt &operator = (const D &nValue) { rObj = nValue; return *this; }
489 };
490 template <class T, class P1, class P2>
491 inline StdParameter2Adapt<T, P1, P2> mkParAdapt(T && rObj, P1 && rPar1, P2 && rPar2)
492 { return StdParameter2Adapt<T, P1, P2>(std::forward<T>(rObj), std::forward<P1>(rPar1), std::forward<P2>(rPar2)); }
493 
494 template <class T>
496 {
497  StdBasicPtrAdapt(T *&rpObj, bool fAllowNull = true, const char *szNaming = "Data")
498  : rpObj(rpObj), fAllowNull(fAllowNull), szNaming(szNaming) {}
499  T *&rpObj; bool fAllowNull; const char *szNaming;
500 
501  // Operators for default checking/setting
502  inline bool operator == (const T &nValue) const { return rpObj && *rpObj == nValue; }
503  inline StdBasicPtrAdapt &operator = (const T &nValue) { delete rpObj; rpObj = new T(nValue); return *this; }
504  inline bool operator == (const T *pValue) const { return rpObj == pValue; }
505  inline StdBasicPtrAdapt &operator = (const T *pValue) { delete rpObj; rpObj = pValue; return *this; }
506 };
507 
508 // * Store pointer (contents)
509 // Defaults to null
510 template <class T>
512 {
513  StdPtrAdapt(T *&rpObj, bool fAllowNull = true, const char *szNaming = "Data")
514  : StdBasicPtrAdapt<T>(rpObj, fAllowNull, szNaming)
515  { }
516 
517  void CompileFunc(StdCompiler *pComp) const
518  {
519  StdPtrAdaptCompileFunc(pComp, *this);
520  }
521 
522  // For use with StdParAdapt
523  template<typename ... P>
524  void CompileFunc(StdCompiler *pComp, P && ...pars)
525  {
526  StdPtrAdaptCompileFunc(pComp, *this, std::forward<P>(pars)...);
527  }
528 };
529 
530 template <class T, class ContextT>
532 {
533  StdContextPtrAdapt(T *&rpObj, const ContextT& rCtx, bool fAllowNull = true, const char *szNaming = "Data")
534  : StdBasicPtrAdapt<T>(rpObj, fAllowNull, szNaming), pCtx(&rCtx)
535  { }
536 
537  const ContextT* pCtx;
538 
539  void CompileFunc(StdCompiler *pComp) const
540  {
541  StdPtrAdaptCompileFunc(pComp, *this);
542  }
543 
544  // For use with StdParAdapt
545  template<class P>
546  void CompileFunc(StdCompiler *pComp, const P& p)
547  {
548  StdPtrAdaptCompileFunc(pComp, *this, p);
549  }
550 };
551 
552 template <class T, typename ... P>
553 void StdPtrAdaptCompileFunc(StdCompiler* pComp, const T& adapt, P && ...pars)
554 {
555  bool deserializing = pComp->isDeserializer(),
556  fNaming = pComp->hasNaming();
557  // Compiling? Clear object before
558  if(deserializing) { delete adapt.rpObj; adapt.rpObj = nullptr; }
559  // Null checks - different with naming support.
560  if(adapt.fAllowNull)
561  if(fNaming)
562  {
563  // Null check: just omit when writing
564  if(!deserializing && !adapt.rpObj) return;
565  // Set up naming
566  if(!pComp->Name(adapt.szNaming)) { assert(deserializing); pComp->NameEnd(); return; }
567  }
568  else
569  {
570  bool fNull = !! adapt.rpObj;
571  pComp->Value(fNull);
572  // Null? Nothing further to do
573  if(fNull) return;
574  }
575  else if(!deserializing)
576  assert(adapt.rpObj);
577  // Compile value
578  if(deserializing)
579  StdPtrAdaptCompileNewFunc(adapt, pComp, std::forward<P>(pars)...);
580  else
581  StdPtrAdaptDecompileNewFunc(adapt, pComp, std::forward<P>(pars)...);
582 
583  // Close naming
584  if(adapt.fAllowNull && fNaming) pComp->NameEnd();
585 }
586 
587 
588 template <class T, typename ... P>
589 void StdPtrAdaptCompileNewFunc(const StdPtrAdapt<T>& adapt, StdCompiler* pComp, P && ...pars) { CompileNewFunc(adapt.rpObj, pComp, std::forward<P>(pars)...); }
590 template <class T, class ContextT, typename ... P>
591 void StdPtrAdaptCompileNewFunc(const StdContextPtrAdapt<T, ContextT>& adapt, StdCompiler* pComp, P && ...pars) { CompileNewFuncCtx(adapt.rpObj, pComp, *adapt.pCtx, std::forward<P>(pars)...); }
592 
593 template <class T>
594 void StdPtrAdaptDecompileNewFunc(const StdPtrAdapt<T>& adapt, StdCompiler* pComp) { pComp->Value(mkDecompileAdapt(*adapt.rpObj)); }
595 template <class T, class ContextT>
597 template <class T, typename ... P>
598 void StdPtrAdaptDecompileNewFunc(const StdPtrAdapt<T>& adapt, StdCompiler* pComp, P && ...pars) { pComp->Value(mkParAdapt(mkDecompileAdapt(*adapt.rpObj), std::forward<P>(pars)...)); }
599 template <class T, class ContextT, typename ... P>
600 void StdPtrAdaptDecompileNewFunc(const StdContextPtrAdapt<T, ContextT>& adapt, StdCompiler* pComp, P && ...pars) { pComp->Value(mkParAdapt(mkDecompileAdapt(*adapt.rpObj), std::forward<P>(pars)...)); }
601 
602 template <class T>
603 inline StdPtrAdapt<T> mkPtrAdapt(T *&rpObj, bool fAllowNull = true) { return StdPtrAdapt<T>(rpObj, fAllowNull); }
604 template <class T>
605 inline StdPtrAdapt<T> mkNamingPtrAdapt(T *&rpObj, const char *szNaming) { return StdPtrAdapt<T>(rpObj, true, szNaming); }
606 template <class T>
607 inline StdPtrAdapt<T> mkPtrAdaptNoNull(T *&rpObj) { return mkPtrAdapt<T>(rpObj, false); }
608 
609 template <class T, class ContextT>
610 inline StdContextPtrAdapt<T, ContextT> mkContextPtrAdapt(T *&rpObj, const ContextT& ctx, bool fAllowNull = true) { return StdContextPtrAdapt<T, ContextT>(rpObj, ctx, fAllowNull); }
611 template <class T, class ContextT>
612 inline StdContextPtrAdapt<T, ContextT> mkNamingContextPtrAdapt(T *&rpObj, const ContextT& ctx, const char* szNaming) { return StdContextPtrAdapt<T, ContextT>(rpObj, ctx, true, szNaming); }
613 template <class T, class ContextT>
614 inline StdContextPtrAdapt<T, ContextT> mkContextPtrAdaptNoNull(T *&rpObj, const ContextT& ctx) { return mkContextPtrAdapt<T, ContextT>(rpObj, ctx, false); }
615 
616 // * Adaptor for STL containers
617 // Writes a comma-separated list for compilers that support it. Otherwise, the size is calculated and safed.
618 // The defaulting uses the standard STL operators (full match)
619 template <class C>
621 {
623  : rStruct(rStruct), eSep(eSep) { }
625  inline void CompileFunc(StdCompiler *pComp) const
626  {
627  typedef typename C::value_type T;
628  // Get compiler specs
629  bool deserializing = pComp->isDeserializer();
630  bool fNaming = pComp->hasNaming();
631  // Decompiling?
632  if (!deserializing)
633  {
634  // Write size (binary only)
635  if (!fNaming)
636  {
637  int32_t iSize = rStruct.size();
638  pComp->Value(iSize);
639  }
640  // Write all entries
641  for (typename C::const_iterator i = rStruct.begin(); i != rStruct.end(); ++i)
642  {
643  if (i != rStruct.begin() && eSep) pComp->Separator(eSep);
644  pComp->Value(const_cast<T &>(*i));
645  }
646  }
647  else
648  {
649  // Compiling: Empty previous
650  rStruct.clear();
651  // Read size (binary only)
652  uint32_t iSize;
653  if (!fNaming) pComp->Value(iSize);
654  // Read new
655  do
656  {
657  // No entries left to read?
658  if (!fNaming && !iSize--)
659  break;
660  // Read entries
661  try
662  {
663  T val;
664  pComp->Value(val);
665  rStruct.push_back(val);
666  }
667  catch (StdCompiler::NotFoundException *pEx)
668  {
669  // No value found: Stop reading loop
670  delete pEx;
671  break;
672  }
673  }
674  while (!eSep || pComp->Separator(eSep));
675  }
676  }
677  // Operators for default checking/setting
678  inline bool operator == (const C &nValue) const { return rStruct == nValue; }
679  inline StdSTLContainerAdapt &operator = (const C &nValue) { rStruct = nValue; return *this; }
680 };
681 template <class C>
683 
684 // Write an integer that is supposed to be small most of the time. The adaptor writes it in
685 // 7-bit-pieces, bit 8 being a continuation marker: If it's set, more data is following, if not,
686 // all following bits are 0.
687 // Code lengths for uint32_t:
688 // 0x00000000 (0) - 0x0000007F (127) : 1 byte
689 // 0x00000080 (128) - 0x00003FFF (16383) : 2 byte
690 // 0x00004000 (16384) - 0x001FFFFF (2097151) : 3 byte
691 // 0x00200000 (2097152) - 0x0FFFFFFF (268435456) : 4 byte
692 // 0x10000000 (268435456) - 0xFFFFFFFF (4294967295) : 5 byte
693 // So this sort of packing is always useful when the integer in question is almost impossible to
694 // grow bigger than 2,097,151.
695 template <class T>
697 {
698  StdIntPackAdapt(T &rVal) : rVal(rVal) { }
699  T &rVal;
700 
701  inline T clearUpper(T x) const
702  {
703  const int CLEARBITS = 8 * sizeof(T) - 7;
704  return (x << CLEARBITS) >> CLEARBITS;
705  }
706 
707  void CompileFunc(StdCompiler *pComp) const
708  {
709  // simply write for textual compilers
710  if (pComp->hasNaming())
711  {
712  pComp->Value(rVal);
713  return;
714  }
715  T val; uint8_t tmp;
716  // writing?
717  if (!pComp->isDeserializer())
718  {
719  val = rVal;
720  for (;;)
721  {
722  tmp = uint8_t(clearUpper(val));
723  // last byte?
724  if (clearUpper(val) == val)
725  break;
726  // write byte
727  tmp ^= 0x80; pComp->Value(tmp);
728  // advance
729  val >>= 7;
730  }
731  // write last byte
732  pComp->Value(tmp);
733  }
734  // reading?
735  else
736  {
737  // read first byte
738  pComp->Value(tmp);
739  val = clearUpper(T(tmp));
740  // read remaining bytes
741  int i = 7; T data = val;
742  while ( uint8_t(data) != tmp )
743  {
744  // read byte
745  pComp->Value(tmp);
746  // add to value
747  data = clearUpper(T(tmp));
748  val = (data << i) | (val & ((1 << i) - 1));
749  // next byte
750  i+=7;
751  }
752  // write
753  rVal = val;
754  }
755  }
756  template <class D> inline bool operator == (const D &nValue) const { return rVal == nValue; }
757  template <class D> inline StdIntPackAdapt &operator = (const D &nValue) { rVal = nValue; return *this; }
758 };
759 template <class T>
761 
762 template <class T>
764 {
765  const char *Name;
766  T Val;
767 };
768 
769 // Enumeration: For text compilers, write a given name for a value.
770 // For everything else, just write an integer of given type.
771 template <class T, class int_t = int32_t>
773 {
775 
776  StdEnumAdapt(T &rVal, const Entry *pNames) : rVal(rVal), pNames(pNames) { assert(pNames); }
777  T &rVal; const Entry *pNames;
778 
779  void CompileFunc(StdCompiler *pComp) const
780  {
781  // Write as int
782  if (!pComp->isVerbose())
783  {
784  pComp->Value(mkIntAdaptT<int_t>(rVal));
785  return;
786  }
787  // writing?
788  if (!pComp->isDeserializer())
789  {
790  // Find value
791  const Entry *pName = pNames;
792  for (; pName->Name; pName++)
793  if (pName->Val == rVal)
794  {
795  // Put name
796  pComp->String(const_cast<char **>(&pName->Name), StdCompiler::RCT_Idtf);
797  break;
798  }
799  // No name found?
800  if (!pName->Name)
801  // Put value as integer
802  pComp->Value(mkIntAdaptT<int_t>(rVal));
803  }
804  // reading?
805  else
806  {
807  int_t val = 0;
808 #ifdef STDCOMPILER_EXCEPTION_WORKAROUND
809  // Try to read as number
810  if (!pComp->ValueSafe(val))
811  {
812  rVal = T(val);
813 #else
814  // Try to read as number
815  try
816  {
817  pComp->Value(val);
818  rVal = T(val);
819  }
820  catch (StdCompiler::NotFoundException *pEx)
821  {
822  delete pEx;
823 #endif
824  // Try to read as string
825  StdStrBuf Name;
826  pComp->Value(mkParAdapt(Name, StdCompiler::RCT_Idtf));
827  // Search in name list
828  const Entry *pName = pNames;
829  for (; pName->Name; pName++)
830  if (Name == pName->Name)
831  {
832  rVal = pName->Val;
833  break;
834  }
835  // Not found? Warn
836  if (!pName->Name)
837  pComp->Warn("Unknown bit name: %s", Name.getData());
838  }
839  }
840  }
841 
842  template <class D> inline bool operator == (const D &nValue) const { return rVal == nValue; }
843  template <class D> inline StdEnumAdapt<T, int_t> &operator = (const D &nValue) { rVal = nValue; return *this; }
844 };
845 template <class T, class int_t>
847 template <class int_t, class T>
849 
850 template <class T>
852 {
853  const char *Name;
854  T Val;
855 };
856 
857 // Convert a bitfield into/from something like "foo | bar | baz", where "foo", "bar" and "baz" are given constants.
858 template <class T>
860 {
862 
863  StdBitfieldAdapt(T &rVal, const Entry *pNames) : rVal(rVal), pNames(pNames) { assert(pNames); }
864  T &rVal; const Entry *pNames;
865 
866  void CompileFunc(StdCompiler *pComp) const
867  {
868  // simply write for non-verbose compilers
869  if (!pComp->isVerbose())
870  {
871  pComp->Value(rVal);
872  return;
873  }
874  // writing?
875  if (!pComp->isDeserializer())
876  {
877  T val = rVal, orig_val = rVal;
878  // Write until value is comsumed
879  bool fFirst = true;
880  for (const Entry *pName = pNames; pName->Name; pName++)
881  if ((pName->Val & val) == pName->Val)
882  {
883  // Avoid writing meaningless none-values (e.g. Category=C4D_None|C4D_Object)
884  if (orig_val && !pName->Val) continue;
885  // Put "|"
886  if (!fFirst) pComp->Separator(StdCompiler::SEP_VLINE);
887  // Put name
888  pComp->String(const_cast<char **>(&pName->Name), StdCompiler::RCT_Idtf);
889  fFirst = false;
890  // Remove bits
891  val &= ~pName->Val;
892  }
893  // Anything left is written as number, or a simple 0 in case no default was used
894  if (val || fFirst)
895  {
896  // Put "|"
897  if (!fFirst) pComp->Separator(StdCompiler::SEP_VLINE);
898  // Put value
899  pComp->Value(val);
900  }
901  }
902  // reading?
903  else
904  {
905  T val = 0;
906  // Read
907  do
908  {
909 #ifdef STDCOMPILER_EXCEPTION_WORKAROUND
910  T tmp;
911  // Try to read as number
912  if (pComp->ValueSafe(tmp))
913  val |= tmp;
914  else
915  {
916 #else
917  // Try to read as number
918  try
919  {
920  T tmp;
921  pComp->Value(tmp);
922  val |= tmp;
923  }
924  catch (StdCompiler::NotFoundException *pEx)
925  {
926  delete pEx;
927 #endif
928  // Try to read as string
929  StdStrBuf Name;
930  pComp->Value(mkParAdapt(Name, StdCompiler::RCT_Idtf));
931  // Search in name list
932  const Entry *pName = pNames;
933  for (; pName->Name; pName++)
934  if (Name == pName->Name)
935  {
936  val |= pName->Val;
937  break;
938  }
939  // Not found? Warn
940  if (!pName->Name)
941  pComp->Warn("Unknown bit name: %s", Name.getData());
942  }
943  // Expect separation
944  } while (pComp->Separator(StdCompiler::SEP_VLINE));
945  // Write value back
946  rVal = val;
947  }
948  }
949 
950  template <class D> inline bool operator == (const D &nValue) const { return rVal == nValue; }
951  template <class D> inline StdBitfieldAdapt<T> &operator = (const D &nValue) { rVal = nValue; return *this; }
952 };
953 template <class T>
955 
956 // * Name count adapter
957 // For compilers without name support, this just compiles the given value. Otherwise, the count
958 // of given namings is returned on compiling, and nothing is done for decompiling (The caller
959 // has to make sure that an appropriate number of namings will be created)
960 template <class int_t>
962 {
963  int_t &iCount; const char *szName;
964  StdNamingCountAdapt(int_t &iCount, const char *szName) : iCount(iCount), szName(szName) { }
965  inline void CompileFunc(StdCompiler *pComp) const
966  {
967  if (pComp->hasNaming())
968  {
969  if (pComp->isDeserializer())
970  iCount = pComp->NameCount(szName);
971  }
972  else
973  pComp->Value(mkIntPackAdapt(iCount));
974  }
975 };
976 template <class int_t>
977 inline StdNamingCountAdapt<int_t> mkNamingCountAdapt(int_t &iCount, const char *szName) { return StdNamingCountAdapt<int_t>(iCount, szName); }
978 
979 // * Hex adapter
980 // Writes raw binary data in hexadecimal
982 {
983  void *pData; size_t iSize;
984 public:
985  StdHexAdapt(void *pData, size_t iSize) : pData(pData), iSize(iSize) { }
986  inline void CompileFunc(StdCompiler *pComp) const
987  {
988  if (!pComp->isVerbose())
989  pComp->Raw(pData, iSize);
990  char szData[2+1]; bool deserializing = pComp->isDeserializer();
991  for (size_t i = 0; i < iSize; i++)
992  {
993  uint8_t *pByte = reinterpret_cast<uint8_t *>(pData) + i;
994  if (!deserializing) sprintf(szData, "%02x", *pByte);
995  pComp->String(szData, 2, StdCompiler::RCT_Idtf);
996  if (deserializing)
997  {
998  unsigned int b;
999  if (sscanf(szData, "%02x", &b) != 1)
1000  pComp->excNotFound(i ? "hexadecimal data: bytes missing!" : "hexadecimal data missing!");
1001  *pByte = b;
1002  }
1003  }
1004  }
1005 };
1006 inline StdHexAdapt mkHexAdapt(void *pData, size_t iSize) { return StdHexAdapt(pData, iSize); }
1007 template <class T>
1008 inline StdHexAdapt mkHexAdapt(T &rData) { return StdHexAdapt(&rData, sizeof(rData)); }
1009 
1010 
1011 #endif //STDADAPTORS_H
const char * getData() const
Definition: StdBuf.h:450
T & operator()(T &rValue) const
Definition: StdAdaptors.h:262
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:756
StdIntPackAdapt(T &rVal)
Definition: StdAdaptors.h:698
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:482
StdNamingAdapt(T &rValue, const char *szName)
Definition: StdAdaptors.h:74
StdCastAdapt & operator=(const D &nValue)
Definition: StdAdaptors.h:253
virtual bool hasNaming()
Definition: StdCompiler.h:68
Definition: StdAdaptors.h:851
bool operator==(const D &nValue) const
Definition: StdAdaptors.h:227
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:129
bool operator==(const T &nValue) const
Definition: StdAdaptors.h:502
void CompileFunc(StdCompiler *pComp, const P &p)
Definition: StdAdaptors.h:546
Definition: StdAdaptors.h:763
StdNamingCountAdapt< int_t > mkNamingCountAdapt(int_t &iCount, const char *szName)
Definition: StdAdaptors.h:977
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:964
StdParameterAdapt< T, P > operator()(T &&rObj) const
Definition: StdAdaptors.h:469
bool operator==(const void *pDefault) const
Definition: StdAdaptors.h:205
void CompileFunc(StdCompiler *pComp, P &&...pars)
Definition: StdAdaptors.h:524
#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:553
StdInsertAdapt(T &rObj, I &rIns, bool fBefore=true)
Definition: StdAdaptors.h:426
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:181
StdEnumAdapt< T, int_t > & operator=(const D &nValue)
Definition: StdAdaptors.h:843
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:418
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:625
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:517
StdContextPtrAdapt< T, ContextT > mkNamingContextPtrAdapt(T *&rpObj, const ContextT &ctx, const char *szNaming)
Definition: StdAdaptors.h:612
StdSTLContainerAdapt & operator=(const C &nValue)
Definition: StdAdaptors.h:679
bool operator==(const D &nValue) const
Definition: StdAdaptors.h:252
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:355
StdParameterAdaptMaker< P > mkParAdaptMaker(P &&rPar)
Definition: StdAdaptors.h:472
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:707
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:97
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:274
StdCastAdapt< T, to_t > mkCastAdapt(T &rValue)
Definition: StdAdaptors.h:255
StdCastAdapt< T, int32_t > mkCastIntAdapt(T &rValue)
Definition: StdAdaptors.h:256
StdParameterAdaptMaker(P &&rPar)
Definition: StdAdaptors.h:467
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:452
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:93
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:447
StdBitfieldAdapt(T &rVal, const Entry *pNames)
Definition: StdAdaptors.h:863
StdArrayAdapt & operator=(const T &rDefault)
Definition: StdAdaptors.h:290
bool isSerializer()
Definition: StdCompiler.h:64
bool operator==(const D &nValue) const
Definition: StdAdaptors.h:842
StdSTLContainerAdapt(C &rStruct, StdCompiler::Sep eSep=StdCompiler::SEP_SEP)
Definition: StdAdaptors.h:622
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:453
StdIntAdapt(T &rValue)
Definition: StdAdaptors.h:218
StdCompiler::RawCompileType eRawType
Definition: StdAdaptors.h:178
StdArrayAdapt< T > mkArrayAdapt(T *pArray, int iSize)
Definition: StdAdaptors.h:311
StdBitfieldAdapt< T > mkBitfieldAdapt(T &rVal, const StdBitfieldEntry< T > *pNames)
Definition: StdAdaptors.h:954
StdDecompileAdapt< T > mkDecompileAdapt(const T &rValue)
Definition: StdAdaptors.h:154
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:986
void CompileFunc(StdCompiler *pComp, P &&...pars) const
Definition: StdAdaptors.h:147
bool operator==(const T *pDefaults) const
Definition: StdAdaptors.h:348
StdPtrAdapt< T > mkPtrAdaptNoNull(T *&rpObj)
Definition: StdAdaptors.h:607
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:965
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:539
StdParameter2Adapt & operator=(const D &nValue)
Definition: StdAdaptors.h:488
StdRuntimeValueAdapt(T &rValue)
Definition: StdAdaptors.h:162
StdArrayDefaultArrayAdapt & operator=(const T *pDefaults)
Definition: StdAdaptors.h:407
T clearUpper(T x) const
Definition: StdAdaptors.h:701
void excNotFound(const char *szMessage,...)
Definition: StdCompiler.h:243
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:779
StdInsertAdapt< T, I > mkInsertAdapt(T &&rObj, I &&rIns, bool fBefore=true)
Definition: StdAdaptors.h:438
StdCastAdapt(T &rValue)
Definition: StdAdaptors.h:239
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:430
bool operator==(const D &nValue) const
Definition: StdAdaptors.h:487
const char * szName
Definition: StdAdaptors.h:100
StdParameter2Adapt(T &&rObj, P1 &&rPar1, P2 &&rPar2)
Definition: StdAdaptors.h:479
void Value(const T &rStruct)
Definition: StdCompiler.h:171
StdBasicPtrAdapt & operator=(const T &nValue)
Definition: StdAdaptors.h:503
StdParameterAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:445
bool operator==(const T *pDefaults) const
Definition: StdAdaptors.h:400
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:219
StdRawAdapt & operator=(const void *pDefault)
Definition: StdAdaptors.h:206
const char * szNaming
Definition: StdAdaptors.h:499
const char * Name
Definition: StdAdaptors.h:765
virtual bool isDeserializer()
Definition: StdCompiler.h:63
const Entry * pNames
Definition: StdAdaptors.h:777
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:533
StdEnumAdapt< T, int_t > mkEnumAdapt(T &rVal, const StdEnumEntry< T > *pNames)
Definition: StdAdaptors.h:846
StdIntPackAdapt< T > mkIntPackAdapt(T &rVal)
Definition: StdAdaptors.h:760
StdDecompileAdapt(const T &rValue)
Definition: StdAdaptors.h:138
StdBitfieldEntry< T > Entry
Definition: StdAdaptors.h:861
StdHexAdapt mkHexAdapt(void *pData, size_t iSize)
Definition: StdAdaptors.h:1006
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:589
StdContextPtrAdapt< T, ContextT > mkContextPtrAdaptNoNull(T *&rpObj, const ContextT &ctx)
Definition: StdAdaptors.h:614
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:201
StdSTLContainerAdapt< C > mkSTLContainerAdapt(C &rTarget, StdCompiler::Sep eSep=StdCompiler::SEP_SEP)
Definition: StdAdaptors.h:682
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:594
virtual void setRuntimeWritesAllowed(int32_t iChange)
Definition: StdCompiler.h:78
const ContextT * pCtx
Definition: StdAdaptors.h:537
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:322
StdParameterAdapt< T, P > mkParAdapt(T &&rObj, P &&rPar)
Definition: StdAdaptors.h:459
StdEnumAdapt< T, int_t > mkEnumAdaptT(T &rVal, const StdEnumEntry< T > *pNames)
Definition: StdAdaptors.h:848
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:326
StdHexAdapt(void *pData, size_t iSize)
Definition: StdAdaptors.h:985
void CompileNewFuncCtx(T *&pStruct, StdCompiler *pComp, const ContextT &rCtx)
Definition: StdCompiler.h:358
StdPtrAdapt< T > mkNamingPtrAdapt(T *&rpObj, const char *szNaming)
Definition: StdAdaptors.h:605
StdEnumEntry< T > Entry
Definition: StdAdaptors.h:774
bool operator==(const T &rDefault) const
Definition: StdAdaptors.h:283
bool operator==(const D &nValue) const
Definition: StdAdaptors.h:89
StdIntPackAdapt & operator=(const D &nValue)
Definition: StdAdaptors.h:757
const char * Name
Definition: StdAdaptors.h:853
StdArrayAdapt(T *pArray, int iSize, M &&map=M())
Definition: StdAdaptors.h:270
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:314
bool operator==(const C &nValue) const
Definition: StdAdaptors.h:678
StdCompiler::RawCompileType eRawType
Definition: StdAdaptors.h:198
StdBasicPtrAdapt(T *&rpObj, bool fAllowNull=true, const char *szNaming="Data")
Definition: StdAdaptors.h:497
StdRuntimeValueAdapt< T > & operator=(const D &nValue)
Definition: StdAdaptors.h:170
StdPtrAdapt< T > mkPtrAdapt(T *&rpObj, bool fAllowNull=true)
Definition: StdAdaptors.h:603
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:866
StdContextPtrAdapt< T, ContextT > mkContextPtrAdapt(T *&rpObj, const ContextT &ctx, bool fAllowNull=true)
Definition: StdAdaptors.h:610
StdIntAdapt< T > mkIntAdapt(T &rValue)
Definition: StdAdaptors.h:230
StdPtrAdapt(T *&rpObj, bool fAllowNull=true, const char *szNaming="Data")
Definition: StdAdaptors.h:513
StdEnumAdapt(T &rVal, const Entry *pNames)
Definition: StdAdaptors.h:776
StdArrayDefaultArrayAdapt(T *pArray, size_t iSize, const D &rDefault, const M &map=M())
Definition: StdAdaptors.h:374
void CompileNewFunc(T *&pStruct, StdCompiler *pComp)
Definition: StdCompiler.h:330
int iSize
Definition: TstC4NetIO.cpp:35
const StdCompiler::Sep eSep
Definition: StdAdaptors.h:624
const char * szName
Definition: StdAdaptors.h:963
void CompileFunc(StdCompiler *pComp) const
Definition: StdAdaptors.h:378
StdArrayDefaultArrayAdapt< T, D > mkArrayAdaptDefArr(T *pArray, size_t iSize, const D &rDefault)
Definition: StdAdaptors.h:415