summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2013-03-19 16:50:47 +0100
committerGravatar Nikias Bassen2013-03-19 16:50:47 +0100
commit553c3849207a29abd1cb58f82d5994e5cd9d1f2d (patch)
treeded1d25c25f4afe5c0b8aad7a8b16f64f8cee0f1
parent057fa38c02913703634da5c40753e1dafd626774 (diff)
downloadlibplist-553c3849207a29abd1cb58f82d5994e5cd9d1f2d.tar.gz
libplist-553c3849207a29abd1cb58f82d5994e5cd9d1f2d.tar.bz2
C++: added support for PLIST_UID nodes (class Uid)
-rw-r--r--include/CMakeLists.txt1
-rw-r--r--include/plist/Uid.h48
-rw-r--r--include/plist/plist++.h1
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Node.cpp7
-rw-r--r--src/Uid.cpp73
6 files changed, 131 insertions, 0 deletions
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
index ca07978..f6d3ea7 100644
--- a/include/CMakeLists.txt
+++ b/include/CMakeLists.txt
@@ -11,6 +11,7 @@ SET( libplist_HDR
11 ${CMAKE_CURRENT_SOURCE_DIR}/plist/Real.h 11 ${CMAKE_CURRENT_SOURCE_DIR}/plist/Real.h
12 ${CMAKE_CURRENT_SOURCE_DIR}/plist/String.h 12 ${CMAKE_CURRENT_SOURCE_DIR}/plist/String.h
13 ${CMAKE_CURRENT_SOURCE_DIR}/plist/Key.h 13 ${CMAKE_CURRENT_SOURCE_DIR}/plist/Key.h
14 ${CMAKE_CURRENT_SOURCE_DIR}/plist/Uid.h
14 ${CMAKE_CURRENT_SOURCE_DIR}/plist/Structure.h 15 ${CMAKE_CURRENT_SOURCE_DIR}/plist/Structure.h
15 ) 16 )
16 17
diff --git a/include/plist/Uid.h b/include/plist/Uid.h
new file mode 100644
index 0000000..62a49e7
--- /dev/null
+++ b/include/plist/Uid.h
@@ -0,0 +1,48 @@
1/*
2 * Uid.h
3 * Uid node type for C++ binding
4 *
5 * Copyright (c) 2012 Nikias Bassen, All Rights Reserved.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#ifndef PLIST__UID_H
23#define PLIST__UID_H
24
25#include <plist/Node.h>
26
27namespace PList
28{
29
30class Uid : public Node
31{
32public :
33 Uid(Node* parent = NULL);
34 Uid(plist_t node, Node* parent = NULL);
35 Uid(Uid& i);
36 Uid& operator=(Uid& i);
37 Uid(uint64_t i);
38 virtual ~Uid();
39
40 Node* Clone();
41
42 void SetValue(uint64_t i);
43 uint64_t GetValue();
44};
45
46};
47
48#endif // PLIST__UID_H
diff --git a/include/plist/plist++.h b/include/plist/plist++.h
index 0690b26..b29fc76 100644
--- a/include/plist/plist++.h
+++ b/include/plist/plist++.h
@@ -32,6 +32,7 @@
32#include "Node.h" 32#include "Node.h"
33#include "Real.h" 33#include "Real.h"
34#include "Key.h" 34#include "Key.h"
35#include "Uid.h"
35#include "String.h" 36#include "String.h"
36#include "Structure.h" 37#include "Structure.h"
37 38
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ad7362b..c4f5483 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -20,6 +20,7 @@ SET(libplist++_SRC
20 Date.cpp 20 Date.cpp
21 Data.cpp 21 Data.cpp
22 Key.cpp 22 Key.cpp
23 Uid.cpp
23 Structure.cpp 24 Structure.cpp
24 Array.cpp 25 Array.cpp
25 Dictionary.cpp 26 Dictionary.cpp
diff --git a/src/Node.cpp b/src/Node.cpp
index 35128a6..516d1ae 100644
--- a/src/Node.cpp
+++ b/src/Node.cpp
@@ -28,6 +28,7 @@
28#include <plist/Real.h> 28#include <plist/Real.h>
29#include <plist/String.h> 29#include <plist/String.h>
30#include <plist/Key.h> 30#include <plist/Key.h>
31#include <plist/Uid.h>
31#include <plist/Data.h> 32#include <plist/Data.h>
32#include <plist/Date.h> 33#include <plist/Date.h>
33 34
@@ -64,6 +65,9 @@ Node::Node(plist_type type, Node* parent) : _parent(parent)
64 _node = plist_new_string(""); 65 _node = plist_new_string("");
65 plist_set_key_val(_node, ""); 66 plist_set_key_val(_node, "");
66 break; 67 break;
68 case PLIST_UID:
69 _node = plist_new_uid(0);
70 break;
67 case PLIST_DATA: 71 case PLIST_DATA:
68 _node = plist_new_data(NULL,0); 72 _node = plist_new_data(NULL,0);
69 break; 73 break;
@@ -137,6 +141,9 @@ Node* Node::FromPlist(plist_t node, Node* parent)
137 case PLIST_KEY: 141 case PLIST_KEY:
138 ret = new Key(node, parent); 142 ret = new Key(node, parent);
139 break; 143 break;
144 case PLIST_UID:
145 ret = new Uid(node, parent);
146 break;
140 case PLIST_DATE: 147 case PLIST_DATE:
141 ret = new Date(node, parent); 148 ret = new Date(node, parent);
142 break; 149 break;
diff --git a/src/Uid.cpp b/src/Uid.cpp
new file mode 100644
index 0000000..02a59b3
--- /dev/null
+++ b/src/Uid.cpp
@@ -0,0 +1,73 @@
1/*
2 * Uid.cpp
3 *
4 * Copyright (c) 2012 Nikias Bassen, 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/Uid.h>
23
24namespace PList
25{
26
27Uid::Uid(Node* parent) : Node(PLIST_UID, parent)
28{
29}
30
31Uid::Uid(plist_t node, Node* parent) : Node(node, parent)
32{
33}
34
35Uid::Uid(PList::Uid& i) : Node(PLIST_UID)
36{
37 plist_set_uid_val(_node, i.GetValue());
38}
39
40Uid& Uid::operator=(PList::Uid& i)
41{
42 plist_free(_node);
43 _node = plist_copy(i.GetPlist());
44 return *this;
45}
46
47Uid::Uid(uint64_t i) : Node(PLIST_UID)
48{
49 plist_set_uid_val(_node, i);
50}
51
52Uid::~Uid()
53{
54}
55
56Node* Uid::Clone()
57{
58 return new Uid(*this);
59}
60
61void Uid::SetValue(uint64_t i)
62{
63 plist_set_uid_val(_node, i);
64}
65
66uint64_t Uid::GetValue()
67{
68 uint64_t i = 0;
69 plist_get_uid_val(_node, &i);
70 return i;
71}
72
73};