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)
85 node->_parent = this; 85 node->_parent = this;
86} 86}
87 87
88static Structure* ImportStruct(plist_t root)
89{
90 Structure* ret = NULL;
91 plist_type type = plist_get_node_type(root);
92
93 if (PLIST_ARRAY == type || PLIST_DICT == type)
94 {
95 ret = static_cast<Structure*>(Node::FromPlist(root));
96 }
97 else
98 {
99 plist_free(root);
100 }
101
102 return ret;
103}
104
105Structure* Structure::FromXml(const std::string& xml)
106{
107 plist_t root = NULL;
108 plist_from_xml(xml.c_str(), xml.size(), &root);
109
110 return ImportStruct(root);
111}
112
113Structure* Structure::FromBin(const std::vector<char>& bin)
114{
115 plist_t root = NULL;
116 plist_from_bin(&bin[0], bin.size(), &root);
117
118 return ImportStruct(root);
119
120}
121
88}; 122};
89 123