vapi/genx.vapi (3033B) - raw
1 /* 2 * http://www.djc.id.au/blog/genx-vala 3 * Released into the public domain 4 */ 5 6 [CCode (cheader_filename = "genx-glib.h")] 7 namespace Genx { 8 9 [CCode (cname = "genxStatus", cprefix = "GENX_")] 10 public enum Status { 11 SUCCESS, 12 BAD_UTF8, 13 NON_XML_CHARACTER, 14 BAD_NAME, 15 ALLOC_FAILED, 16 BAD_NAMESPACE_NAME, 17 INTERNAL_ERROR, 18 DUPLICATE_PREFIX, 19 SEQUENCE_ERROR, 20 NO_START_TAG, 21 IO_ERROR, 22 MISSING_VALUE, 23 MALFORMED_COMMENT, 24 XML_PI_TARGET, 25 MALFORMED_PI, 26 DUPLICATE_ATTRIBUTE, 27 ATTRIBUTE_IN_DEFAULT_NAMESPACE, 28 DUPLICATE_NAMESPACE, 29 BAD_DEFAULT_DECLARATION 30 } 31 32 [Compact] 33 [CCode (cname = "genxWriter_rec", free_function = "genxDispose")] 34 public class Writer { 35 36 [CCode (has_target = 0)] 37 public delegate void* AllocCallback(void* user_data, int bytes); 38 [CCode (has_target = 0)] 39 public delegate void DeallocCallback(void* user_data, void* data); 40 41 private static void* default_alloc(void* user_data, int bytes) { 42 return GLib.malloc(bytes); 43 } 44 private static void default_dealloc(void* user_data, void* data) { 45 GLib.free(data); 46 } 47 48 [CCode (cname = "genxNew")] 49 public Writer( 50 AllocCallback alloc = default_alloc, 51 DeallocCallback dealloc = default_dealloc, 52 void* user_data = null); 53 54 public unowned Namespace declare_namespace(string uri, string prefix); 55 56 public unowned Element declare_element(Namespace ns, string type); 57 58 public unowned Attribute declare_attribute(Namespace ns, string name); 59 60 [CCode (cname = "genx_writer_start_doc_gstring")] 61 public void start_doc(GLib.StringBuilder output); 62 63 public void end_document(); 64 65 public void comment(string text); 66 67 public void pi(string target, string text); 68 69 public void start_element_literal(string xmlns, string type); 70 71 public void add_attribute_literal(string xmlns, string name, string value); 72 73 public void unset_default_namespace(); 74 75 public void end_element(); 76 77 public void add_text(string text); 78 79 public void add_character(int character); 80 81 } 82 83 [Compact] 84 [CCode (cname = "struct genxNamespace_rec", free_function = "NAMESPACE_HAS_NO_PUBLIC_FREE")] 85 public class Namespace { 86 87 public void add(string? prefix = null); 88 89 } 90 91 [Compact] 92 [CCode (cname = "struct genxElement_rec", free_function = "ELEMENT_HAS_NO_PUBLIC_FREE")] 93 public class Element { 94 95 public void start(); 96 97 } 98 99 [Compact] 100 [CCode (cname = "struct genxAttribute_rec", free_function = "ATTRIBUTE_HAS_NO_PUBLIC_FREE")] 101 public class Attribute { 102 103 public void add(string value); 104 105 } 106 107 }