textual_decoder_init.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * ESG parser
  3. *
  4. * Copyright (C) 2006 Stephane Este-Gracias (sestegra@free.fr)
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  19. */
  20. #ifndef _ESG_REPRESENTATION_TEXTUAL_DECODER_INIT_H
  21. #define _ESG_REPRESENTATION_TEXTUAL_DECODER_INIT_H 1
  22. #ifdef __cplusplus
  23. extern "C"
  24. {
  25. #endif
  26. #include <stdint.h>
  27. /**
  28. * esg_namespace_prefix structure.
  29. */
  30. struct esg_namespace_prefix {
  31. uint16_t prefix_string_ptr;
  32. uint16_t namespace_uri_ptr;
  33. struct esg_namespace_prefix *_next;
  34. };
  35. /**
  36. * esg_fragment_type structure.
  37. */
  38. struct esg_xml_fragment_type {
  39. uint16_t xpath_ptr;
  40. uint16_t xml_fragment_type;
  41. struct esg_xml_fragment_type *_next;
  42. };
  43. /**
  44. * esg_textual_decoder_init structure.
  45. */
  46. struct esg_textual_decoder_init {
  47. uint8_t version;
  48. uint8_t num_namespace_prefixes;
  49. struct esg_namespace_prefix *namespace_prefix_list;
  50. uint8_t num_fragment_types;
  51. struct esg_xml_fragment_type *xml_fragment_type_list;
  52. };
  53. /**
  54. * Process an esg_textual_decoder_init.
  55. *
  56. * @param buffer Binary buffer to decode.
  57. * @param size Binary buffer size.
  58. * @return Pointer to an esg_textual_decoder_init structure, or NULL on error.
  59. */
  60. extern struct esg_textual_decoder_init *esg_textual_decoder_init_decode(uint8_t *buffer, uint32_t size);
  61. /**
  62. * Free an esg_textual_decoder_init.
  63. *
  64. * @param decoder_init Pointer to an esg_textual_decoder_init structure.
  65. */
  66. extern void esg_textual_decoder_init_free(struct esg_textual_decoder_init *decoder_init);
  67. /**
  68. * Convenience iterator for namespace_prefix_list field of an esg_textual_decoder_init.
  69. *
  70. * @param decoder_init The esg_textual_decoder_init pointer.
  71. * @param namespace_prefix Variable holding a pointer to the current esg_namespace_prefix.
  72. */
  73. #define esg_textual_decoder_namespace_prefix_list_for_each(decoder_init, namespace_prefix) \
  74. for ((namespace_prefix) = (decoder_init)->namespace_prefix_list; \
  75. (namespace_prefix); \
  76. (namespace_prefix) = (namespace_prefix)->_next)
  77. /**
  78. * Convenience iterator for xml_fragment_type_list field of an esg_textual_decoder_init.
  79. *
  80. * @param decoder_init The esg_textual_decoder_init pointer.
  81. * @param xml_fragment_type Variable holding a pointer to the current esg_xml_fragment_type.
  82. */
  83. #define esg_textual_decoder_xml_fragment_type_list_for_each(decoder_init, xml_fragment_type) \
  84. for ((xml_fragment_type) = (decoder_init)->xml_fragment_type_list; \
  85. (xml_fragment_type); \
  86. (xml_fragment_type) = (xml_fragment_type)->_next)
  87. #ifdef __cplusplus
  88. }
  89. #endif
  90. #endif