aboutsummaryrefslogtreecommitdiff
path: root/core/encoding/xml
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2022-04-30 14:51:46 +0200
committerGitHub <noreply@github.com>2022-04-30 14:51:46 +0200
commit41a18f078dc6044df484cc79f2ebcc25e81fddf4 (patch)
tree1e3ef406e8dcd2b1127f2e46b964ec03da929447 /core/encoding/xml
parentb758c696f2b07a1bcdd2d5a6bb723e286dcfca75 (diff)
parent3978e7e1cac9305698e9270fec02d7cd9557cf35 (diff)
Merge pull request #1757 from Kelimion/xml
[xml] Add `parse_from_string` overload.
Diffstat (limited to 'core/encoding/xml')
-rw-r--r--core/encoding/xml/xml_reader.odin13
1 files changed, 10 insertions, 3 deletions
diff --git a/core/encoding/xml/xml_reader.odin b/core/encoding/xml/xml_reader.odin
index 6d0d4e1aa..151d44e2a 100644
--- a/core/encoding/xml/xml_reader.odin
+++ b/core/encoding/xml/xml_reader.odin
@@ -493,7 +493,16 @@ parse_from_slice :: proc(data: []u8, options := DEFAULT_Options, path := "", err
return doc, .None
}
-parse_from_file :: proc(filename: string, options := DEFAULT_Options, error_handler := default_error_handler, allocator := context.allocator) -> (doc: ^Document, err: Error) {
+parse_from_string :: proc(data: string, options := DEFAULT_Options, path := "", error_handler := default_error_handler, allocator := context.allocator) -> (doc: ^Document, err: Error) {
+ _data := transmute([]u8)data
+
+ return parse_from_slice(_data, options, path, error_handler, allocator)
+}
+
+parse :: proc { parse_from_string, parse_from_slice }
+
+// Load an XML file
+load_from_file :: proc(filename: string, options := DEFAULT_Options, error_handler := default_error_handler, allocator := context.allocator) -> (doc: ^Document, err: Error) {
context.allocator = allocator
options := options
@@ -505,8 +514,6 @@ parse_from_file :: proc(filename: string, options := DEFAULT_Options, error_hand
return parse_from_slice(data, options, filename, error_handler, allocator)
}
-parse :: proc { parse_from_file, parse_from_slice }
-
destroy :: proc(doc: ^Document) {
if doc == nil { return }