gmarkup.inc 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. {*
  2. * gmarkup.inc
  3. *
  4. * depends on gerror.inc
  5. *}
  6. { These three are primarily intended for specific GMarkupParser
  7. implementations to set.
  8. }
  9. type
  10. PGMarkupError = ^TGMarkupError;
  11. TGMarkupError = (G_MARKUP_ERROR_BAD_UTF8,
  12. G_MARKUP_ERROR_EMPTY,
  13. G_MARKUP_ERROR_PARSE,
  14. G_MARKUP_ERROR_UNKNOWN_ELEMENT,
  15. G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE,
  16. G_MARKUP_ERROR_INVALID_CONTENT);
  17. function G_MARKUP_ERROR : TGQuark;
  18. function g_markup_error_quark:TGQuark;cdecl;external gliblib name 'g_markup_error_quark';
  19. type
  20. PGMarkupParseFlags = ^TGMarkupParseFlags;
  21. TGMarkupParseFlags = integer;
  22. const
  23. { Hmm, can't think of any at the moment }
  24. G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG = 1 shl 0;
  25. type
  26. PGMarkupParseContext = ^TGMarkupParseContext;
  27. TGMarkupParseContext = pointer; // please correct me if it's wrong
  28. PGMarkupParser = ^TGMarkupParser;
  29. TGMarkupParser = record
  30. { Called for open tags <foo bar="baz"> }
  31. start_element : procedure (context : PGMarkupParseContext;
  32. element_name : Pgchar;
  33. attribute_names : PPgchar;
  34. attribute_values : PPgchar;
  35. user_data : gpointer; error:PPGError);cdecl;
  36. { Called for close tags </foo> }
  37. end_element : procedure (context : PGMarkupParseContext;
  38. element_name : Pgchar;
  39. user_data : gpointer;
  40. error : PPGError); cdecl;
  41. { Called for character data }
  42. { text is not nul-terminated }
  43. text : procedure (context : PGMarkupParseContext;
  44. text : Pgchar;
  45. text_len : gsize;
  46. user_data : gpointer;
  47. error : PPGError); cdecl;
  48. { Called for strings that should be re-saved verbatim in this same
  49. position, but are not otherwise interpretable. At the moment
  50. this includes comments and processing instructions.
  51. }
  52. { text is not nul-terminated. }
  53. passthrough : procedure (context : PGMarkupParseContext;
  54. passthrough_text : Pgchar;
  55. text_len : gsize;
  56. user_data : gpointer;
  57. error : PPGError); cdecl;
  58. { Called on error, including one set by other
  59. methods in the vtable. The GError should not be freed.
  60. }
  61. error : procedure (context : PGMarkupParseContext;
  62. error : PGError;
  63. user_data : gpointer); cdecl;
  64. end;
  65. function g_markup_parse_context_new (parser : PGMarkupParser;
  66. flags : TGMarkupParseFlags;
  67. user_data : gpointer;
  68. user_data_dnotify : TGDestroyNotify): PGMarkupParseContext; cdecl;external gliblib name 'g_markup_parse_context_new';
  69. procedure g_markup_parse_context_free(context : PGMarkupParseContext);cdecl;external gliblib name 'g_markup_parse_context_free';
  70. function g_markup_parse_context_parse(context : PGMarkupParseContext;
  71. text : Pgchar;
  72. text_len : gssize;
  73. error : PPGError):gboolean;cdecl;external gliblib name 'g_markup_parse_context_parse';
  74. function g_markup_parse_context_end_parse(context : PGMarkupParseContext;
  75. error : PPGError):gboolean;cdecl;external gliblib name 'g_markup_parse_context_end_parse';
  76. { For user-constructed error messages, has no precise semantics }
  77. procedure g_markup_parse_context_get_position(context : PGMarkupParseContext;
  78. line_number : Pgint;
  79. char_number : Pgint);cdecl;external gliblib name 'g_markup_parse_context_get_position';
  80. { useful when saving }
  81. function g_markup_escape_text (text : Pgchar;
  82. length : gssize):Pgchar;cdecl;external gliblib name 'g_markup_escape_text';