From 8c6a809fafa6befff7e2b1adc3df2bdb47042dd1 Mon Sep 17 00:00:00 2001 From: Jonathan Beck Date: Wed, 11 Nov 2009 00:18:14 +0100 Subject: Move some methods and drop Utils class in C++ binding. --- src/Structure.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/Structure.cpp') diff --git a/src/Structure.cpp b/src/Structure.cpp index cf7c611..18b19ef 100644 --- a/src/Structure.cpp +++ b/src/Structure.cpp @@ -85,5 +85,39 @@ void Structure::UpdateNodeParent(Node* node) node->_parent = this; } +static Structure* ImportStruct(plist_t root) +{ + Structure* ret = NULL; + plist_type type = plist_get_node_type(root); + + if (PLIST_ARRAY == type || PLIST_DICT == type) + { + ret = static_cast(Node::FromPlist(root)); + } + else + { + plist_free(root); + } + + return ret; +} + +Structure* Structure::FromXml(const std::string& xml) +{ + plist_t root = NULL; + plist_from_xml(xml.c_str(), xml.size(), &root); + + return ImportStruct(root); +} + +Structure* Structure::FromBin(const std::vector& bin) +{ + plist_t root = NULL; + plist_from_bin(&bin[0], bin.size(), &root); + + return ImportStruct(root); + +} + }; -- cgit v1.1-32-gdbae