diff options
| -rw-r--r-- | include/plist/Array.h | 10 | ||||
| -rw-r--r-- | include/plist/Dictionary.h | 7 | ||||
| -rw-r--r-- | include/plist/Structure.h | 1 | ||||
| -rw-r--r-- | src/Structure.cpp | 10 |
4 files changed, 24 insertions, 4 deletions
diff --git a/include/plist/Array.h b/include/plist/Array.h index 0239c78..34ddd6f 100644 --- a/include/plist/Array.h +++ b/include/plist/Array.h | |||
| @@ -57,6 +57,16 @@ public : | |||
| 57 | void Remove(Node* node); | 57 | void Remove(Node* node); |
| 58 | void Remove(unsigned int pos); | 58 | void Remove(unsigned int pos); |
| 59 | unsigned int GetNodeIndex(Node* node) const; | 59 | unsigned int GetNodeIndex(Node* node) const; |
| 60 | template <typename T> | ||
| 61 | T* at(unsigned int index) | ||
| 62 | { | ||
| 63 | return (T*)(_array.at(index)); | ||
| 64 | } | ||
| 65 | template <typename T> | ||
| 66 | T* At(unsigned int index) | ||
| 67 | { | ||
| 68 | return (T*)(_array.at(index)); | ||
| 69 | } | ||
| 60 | 70 | ||
| 61 | private : | 71 | private : |
| 62 | std::vector<Node*> _array; | 72 | std::vector<Node*> _array; |
diff --git a/include/plist/Dictionary.h b/include/plist/Dictionary.h index 583a430..fc7e558 100644 --- a/include/plist/Dictionary.h +++ b/include/plist/Dictionary.h | |||
| @@ -60,11 +60,14 @@ public : | |||
| 60 | void Remove(Node* node); | 60 | void Remove(Node* node); |
| 61 | void Remove(const std::string& key); | 61 | void Remove(const std::string& key); |
| 62 | std::string GetNodeKey(Node* node); | 62 | std::string GetNodeKey(Node* node); |
| 63 | template <typename T> | ||
| 64 | T* Get(const std::string& key) | ||
| 65 | { | ||
| 66 | return (T*)(_map[key]); | ||
| 67 | } | ||
| 63 | 68 | ||
| 64 | private : | 69 | private : |
| 65 | std::map<std::string,Node*> _map; | 70 | std::map<std::string,Node*> _map; |
| 66 | |||
| 67 | |||
| 68 | }; | 71 | }; |
| 69 | 72 | ||
| 70 | }; | 73 | }; |
diff --git a/include/plist/Structure.h b/include/plist/Structure.h index eded8b2..d85b17a 100644 --- a/include/plist/Structure.h +++ b/include/plist/Structure.h | |||
| @@ -43,6 +43,7 @@ public : | |||
| 43 | 43 | ||
| 44 | static Structure* FromXml(const std::string& xml); | 44 | static Structure* FromXml(const std::string& xml); |
| 45 | static Structure* FromBin(const std::vector<char>& bin); | 45 | static Structure* FromBin(const std::vector<char>& bin); |
| 46 | static Structure* FromBin(const char* bin, uint64_t size); | ||
| 46 | 47 | ||
| 47 | protected: | 48 | protected: |
| 48 | Structure(Node* parent = NULL); | 49 | Structure(Node* parent = NULL); |
diff --git a/src/Structure.cpp b/src/Structure.cpp index 670cce6..b33de96 100644 --- a/src/Structure.cpp +++ b/src/Structure.cpp | |||
| @@ -77,7 +77,7 @@ void Structure::UpdateNodeParent(Node* node) | |||
| 77 | if ( NULL != node->_parent ) | 77 | if ( NULL != node->_parent ) |
| 78 | { | 78 | { |
| 79 | plist_type type = plist_get_node_type(node->_parent); | 79 | plist_type type = plist_get_node_type(node->_parent); |
| 80 | if (PLIST_ARRAY ==type || PLIST_DICT == type ) | 80 | if (PLIST_ARRAY == type || PLIST_DICT == type) |
| 81 | { | 81 | { |
| 82 | Structure* s = static_cast<Structure*>(node->_parent); | 82 | Structure* s = static_cast<Structure*>(node->_parent); |
| 83 | s->Remove(node); | 83 | s->Remove(node); |
| @@ -117,8 +117,14 @@ Structure* Structure::FromBin(const std::vector<char>& bin) | |||
| 117 | plist_from_bin(&bin[0], bin.size(), &root); | 117 | plist_from_bin(&bin[0], bin.size(), &root); |
| 118 | 118 | ||
| 119 | return ImportStruct(root); | 119 | return ImportStruct(root); |
| 120 | } | ||
| 121 | |||
| 122 | Structure* Structure::FromBin(const char* bin, uint64_t size) | ||
| 123 | { | ||
| 124 | plist_t root = NULL; | ||
| 125 | plist_from_bin(bin, size, &root); | ||
| 120 | 126 | ||
| 127 | return ImportStruct(root); | ||
| 121 | } | 128 | } |
| 122 | 129 | ||
| 123 | } // namespace PList | 130 | } // namespace PList |
| 124 | |||
