summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/plist/Array.h52
-rw-r--r--include/plist/Boolean.h43
-rw-r--r--include/plist/Data.h44
-rw-r--r--include/plist/Date.h43
-rw-r--r--include/plist/Dictionary.h58
-rw-r--r--include/plist/Integer.h43
-rw-r--r--include/plist/Node.h49
-rw-r--r--include/plist/Real.h43
-rw-r--r--include/plist/String.h44
-rw-r--r--include/plist/Structure.h53
-rw-r--r--include/plist/Utils.h42
-rw-r--r--include/plist/plist++.h38
-rw-r--r--src/Array.cpp194
-rw-r--r--src/Boolean.cpp52
-rw-r--r--src/CMakeLists.txt17
-rw-r--r--src/Data.cpp57
-rw-r--r--src/Date.cpp52
-rw-r--r--src/Dictionary.cpp217
-rw-r--r--src/Integer.cpp52
-rw-r--r--src/Node.cpp105
-rw-r--r--src/Real.cpp52
-rw-r--r--src/String.cpp54
-rw-r--r--src/Structure.cpp74
-rw-r--r--src/Utils.cpp74
24 files changed, 1552 insertions, 0 deletions
diff --git a/include/plist/Array.h b/include/plist/Array.h
new file mode 100644
index 0000000..8f8d992
--- /dev/null
+++ b/include/plist/Array.h
@@ -0,0 +1,52 @@
+/*
+ * Array.h
+ * Array node type for C++ binding
+ *
+ * Copyright (c) 2009 Jonathan Beck All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef STRING_H
+#define STRING_H
+
+#include <plist/Structure.h>
+#include <vector>
+
+namespace PList
+{
+
+class Array : public Structure
+{
+ public :
+ Array();
+ Array(plist_t node);
+ Array(Array& a);
+ Array& operator=(const Array& a);
+ virtual ~Array();
+
+ Node* operator[](unsigned int index);
+ void Append(Node* node);
+ void Insert(Node* node, unsigned int pos);
+ void Remove(Node* node);
+ void Remove(unsigned int pos);
+
+ private :
+ std::vector<Node*> _array;
+};
+
+};
+
+#endif // STRING_H
diff --git a/include/plist/Boolean.h b/include/plist/Boolean.h
new file mode 100644
index 0000000..89761ca
--- /dev/null
+++ b/include/plist/Boolean.h
@@ -0,0 +1,43 @@
+/*
+ * Boolean.h
+ * Boolean node type for C++ binding
+ *
+ * Copyright (c) 2009 Jonathan Beck All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef BOOLEAN_H
+#define BOOLEAN_H
+
+#include <plist/Node.h>
+
+namespace PList
+{
+
+class Boolean : public Node
+{
+ public :
+ Boolean();
+ Boolean(bool b);
+ virtual ~Boolean();
+
+ void SetValue(bool b);
+ bool GetValue();
+};
+
+};
+
+#endif // BOOLEAN_H
diff --git a/include/plist/Data.h b/include/plist/Data.h
new file mode 100644
index 0000000..f7e5cd2
--- /dev/null
+++ b/include/plist/Data.h
@@ -0,0 +1,44 @@
+/*
+ * Data.h
+ * Data node type for C++ binding
+ *
+ * Copyright (c) 2009 Jonathan Beck All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef DATA_H
+#define DATA_H
+
+#include <plist/Node.h>
+#include <vector>
+
+namespace PList
+{
+
+class Data : public Node
+{
+ public :
+ Data();
+ Data(std::vector<char>& buff);
+ virtual ~Data();
+
+ void SetValue(std::vector<char>& buff);
+ std::vector<char> GetValue();
+};
+
+};
+
+#endif // DATA_H
diff --git a/include/plist/Date.h b/include/plist/Date.h
new file mode 100644
index 0000000..df185db
--- /dev/null
+++ b/include/plist/Date.h
@@ -0,0 +1,43 @@
+/*
+ * Date.h
+ * Date node type for C++ binding
+ *
+ * Copyright (c) 2009 Jonathan Beck All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef DATE_H
+#define DATE_H
+
+#include <plist/Node.h>
+
+namespace PList
+{
+
+class Date : public Node
+{
+ public :
+ Date();
+ Date(uint64_t i);
+ virtual ~Date();
+
+ void SetValue(uint64_t i);
+ uint64_t GetValue();
+};
+
+};
+
+#endif // DATE_H
diff --git a/include/plist/Dictionary.h b/include/plist/Dictionary.h
new file mode 100644
index 0000000..8468ab5
--- /dev/null
+++ b/include/plist/Dictionary.h
@@ -0,0 +1,58 @@
+/*
+ * Dictionary.h
+ * Dictionary node type for C++ binding
+ *
+ * Copyright (c) 2009 Jonathan Beck All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef DICTIONARY_H
+#define DICTIONARY_H
+
+#include <plist/Structure.h>
+#include <map>
+#include <string>
+
+namespace PList
+{
+
+class Dictionary : public Structure
+{
+ public :
+ Dictionary();
+ Dictionary(plist_t node);
+ Dictionary(Dictionary& d);
+ Dictionary& operator=(const Dictionary& d);
+ virtual ~Dictionary();
+
+ typedef std::map<std::string,Node*>::iterator iterator;
+
+ Node* operator[](std::string& key);
+ iterator Begin();
+ iterator End();
+ void Insert(std::string& key, Node* node);
+ void Remove(Node* node);
+ void Remove(std::string& key);
+
+ private :
+ std::map<std::string,Node*> _map;
+
+
+};
+
+};
+
+#endif // DICTIONARY_H
diff --git a/include/plist/Integer.h b/include/plist/Integer.h
new file mode 100644
index 0000000..8f1ecdb
--- /dev/null
+++ b/include/plist/Integer.h
@@ -0,0 +1,43 @@
+/*
+ * Integer.h
+ * Integer node type for C++ binding
+ *
+ * Copyright (c) 2009 Jonathan Beck All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef INTEGER_H
+#define INTEGER_H
+
+#include <plist/Node.h>
+
+namespace PList
+{
+
+class Integer : public Node
+{
+ public :
+ Integer();
+ Integer(uint64_t i);
+ virtual ~Integer();
+
+ void SetValue(uint64_t i);
+ uint64_t GetValue();
+};
+
+};
+
+#endif // INTEGER_H
diff --git a/include/plist/Node.h b/include/plist/Node.h
new file mode 100644
index 0000000..0f6100e
--- /dev/null
+++ b/include/plist/Node.h
@@ -0,0 +1,49 @@
+/*
+ * Node.h
+ * Abstract node type for C++ binding
+ *
+ * Copyright (c) 2009 Jonathan Beck All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef NODE_H
+#define NODE_H
+
+#include <plist/plist.h>
+
+namespace PList
+{
+
+class Node
+{
+ public :
+ virtual ~Node();
+ Node(plist_t node);
+ Node(Node& node);
+ Node& operator=(const Node& node);
+
+ plist_type GetType();
+ plist_t GetPlist() const;
+
+ protected:
+ Node();
+ Node(plist_type type);
+ plist_t _node;
+};
+
+};
+
+#endif // NODE_H
diff --git a/include/plist/Real.h b/include/plist/Real.h
new file mode 100644
index 0000000..272f431
--- /dev/null
+++ b/include/plist/Real.h
@@ -0,0 +1,43 @@
+/*
+ * Real.h
+ * Real node type for C++ binding
+ *
+ * Copyright (c) 2009 Jonathan Beck All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef REAL_H
+#define REAL_H
+
+#include <plist/Node.h>
+
+namespace PList
+{
+
+class Real : public Node
+{
+ public :
+ Real();
+ Real(double d);
+ virtual ~Real();
+
+ void SetValue(double d);
+ double GetValue();
+};
+
+};
+
+#endif // REAL_H
diff --git a/include/plist/String.h b/include/plist/String.h
new file mode 100644
index 0000000..14becac
--- /dev/null
+++ b/include/plist/String.h
@@ -0,0 +1,44 @@
+/*
+ * String.h
+ * String node type for C++ binding
+ *
+ * Copyright (c) 2009 Jonathan Beck All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef STRING_H
+#define STRING_H
+
+#include <plist/Node.h>
+#include <string>
+
+namespace PList
+{
+
+class String : public Node
+{
+ public :
+ String();
+ String(std::string& s);
+ virtual ~String();
+
+ void SetValue(std::string& s);
+ std::string GetValue();
+};
+
+};
+
+#endif // STRING_H
diff --git a/include/plist/Structure.h b/include/plist/Structure.h
new file mode 100644
index 0000000..a0bdcbc
--- /dev/null
+++ b/include/plist/Structure.h
@@ -0,0 +1,53 @@
+/*
+ * Structure.h
+ * Structure node type for C++ binding
+ *
+ * Copyright (c) 2009 Jonathan Beck All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef STRUCTURE_H
+#define STRUCTURE_H
+
+#include <plist/Node.h>
+#include <string>
+#include <vector>
+
+namespace PList
+{
+
+class Structure : public Node
+{
+ public :
+ virtual ~Structure();
+
+ uint32_t GetSize();
+
+ std::string ToXml();
+ std::vector<char> ToBin();
+
+ protected:
+ Structure();
+ Structure(plist_type type);
+
+ private:
+ Structure(Structure& s);
+ Structure& operator=(const Structure& s);
+};
+
+};
+
+#endif // STRUCTURE_H
diff --git a/include/plist/Utils.h b/include/plist/Utils.h
new file mode 100644
index 0000000..b499635
--- /dev/null
+++ b/include/plist/Utils.h
@@ -0,0 +1,42 @@
+/*
+ * Utils.h
+ * Import functions for C++ binding
+ *
+ * Copyright (c) 2009 Jonathan Beck All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef UTILS_H
+#define UTILS_H
+
+#include <plist/Structure.h>
+#include <string>
+
+namespace PList
+{
+ class Utils
+ {
+ public:
+ static Structure* FromXml(std::string& in);
+ static Structure* FromBin(std::vector<char>& in);
+
+ private:
+ Utils();
+ ~Utils();
+ };
+};
+
+#endif // UTILS_H
diff --git a/include/plist/plist++.h b/include/plist/plist++.h
new file mode 100644
index 0000000..209d874
--- /dev/null
+++ b/include/plist/plist++.h
@@ -0,0 +1,38 @@
+/*
+ * plist++.h
+ * Main include of libplist C++ binding
+ *
+ * Copyright (c) 2009 Jonathan Beck All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef LIBPLIST++_H
+#define LIBPLIST++_H
+
+#include "plist.h"
+#include "Array.h"
+#include "Boolean.h"
+#include "Data.h"
+#include "Date.h"
+#include "Dictionary.h"
+#include "Integer.h"
+#include "Node.h"
+#include "Real.h"
+#include "String.h"
+#include "Structure.h"
+#include "Utils.h"
+
+#endif
diff --git a/src/Array.cpp b/src/Array.cpp
new file mode 100644
index 0000000..6f1d3f9
--- /dev/null
+++ b/src/Array.cpp
@@ -0,0 +1,194 @@
+/*
+ * Array.cpp
+ *
+ * Copyright (c) 2009 Jonathan Beck All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdlib.h>
+#include <plist/Array.h>
+#include <plist/Dictionary.h>
+
+namespace PList
+{
+
+Array::Array() : Structure(PLIST_ARRAY)
+{
+ _array.clear();
+}
+
+Array::Array(plist_t node) : Structure()
+{
+ _node = node;
+ uint32_t size = plist_array_get_size(_node);
+
+ for (uint32_t i = 0; i < size; i++)
+ {
+ plist_t subnode = plist_array_get_item(_node, i);
+ plist_type subtype = plist_get_node_type(subnode);
+ switch(subtype)
+ {
+ case PLIST_DICT:
+ _array.push_back( new Dictionary(subnode) );
+ break;
+ case PLIST_ARRAY:
+ _array.push_back( new Array(subnode) );
+ break;
+ case PLIST_BOOLEAN:
+ case PLIST_UINT:
+ case PLIST_REAL:
+ case PLIST_STRING:
+ case PLIST_DATE:
+ case PLIST_DATA:
+ default:
+ _array.push_back( new Node(subnode) );
+ break;
+ }
+ }
+}
+
+Array::Array(Array& a)
+{
+ plist_free(_node);
+ for (int it = 0; it < _array.size(); it++)
+ {
+ delete _array.at(it);
+ }
+ _array.clear();
+
+ _node = plist_copy(a.GetPlist());
+ uint32_t size = plist_array_get_size(_node);
+
+ for (uint32_t i = 0; i < size; i++)
+ {
+ plist_t subnode = plist_array_get_item(_node, i);
+ plist_type subtype = plist_get_node_type(subnode);
+ switch(subtype)
+ {
+ case PLIST_DICT:
+ _array.push_back( new Dictionary(subnode) );
+ break;
+ case PLIST_ARRAY:
+ _array.push_back( new Array(subnode) );
+ break;
+ case PLIST_BOOLEAN:
+ case PLIST_UINT:
+ case PLIST_REAL:
+ case PLIST_STRING:
+ case PLIST_DATE:
+ case PLIST_DATA:
+ default:
+ _array.push_back( new Node(subnode) );
+ break;
+ }
+ }
+}
+
+Array& Array::operator=(const Array& a)
+{
+ plist_free(_node);
+ for (int it = 0; it < _array.size(); it++)
+ {
+ delete _array.at(it);
+ }
+ _array.clear();
+
+ _node = plist_copy(a.GetPlist());
+ uint32_t size = plist_array_get_size(_node);
+
+ for (uint32_t i = 0; i < size; i++)
+ {
+ plist_t subnode = plist_array_get_item(_node, i);
+ plist_type subtype = plist_get_node_type(subnode);
+ switch(subtype)
+ {
+ case PLIST_DICT:
+ _array.push_back( new Dictionary(subnode) );
+ break;
+ case PLIST_ARRAY:
+ _array.push_back( new Array(subnode) );
+ break;
+ case PLIST_BOOLEAN:
+ case PLIST_UINT:
+ case PLIST_REAL:
+ case PLIST_STRING:
+ case PLIST_DATE:
+ case PLIST_DATA:
+ default:
+ _array.push_back( new Node(subnode) );
+ break;
+ }
+ }
+}
+
+Array::~Array()
+{
+ plist_free(_node);
+ for (int it = 0; it < _array.size(); it++)
+ {
+ delete _array.at(it);
+ }
+ _array.clear();
+}
+
+Node* Array::operator[](unsigned int index)
+{
+ return _array.at(index);
+}
+
+void Array::Append(Node* node)
+{
+ if (node)
+ {
+ plist_array_append_item(_node, node->GetPlist());
+ _array.push_back(node);
+ }
+}
+
+void Array::Insert(Node* node, unsigned int pos)
+{
+ if (node)
+ {
+ plist_array_insert_item(_node, node->GetPlist(), pos);
+ std::vector<Node*>::iterator it = _array.begin();
+ it += pos;
+ _array.insert(it, node);
+ }
+}
+
+void Array::Remove(Node* node)
+{
+ if (node)
+ {
+ uint32_t pos = plist_array_get_item_index(node->GetPlist());
+ plist_array_remove_item(_node, pos);
+ std::vector<Node*>::iterator it = _array.begin();
+ it += pos;
+ _array.erase(it);
+ delete node;
+ }
+}
+
+void Array::Remove(unsigned int pos)
+{
+ plist_array_remove_item(_node, pos);
+ std::vector<Node*>::iterator it = _array.begin();
+ it += pos;
+ delete _array.at(pos);
+ _array.erase(it);
+}
+
+};
diff --git a/src/Boolean.cpp b/src/Boolean.cpp
new file mode 100644
index 0000000..5797d88
--- /dev/null
+++ b/src/Boolean.cpp
@@ -0,0 +1,52 @@
+/*
+ * Boolean.cpp
+ *
+ * Copyright (c) 2009 Jonathan Beck All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdlib.h>
+#include <plist/Boolean.h>
+
+namespace PList
+{
+
+Boolean::Boolean() : Node(PLIST_BOOLEAN)
+{
+}
+
+Boolean::Boolean(bool b) : Node(PLIST_BOOLEAN)
+{
+ plist_set_bool_val(_node, b);
+}
+
+Boolean::~Boolean()
+{
+}
+
+void Boolean::SetValue(bool b)
+{
+ plist_set_bool_val(_node, b);
+}
+
+bool Boolean::GetValue()
+{
+ uint8_t b = 0;
+ plist_get_bool_val(_node, &b);
+ return b;
+}
+
+};
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ab3f694..5e03748 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -7,11 +7,28 @@ SET(libplist_SRC
bplist.c
xplist.c )
+SET(libplist++_SRC
+ Node.cpp
+ Boolean.cpp
+ Integer.cpp
+ Real.cpp
+ String.cpp
+ Date.cpp
+ Data.cpp
+ Structure.cpp
+ Array.cpp
+ Dictionary.cpp
+ Utils.cpp
+ )
+
ADD_LIBRARY( plist SHARED ${libplist_SRC} )
TARGET_LINK_LIBRARIES( plist ${LIBXML2_LIBRARIES} ${GLIB2_LIBRARIES} )
SET_TARGET_PROPERTIES( plist PROPERTIES VERSION ${LIBPLIST_LIBVERSION} )
SET_TARGET_PROPERTIES( plist PROPERTIES SOVERSION ${LIBPLIST_SOVERSION} )
+ADD_LIBRARY( plist++ SHARED ${libplist++_SRC} )
+TARGET_LINK_LIBRARIES( plist++ plist )
+
INSTALL(TARGETS plist
RUNTIME DESTINATION bin COMPONENT lib
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT dev
diff --git a/src/Data.cpp b/src/Data.cpp
new file mode 100644
index 0000000..2ce610d
--- /dev/null
+++ b/src/Data.cpp
@@ -0,0 +1,57 @@
+/*
+ * Data.cpp
+ *
+ * Copyright (c) 2009 Jonathan Beck All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdlib.h>
+#include <plist/Data.h>
+
+namespace PList
+{
+
+Data::Data() : Node(PLIST_DATA)
+{
+}
+
+Data::Data(std::vector<char>& buff) : Node(PLIST_DATA)
+{
+ plist_set_data_val(_node, &buff[0], buff.size());
+}
+
+Data::~Data()
+{
+}
+
+void Data::SetValue(std::vector<char>& buff)
+{
+ plist_set_data_val(_node, &buff[0], buff.size());
+}
+
+std::vector<char> Data::GetValue()
+{
+ char* buff = NULL;
+ uint64_t length = 0;
+ plist_get_data_val(_node, &buff, &length);
+ std::vector<char> ret(buff, buff + length);
+ free(buff);
+ return ret;
+}
+
+
+
+};
diff --git a/src/Date.cpp b/src/Date.cpp
new file mode 100644
index 0000000..56e1e8e
--- /dev/null
+++ b/src/Date.cpp
@@ -0,0 +1,52 @@
+/*
+ * Date.cpp
+ *
+ * Copyright (c) 2009 Jonathan Beck All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdlib.h>
+#include <plist/Date.h>
+
+namespace PList
+{
+
+Date::Date() : Node(PLIST_DATE)
+{
+}
+
+Date::Date(uint64_t i) : Node(PLIST_DATE)
+{
+ plist_set_date_val(_node, i, 0);
+}
+
+Date::~Date()
+{
+}
+
+void Date::SetValue(uint64_t i)
+{
+ plist_set_date_val(_node, i, 0);
+}
+
+uint64_t Date::GetValue()
+{
+ int32_t i = 0;
+ plist_get_date_val(_node, &i, &i);
+ return i;
+}
+
+};
diff --git a/src/Dictionary.cpp b/src/Dictionary.cpp
new file mode 100644
index 0000000..5bace76
--- /dev/null
+++ b/src/Dictionary.cpp
@@ -0,0 +1,217 @@
+/*
+ * Dictionary.cpp
+ *
+ * Copyright (c) 2009 Jonathan Beck All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdlib.h>
+#include <plist/Dictionary.h>
+#include <plist/Array.h>
+
+namespace PList
+{
+
+Dictionary::Dictionary() : Structure(PLIST_DICT)
+{
+}
+
+Dictionary::Dictionary(plist_t node) : Structure()
+{
+ _node = node;
+ plist_dict_iter it = NULL;
+
+ char* key = NULL;
+ plist_t subnode = NULL;
+ plist_dict_new_iter(_node, &it);
+ plist_dict_next_item(_node, it, &key, &subnode);
+ while (subnode)
+ {
+ plist_type subtype = plist_get_node_type(subnode);
+ switch(subtype)
+ {
+ case PLIST_DICT:
+ _map[std::string(key)] = new Dictionary(subnode);
+ break;
+ case PLIST_ARRAY:
+ _map[std::string(key)] = new Array(subnode);
+ break;
+ case PLIST_BOOLEAN:
+ case PLIST_UINT:
+ case PLIST_REAL:
+ case PLIST_STRING:
+ case PLIST_DATE:
+ case PLIST_DATA:
+ default:
+ _map[std::string(key)] = new Node(subnode);
+ break;
+ }
+
+ subnode = NULL;
+ free(key);
+ key = NULL;
+ plist_dict_next_item(_node, it, NULL, &subnode);
+ }
+ free(it);
+}
+
+Dictionary::Dictionary(Dictionary& d)
+{
+ for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++)
+ {
+ plist_free(it->second->GetPlist());
+ delete it->second;
+ }
+ _map.clear();
+
+ _node = plist_copy(d.GetPlist());
+ plist_dict_iter it = NULL;
+
+ char* key = NULL;
+ plist_t subnode = NULL;
+ plist_dict_new_iter(_node, &it);
+ plist_dict_next_item(_node, it, &key, &subnode);
+ while (subnode)
+ {
+ plist_type subtype = plist_get_node_type(subnode);
+ switch(subtype)
+ {
+ case PLIST_DICT:
+ _map[std::string(key)] = new Dictionary(subnode);
+ break;
+ case PLIST_ARRAY:
+ _map[std::string(key)] = new Array(subnode);
+ break;
+ case PLIST_BOOLEAN:
+ case PLIST_UINT:
+ case PLIST_REAL:
+ case PLIST_STRING:
+ case PLIST_DATE:
+ case PLIST_DATA:
+ default:
+ _map[std::string(key)] = new Node(subnode);
+ break;
+ }
+
+ subnode = NULL;
+ free(key);
+ key = NULL;
+ plist_dict_next_item(_node, it, NULL, &subnode);
+ }
+ free(it);
+}
+
+Dictionary& Dictionary::operator=(const Dictionary& d)
+{
+ for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++)
+ {
+ plist_free(it->second->GetPlist());
+ delete it->second;
+ }
+ _map.clear();
+
+ _node = plist_copy(d.GetPlist());
+ plist_dict_iter it = NULL;
+
+ char* key = NULL;
+ plist_t subnode = NULL;
+ plist_dict_new_iter(_node, &it);
+ plist_dict_next_item(_node, it, &key, &subnode);
+ while (subnode)
+ {
+ plist_type subtype = plist_get_node_type(subnode);
+ switch(subtype)
+ {
+ case PLIST_DICT:
+ _map[std::string(key)] = new Dictionary(subnode);
+ break;
+ case PLIST_ARRAY:
+ _map[std::string(key)] = new Array(subnode);
+ break;
+ case PLIST_BOOLEAN:
+ case PLIST_UINT:
+ case PLIST_REAL:
+ case PLIST_STRING:
+ case PLIST_DATE:
+ case PLIST_DATA:
+ default:
+ _map[std::string(key)] = new Node(subnode);
+ break;
+ }
+
+ subnode = NULL;
+ free(key);
+ key = NULL;
+ plist_dict_next_item(_node, it, NULL, &subnode);
+ }
+ free(it);
+}
+
+Dictionary::~Dictionary()
+{
+ for (Dictionary::iterator it = _map.begin(); it != _map.end(); it++)
+ {
+ plist_free(it->second->GetPlist());
+ delete it->second;
+ }
+ _map.clear();
+}
+
+Node* Dictionary::operator[](std::string& key)
+{
+ return _map[key];
+}
+
+Dictionary::iterator Dictionary::Begin()
+{
+ return _map.begin();
+}
+
+Dictionary::iterator Dictionary::End()
+{
+ return _map.end();
+}
+
+void Dictionary::Insert(std::string& key, Node* node)
+{
+ if (node)
+ {
+ plist_dict_insert_item(_node, key.c_str(), node->GetPlist());
+ delete _map[key];
+ _map[key] = node;
+ }
+}
+
+void Dictionary::Remove(Node* node)
+{
+ if (node)
+ {
+ char* key = NULL;
+ plist_dict_get_item_key(node->GetPlist(), &key);
+ plist_dict_remove_item(_node, key);
+ std::string skey = key;
+ free(key);
+ delete node;
+ }
+}
+
+void Dictionary::Remove(std::string& key)
+{
+ plist_dict_remove_item(_node, key.c_str());
+ delete _map[key];
+}
+
+};
diff --git a/src/Integer.cpp b/src/Integer.cpp
new file mode 100644
index 0000000..d4a7645
--- /dev/null
+++ b/src/Integer.cpp
@@ -0,0 +1,52 @@
+/*
+ * Integer.cpp
+ *
+ * Copyright (c) 2009 Jonathan Beck All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdlib.h>
+#include <plist/Integer.h>
+
+namespace PList
+{
+
+Integer::Integer() : Node(PLIST_UINT)
+{
+}
+
+Integer::Integer(uint64_t i) : Node(PLIST_UINT)
+{
+ plist_set_uint_val(_node, i);
+}
+
+Integer::~Integer()
+{
+}
+
+void Integer::SetValue(uint64_t i)
+{
+ plist_set_uint_val(_node, i);
+}
+
+uint64_t Integer::GetValue()
+{
+ uint64_t i = 0;
+ plist_get_uint_val(_node, &i);
+ return i;
+}
+
+};
diff --git a/src/Node.cpp b/src/Node.cpp
new file mode 100644
index 0000000..dbcd6d6
--- /dev/null
+++ b/src/Node.cpp
@@ -0,0 +1,105 @@
+/*
+ * Node.cpp
+ *
+ * Copyright (c) 2009 Jonathan Beck All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdlib.h>
+#include <plist/Node.h>
+
+namespace PList
+{
+
+Node::Node()
+{
+}
+
+Node::Node(plist_t node) : _node(node)
+{
+}
+
+Node::Node(plist_type type)
+{
+ _node = NULL;
+
+ switch(type) {
+ case PLIST_BOOLEAN:
+ _node = plist_new_bool(0);
+ break;
+ case PLIST_UINT:
+ _node = plist_new_uint(0);
+ break;
+ case PLIST_REAL:
+ _node = plist_new_real(0.);
+ break;
+ case PLIST_STRING:
+ _node = plist_new_string("");
+ break;
+ case PLIST_DATA:
+ _node = plist_new_data(NULL,0);
+ break;
+ case PLIST_DATE:
+ _node = plist_new_date(0,0);
+ break;
+ case PLIST_ARRAY:
+ _node = plist_new_array();
+ break;
+ case PLIST_DICT:
+ _node = plist_new_dict();
+ break;
+ case PLIST_KEY:
+ case PLIST_NONE:
+ default:
+ break;
+ }
+}
+
+Node::~Node()
+{
+ plist_free(_node);
+ _node = NULL;
+}
+
+Node::Node(Node& node)
+{
+ plist_free(_node);
+ _node = NULL;
+
+ _node = plist_copy(_node);
+}
+
+Node& Node::operator=(const Node& node)
+{
+ plist_free(_node);
+ _node = NULL;
+
+ _node = plist_copy(_node);
+}
+
+plist_type Node::GetType()
+{
+ if (_node)
+ {
+ return plist_get_node_type(_node);
+ }
+}
+
+plist_t Node::GetPlist() const
+{
+ return _node;
+}
+};
diff --git a/src/Real.cpp b/src/Real.cpp
new file mode 100644
index 0000000..41c5d87
--- /dev/null
+++ b/src/Real.cpp
@@ -0,0 +1,52 @@
+/*
+ * Real.cpp
+ *
+ * Copyright (c) 2009 Jonathan Beck All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdlib.h>
+#include <plist/Real.h>
+
+namespace PList
+{
+
+Real::Real() : Node(PLIST_REAL)
+{
+}
+
+Real::Real(double d) : Node(PLIST_REAL)
+{
+ plist_set_real_val(_node, d);
+}
+
+Real::~Real()
+{
+}
+
+void Real::SetValue(double d)
+{
+ plist_set_real_val(_node, d);
+}
+
+double Real::GetValue()
+{
+ double d = 0.;
+ plist_get_real_val(_node, &d);
+ return d;
+}
+
+};
diff --git a/src/String.cpp b/src/String.cpp
new file mode 100644
index 0000000..24b4ce8
--- /dev/null
+++ b/src/String.cpp
@@ -0,0 +1,54 @@
+/*
+ * String.cpp
+ *
+ * Copyright (c) 2009 Jonathan Beck All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdlib.h>
+#include <plist/String.h>
+
+namespace PList
+{
+
+String::String() : Node(PLIST_STRING)
+{
+}
+
+String::String(std::string& s) : Node(PLIST_STRING)
+{
+ plist_set_string_val(_node, s.c_str());
+}
+
+String::~String()
+{
+}
+
+void String::SetValue(std::string& s)
+{
+ plist_set_string_val(_node, s.c_str());
+}
+
+std::string String::GetValue()
+{
+ char* s = NULL;
+ plist_get_string_val(_node, &s);
+ std::string ret = s;
+ free(s);
+ return ret;
+}
+
+};
diff --git a/src/Structure.cpp b/src/Structure.cpp
new file mode 100644
index 0000000..6fd9b3d
--- /dev/null
+++ b/src/Structure.cpp
@@ -0,0 +1,74 @@
+/*
+ * Structure.cpp
+ *
+ * Copyright (c) 2009 Jonathan Beck All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdlib.h>
+#include <plist/Structure.h>
+
+namespace PList
+{
+
+Structure::Structure() : Node()
+{
+}
+Structure::Structure(plist_type type) : Node(type)
+{
+}
+
+Structure::~Structure()
+{
+}
+
+uint32_t Structure::GetSize()
+{
+ uint32_t size = 0;
+ plist_type type = plist_get_node_type(_node);
+ if (type == PLIST_ARRAY)
+ {
+ size = plist_array_get_size(_node);
+ }
+ else if (type == PLIST_DICT)
+ {
+ size = plist_dict_get_size(_node);
+ }
+ return size;
+}
+
+std::string Structure::ToXml()
+{
+ char* xml = NULL;
+ uint32_t length = 0;
+ plist_to_xml(_node, &xml, &length);
+ std::string ret(xml, xml+length);
+ free(xml);
+ return ret;
+}
+
+std::vector<char> Structure::ToBin()
+{
+ char* bin = NULL;
+ uint32_t length = 0;
+ plist_to_bin(_node, &bin, &length);
+ std::vector<char> ret(bin, bin+length);
+ free(bin);
+ return ret;
+}
+
+};
+
diff --git a/src/Utils.cpp b/src/Utils.cpp
new file mode 100644
index 0000000..a9d2459
--- /dev/null
+++ b/src/Utils.cpp
@@ -0,0 +1,74 @@
+/*
+ * Utils.cpp
+ *
+ * Copyright (c) 2009 Jonathan Beck All Rights Reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdlib.h>
+#include <plist/Utils.h>
+#include <plist/Dictionary.h>
+#include <plist/Array.h>
+
+namespace PList
+{
+
+static Structure* FromPlist(plist_t root)
+{
+ Structure* ret = NULL;
+ if (root)
+ {
+ plist_type type = plist_get_node_type(root);
+ switch(type)
+ {
+ case PLIST_DICT:
+ ret = new Dictionary(root);
+ break;
+ case PLIST_ARRAY:
+ ret = new Array(root);
+ break;
+ case PLIST_BOOLEAN:
+ case PLIST_UINT:
+ case PLIST_REAL:
+ case PLIST_STRING:
+ case PLIST_DATE:
+ case PLIST_DATA:
+ default:
+ plist_free(root);
+ break;
+ }
+ }
+ return ret;
+}
+
+Structure* Utils::FromXml(std::string& in)
+{
+ plist_t root = NULL;
+ plist_from_xml(in.c_str(), in.size(), &root);
+
+ return FromPlist(root);
+}
+
+Structure* Utils::FromBin(std::vector<char>& in)
+{
+ plist_t root = NULL;
+ plist_from_bin(&in[0], in.size(), &root);
+
+ return FromPlist(root);
+
+}
+
+};