summaryrefslogtreecommitdiffstats
path: root/src/Structure.cpp
diff options
context:
space:
mode:
authorGravatar Jonathan Beck2009-11-11 00:18:14 +0100
committerGravatar Jonathan Beck2009-11-11 00:18:14 +0100
commit8c6a809fafa6befff7e2b1adc3df2bdb47042dd1 (patch)
tree2336ae7ee66dbb639c8b8bd8c06171c1f6f6e334 /src/Structure.cpp
parent53a9f891f82e973440709593d259bd7c1f22dd1a (diff)
downloadlibplist-8c6a809fafa6befff7e2b1adc3df2bdb47042dd1.tar.gz
libplist-8c6a809fafa6befff7e2b1adc3df2bdb47042dd1.tar.bz2
Move some methods and drop Utils class in C++ binding.
Diffstat (limited to 'src/Structure.cpp')
-rw-r--r--src/Structure.cpp34
1 files changed, 34 insertions, 0 deletions
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<Structure*>(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<char>& bin)
+{
+ plist_t root = NULL;
+ plist_from_bin(&bin[0], bin.size(), &root);
+
+ return ImportStruct(root);
+
+}
+
};