From a922b714c9b75fdc67735d674758d4eaedfd32f9 Mon Sep 17 00:00:00 2001 From: Jonathan Beck Date: Tue, 13 Oct 2009 20:04:06 +0200 Subject: Add C++ binding. --- include/plist/Array.h | 52 +++++++++++++++++++++++++++++++++++++++++ include/plist/Boolean.h | 43 ++++++++++++++++++++++++++++++++++ include/plist/Data.h | 44 +++++++++++++++++++++++++++++++++++ include/plist/Date.h | 43 ++++++++++++++++++++++++++++++++++ include/plist/Dictionary.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++ include/plist/Integer.h | 43 ++++++++++++++++++++++++++++++++++ include/plist/Node.h | 49 +++++++++++++++++++++++++++++++++++++++ include/plist/Real.h | 43 ++++++++++++++++++++++++++++++++++ include/plist/String.h | 44 +++++++++++++++++++++++++++++++++++ include/plist/Structure.h | 53 ++++++++++++++++++++++++++++++++++++++++++ include/plist/Utils.h | 42 +++++++++++++++++++++++++++++++++ include/plist/plist++.h | 38 ++++++++++++++++++++++++++++++ 12 files changed, 552 insertions(+) create mode 100644 include/plist/Array.h create mode 100644 include/plist/Boolean.h create mode 100644 include/plist/Data.h create mode 100644 include/plist/Date.h create mode 100644 include/plist/Dictionary.h create mode 100644 include/plist/Integer.h create mode 100644 include/plist/Node.h create mode 100644 include/plist/Real.h create mode 100644 include/plist/String.h create mode 100644 include/plist/Structure.h create mode 100644 include/plist/Utils.h create mode 100644 include/plist/plist++.h (limited to 'include') 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 +#include + +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 _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 + +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 +#include + +namespace PList +{ + +class Data : public Node +{ + public : + Data(); + Data(std::vector& buff); + virtual ~Data(); + + void SetValue(std::vector& buff); + std::vector 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 + +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 +#include +#include + +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::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 _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 + +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 + +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 + +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 +#include + +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 +#include +#include + +namespace PList +{ + +class Structure : public Node +{ + public : + virtual ~Structure(); + + uint32_t GetSize(); + + std::string ToXml(); + std::vector 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 +#include + +namespace PList +{ + class Utils + { + public: + static Structure* FromXml(std::string& in); + static Structure* FromBin(std::vector& 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 -- cgit v1.1-32-gdbae