summaryrefslogtreecommitdiffstats
path: root/src/Node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Node.cpp')
-rw-r--r--src/Node.cpp105
1 files changed, 105 insertions, 0 deletions
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 @@
1/*
2 * Node.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/Node.h>
23
24namespace PList
25{
26
27Node::Node()
28{
29}
30
31Node::Node(plist_t node) : _node(node)
32{
33}
34
35Node::Node(plist_type type)
36{
37 _node = NULL;
38
39 switch(type) {
40 case PLIST_BOOLEAN:
41 _node = plist_new_bool(0);
42 break;
43 case PLIST_UINT:
44 _node = plist_new_uint(0);
45 break;
46 case PLIST_REAL:
47 _node = plist_new_real(0.);
48 break;
49 case PLIST_STRING:
50 _node = plist_new_string("");
51 break;
52 case PLIST_DATA:
53 _node = plist_new_data(NULL,0);
54 break;
55 case PLIST_DATE:
56 _node = plist_new_date(0,0);
57 break;
58 case PLIST_ARRAY:
59 _node = plist_new_array();
60 break;
61 case PLIST_DICT:
62 _node = plist_new_dict();
63 break;
64 case PLIST_KEY:
65 case PLIST_NONE:
66 default:
67 break;
68 }
69}
70
71Node::~Node()
72{
73 plist_free(_node);
74 _node = NULL;
75}
76
77Node::Node(Node& node)
78{
79 plist_free(_node);
80 _node = NULL;
81
82 _node = plist_copy(_node);
83}
84
85Node& Node::operator=(const Node& node)
86{
87 plist_free(_node);
88 _node = NULL;
89
90 _node = plist_copy(_node);
91}
92
93plist_type Node::GetType()
94{
95 if (_node)
96 {
97 return plist_get_node_type(_node);
98 }
99}
100
101plist_t Node::GetPlist() const
102{
103 return _node;
104}
105};