Commit ccd6f05f authored by Aaron Burghardt's avatar Aaron Burghardt Committed by Nikias Bassen

Change Clone() to be const, which required constructors with const references...

Change Clone() to be const, which required constructors with const references and a const GetValue().
parent bc147d80
......@@ -33,11 +33,11 @@ class Array : public Structure
public :
Array(Node* parent = NULL);
Array(plist_t node, Node* parent = NULL);
Array(Array& a);
Array(const Array& a);
Array& operator=(Array& a);
virtual ~Array();
Node* Clone();
Node* Clone() const;
Node* operator[](unsigned int index);
void Append(Node* node);
......
......@@ -32,15 +32,15 @@ class Boolean : public Node
public :
Boolean(Node* parent = NULL);
Boolean(plist_t node, Node* parent = NULL);
Boolean(Boolean& b);
Boolean(const Boolean& b);
Boolean& operator=(Boolean& b);
Boolean(bool b);
virtual ~Boolean();
Node* Clone();
Node* Clone() const;
void SetValue(bool b);
bool GetValue();
bool GetValue() const;
};
};
......
......@@ -33,15 +33,15 @@ class Data : public Node
public :
Data(Node* parent = NULL);
Data(plist_t node, Node* parent = NULL);
Data(Data& d);
Data(const Data& d);
Data& operator=(Data& d);
Data(const std::vector<char>& buff);
virtual ~Data();
Node* Clone();
Node* Clone() const;
void SetValue(const std::vector<char>& buff);
std::vector<char> GetValue();
std::vector<char> GetValue() const;
};
};
......
......@@ -34,15 +34,15 @@ class Date : public Node
public :
Date(Node* parent = NULL);
Date(plist_t node, Node* parent = NULL);
Date(Date& d);
Date(const Date& d);
Date& operator=(Date& d);
Date(timeval t);
virtual ~Date();
Node* Clone();
Node* Clone() const;
void SetValue(timeval t);
timeval GetValue();
timeval GetValue() const;
};
};
......
......@@ -34,11 +34,11 @@ class Dictionary : public Structure
public :
Dictionary(Node* parent = NULL);
Dictionary(plist_t node, Node* parent = NULL);
Dictionary(Dictionary& d);
Dictionary(const Dictionary& d);
Dictionary& operator=(Dictionary& d);
virtual ~Dictionary();
Node* Clone();
Node* Clone() const;
typedef std::map<std::string,Node*>::iterator iterator;
......@@ -46,7 +46,8 @@ public :
iterator Begin();
iterator End();
iterator Find(const std::string& key);
iterator Set(const std::string& key, Node* node);
iterator Set(const std::string& key, const Node* node);
iterator Set(const std::string& key, const Node& node);
iterator Insert(const std::string& key, Node* node) PLIST_WARN_DEPRECATED("use Set() instead");
void Remove(Node* node);
void Remove(const std::string& key);
......
......@@ -32,15 +32,15 @@ class Integer : public Node
public :
Integer(Node* parent = NULL);
Integer(plist_t node, Node* parent = NULL);
Integer(Integer& i);
Integer(const Integer& i);
Integer& operator=(Integer& i);
Integer(uint64_t i);
virtual ~Integer();
Node* Clone();
Node* Clone() const;
void SetValue(uint64_t i);
uint64_t GetValue();
uint64_t GetValue() const;
};
};
......
......@@ -33,15 +33,15 @@ class Key : public Node
public :
Key(Node* parent = NULL);
Key(plist_t node, Node* parent = NULL);
Key(Key& s);
Key(const Key& s);
Key& operator=(Key& s);
Key(const std::string& s);
virtual ~Key();
Node* Clone();
Node* Clone() const;
void SetValue(const std::string& s);
std::string GetValue();
std::string GetValue() const;
};
};
......
......@@ -32,11 +32,11 @@ class Node
public :
virtual ~Node();
virtual Node* Clone() = 0;
virtual Node* Clone() const = 0;
Node * GetParent();
plist_type GetType();
plist_t GetPlist();
Node * GetParent() const;
plist_type GetType() const;
plist_t GetPlist() const;
static Node* FromPlist(plist_t node, Node* parent = NULL);
......
......@@ -32,15 +32,15 @@ class Real : public Node
public :
Real(Node* parent = NULL);
Real(plist_t node, Node* parent = NULL);
Real(Real& d);
Real(const Real& d);
Real& operator=(Real& d);
Real(double d);
virtual ~Real();
Node* Clone();
Node* Clone() const;
void SetValue(double d);
double GetValue();
double GetValue() const;
};
};
......
......@@ -33,15 +33,15 @@ class String : public Node
public :
String(Node* parent = NULL);
String(plist_t node, Node* parent = NULL);
String(String& s);
String(const String& s);
String& operator=(String& s);
String(const std::string& s);
virtual ~String();
Node* Clone();
Node* Clone() const;
void SetValue(const std::string& s);
std::string GetValue();
std::string GetValue() const;
};
};
......
......@@ -32,15 +32,15 @@ class Uid : public Node
public :
Uid(Node* parent = NULL);
Uid(plist_t node, Node* parent = NULL);
Uid(Uid& i);
Uid(const Uid& i);
Uid& operator=(Uid& i);
Uid(uint64_t i);
virtual ~Uid();
Node* Clone();
Node* Clone() const;
void SetValue(uint64_t i);
uint64_t GetValue();
uint64_t GetValue() const;
};
};
......
......@@ -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);
}
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment