diff options
Diffstat (limited to 'src/Structure.cpp')
| -rw-r--r-- | src/Structure.cpp | 34 |
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 | ||
| 88 | static 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 | |||
| 105 | Structure* 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 | |||
| 113 | Structure* 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 | ||
