summaryrefslogtreecommitdiffstats
path: root/src/Structure.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Structure.cpp')
-rw-r--r--src/Structure.cpp74
1 files changed, 74 insertions, 0 deletions
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 @@
1/*
2 * Structure.cpp
3 *
4 * Copyright (c) 2009 Jonathan Beck All Rights Reserved.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include <stdlib.h>
22#include <plist/Structure.h>
23
24namespace PList
25{
26
27Structure::Structure() : Node()
28{
29}
30Structure::Structure(plist_type type) : Node(type)
31{
32}
33
34Structure::~Structure()
35{
36}
37
38uint32_t Structure::GetSize()
39{
40 uint32_t size = 0;
41 plist_type type = plist_get_node_type(_node);
42 if (type == PLIST_ARRAY)
43 {
44 size = plist_array_get_size(_node);
45 }
46 else if (type == PLIST_DICT)
47 {
48 size = plist_dict_get_size(_node);
49 }
50 return size;
51}
52
53std::string Structure::ToXml()
54{
55 char* xml = NULL;
56 uint32_t length = 0;
57 plist_to_xml(_node, &xml, &length);
58 std::string ret(xml, xml+length);
59 free(xml);
60 return ret;
61}
62
63std::vector<char> Structure::ToBin()
64{
65 char* bin = NULL;
66 uint32_t length = 0;
67 plist_to_bin(_node, &bin, &length);
68 std::vector<char> ret(bin, bin+length);
69 free(bin);
70 return ret;
71}
72
73};
74