libcm is a C development framework with an emphasis on audio signal processing applications.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cmData.h 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. #ifndef cmData_h
  2. #define cmData_h
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. enum
  7. {
  8. kOkDtRC = cmOkRC,
  9. kCvtErrDtRC,
  10. kVarArgErrDtRC,
  11. kEolDtRC
  12. };
  13. enum
  14. {
  15. kInvalidDtChar = 0xff,
  16. kInvalidDtUChar = 0xff,
  17. kInvalidDtShort = 0xffff,
  18. kInvalidDtUShort = 0xffff,
  19. kInvalidDtInt = 0xffffffff,
  20. kInvalidDtUInt = 0xffffffff,
  21. kInvalidDtLong = 0xffffffff,
  22. kInvalidDtULong = 0xffffffff,
  23. };
  24. typedef enum
  25. {
  26. kInvalidDtId,
  27. kMinValDtId,
  28. kNullDtId = kMinValDtId,
  29. kUCharDtId,
  30. kCharDtId,
  31. kUShortDtId,
  32. kShortDtId,
  33. kUIntDtId,
  34. kIntDtId,
  35. kULongDtId,
  36. kLongDtId,
  37. kFloatDtId,
  38. kDoubleDtId,
  39. kStrDtId,
  40. kConstStrDtId,
  41. kMaxValDtId = kConstStrDtId,
  42. kMinPtrDtId,
  43. kUCharPtrDtId = kMinPtrDtId, // cnt=array element count
  44. kCharPtrDtId,
  45. kUShortPtrDtId,
  46. kShortPtrDtId,
  47. kUIntPtrDtId,
  48. kIntPtrDtId,
  49. kULongPtrDtId,
  50. kLongPtrDtId,
  51. kFloatPtrDtId,
  52. kDoublePtrDtId,
  53. kVoidPtrDtId,
  54. kMaxPtrDtId = kVoidPtrDtId,
  55. kMinStructDtId,
  56. kListDtId = kMinStructDtId, // children nodes are array elements, cnt=child count
  57. kPairDtId, // key/value pairs, cnt=2, first child is key, second is value
  58. kRecordDtId, // children nodes are pairs, cnt=pair count
  59. kMaxStructDtId
  60. } cmDataFmtId_t;
  61. enum
  62. {
  63. kDynObjDtFl = 0x01, // object was dynamically allocated
  64. kDynPtrDtFl = 0x02 // ptr array was dynamically allocated
  65. };
  66. typedef struct cmData_str
  67. {
  68. cmDataFmtId_t tid; // data format id
  69. unsigned flags; //
  70. struct cmData_str* parent; // this childs parent
  71. struct cmData_str* sibling; // this childs left sibling
  72. unsigned cnt; // array ele count
  73. union
  74. {
  75. char c;
  76. unsigned char uc;
  77. short s;
  78. unsigned short us;
  79. int i;
  80. unsigned int ui;
  81. long l;
  82. unsigned long ul;
  83. float f;
  84. double d;
  85. cmChar_t* z;
  86. const cmChar_t* cz;
  87. void* vp;
  88. char* cp;
  89. unsigned char* ucp;
  90. short* sp;
  91. unsigned short* usp;
  92. int* ip;
  93. unsigned int* uip;
  94. long* lp;
  95. unsigned long* ulp;
  96. float* fp;
  97. double* dp;
  98. struct cmData_str* child; // first child (array,record,pair)
  99. } u;
  100. } cmData_t;
  101. typedef unsigned cmDtRC_t;
  102. extern cmData_t cmDataNull;
  103. bool cmDataIsValue( const cmData_t* p );
  104. bool cmDataIsPtr( const cmData_t* p );
  105. bool cmDataIsStruct( const cmData_t* p );
  106. /*
  107. TODO:
  108. 0) Figure out a error handling scheme that does not rely on
  109. a global errno. This is not useful in multi-thread environments.
  110. It might be ok to go with an 'all errors are fatal' model
  111. (except in the var-args functions).
  112. Consider the use of a context object for use with functions
  113. that can have runtime errors or need to allocate memory.
  114. 1) Implement the canConvert and willTruncate functions.
  115. 2) Make a set of cmDataAllocXXXPtr() functions which take
  116. a flag indicating whether or not to dynamically allocate
  117. the array space. This will allow dynamic allocattion to
  118. occur at runtime. Make var args functions for list and
  119. record objects which also take this flag.
  120. Where ever a function may be implemented using
  121. static/dynamic allocation this flag should be present.
  122. (e.g. string allocation for pair labels)
  123. This choice is common enough that it may be worth
  124. suffixing function names with a capital letter to
  125. be clear what the functions memory policy is.
  126. 3) Come up with a var-args format which allows a
  127. hierchy of records to be defined in one line.
  128. 4) Implement the serialization functions.
  129. 5) Implement an ascii string/parse format for writing/reading.
  130. 6) Implement fast lookup of record fields.
  131. 7) Allow for user defined types. For example a 'matrix'
  132. data type. This might be as simple as adding an extra 'user_tid'
  133. field to cmData_t.
  134. 8) Implement type specific cmDataGetRecordValueXXX() functions.
  135. 9) Implement cmDataIsEqual(), cmDataIsLtE(), ...
  136. */
  137. bool canConvertType( cmDataFmtId_t srcId, cmDataFmtId_t dstId );
  138. bool willTruncate( cmDataFmtId_t srcId, cmDataFmtId_t dstId );
  139. bool canConvertObj( const cmData_t* srcObj, cmData_t* dstObj );
  140. bool willTruncateObj(const cmData_t* srcObj, cmData_t* dstObj );
  141. // Get the value of an object without conversion.
  142. // The data type id must match the return type or the
  143. // conversion must be an automatic C conversion.
  144. char cmDataChar( const cmData_t* p );
  145. unsigned char cmDataUChar( const cmData_t* p );
  146. short cmDataShort( const cmData_t* p );
  147. unsigned short cmDataUShort( const cmData_t* p );
  148. int cmDataInt( const cmData_t* p );
  149. unsigned int cmDataUInt( const cmData_t* p );
  150. long cmDataLong( const cmData_t* p );
  151. unsigned long cmDataULong( const cmData_t* p );
  152. float cmDataFloat( const cmData_t* p );
  153. double cmDataDouble( const cmData_t* p );
  154. cmChar_t* cmDataStr( const cmData_t* p );
  155. const cmChar_t* cmDataConstStr( const cmData_t* p );
  156. void* cmDataVoidPtr( const cmData_t* p );
  157. char* cmDataCharPtr( const cmData_t* p );
  158. unsigned char* cmDataUCharPtr( const cmData_t* p );
  159. short* cmDataShortPtr( const cmData_t* p );
  160. unsigned short* cmDataUShortPtr( const cmData_t* p );
  161. int* cmDataIntPtr( const cmData_t* p );
  162. unsigned int* cmDataUIntPtr( const cmData_t* p );
  163. long* cmDataLongPtr( const cmData_t* p );
  164. unsigned long* cmDataULongPtr( const cmData_t* p );
  165. float* cmDataFloatPtr( const cmData_t* p );
  166. double* cmDataDoublePtr( const cmData_t* p );
  167. // Get the value of an object with conversion.
  168. char cmDataGetChar( const cmData_t* p );
  169. unsigned char cmDataGetUChar( const cmData_t* p );
  170. short cmDataGetShort( const cmData_t* p );
  171. unsigned short cmDataGetUShort( const cmData_t* p );
  172. int cmDataGetInt( const cmData_t* p );
  173. unsigned int cmDataGetUInt( const cmData_t* p );
  174. long cmDataGetLong( const cmData_t* p );
  175. unsigned long cmDataGetULong( const cmData_t* p );
  176. float cmDataGetFloat( const cmData_t* p );
  177. double cmDataGetDouble( const cmData_t* p );
  178. cmChar_t* cmDataGetStr( const cmData_t* p );
  179. const cmChar_t* cmDataGetConstStr( const cmData_t* p );
  180. void* cmDataGetVoidPtr( const cmData_t* p );
  181. char* cmDataGetCharPtr( const cmData_t* p );
  182. unsigned char* cmDataGetUCharPtr( const cmData_t* p );
  183. short* cmDataGetShortPtr( const cmData_t* p );
  184. unsigned short* cmDataGetUShortPtr( const cmData_t* p );
  185. int* cmDataGetIntPtr( const cmData_t* p );
  186. unsigned int* cmDataGetUIntPtr( const cmData_t* p );
  187. long* cmDataGetLongPtr( const cmData_t* p );
  188. unsigned long* cmDataGetULongPtr( const cmData_t* p );
  189. float* cmDataGetFloatPtr( const cmData_t* p );
  190. double* cmDataGetDoublePtr( const cmData_t* p );
  191. // Set the value of an existing scalar data object.
  192. cmData_t* cmDataSetNull( cmData_t* p );
  193. cmData_t* cmDataSetChar( cmData_t* p, char v );
  194. cmData_t* cmDataSetUChar( cmData_t* p, unsigned char v );
  195. cmData_t* cmDataSetShort( cmData_t* p, short v );
  196. cmData_t* cmDataSetUShort( cmData_t* p, unsigned short v );
  197. cmData_t* cmDataSetInt( cmData_t* p, int v );
  198. cmData_t* cmDataSetUInt( cmData_t* p, unsigned int v );
  199. cmData_t* cmDataSetLong( cmData_t* p, long v );
  200. cmData_t* cmDataSetULong( cmData_t* p, unsigned long v );
  201. cmData_t* cmDataSetFloat( cmData_t* p, float v );
  202. cmData_t* cmDataSetDouble( cmData_t* p, double v );
  203. cmData_t* cmDataSetStr( cmData_t* p, cmChar_t* s );
  204. cmData_t* cmDataSetConstStr( cmData_t* p, const cmChar_t* s );
  205. // Set the value of an existing data object to an external array.
  206. // 'vp' is assigned as the data space for the object and therefore must remain
  207. // valid for the life of the object.
  208. cmData_t* cmDataSetVoidPtr( cmData_t* p, void* vp, unsigned cnt );
  209. cmData_t* cmDataSetCharPtr( cmData_t* p, char* vp, unsigned cnt );
  210. cmData_t* cmDataSetUCharPtr( cmData_t* p, unsigned char* vp, unsigned cnt );
  211. cmData_t* cmDataSetShortPtr( cmData_t* p, short* vp, unsigned cnt );
  212. cmData_t* cmDataSetUShortPtr( cmData_t* p, unsigned short* vp, unsigned cnt );
  213. cmData_t* cmDataSetIntPtr( cmData_t* p, int* vp, unsigned cnt );
  214. cmData_t* cmDataSetUIntPtr( cmData_t* p, unsigned int* vp, unsigned cnt );
  215. cmData_t* cmDataSetLongPtr( cmData_t* p, long* vp, unsigned cnt );
  216. cmData_t* cmDataSetULongPtr( cmData_t* p, unsigned long* vp, unsigned cnt );
  217. cmData_t* cmDataSetFloatPtr( cmData_t* p, float* vp, unsigned cnt );
  218. cmData_t* cmDataSetDoublePtr( cmData_t* p, double* vp, unsigned cnt );
  219. // Set the value of an existing array based data object.
  220. // Dynamically allocate the internal array and copy the array data into it.
  221. cmData_t* cmDataSetStrAlloc( cmData_t* p, const cmChar_t* s );
  222. cmData_t* cmDataSetConstStrAlloc( cmData_t* p, const cmChar_t* s );
  223. cmData_t* cmDataSetVoidAllocPtr( cmData_t* p, const void* vp, unsigned cnt );
  224. cmData_t* cmDataSetCharAllocPtr( cmData_t* p, const char* vp, unsigned cnt );
  225. cmData_t* cmDataSetUCharAllocPtr( cmData_t* p, const unsigned char* vp, unsigned cnt );
  226. cmData_t* cmDataSetShortAllocPtr( cmData_t* p, const short* vp, unsigned cnt );
  227. cmData_t* cmDataSetUShortAllocPtr( cmData_t* p, const unsigned short* vp, unsigned cnt );
  228. cmData_t* cmDataSetIntAllocPtr( cmData_t* p, const int* vp, unsigned cnt );
  229. cmData_t* cmDataSetUIntAllocPtr( cmData_t* p, const unsigned int* vp, unsigned cnt );
  230. cmData_t* cmDataSetLongAllocPtr( cmData_t* p, const long* vp, unsigned cnt );
  231. cmData_t* cmDataSetULongAllocPtr( cmData_t* p, const unsigned long* vp, unsigned cnt );
  232. cmData_t* cmDataSetFloatAllocPtr( cmData_t* p, const float* vp, unsigned cnt );
  233. cmData_t* cmDataSetDoubleAllocPtr( cmData_t* p, const double* vp, unsigned cnt );
  234. // Dynamically allocate a data object and set it's value.
  235. cmData_t* cmDataAllocNull( cmData_t* parent );
  236. cmData_t* cmDataAllocChar( cmData_t* parent, char v );
  237. cmData_t* cmDataAllocUChar( cmData_t* parent, unsigned char v );
  238. cmData_t* cmDataAllocShort( cmData_t* parent, short v );
  239. cmData_t* cmDataAllocUShort( cmData_t* parent, unsigned short v );
  240. cmData_t* cmDataAllocInt( cmData_t* parent, int v );
  241. cmData_t* cmDataAllocUInt( cmData_t* parent, unsigned int v );
  242. cmData_t* cmDataAllocLong( cmData_t* parent, long v );
  243. cmData_t* cmDataAllocULong( cmData_t* parent, unsigned long v );
  244. cmData_t* cmDataAllocFloat( cmData_t* parent, float v );
  245. cmData_t* cmDataAllocDouble( cmData_t* parent, double v );
  246. // Dynamically allocate a data object and set its array value to an external
  247. // array. v[cnt] is assigned as the internal data space for the object and
  248. // therefore must remain valid for the life of the object.
  249. // See the cmDataXXXAlocPtr() for equivalent functions which dynamically
  250. // allocate the intenal data space.
  251. cmData_t* cmDataAllocStr( cmData_t* parent, cmChar_t* str );
  252. cmData_t* cmDataAllocConstStr( cmData_t* parent, const cmChar_t* str );
  253. cmData_t* cmDataAllocCharPtr( cmData_t* parent, char* v, unsigned cnt );
  254. cmData_t* cmDataAllocUCharPtr( cmData_t* parent, unsigned char* v, unsigned cnt );
  255. cmData_t* cmDataAllocShortPtr( cmData_t* parent, short* v, unsigned cnt );
  256. cmData_t* cmDataAllocUShortPtr( cmData_t* parent, unsigned short* v, unsigned cnt );
  257. cmData_t* cmDataAllocIntPtr( cmData_t* parent, int* v, unsigned cnt );
  258. cmData_t* cmDataAllocUIntPtr( cmData_t* parent, unsigned int* v, unsigned cnt );
  259. cmData_t* cmDataAllocLongPtr( cmData_t* parent, long* v, unsigned cnt );
  260. cmData_t* cmDataAllocULongPtr( cmData_t* parent, unsigned long* v, unsigned cnt );
  261. cmData_t* cmDataAllocFloatPtr( cmData_t* parent, float* v, unsigned cnt );
  262. cmData_t* cmDataAllocDoublePtr( cmData_t* parent, double* v, unsigned cnt );
  263. cmData_t* cmDataAllocVoidPtr( cmData_t* parent, void* v, unsigned cnt );
  264. // Dynamically allocate a data object and its array value.
  265. // These functions dynamically allocate the internal array data space
  266. // and copy v[cnt] into it.
  267. cmData_t* cmDataStrAlloc( cmData_t* parent, cmChar_t* str );
  268. cmData_t* cmDataConstStrAlloc( cmData_t* parent, const cmChar_t* str );
  269. cmData_t* cmDataCharAllocPtr( cmData_t* parent, const char* v, unsigned cnt );
  270. cmData_t* cmDataUCharAllocPtr( cmData_t* parent, const unsigned char* v, unsigned cnt );
  271. cmData_t* cmDataShortAllocPtr( cmData_t* parent, const short* v, unsigned cnt );
  272. cmData_t* cmDataUShortAllocPtr( cmData_t* parent, const unsigned short* v, unsigned cnt );
  273. cmData_t* cmDataIntAllocPtr( cmData_t* parent, const int* v, unsigned cnt );
  274. cmData_t* cmDataUIntAllocPtr( cmData_t* parent, const unsigned int* v, unsigned cnt );
  275. cmData_t* cmDataLongAllocPtr( cmData_t* parent, const long* v, unsigned cnt );
  276. cmData_t* cmDataULongAllocPtr( cmData_t* parent, const unsigned long* v, unsigned cnt );
  277. cmData_t* cmDataFloatAllocPtr( cmData_t* parent, const float* v, unsigned cnt );
  278. cmData_t* cmDataDoubleAllocPtr( cmData_t* parent, const double* v, unsigned cnt );
  279. cmData_t* cmDataVoidAllocPtr( cmData_t* parent, const void* v, unsigned cnt );
  280. //----------------------------------------------------------------------------
  281. // Structure related functions
  282. //
  283. // Release an object and any resources held by it.
  284. // Note the this function does not unlink the object
  285. // from it's parent. Use cmDataUnlinkAndFree()
  286. // to remove a object from it's parent list prior
  287. // to releasing it.
  288. void cmDataFree( cmData_t* p );
  289. // Unlink 'p' from its parents and siblings.
  290. // Asserts if parent is not a structure.
  291. // Returns 'p'.
  292. cmData_t* cmDataUnlink( cmData_t* p );
  293. // Wrapper function to cmDataUnlink() and cmDataFree().
  294. void cmDataUnlinkAndFree( cmData_t* p );
  295. // Replace the 'dst' node with the 'src' node and
  296. // return 'src'. This operation does not duplicate
  297. // 'src' it simply links in 'src' at the location of
  298. // 'dst' and then unlinks and free's 'dst'.
  299. cmData_t* cmDataReplace( cmData_t* dst, cmData_t* src );
  300. // Return the count of child nodes.
  301. // 1. Array nodes have one child per array element.
  302. // 2. List nodes have one child pair.
  303. // 3. Pair nodes have two children.
  304. // 4. Leaf nodes have 0 children.
  305. unsigned cmDataChildCount( const cmData_t* p );
  306. // Returns the ith child of 'p'.
  307. // Returns NULL if p has no children or index is invalid.
  308. cmData_t* cmDataChild( cmData_t* p, unsigned index );
  309. // Prepend 'p' to 'parents' child list.
  310. // The source node 'p' is not duplicated it is simply linked in.
  311. // Returns 'p'.
  312. cmData_t* cmDataPrependChild(cmData_t* parent, cmData_t* p );
  313. // Append 'p' to the end of 'parent' child list.
  314. // The source node 'p' is not duplicated it is simply linked in.
  315. // Returns 'p'.
  316. cmData_t* cmDataAppendChild( cmData_t* parent, cmData_t* p );
  317. // Insert 'p' at index. Index must be in the range:
  318. // 0 to cmDataChildCount(parent).
  319. // The source node 'p' is not duplicated it is simply linked in.
  320. // Returns 'p'.
  321. cmData_t* cmDataInsertChild( cmData_t* parent, unsigned index, cmData_t* p );
  322. //----------------------------------------------------------------------------
  323. // Pair related functions
  324. //
  325. // Get the key/value of a pair
  326. cmData_t* cmDataPairKey( cmData_t* p );
  327. unsigned cmDataPairKeyId( cmData_t* p );
  328. const cmChar_t* cmDataPairKeyLabel( cmData_t* p );
  329. cmData_t* cmDataPairValue( cmData_t* p );
  330. // Set the value of an existing pair node.
  331. // 'value' is not duplicated it is simply linked in place of the
  332. // previous pair value node. The previous pair value node is
  333. // unlinked and freed.
  334. // Returns 'p'.
  335. cmData_t* cmDataPairSetValue( cmData_t* p, cmData_t* value );
  336. // Set the key of an existing pair node.
  337. //
  338. // Returns 'p'.
  339. cmData_t* cmDataPairSetKey( cmData_t* p, cmData_t* key );
  340. cmData_t* cmDataPairSetKeyId( cmData_t* p, unsigned id );
  341. // The data space for the 'label' string is dynamically allocated.
  342. cmData_t* cmDataPairSetKeyLabel( cmData_t* p, const cmChar_t* label );
  343. cmData_t* cmDataMakePair( cmData_t* parent, cmData_t* p, cmData_t* key, cmData_t* value );
  344. // Dynamically allocate a pair node
  345. cmData_t* cmDataAllocPair( cmData_t* parent, const cmData_t* key, const cmData_t* value );
  346. cmData_t* cmDataAllocPairId( cmData_t* parent, unsigned keyId, cmData_t* value );
  347. // The data space for the 'label' string is dynamically allocated.
  348. cmData_t* cmDataAllocPairLabel( cmData_t* parent, const cmChar_t* label, cmData_t* value );
  349. //----------------------------------------------------------------------------
  350. // List related functions
  351. //
  352. // Return the count of ele's in the list.
  353. unsigned cmDataListCount( const cmData_t* p );
  354. // Return the ith element in the list.
  355. cmData_t* cmDataListEle( cmData_t* p, unsigned index );
  356. cmData_t* cmDataListMake( cmData_t* parent, cmData_t* p );
  357. cmData_t* cmDataListAlloc( cmData_t* parent);
  358. // Var-args fmt:
  359. // <typeId> <value> {<cnt>}
  360. // scalar types: <value> is literal,<cnt> is not included
  361. // null has no <value> or <cnt>
  362. // ptr types: <value> is pointer,<cnt> is element count
  363. // struct types: <value> is cmData_t, <cnt> is not included
  364. // Indicate the end of argument list by setting <typeId> to kInvalidDtId.
  365. // The memory for array based data types is dynamically allocated.
  366. cmData_t* cmDataListAllocV(cmData_t* parent, va_list vl );
  367. cmData_t* cmDataListAllocA(cmData_t* parent, ... );
  368. // Returns a ptr to 'ele'.
  369. cmData_t* cmDataListAppendEle( cmData_t* p, cmData_t* ele );
  370. cmDtRC_t cmDataListAppendV( cmData_t* p, va_list vl );
  371. cmDtRC_t cmDataListAppend( cmData_t* p, ... );
  372. // Return 'p'.
  373. cmData_t* cmDataListInsertEle( cmData_t* p, unsigned index, cmData_t* ele );
  374. cmData_t* cmDataListInsertEleN(cmData_t* p, unsigned index, cmData_t* ele[], unsigned n );
  375. cmData_t* cmDataListUnlink( cmData_t* p, unsigned index );
  376. cmData_t* cmDataListFree( cmData_t* p, unsigned index );
  377. //----------------------------------------------------------------------------
  378. // Record related functions
  379. //
  380. // Return count of pairs.
  381. unsigned cmDataRecdCount( const cmData_t* p );
  382. // Return the ith pair.
  383. cmData_t* cmDataRecdEle( cmData_t* p, unsigned index );
  384. // Return the ith value.
  385. cmData_t* cmDataRecdValueFromIndex( cmData_t* p, unsigned index );
  386. cmData_t* cmDataRecdValueFromId( cmData_t* p, unsigned id );
  387. cmData_t* cmDataRecdValueFromLabel( cmData_t* p, const cmChar_t* label );
  388. // Return the ith key
  389. cmData_t* cmDataRecdKey( cmData_t* p, unsigned index );
  390. unsigned cmDataRecdKeyId( cmData_t* p, unsigned index );
  391. const cmChar_t* cmDataRecdKeyLabel( cmData_t* p, unsigned index );
  392. cmData_t* cmRecdMake( cmData_t* parent, cmData_t* p );
  393. cmData_t* cmRecdAlloc( cmData_t* parent );
  394. cmData_t* cmRecdAppendPair( cmData_t* p, cmData_t* pair );
  395. // Var-args fmt:
  396. // <label|id> <typeId> <value> {<cnt>}
  397. // scalar types: <value> is literal,<cnt> is not included
  398. // null has no <value> or <cnt>
  399. // ptr types: <value> is pointer,<cnt> is element count
  400. // struct types: <value> is cmData_t, <cnt> is not included
  401. // Indicate the end of argument list by setting <typeId> to kInvalidDtId.
  402. // The memory for array based data types is dynamically allocated.
  403. cmData_t* cmDataRecdAllocLabelV( cmData_t* parent, va_list vl );
  404. cmData_t* cmDataRecdAllocLabelA( cmData_t* parent, ... );
  405. cmData_t* cmDataRecdAllocIdV( cmData_t* parent, va_list vl );
  406. cmData_t* cmDataRecdAllocIdA( cmData_t* parent, ... );
  407. unsigned cmDataSerializeByteCount( const cmData_t* p );
  408. cmDtRC_t cmDataSerialize( const cmData_t* p, void* buf, unsigned bufByteCnt );
  409. cmDtRC_t cmDataDeserialize( const void* buf, unsigned bufByteCnt, cmData_t** pp );
  410. void cmDataPrint( const cmData_t* p, cmRpt_t* rpt );
  411. void cmDataTest( cmCtx_t* ctx );
  412. #ifdef __cplusplus
  413. }
  414. #endif
  415. #endif