diff options
| author | 2014-08-15 21:59:01 -0400 | |
|---|---|---|
| committer | 2014-09-20 00:10:46 +0200 | |
| commit | ccd6f05fe1e6cd5a1611b0df78974fa39869013d (patch) | |
| tree | 3c9e2c431d85cfb683de1724b121819aa16d29aa /src | |
| parent | bc147d80b5a608b8a0478041e5198093ecd767b8 (diff) | |
| download | libplist-ccd6f05fe1e6cd5a1611b0df78974fa39869013d.tar.gz libplist-ccd6f05fe1e6cd5a1611b0df78974fa39869013d.tar.bz2 | |
Change Clone() to be const, which required constructors with const references and a const GetValue().
Diffstat (limited to 'src')
| -rw-r--r-- | src/Array.cpp | 4 | ||||
| -rw-r--r-- | src/Boolean.cpp | 6 | ||||
| -rw-r--r-- | src/Data.cpp | 6 | ||||
| -rw-r--r-- | src/Date.cpp | 6 | ||||
| -rw-r--r-- | src/Dictionary.cpp | 11 | ||||
| -rw-r--r-- | src/Integer.cpp | 6 | ||||
| -rw-r--r-- | src/Key.cpp | 6 | ||||
| -rw-r--r-- | src/Node.cpp | 6 | ||||
| -rw-r--r-- | src/Real.cpp | 6 | ||||
| -rw-r--r-- | src/String.cpp | 6 | ||||
| -rw-r--r-- | src/Uid.cpp | 6 |
11 files changed, 37 insertions, 32 deletions
diff --git a/src/Array.cpp b/src/Array.cpp index a4ea02a..3036476 100644 --- a/src/Array.cpp +++ b/src/Array.cpp | |||
| @@ -43,7 +43,7 @@ Array::Array(plist_t node, Node* parent) : Structure(parent) | |||
| 43 | } | 43 | } |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | Array::Array(PList::Array& a) : Structure() | 46 | Array::Array(const PList::Array& a) : Structure() |
| 47 | { | 47 | { |
| 48 | _array.clear(); | 48 | _array.clear(); |
| 49 | _node = plist_copy(a.GetPlist()); | 49 | _node = plist_copy(a.GetPlist()); |
| @@ -85,7 +85,7 @@ Array::~Array() | |||
| 85 | _array.clear(); | 85 | _array.clear(); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | Node* Array::Clone() | 88 | Node* Array::Clone() const |
| 89 | { | 89 | { |
| 90 | return new Array(*this); | 90 | return new Array(*this); |
| 91 | } | 91 | } |
diff --git a/src/Boolean.cpp b/src/Boolean.cpp index e58472f..4608eaf 100644 --- a/src/Boolean.cpp +++ b/src/Boolean.cpp | |||
| @@ -32,7 +32,7 @@ Boolean::Boolean(plist_t node, Node* parent) : Node(node, parent) | |||
| 32 | { | 32 | { |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | Boolean::Boolean(PList::Boolean& b) : Node(PLIST_BOOLEAN) | 35 | Boolean::Boolean(const PList::Boolean& b) : Node(PLIST_BOOLEAN) |
| 36 | { | 36 | { |
| 37 | plist_set_bool_val(_node, b.GetValue()); | 37 | plist_set_bool_val(_node, b.GetValue()); |
| 38 | } | 38 | } |
| @@ -53,7 +53,7 @@ Boolean::~Boolean() | |||
| 53 | { | 53 | { |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | Node* Boolean::Clone() | 56 | Node* Boolean::Clone() const |
| 57 | { | 57 | { |
| 58 | return new Boolean(*this); | 58 | return new Boolean(*this); |
| 59 | } | 59 | } |
| @@ -63,7 +63,7 @@ void Boolean::SetValue(bool b) | |||
| 63 | plist_set_bool_val(_node, b); | 63 | plist_set_bool_val(_node, b); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | bool Boolean::GetValue() | 66 | bool Boolean::GetValue() const |
| 67 | { | 67 | { |
| 68 | uint8_t b = 0; | 68 | uint8_t b = 0; |
| 69 | plist_get_bool_val(_node, &b); | 69 | plist_get_bool_val(_node, &b); |
diff --git a/src/Data.cpp b/src/Data.cpp index df5c1c7..2e93007 100644 --- a/src/Data.cpp +++ b/src/Data.cpp | |||
| @@ -32,7 +32,7 @@ Data::Data(plist_t node, Node* parent) : Node(node, parent) | |||
| 32 | { | 32 | { |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | Data::Data(PList::Data& d) : Node(PLIST_DATA) | 35 | Data::Data(const PList::Data& d) : Node(PLIST_DATA) |
| 36 | { | 36 | { |
| 37 | std::vector<char> b = d.GetValue(); | 37 | std::vector<char> b = d.GetValue(); |
| 38 | plist_set_data_val(_node, &b[0], b.size()); | 38 | plist_set_data_val(_node, &b[0], b.size()); |
| @@ -54,7 +54,7 @@ Data::~Data() | |||
| 54 | { | 54 | { |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | Node* Data::Clone() | 57 | Node* Data::Clone() const |
| 58 | { | 58 | { |
| 59 | return new Data(*this); | 59 | return new Data(*this); |
| 60 | } | 60 | } |
| @@ -64,7 +64,7 @@ void Data::SetValue(const std::vector<char>& buff) | |||
| 64 | plist_set_data_val(_node, &buff[0], buff.size()); | 64 | plist_set_data_val(_node, &buff[0], buff.size()); |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | std::vector<char> Data::GetValue() | 67 | std::vector<char> Data::GetValue() const |
| 68 | { | 68 | { |
| 69 | char* buff = NULL; | 69 | char* buff = NULL; |
| 70 | uint64_t length = 0; | 70 | uint64_t length = 0; |
diff --git a/src/Date.cpp b/src/Date.cpp index 2430184..4b5e0a1 100644 --- a/src/Date.cpp +++ b/src/Date.cpp | |||
| @@ -32,7 +32,7 @@ Date::Date(plist_t node, Node* parent) : Node(node, parent) | |||
| 32 | { | 32 | { |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | Date::Date(PList::Date& d) : Node(PLIST_DATE) | 35 | Date::Date(const PList::Date& d) : Node(PLIST_DATE) |
| 36 | { | 36 | { |
| 37 | timeval t = d.GetValue(); | 37 | timeval t = d.GetValue(); |
| 38 | plist_set_date_val(_node, t.tv_sec, t.tv_usec); | 38 | plist_set_date_val(_node, t.tv_sec, t.tv_usec); |
| @@ -54,7 +54,7 @@ Date::~Date() | |||
| 54 | { | 54 | { |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | Node* Date::Clone() | 57 | Node* Date::Clone() const |
| 58 | { | 58 | { |
| 59 | return new Date(*this); | 59 | return new Date(*this); |
| 60 | } | 60 | } |
| @@ -64,7 +64,7 @@ void Date::SetValue(timeval t) | |||
| 64 | plist_set_date_val(_node, t.tv_sec, t.tv_usec); | 64 | plist_set_date_val(_node, t.tv_sec, t.tv_usec); |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | timeval Date::GetValue() | 67 | timeval Date::GetValue() const |
| 68 | { | 68 | { |
| 69 | int32_t tv_sec = 0; | 69 | int32_t tv_sec = 0; |
| 70 | int32_t tv_usec = 0; | 70 | int32_t tv_usec = 0; |
diff --git a/src/Dictionary.cpp b/src/Dictionary.cpp index 6009ea4..98eeb93 100644 --- a/src/Dictionary.cpp +++ b/src/Dictionary.cpp | |||
| @@ -49,7 +49,7 @@ Dictionary::Dictionary(plist_t node, Node* parent) : Structure(parent) | |||
| 49 | free(it); | 49 | free(it); |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | Dictionary::Dictionary(PList::Dictionary& d) : Structure() | 52 | Dictionary::Dictionary(const PList::Dictionary& d) : Structure() |
| 53 | { | 53 | { |
| 54 | for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++) | 54 | for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++) |
| 55 | { | 55 | { |
| @@ -115,7 +115,7 @@ Dictionary::~Dictionary() | |||
| 115 | _map.clear(); | 115 | _map.clear(); |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | Node* Dictionary::Clone() | 118 | Node* Dictionary::Clone() const |
| 119 | { | 119 | { |
| 120 | return new Dictionary(*this); | 120 | return new Dictionary(*this); |
| 121 | } | 121 | } |
| @@ -140,7 +140,7 @@ Dictionary::iterator Dictionary::Find(const std::string& key) | |||
| 140 | return _map.find(key); | 140 | return _map.find(key); |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | Dictionary::iterator Dictionary::Set(const std::string& key, Node* node) | 143 | Dictionary::iterator Dictionary::Set(const std::string& key, const Node* node) |
| 144 | { | 144 | { |
| 145 | if (node) | 145 | if (node) |
| 146 | { | 146 | { |
| @@ -154,6 +154,11 @@ Dictionary::iterator Dictionary::Set(const std::string& key, Node* node) | |||
| 154 | return iterator(this->_map.end()); | 154 | return iterator(this->_map.end()); |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | Dictionary::iterator Dictionary::Set(const std::string& key, const Node& node) | ||
| 158 | { | ||
| 159 | return Set(key, &node); | ||
| 160 | } | ||
| 161 | |||
| 157 | Dictionary::iterator Dictionary::Insert(const std::string& key, Node* node) | 162 | Dictionary::iterator Dictionary::Insert(const std::string& key, Node* node) |
| 158 | { | 163 | { |
| 159 | return this->Set(key, node); | 164 | return this->Set(key, node); |
diff --git a/src/Integer.cpp b/src/Integer.cpp index fed03f6..04315d7 100644 --- a/src/Integer.cpp +++ b/src/Integer.cpp | |||
| @@ -32,7 +32,7 @@ Integer::Integer(plist_t node, Node* parent) : Node(node, parent) | |||
| 32 | { | 32 | { |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | Integer::Integer(PList::Integer& i) : Node(PLIST_UINT) | 35 | Integer::Integer(const PList::Integer& i) : Node(PLIST_UINT) |
| 36 | { | 36 | { |
| 37 | plist_set_uint_val(_node, i.GetValue()); | 37 | plist_set_uint_val(_node, i.GetValue()); |
| 38 | } | 38 | } |
| @@ -53,7 +53,7 @@ Integer::~Integer() | |||
| 53 | { | 53 | { |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | Node* Integer::Clone() | 56 | Node* Integer::Clone() const |
| 57 | { | 57 | { |
| 58 | return new Integer(*this); | 58 | return new Integer(*this); |
| 59 | } | 59 | } |
| @@ -63,7 +63,7 @@ void Integer::SetValue(uint64_t i) | |||
| 63 | plist_set_uint_val(_node, i); | 63 | plist_set_uint_val(_node, i); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | uint64_t Integer::GetValue() | 66 | uint64_t Integer::GetValue() const |
| 67 | { | 67 | { |
| 68 | uint64_t i = 0; | 68 | uint64_t i = 0; |
| 69 | plist_get_uint_val(_node, &i); | 69 | plist_get_uint_val(_node, &i); |
diff --git a/src/Key.cpp b/src/Key.cpp index 4145f05..e3ccbe6 100644 --- a/src/Key.cpp +++ b/src/Key.cpp | |||
| @@ -32,7 +32,7 @@ Key::Key(plist_t node, Node* parent) : Node(node, parent) | |||
| 32 | { | 32 | { |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | Key::Key(PList::Key& k) : Node(PLIST_UINT) | 35 | Key::Key(const PList::Key& k) : Node(PLIST_UINT) |
| 36 | { | 36 | { |
| 37 | plist_set_key_val(_node, k.GetValue().c_str()); | 37 | plist_set_key_val(_node, k.GetValue().c_str()); |
| 38 | } | 38 | } |
| @@ -53,7 +53,7 @@ Key::~Key() | |||
| 53 | { | 53 | { |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | Node* Key::Clone() | 56 | Node* Key::Clone() const |
| 57 | { | 57 | { |
| 58 | return new Key(*this); | 58 | return new Key(*this); |
| 59 | } | 59 | } |
| @@ -63,7 +63,7 @@ void Key::SetValue(const std::string& s) | |||
| 63 | plist_set_key_val(_node, s.c_str()); | 63 | plist_set_key_val(_node, s.c_str()); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | std::string Key::GetValue() | 66 | std::string Key::GetValue() const |
| 67 | { | 67 | { |
| 68 | char* s = NULL; | 68 | char* s = NULL; |
| 69 | plist_get_key_val(_node, &s); | 69 | plist_get_key_val(_node, &s); |
diff --git a/src/Node.cpp b/src/Node.cpp index 516d1ae..aaadd52 100644 --- a/src/Node.cpp +++ b/src/Node.cpp | |||
| @@ -93,7 +93,7 @@ Node::~Node() | |||
| 93 | _parent = NULL; | 93 | _parent = NULL; |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | plist_type Node::GetType() | 96 | plist_type Node::GetType() const |
| 97 | { | 97 | { |
| 98 | if (_node) | 98 | if (_node) |
| 99 | { | 99 | { |
| @@ -102,12 +102,12 @@ plist_type Node::GetType() | |||
| 102 | return PLIST_NONE; | 102 | return PLIST_NONE; |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | plist_t Node::GetPlist() | 105 | plist_t Node::GetPlist() const |
| 106 | { | 106 | { |
| 107 | return _node; | 107 | return _node; |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | Node* Node::GetParent() | 110 | Node* Node::GetParent() const |
| 111 | { | 111 | { |
| 112 | return _parent; | 112 | return _parent; |
| 113 | } | 113 | } |
diff --git a/src/Real.cpp b/src/Real.cpp index 768d07c..ec300c9 100644 --- a/src/Real.cpp +++ b/src/Real.cpp | |||
| @@ -32,7 +32,7 @@ Real::Real(plist_t node, Node* parent) : Node(node, parent) | |||
| 32 | { | 32 | { |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | Real::Real(PList::Real& d) : Node(PLIST_UINT) | 35 | Real::Real(const PList::Real& d) : Node(PLIST_UINT) |
| 36 | { | 36 | { |
| 37 | plist_set_real_val(_node, d.GetValue()); | 37 | plist_set_real_val(_node, d.GetValue()); |
| 38 | } | 38 | } |
| @@ -53,7 +53,7 @@ Real::~Real() | |||
| 53 | { | 53 | { |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | Node* Real::Clone() | 56 | Node* Real::Clone() const |
| 57 | { | 57 | { |
| 58 | return new Real(*this); | 58 | return new Real(*this); |
| 59 | } | 59 | } |
| @@ -63,7 +63,7 @@ void Real::SetValue(double d) | |||
| 63 | plist_set_real_val(_node, d); | 63 | plist_set_real_val(_node, d); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | double Real::GetValue() | 66 | double Real::GetValue() const |
| 67 | { | 67 | { |
| 68 | double d = 0.; | 68 | double d = 0.; |
| 69 | plist_get_real_val(_node, &d); | 69 | plist_get_real_val(_node, &d); |
diff --git a/src/String.cpp b/src/String.cpp index bf65605..09b47b5 100644 --- a/src/String.cpp +++ b/src/String.cpp | |||
| @@ -32,7 +32,7 @@ String::String(plist_t node, Node* parent) : Node(node, parent) | |||
| 32 | { | 32 | { |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | String::String(PList::String& s) : Node(PLIST_UINT) | 35 | String::String(const PList::String& s) : Node(PLIST_UINT) |
| 36 | { | 36 | { |
| 37 | plist_set_string_val(_node, s.GetValue().c_str()); | 37 | plist_set_string_val(_node, s.GetValue().c_str()); |
| 38 | } | 38 | } |
| @@ -53,7 +53,7 @@ String::~String() | |||
| 53 | { | 53 | { |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | Node* String::Clone() | 56 | Node* String::Clone() const |
| 57 | { | 57 | { |
| 58 | return new String(*this); | 58 | return new String(*this); |
| 59 | } | 59 | } |
| @@ -63,7 +63,7 @@ void String::SetValue(const std::string& s) | |||
| 63 | plist_set_string_val(_node, s.c_str()); | 63 | plist_set_string_val(_node, s.c_str()); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | std::string String::GetValue() | 66 | std::string String::GetValue() const |
| 67 | { | 67 | { |
| 68 | char* s = NULL; | 68 | char* s = NULL; |
| 69 | plist_get_string_val(_node, &s); | 69 | plist_get_string_val(_node, &s); |
diff --git a/src/Uid.cpp b/src/Uid.cpp index 02a59b3..440dec4 100644 --- a/src/Uid.cpp +++ b/src/Uid.cpp | |||
| @@ -32,7 +32,7 @@ Uid::Uid(plist_t node, Node* parent) : Node(node, parent) | |||
| 32 | { | 32 | { |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | Uid::Uid(PList::Uid& i) : Node(PLIST_UID) | 35 | Uid::Uid(const PList::Uid& i) : Node(PLIST_UID) |
| 36 | { | 36 | { |
| 37 | plist_set_uid_val(_node, i.GetValue()); | 37 | plist_set_uid_val(_node, i.GetValue()); |
| 38 | } | 38 | } |
| @@ -53,7 +53,7 @@ Uid::~Uid() | |||
| 53 | { | 53 | { |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | Node* Uid::Clone() | 56 | Node* Uid::Clone() const |
| 57 | { | 57 | { |
| 58 | return new Uid(*this); | 58 | return new Uid(*this); |
| 59 | } | 59 | } |
| @@ -63,7 +63,7 @@ void Uid::SetValue(uint64_t i) | |||
| 63 | plist_set_uid_val(_node, i); | 63 | plist_set_uid_val(_node, i); |
| 64 | } | 64 | } |
| 65 | 65 | ||
| 66 | uint64_t Uid::GetValue() | 66 | uint64_t Uid::GetValue() const |
| 67 | { | 67 | { |
| 68 | uint64_t i = 0; | 68 | uint64_t i = 0; |
| 69 | plist_get_uid_val(_node, &i); | 69 | plist_get_uid_val(_node, &i); |
