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