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