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.

cmXml.h 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #ifndef cmXml_h
  2. #define cmXml_h
  3. #ifdef __cpluspus
  4. extern "C" {
  5. #endif
  6. //( { file_desc:"XML file reader." kw[file] }
  7. enum
  8. {
  9. kOkXmlRC = cmOkRC,
  10. kMemAllocErrXmlRC,
  11. kLHeapXmlRC,
  12. kSyntaxErrorXmlRC,
  13. kTestFailXmlRC,
  14. kInvalidTypeXmlRC,
  15. kNodeNotFoundXmlRC
  16. };
  17. typedef struct cmXmlAttr_str
  18. {
  19. const cmChar_t* label;
  20. const cmChar_t* value;
  21. struct cmXmlAttr_str* link;
  22. } cmXmlAttr_t;
  23. enum
  24. {
  25. kRootXmlFl = 0x0001,
  26. kDeclXmlFl = 0x0002,
  27. kDoctypeXmlFl = 0x0004,
  28. kNormalXmlFl = 0x0008,
  29. kTypeXmlFlags = kRootXmlFl | kDeclXmlFl | kDoctypeXmlFl | kNormalXmlFl,
  30. kClosedXmlFl = 0x0010
  31. };
  32. typedef struct cmXmlNode_str
  33. {
  34. unsigned line; // line number
  35. unsigned flags; // See k???XmlFl
  36. const cmChar_t* label; // node label
  37. const cmChar_t* dataStr; // node data string
  38. cmXmlAttr_t* attr; // attribute list
  39. struct cmXmlNode_str* parent; // parent node
  40. struct cmXmlNode_str* children; // first child node list
  41. struct cmXmlNode_str* sibling; //
  42. } cmXmlNode_t;
  43. typedef cmHandle_t cmXmlH_t;
  44. typedef cmRC_t cmXmlRC_t;
  45. extern cmXmlH_t cmXmlNullHandle;
  46. cmXmlRC_t cmXmlAlloc( cmCtx_t* ctx, cmXmlH_t* hh, const cmChar_t* fn );
  47. cmXmlRC_t cmXmlFree( cmXmlH_t* hh );
  48. bool cmXmlIsValid( cmXmlH_t h );
  49. cmXmlRC_t cmXmlParse( cmXmlH_t h, const cmChar_t* fn );
  50. cmXmlRC_t cmXmlClear( cmXmlH_t h );
  51. const cmXmlNode_t* cmXmlRoot( cmXmlH_t h );
  52. void cmXmlPrint( cmXmlH_t h, cmRpt_t* rpt );
  53. const cmXmlNode_t* cmXmlSearch( const cmXmlNode_t* np, const cmChar_t* label, const cmXmlAttr_t* attrV, unsigned attrN );
  54. const cmXmlAttr_t* cmXmlFindAttrib( const cmXmlNode_t* np, const cmChar_t* label );
  55. cmXmlRC_t cmXmlAttrInt( const cmXmlNode_t* np, const cmChar_t* attrLabel, int* retRef );
  56. cmXmlRC_t cmXmlAttrUInt( const cmXmlNode_t* np, const cmChar_t* attrLabel, unsigned* retRef );
  57. // Return the data value for a node or attributes.
  58. // Terminate node label list with NULL.
  59. const cmChar_t* cmXmlNodeValueV( const cmXmlNode_t* np, va_list vl );
  60. const cmChar_t* cmXmlNodeValue( const cmXmlNode_t* np, ... );
  61. // Terminate node label list with NULL.
  62. cmXmlRC_t cmXmlNodeIntV( const cmXmlNode_t* np, int* retRef, va_list vl );
  63. cmXmlRC_t cmXmlNodeUIntV( const cmXmlNode_t* np, unsigned* retRef, va_list vl );
  64. cmXmlRC_t cmXmlNodeDoubleV( const cmXmlNode_t* np, double* retRef, va_list vl );
  65. // Terminate node label list with NULL.
  66. cmXmlRC_t cmXmlNodeInt( const cmXmlNode_t* np, int* retRef, ... );
  67. cmXmlRC_t cmXmlNodeUInt( const cmXmlNode_t* np, unsigned* retRef, ... );
  68. cmXmlRC_t cmXmlNodeDouble(const cmXmlNode_t* np, double* retRef, ... );
  69. // Terminate node label list with NULL.
  70. bool cmXmlNodeHasChildV(const cmXmlNode_t* np, const cmChar_t* label, va_list vl );
  71. bool cmXmlNodeHasChild( const cmXmlNode_t* np, const cmChar_t* label, ... );
  72. // Last label in list is an attribute label.
  73. // Terminate the list with NULL.
  74. bool cmXmlNodeHasChildWithAttrV( const cmXmlNode_t* np, const cmChar_t* label, va_list vl );
  75. bool cmXmlNodeHasChildWithAttr( const cmXmlNode_t* np, const cmChar_t* label, ... );
  76. // Last second to last label in the list is an attribute label.
  77. // THe last label in the list is an attribute value.
  78. // Terminate the list with NULL.
  79. bool cmXmlNodeHasChildWithAttrAndValueV( const cmXmlNode_t* np, const cmChar_t* label, va_list vl );
  80. bool cmXmlNodeHasChildWithAttrAndValue( const cmXmlNode_t* np, const cmChar_t* label, ... );
  81. cmXmlRC_t cmXmlTest( cmCtx_t* ctx, const cmChar_t* fn );
  82. //)
  83. #ifdef __cpluspus
  84. }
  85. #endif
  86. #endif