diff options
| author | ruki <[email protected]> | 2025-11-15 00:48:55 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-11-15 00:48:55 +0800 |
| commit | 29fbfdef99861931d81578eac3434f452efddb8e (patch) | |
| tree | aee48deac545d5d3fb8e1916c0e1c923e6afb40b /xmake/core/sandbox/modules | |
| parent | 100900c957fa0db180ccaf5f1f157a78e9db665d (diff) | |
add xml module
Diffstat (limited to 'xmake/core/sandbox/modules')
| -rw-r--r-- | xmake/core/sandbox/modules/import/core/base/xml.lua | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/xmake/core/sandbox/modules/import/core/base/xml.lua b/xmake/core/sandbox/modules/import/core/base/xml.lua new file mode 100644 index 000000000..7867c3295 --- /dev/null +++ b/xmake/core/sandbox/modules/import/core/base/xml.lua @@ -0,0 +1,64 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, Xmake Open Source Community. +-- +-- @author ruki +-- @file xml.lua +-- + +-- define module +local sandbox_core_base_xml = sandbox_core_base_xml or {} + +-- load modules +local xml = require("base/xml") +local raise = require("sandbox/modules/raise") + +-- inherit some builtin interfaces +sandbox_core_base_xml.encode = xml.encode +sandbox_core_base_xml.find = xml.find +sandbox_core_base_xml.text_of = xml.text_of +sandbox_core_base_xml.text = xml.text +sandbox_core_base_xml.new = xml.new + +-- decode xml data +function sandbox_core_base_xml.decode(data, opt) + local node, errors = xml.decode(data, opt) + if not node then + raise(errors) + end + return node +end + +-- load xml file to the lua table +function sandbox_core_base_xml.load(filepath, opt) + local node, errors = xml.load(filepath, opt) + if not node then + raise(errors) + end + return node +end + +-- save xml node to the file +function sandbox_core_base_xml.save(filepath, node, opt) + local ok, errors = xml.save(filepath, node, opt) + if not ok then + raise(errors) + end + return ok +end + +-- return module +return sandbox_core_base_xml + |
