summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorGravatar guyingzhao2025-02-28 00:17:57 +0800
committerGravatar Nikias Bassen2025-03-01 23:42:06 +0100
commitd40f03e4090edafea75f04a1697ef0384231d333 (patch)
treee3915131a791b3ce5669ee7938ff4eb4f2c5bbba /include
parent02be84957d44ce68dcf81bada0d3250d4d81395a (diff)
downloadlibplist-d40f03e4090edafea75f04a1697ef0384231d333.tar.gz
libplist-d40f03e4090edafea75f04a1697ef0384231d333.tar.bz2
C++: Add more convenience functions to the interface
Diffstat (limited to 'include')
-rw-r--r--include/plist/Array.h10
-rw-r--r--include/plist/Dictionary.h7
-rw-r--r--include/plist/Structure.h1
3 files changed, 16 insertions, 2 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
61private : 71private :
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
64private : 69private :
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
47protected: 48protected:
48 Structure(Node* parent = NULL); 49 Structure(Node* parent = NULL);