libcm is a C development framework with an emphasis on audio signal processing applications.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

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