diff options
author | Aaron Burghardt | 2014-08-15 21:59:01 -0400 |
---|---|---|
committer | Nikias Bassen | 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) } } -Array::Array(PList::Array& a) : Structure() +Array::Array(const PList::Array& a) : Structure() { _array.clear(); _node = plist_copy(a.GetPlist()); @@ -85,7 +85,7 @@ Array::~Array() _array.clear(); } -Node* Array::Clone() +Node* Array::Clone() const { return new Array(*this); } 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) { } -Boolean::Boolean(PList::Boolean& b) : Node(PLIST_BOOLEAN) +Boolean::Boolean(const PList::Boolean& b) : Node(PLIST_BOOLEAN) { plist_set_bool_val(_node, b.GetValue()); } @@ -53,7 +53,7 @@ Boolean::~Boolean() { } -Node* Boolean::Clone() +Node* Boolean::Clone() const { return new Boolean(*this); } @@ -63,7 +63,7 @@ void Boolean::SetValue(bool b) plist_set_bool_val(_node, b); } -bool Boolean::GetValue() +bool Boolean::GetValue() const { uint8_t b = 0; 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) { } -Data::Data(PList::Data& d) : Node(PLIST_DATA) +Data::Data(const PList::Data& d) : Node(PLIST_DATA) { std::vector<char> b = d.GetValue(); plist_set_data_val(_node, &b[0], b.size()); @@ -54,7 +54,7 @@ Data::~Data() { } -Node* Data::Clone() +Node* Data::Clone() const { return new Data(*this); } @@ -64,7 +64,7 @@ void Data::SetValue(const std::vector<char>& buff) plist_set_data_val(_node, &buff[0], buff.size()); } -std::vector<char> Data::GetValue() +std::vector<char> Data::GetValue() const { char* buff = NULL; 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) { } -Date::Date(PList::Date& d) : Node(PLIST_DATE) +Date::Date(const PList::Date& d) : Node(PLIST_DATE) { timeval t = d.GetValue(); plist_set_date_val(_node, t.tv_sec, t.tv_usec); @@ -54,7 +54,7 @@ Date::~Date() { } -Node* Date::Clone() +Node* Date::Clone() const { return new Date(*this); } @@ -64,7 +64,7 @@ void Date::SetValue(timeval t) plist_set_date_val(_node, t.tv_sec, t.tv_usec); } -timeval Date::GetValue() +timeval Date::GetValue() const { int32_t tv_sec = 0; 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) free(it); } -Dictionary::Dictionary(PList::Dictionary& d) : Structure() +Dictionary::Dictionary(const PList::Dictionary& d) : Structure() { for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++) { @@ -115,7 +115,7 @@ Dictionary::~Dictionary() _map.clear(); } -Node* Dictionary::Clone() +Node* Dictionary::Clone() const { return new Dictionary(*this); } @@ -140,7 +140,7 @@ Dictionary::iterator Dictionary::Find(const std::string& key) return _map.find(key); } -Dictionary::iterator Dictionary::Set(const std::string& key, Node* node) +Dictionary::iterator Dictionary::Set(const std::string& key, const Node* node) { if (node) { @@ -154,6 +154,11 @@ Dictionary::iterator Dictionary::Set(const std::string& key, Node* node) return iterator(this->_map.end()); } +Dictionary::iterator Dictionary::Set(const std::string& key, const Node& node) +{ + return Set(key, &node); +} + Dictionary::iterator Dictionary::Insert(const std::string& key, Node* node) { 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) { } -Integer::Integer(PList::Integer& i) : Node(PLIST_UINT) +Integer::Integer(const PList::Integer& i) : Node(PLIST_UINT) { plist_set_uint_val(_node, i.GetValue()); } @@ -53,7 +53,7 @@ Integer::~Integer() { } -Node* Integer::Clone() +Node* Integer::Clone() const { return new Integer(*this); } @@ -63,7 +63,7 @@ void Integer::SetValue(uint64_t i) plist_set_uint_val(_node, i); } -uint64_t Integer::GetValue() +uint64_t Integer::GetValue() const { uint64_t i = 0; 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) { } -Key::Key(PList::Key& k) : Node(PLIST_UINT) +Key::Key(const PList::Key& k) : Node(PLIST_UINT) { plist_set_key_val(_node, k.GetValue().c_str()); } @@ -53,7 +53,7 @@ Key::~Key() { } -Node* Key::Clone() +Node* Key::Clone() const { return new Key(*this); } @@ -63,7 +63,7 @@ void Key::SetValue(const std::string& s) plist_set_key_val(_node, s.c_str()); } -std::string Key::GetValue() +std::string Key::GetValue() const { char* s = NULL; 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() _parent = NULL; } -plist_type Node::GetType() +plist_type Node::GetType() const { if (_node) { @@ -102,12 +102,12 @@ plist_type Node::GetType() return PLIST_NONE; } -plist_t Node::GetPlist() +plist_t Node::GetPlist() const { return _node; } -Node* Node::GetParent() +Node* Node::GetParent() const { return _parent; } 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) { } -Real::Real(PList::Real& d) : Node(PLIST_UINT) +Real::Real(const PList::Real& d) : Node(PLIST_UINT) { plist_set_real_val(_node, d.GetValue()); } @@ -53,7 +53,7 @@ Real::~Real() { } -Node* Real::Clone() +Node* Real::Clone() const { return new Real(*this); } @@ -63,7 +63,7 @@ void Real::SetValue(double d) plist_set_real_val(_node, d); } -double Real::GetValue() +double Real::GetValue() const { double d = 0.; 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) { } -String::String(PList::String& s) : Node(PLIST_UINT) +String::String(const PList::String& s) : Node(PLIST_UINT) { plist_set_string_val(_node, s.GetValue().c_str()); } @@ -53,7 +53,7 @@ String::~String() { } -Node* String::Clone() +Node* String::Clone() const { return new String(*this); } @@ -63,7 +63,7 @@ void String::SetValue(const std::string& s) plist_set_string_val(_node, s.c_str()); } -std::string String::GetValue() +std::string String::GetValue() const { char* s = NULL; 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) { } -Uid::Uid(PList::Uid& i) : Node(PLIST_UID) +Uid::Uid(const PList::Uid& i) : Node(PLIST_UID) { plist_set_uid_val(_node, i.GetValue()); } @@ -53,7 +53,7 @@ Uid::~Uid() { } -Node* Uid::Clone() +Node* Uid::Clone() const { return new Uid(*this); } @@ -63,7 +63,7 @@ void Uid::SetValue(uint64_t i) plist_set_uid_val(_node, i); } -uint64_t Uid::GetValue() +uint64_t Uid::GetValue() const { uint64_t i = 0; plist_get_uid_val(_node, &i); |