diff options
| -rw-r--r-- | include/plist/Array.h | 6 | ||||
| -rw-r--r-- | include/plist/Boolean.h | 4 | ||||
| -rw-r--r-- | include/plist/Data.h | 8 | ||||
| -rw-r--r-- | include/plist/Date.h | 4 | ||||
| -rw-r--r-- | include/plist/Dictionary.h | 12 | ||||
| -rw-r--r-- | include/plist/Integer.h | 4 | ||||
| -rw-r--r-- | include/plist/Node.h | 8 | ||||
| -rw-r--r-- | include/plist/Real.h | 4 | ||||
| -rw-r--r-- | include/plist/String.h | 8 | ||||
| -rw-r--r-- | include/plist/Utils.h | 4 | ||||
| -rw-r--r-- | src/Array.cpp | 36 | ||||
| -rw-r--r-- | src/Boolean.cpp | 16 | ||||
| -rw-r--r-- | src/Data.cpp | 21 | ||||
| -rw-r--r-- | src/Date.cpp | 15 | ||||
| -rw-r--r-- | src/Dictionary.cpp | 20 | ||||
| -rw-r--r-- | src/Integer.cpp | 16 | ||||
| -rw-r--r-- | src/Node.cpp | 18 | ||||
| -rw-r--r-- | src/Real.cpp | 16 | ||||
| -rw-r--r-- | src/String.cpp | 20 | ||||
| -rw-r--r-- | src/Utils.cpp | 4 |
20 files changed, 179 insertions, 65 deletions
diff --git a/include/plist/Array.h b/include/plist/Array.h index f990928..106555d 100644 --- a/include/plist/Array.h +++ b/include/plist/Array.h | |||
| @@ -34,9 +34,11 @@ class Array : public Structure | |||
| 34 | Array(); | 34 | Array(); |
| 35 | Array(plist_t node); | 35 | Array(plist_t node); |
| 36 | Array(Array& a); | 36 | Array(Array& a); |
| 37 | Array& operator=(const Array& a); | 37 | Array& operator=(Array& a); |
| 38 | virtual ~Array(); | 38 | virtual ~Array(); |
| 39 | 39 | ||
| 40 | Node* Clone(); | ||
| 41 | |||
| 40 | Node* operator[](unsigned int index); | 42 | Node* operator[](unsigned int index); |
| 41 | void Append(Node* node); | 43 | void Append(Node* node); |
| 42 | void Insert(Node* node, unsigned int pos); | 44 | void Insert(Node* node, unsigned int pos); |
diff --git a/include/plist/Boolean.h b/include/plist/Boolean.h index 01b5b85..917bc9d 100644 --- a/include/plist/Boolean.h +++ b/include/plist/Boolean.h | |||
| @@ -32,9 +32,13 @@ class Boolean : public Node | |||
| 32 | public : | 32 | public : |
| 33 | Boolean(); | 33 | Boolean(); |
| 34 | Boolean(plist_t node); | 34 | Boolean(plist_t node); |
| 35 | Boolean(Boolean& b); | ||
| 36 | Boolean& operator=(Boolean& b); | ||
| 35 | Boolean(bool b); | 37 | Boolean(bool b); |
| 36 | virtual ~Boolean(); | 38 | virtual ~Boolean(); |
| 37 | 39 | ||
| 40 | Node* Clone(); | ||
| 41 | |||
| 38 | void SetValue(bool b); | 42 | void SetValue(bool b); |
| 39 | bool GetValue(); | 43 | bool GetValue(); |
| 40 | }; | 44 | }; |
diff --git a/include/plist/Data.h b/include/plist/Data.h index 92bda0a..86a26d9 100644 --- a/include/plist/Data.h +++ b/include/plist/Data.h | |||
| @@ -33,10 +33,14 @@ class Data : public Node | |||
| 33 | public : | 33 | public : |
| 34 | Data(); | 34 | Data(); |
| 35 | Data(plist_t node); | 35 | Data(plist_t node); |
| 36 | Data(std::vector<char>& buff); | 36 | Data(Data& d); |
| 37 | Data& operator=(Data& d); | ||
| 38 | Data(const std::vector<char>& buff); | ||
| 37 | virtual ~Data(); | 39 | virtual ~Data(); |
| 38 | 40 | ||
| 39 | void SetValue(std::vector<char>& buff); | 41 | Node* Clone(); |
| 42 | |||
| 43 | void SetValue(const std::vector<char>& buff); | ||
| 40 | std::vector<char> GetValue(); | 44 | std::vector<char> GetValue(); |
| 41 | }; | 45 | }; |
| 42 | 46 | ||
diff --git a/include/plist/Date.h b/include/plist/Date.h index 78d8601..e9645aa 100644 --- a/include/plist/Date.h +++ b/include/plist/Date.h | |||
| @@ -32,9 +32,13 @@ class Date : public Node | |||
| 32 | public : | 32 | public : |
| 33 | Date(); | 33 | Date(); |
| 34 | Date(plist_t node); | 34 | Date(plist_t node); |
| 35 | Date(Date& d); | ||
| 36 | Date& operator=(Date& d); | ||
| 35 | Date(uint64_t i); | 37 | Date(uint64_t i); |
| 36 | virtual ~Date(); | 38 | virtual ~Date(); |
| 37 | 39 | ||
| 40 | Node* Clone(); | ||
| 41 | |||
| 38 | void SetValue(uint64_t i); | 42 | void SetValue(uint64_t i); |
| 39 | uint64_t GetValue(); | 43 | uint64_t GetValue(); |
| 40 | }; | 44 | }; |
diff --git a/include/plist/Dictionary.h b/include/plist/Dictionary.h index 8468ab5..6169774 100644 --- a/include/plist/Dictionary.h +++ b/include/plist/Dictionary.h | |||
| @@ -35,17 +35,19 @@ class Dictionary : public Structure | |||
| 35 | Dictionary(); | 35 | Dictionary(); |
| 36 | Dictionary(plist_t node); | 36 | Dictionary(plist_t node); |
| 37 | Dictionary(Dictionary& d); | 37 | Dictionary(Dictionary& d); |
| 38 | Dictionary& operator=(const Dictionary& d); | 38 | Dictionary& operator=(Dictionary& d); |
| 39 | virtual ~Dictionary(); | 39 | virtual ~Dictionary(); |
| 40 | 40 | ||
| 41 | Node* Clone(); | ||
| 42 | |||
| 41 | typedef std::map<std::string,Node*>::iterator iterator; | 43 | typedef std::map<std::string,Node*>::iterator iterator; |
| 42 | 44 | ||
| 43 | Node* operator[](std::string& key); | 45 | Node* operator[](const std::string& key); |
| 44 | iterator Begin(); | 46 | iterator Begin(); |
| 45 | iterator End(); | 47 | iterator End(); |
| 46 | void Insert(std::string& key, Node* node); | 48 | void Insert(const std::string& key, Node* node); |
| 47 | void Remove(Node* node); | 49 | void Remove(Node* node); |
| 48 | void Remove(std::string& key); | 50 | void Remove(const std::string& key); |
| 49 | 51 | ||
| 50 | private : | 52 | private : |
| 51 | std::map<std::string,Node*> _map; | 53 | std::map<std::string,Node*> _map; |
diff --git a/include/plist/Integer.h b/include/plist/Integer.h index 823e3a0..3a3a0e3 100644 --- a/include/plist/Integer.h +++ b/include/plist/Integer.h | |||
| @@ -32,9 +32,13 @@ class Integer : public Node | |||
| 32 | public : | 32 | public : |
| 33 | Integer(); | 33 | Integer(); |
| 34 | Integer(plist_t node); | 34 | Integer(plist_t node); |
| 35 | Integer(Integer& i); | ||
| 36 | Integer& operator=(Integer& i); | ||
| 35 | Integer(uint64_t i); | 37 | Integer(uint64_t i); |
| 36 | virtual ~Integer(); | 38 | virtual ~Integer(); |
| 37 | 39 | ||
| 40 | Node* Clone(); | ||
| 41 | |||
| 38 | void SetValue(uint64_t i); | 42 | void SetValue(uint64_t i); |
| 39 | uint64_t GetValue(); | 43 | uint64_t GetValue(); |
| 40 | }; | 44 | }; |
diff --git a/include/plist/Node.h b/include/plist/Node.h index 3be900a..a59d469 100644 --- a/include/plist/Node.h +++ b/include/plist/Node.h | |||
| @@ -31,11 +31,11 @@ class Node | |||
| 31 | { | 31 | { |
| 32 | public : | 32 | public : |
| 33 | virtual ~Node(); | 33 | virtual ~Node(); |
| 34 | Node(Node& node); | 34 | |
| 35 | Node& operator=(const Node& node); | 35 | virtual Node* Clone() = 0; |
| 36 | 36 | ||
| 37 | plist_type GetType(); | 37 | plist_type GetType(); |
| 38 | plist_t GetPlist() const; | 38 | plist_t GetPlist(); |
| 39 | 39 | ||
| 40 | protected: | 40 | protected: |
| 41 | Node(); | 41 | Node(); |
diff --git a/include/plist/Real.h b/include/plist/Real.h index 8d898c7..c0095e4 100644 --- a/include/plist/Real.h +++ b/include/plist/Real.h | |||
| @@ -32,9 +32,13 @@ class Real : public Node | |||
| 32 | public : | 32 | public : |
| 33 | Real(); | 33 | Real(); |
| 34 | Real(plist_t node); | 34 | Real(plist_t node); |
| 35 | Real(Real& d); | ||
| 36 | Real& operator=(Real& d); | ||
| 35 | Real(double d); | 37 | Real(double d); |
| 36 | virtual ~Real(); | 38 | virtual ~Real(); |
| 37 | 39 | ||
| 40 | Node* Clone(); | ||
| 41 | |||
| 38 | void SetValue(double d); | 42 | void SetValue(double d); |
| 39 | double GetValue(); | 43 | double GetValue(); |
| 40 | }; | 44 | }; |
diff --git a/include/plist/String.h b/include/plist/String.h index 5314065..769c98b 100644 --- a/include/plist/String.h +++ b/include/plist/String.h | |||
| @@ -33,10 +33,14 @@ class String : public Node | |||
| 33 | public : | 33 | public : |
| 34 | String(); | 34 | String(); |
| 35 | String(plist_t node); | 35 | String(plist_t node); |
| 36 | String(std::string& s); | 36 | String(String& s); |
| 37 | String& operator=(String& s); | ||
| 38 | String(const std::string& s); | ||
| 37 | virtual ~String(); | 39 | virtual ~String(); |
| 38 | 40 | ||
| 39 | void SetValue(std::string& s); | 41 | Node* Clone(); |
| 42 | |||
| 43 | void SetValue(const std::string& s); | ||
| 40 | std::string GetValue(); | 44 | std::string GetValue(); |
| 41 | }; | 45 | }; |
| 42 | 46 | ||
diff --git a/include/plist/Utils.h b/include/plist/Utils.h index b499635..f3e2685 100644 --- a/include/plist/Utils.h +++ b/include/plist/Utils.h | |||
| @@ -30,8 +30,8 @@ namespace PList | |||
| 30 | class Utils | 30 | class Utils |
| 31 | { | 31 | { |
| 32 | public: | 32 | public: |
| 33 | static Structure* FromXml(std::string& in); | 33 | static Structure* FromXml(const std::string& in); |
| 34 | static Structure* FromBin(std::vector<char>& in); | 34 | static Structure* FromBin(const std::vector<char>& in); |
| 35 | 35 | ||
| 36 | private: | 36 | private: |
| 37 | Utils(); | 37 | Utils(); |
diff --git a/src/Array.cpp b/src/Array.cpp index 0505a27..b85a114 100644 --- a/src/Array.cpp +++ b/src/Array.cpp | |||
| @@ -77,15 +77,9 @@ Array::Array(plist_t node) : Structure() | |||
| 77 | } | 77 | } |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | Array::Array(Array& a) | 80 | Array::Array(PList::Array& a) : Structure() |
| 81 | { | 81 | { |
| 82 | plist_free(_node); | ||
| 83 | for (int it = 0; it < _array.size(); it++) | ||
| 84 | { | ||
| 85 | delete _array.at(it); | ||
| 86 | } | ||
| 87 | _array.clear(); | 82 | _array.clear(); |
| 88 | |||
| 89 | _node = plist_copy(a.GetPlist()); | 83 | _node = plist_copy(a.GetPlist()); |
| 90 | uint32_t size = plist_array_get_size(_node); | 84 | uint32_t size = plist_array_get_size(_node); |
| 91 | 85 | ||
| @@ -125,7 +119,7 @@ Array::Array(Array& a) | |||
| 125 | } | 119 | } |
| 126 | } | 120 | } |
| 127 | 121 | ||
| 128 | Array& Array::operator=(const Array& a) | 122 | Array& Array::operator=(PList::Array& a) |
| 129 | { | 123 | { |
| 130 | plist_free(_node); | 124 | plist_free(_node); |
| 131 | for (int it = 0; it < _array.size(); it++) | 125 | for (int it = 0; it < _array.size(); it++) |
| @@ -175,12 +169,16 @@ Array& Array::operator=(const Array& a) | |||
| 175 | 169 | ||
| 176 | Array::~Array() | 170 | Array::~Array() |
| 177 | { | 171 | { |
| 178 | plist_free(_node); | 172 | for (int it = 0; it < _array.size(); it++) |
| 179 | for (int it = 0; it < _array.size(); it++) | 173 | { |
| 180 | { | 174 | delete (_array.at(it)); |
| 181 | delete _array.at(it); | 175 | } |
| 182 | } | 176 | _array.clear(); |
| 183 | _array.clear(); | 177 | } |
| 178 | |||
| 179 | Node* Array::Clone() | ||
| 180 | { | ||
| 181 | return new Array(*this); | ||
| 184 | } | 182 | } |
| 185 | 183 | ||
| 186 | Node* Array::operator[](unsigned int index) | 184 | Node* Array::operator[](unsigned int index) |
| @@ -192,8 +190,9 @@ void Array::Append(Node* node) | |||
| 192 | { | 190 | { |
| 193 | if (node) | 191 | if (node) |
| 194 | { | 192 | { |
| 195 | plist_array_append_item(_node, node->GetPlist()); | 193 | Node* clone = node->Clone(); |
| 196 | _array.push_back(node); | 194 | plist_array_append_item(_node, clone->GetPlist()); |
| 195 | _array.push_back(clone); | ||
| 197 | } | 196 | } |
| 198 | } | 197 | } |
| 199 | 198 | ||
| @@ -201,10 +200,11 @@ void Array::Insert(Node* node, unsigned int pos) | |||
| 201 | { | 200 | { |
| 202 | if (node) | 201 | if (node) |
| 203 | { | 202 | { |
| 204 | plist_array_insert_item(_node, node->GetPlist(), pos); | 203 | Node* clone = node->Clone(); |
| 204 | plist_array_insert_item(_node, clone->GetPlist(), pos); | ||
| 205 | std::vector<Node*>::iterator it = _array.begin(); | 205 | std::vector<Node*>::iterator it = _array.begin(); |
| 206 | it += pos; | 206 | it += pos; |
| 207 | _array.insert(it, node); | 207 | _array.insert(it, clone); |
| 208 | } | 208 | } |
| 209 | } | 209 | } |
| 210 | 210 | ||
diff --git a/src/Boolean.cpp b/src/Boolean.cpp index cc704c9..03d17c8 100644 --- a/src/Boolean.cpp +++ b/src/Boolean.cpp | |||
| @@ -32,6 +32,17 @@ Boolean::Boolean(plist_t node) : Node(node) | |||
| 32 | { | 32 | { |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | Boolean::Boolean(PList::Boolean& b) : Node(PLIST_BOOLEAN) | ||
| 36 | { | ||
| 37 | plist_set_bool_val(_node, b.GetValue()); | ||
| 38 | } | ||
| 39 | |||
| 40 | Boolean& Boolean::operator=(PList::Boolean& b) | ||
| 41 | { | ||
| 42 | plist_free(_node); | ||
| 43 | _node = plist_copy(b.GetPlist()); | ||
| 44 | } | ||
| 45 | |||
| 35 | Boolean::Boolean(bool b) : Node(PLIST_BOOLEAN) | 46 | Boolean::Boolean(bool b) : Node(PLIST_BOOLEAN) |
| 36 | { | 47 | { |
| 37 | plist_set_bool_val(_node, b); | 48 | plist_set_bool_val(_node, b); |
| @@ -41,6 +52,11 @@ Boolean::~Boolean() | |||
| 41 | { | 52 | { |
| 42 | } | 53 | } |
| 43 | 54 | ||
| 55 | Node* Boolean::Clone() | ||
| 56 | { | ||
| 57 | return new Boolean(*this); | ||
| 58 | } | ||
| 59 | |||
| 44 | void Boolean::SetValue(bool b) | 60 | void Boolean::SetValue(bool b) |
| 45 | { | 61 | { |
| 46 | plist_set_bool_val(_node, b); | 62 | plist_set_bool_val(_node, b); |
diff --git a/src/Data.cpp b/src/Data.cpp index 53adfa4..87a508a 100644 --- a/src/Data.cpp +++ b/src/Data.cpp | |||
| @@ -32,7 +32,19 @@ Data::Data(plist_t node) : Node(node) | |||
| 32 | { | 32 | { |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | Data::Data(std::vector<char>& buff) : Node(PLIST_DATA) | 35 | Data::Data(PList::Data& d) : Node(PLIST_DATA) |
| 36 | { | ||
| 37 | std::vector<char> b = d.GetValue(); | ||
| 38 | plist_set_data_val(_node, &b[0], b.size()); | ||
| 39 | } | ||
| 40 | |||
| 41 | Data& Data::operator=(PList::Data& b) | ||
| 42 | { | ||
| 43 | plist_free(_node); | ||
| 44 | _node = plist_copy(b.GetPlist()); | ||
| 45 | } | ||
| 46 | |||
| 47 | Data::Data(const std::vector<char>& buff) : Node(PLIST_DATA) | ||
| 36 | { | 48 | { |
| 37 | plist_set_data_val(_node, &buff[0], buff.size()); | 49 | plist_set_data_val(_node, &buff[0], buff.size()); |
| 38 | } | 50 | } |
| @@ -41,7 +53,12 @@ Data::~Data() | |||
| 41 | { | 53 | { |
| 42 | } | 54 | } |
| 43 | 55 | ||
| 44 | void Data::SetValue(std::vector<char>& buff) | 56 | Node* Data::Clone() |
| 57 | { | ||
| 58 | return new Data(*this); | ||
| 59 | } | ||
| 60 | |||
| 61 | void Data::SetValue(const std::vector<char>& buff) | ||
| 45 | { | 62 | { |
| 46 | plist_set_data_val(_node, &buff[0], buff.size()); | 63 | plist_set_data_val(_node, &buff[0], buff.size()); |
| 47 | } | 64 | } |
diff --git a/src/Date.cpp b/src/Date.cpp index f6a6f42..18e1d27 100644 --- a/src/Date.cpp +++ b/src/Date.cpp | |||
| @@ -32,6 +32,16 @@ Date::Date(plist_t node) : Node(node) | |||
| 32 | { | 32 | { |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | Date::Date(Date& d) : Node(PLIST_DATE) | ||
| 36 | { | ||
| 37 | //TODO | ||
| 38 | } | ||
| 39 | |||
| 40 | Date& Date::operator=(PList::Date& b) | ||
| 41 | { | ||
| 42 | //TODO | ||
| 43 | } | ||
| 44 | |||
| 35 | Date::Date(uint64_t i) : Node(PLIST_DATE) | 45 | Date::Date(uint64_t i) : Node(PLIST_DATE) |
| 36 | { | 46 | { |
| 37 | plist_set_date_val(_node, i, 0); | 47 | plist_set_date_val(_node, i, 0); |
| @@ -41,6 +51,11 @@ Date::~Date() | |||
| 41 | { | 51 | { |
| 42 | } | 52 | } |
| 43 | 53 | ||
| 54 | Node* Date::Clone() | ||
| 55 | { | ||
| 56 | return new Date(*this); | ||
| 57 | } | ||
| 58 | |||
| 44 | void Date::SetValue(uint64_t i) | 59 | void Date::SetValue(uint64_t i) |
| 45 | { | 60 | { |
| 46 | plist_set_date_val(_node, i, 0); | 61 | plist_set_date_val(_node, i, 0); |
diff --git a/src/Dictionary.cpp b/src/Dictionary.cpp index 6879e33..15df0b4 100644 --- a/src/Dictionary.cpp +++ b/src/Dictionary.cpp | |||
| @@ -85,7 +85,7 @@ Dictionary::Dictionary(plist_t node) : Structure() | |||
| 85 | free(it); | 85 | free(it); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | Dictionary::Dictionary(Dictionary& d) | 88 | Dictionary::Dictionary(PList::Dictionary& d) : Structure() |
| 89 | { | 89 | { |
| 90 | for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++) | 90 | for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++) |
| 91 | { | 91 | { |
| @@ -142,7 +142,7 @@ Dictionary::Dictionary(Dictionary& d) | |||
| 142 | free(it); | 142 | free(it); |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | Dictionary& Dictionary::operator=(const Dictionary& d) | 145 | Dictionary& Dictionary::operator=(PList::Dictionary& d) |
| 146 | { | 146 | { |
| 147 | for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++) | 147 | for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++) |
| 148 | { | 148 | { |
| @@ -209,7 +209,12 @@ Dictionary::~Dictionary() | |||
| 209 | _map.clear(); | 209 | _map.clear(); |
| 210 | } | 210 | } |
| 211 | 211 | ||
| 212 | Node* Dictionary::operator[](std::string& key) | 212 | Node* Dictionary::Clone() |
| 213 | { | ||
| 214 | return new Dictionary(*this); | ||
| 215 | } | ||
| 216 | |||
| 217 | Node* Dictionary::operator[](const std::string& key) | ||
| 213 | { | 218 | { |
| 214 | return _map[key]; | 219 | return _map[key]; |
| 215 | } | 220 | } |
| @@ -224,13 +229,14 @@ Dictionary::iterator Dictionary::End() | |||
| 224 | return _map.end(); | 229 | return _map.end(); |
| 225 | } | 230 | } |
| 226 | 231 | ||
| 227 | void Dictionary::Insert(std::string& key, Node* node) | 232 | void Dictionary::Insert(const std::string& key, Node* node) |
| 228 | { | 233 | { |
| 229 | if (node) | 234 | if (node) |
| 230 | { | 235 | { |
| 231 | plist_dict_insert_item(_node, key.c_str(), node->GetPlist()); | 236 | Node* clone = node->Clone(); |
| 237 | plist_dict_insert_item(_node, key.c_str(), clone->GetPlist()); | ||
| 232 | delete _map[key]; | 238 | delete _map[key]; |
| 233 | _map[key] = node; | 239 | _map[key] = clone; |
| 234 | } | 240 | } |
| 235 | } | 241 | } |
| 236 | 242 | ||
| @@ -247,7 +253,7 @@ void Dictionary::Remove(Node* node) | |||
| 247 | } | 253 | } |
| 248 | } | 254 | } |
| 249 | 255 | ||
| 250 | void Dictionary::Remove(std::string& key) | 256 | void Dictionary::Remove(const std::string& key) |
| 251 | { | 257 | { |
| 252 | plist_dict_remove_item(_node, key.c_str()); | 258 | plist_dict_remove_item(_node, key.c_str()); |
| 253 | delete _map[key]; | 259 | delete _map[key]; |
diff --git a/src/Integer.cpp b/src/Integer.cpp index 2a7429a..cf1ad33 100644 --- a/src/Integer.cpp +++ b/src/Integer.cpp | |||
| @@ -32,6 +32,17 @@ Integer::Integer(plist_t node) : Node(node) | |||
| 32 | { | 32 | { |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | Integer::Integer(PList::Integer& i) : Node(PLIST_UINT) | ||
| 36 | { | ||
| 37 | plist_set_uint_val(_node, i.GetValue()); | ||
| 38 | } | ||
| 39 | |||
| 40 | Integer& Integer::operator=(PList::Integer& i) | ||
| 41 | { | ||
| 42 | plist_free(_node); | ||
| 43 | _node = plist_copy(i.GetPlist()); | ||
| 44 | } | ||
| 45 | |||
| 35 | Integer::Integer(uint64_t i) : Node(PLIST_UINT) | 46 | Integer::Integer(uint64_t i) : Node(PLIST_UINT) |
| 36 | { | 47 | { |
| 37 | plist_set_uint_val(_node, i); | 48 | plist_set_uint_val(_node, i); |
| @@ -41,6 +52,11 @@ Integer::~Integer() | |||
| 41 | { | 52 | { |
| 42 | } | 53 | } |
| 43 | 54 | ||
| 55 | Node* Integer::Clone() | ||
| 56 | { | ||
| 57 | return new Integer(*this); | ||
| 58 | } | ||
| 59 | |||
| 44 | void Integer::SetValue(uint64_t i) | 60 | void Integer::SetValue(uint64_t i) |
| 45 | { | 61 | { |
| 46 | plist_set_uint_val(_node, i); | 62 | plist_set_uint_val(_node, i); |
diff --git a/src/Node.cpp b/src/Node.cpp index dbcd6d6..ace1990 100644 --- a/src/Node.cpp +++ b/src/Node.cpp | |||
| @@ -74,22 +74,6 @@ Node::~Node() | |||
| 74 | _node = NULL; | 74 | _node = NULL; |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | Node::Node(Node& node) | ||
| 78 | { | ||
| 79 | plist_free(_node); | ||
| 80 | _node = NULL; | ||
| 81 | |||
| 82 | _node = plist_copy(_node); | ||
| 83 | } | ||
| 84 | |||
| 85 | Node& Node::operator=(const Node& node) | ||
| 86 | { | ||
| 87 | plist_free(_node); | ||
| 88 | _node = NULL; | ||
| 89 | |||
| 90 | _node = plist_copy(_node); | ||
| 91 | } | ||
| 92 | |||
| 93 | plist_type Node::GetType() | 77 | plist_type Node::GetType() |
| 94 | { | 78 | { |
| 95 | if (_node) | 79 | if (_node) |
| @@ -98,7 +82,7 @@ plist_type Node::GetType() | |||
| 98 | } | 82 | } |
| 99 | } | 83 | } |
| 100 | 84 | ||
| 101 | plist_t Node::GetPlist() const | 85 | plist_t Node::GetPlist() |
| 102 | { | 86 | { |
| 103 | return _node; | 87 | return _node; |
| 104 | } | 88 | } |
diff --git a/src/Real.cpp b/src/Real.cpp index 5416887..e527f6d 100644 --- a/src/Real.cpp +++ b/src/Real.cpp | |||
| @@ -32,6 +32,17 @@ Real::Real(plist_t node) : Node(node) | |||
| 32 | { | 32 | { |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | Real::Real(PList::Real& d) : Node(PLIST_UINT) | ||
| 36 | { | ||
| 37 | plist_set_real_val(_node, d.GetValue()); | ||
| 38 | } | ||
| 39 | |||
| 40 | Real& Real::operator=(PList::Real& d) | ||
| 41 | { | ||
| 42 | plist_free(_node); | ||
| 43 | _node = plist_copy(d.GetPlist()); | ||
| 44 | } | ||
| 45 | |||
| 35 | Real::Real(double d) : Node(PLIST_REAL) | 46 | Real::Real(double d) : Node(PLIST_REAL) |
| 36 | { | 47 | { |
| 37 | plist_set_real_val(_node, d); | 48 | plist_set_real_val(_node, d); |
| @@ -41,6 +52,11 @@ Real::~Real() | |||
| 41 | { | 52 | { |
| 42 | } | 53 | } |
| 43 | 54 | ||
| 55 | Node* Real::Clone() | ||
| 56 | { | ||
| 57 | return new Real(*this); | ||
| 58 | } | ||
| 59 | |||
| 44 | void Real::SetValue(double d) | 60 | void Real::SetValue(double d) |
| 45 | { | 61 | { |
| 46 | plist_set_real_val(_node, d); | 62 | plist_set_real_val(_node, d); |
diff --git a/src/String.cpp b/src/String.cpp index 7bf744c..dbc81ac 100644 --- a/src/String.cpp +++ b/src/String.cpp | |||
| @@ -32,7 +32,18 @@ String::String(plist_t node) : Node(node) | |||
| 32 | { | 32 | { |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | String::String(std::string& s) : Node(PLIST_STRING) | 35 | String::String(PList::String& s) : Node(PLIST_UINT) |
| 36 | { | ||
| 37 | plist_set_string_val(_node, s.GetValue().c_str()); | ||
| 38 | } | ||
| 39 | |||
| 40 | String& String::operator=(PList::String& s) | ||
| 41 | { | ||
| 42 | plist_free(_node); | ||
| 43 | _node = plist_copy(s.GetPlist()); | ||
| 44 | } | ||
| 45 | |||
| 46 | String::String(const std::string& s) : Node(PLIST_STRING) | ||
| 36 | { | 47 | { |
| 37 | plist_set_string_val(_node, s.c_str()); | 48 | plist_set_string_val(_node, s.c_str()); |
| 38 | } | 49 | } |
| @@ -41,7 +52,12 @@ String::~String() | |||
| 41 | { | 52 | { |
| 42 | } | 53 | } |
| 43 | 54 | ||
| 44 | void String::SetValue(std::string& s) | 55 | Node* String::Clone() |
| 56 | { | ||
| 57 | return new String(*this); | ||
| 58 | } | ||
| 59 | |||
| 60 | void String::SetValue(const std::string& s) | ||
| 45 | { | 61 | { |
| 46 | plist_set_string_val(_node, s.c_str()); | 62 | plist_set_string_val(_node, s.c_str()); |
| 47 | } | 63 | } |
diff --git a/src/Utils.cpp b/src/Utils.cpp index a9d2459..4e47994 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp | |||
| @@ -54,7 +54,7 @@ static Structure* FromPlist(plist_t root) | |||
| 54 | return ret; | 54 | return ret; |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | Structure* Utils::FromXml(std::string& in) | 57 | Structure* Utils::FromXml(const std::string& in) |
| 58 | { | 58 | { |
| 59 | plist_t root = NULL; | 59 | plist_t root = NULL; |
| 60 | plist_from_xml(in.c_str(), in.size(), &root); | 60 | plist_from_xml(in.c_str(), in.size(), &root); |
| @@ -62,7 +62,7 @@ Structure* Utils::FromXml(std::string& in) | |||
| 62 | return FromPlist(root); | 62 | return FromPlist(root); |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | Structure* Utils::FromBin(std::vector<char>& in) | 65 | Structure* Utils::FromBin(const std::vector<char>& in) |
| 66 | { | 66 | { |
| 67 | plist_t root = NULL; | 67 | plist_t root = NULL; |
| 68 | plist_from_bin(&in[0], in.size(), &root); | 68 | plist_from_bin(&in[0], in.size(), &root); |
