Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libplist
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pwn
libplist
Commits
c1363bea
Commit
c1363bea
authored
Oct 26, 2009
by
Jonathan Beck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Set/Get Parent and a helper to create a Node from a plist_t.
parent
bef50c08
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
113 additions
and
245 deletions
+113
-245
Array.h
include/plist/Array.h
+2
-2
Boolean.h
include/plist/Boolean.h
+2
-2
Data.h
include/plist/Data.h
+2
-2
Date.h
include/plist/Date.h
+2
-2
Dictionary.h
include/plist/Dictionary.h
+2
-2
Integer.h
include/plist/Integer.h
+2
-2
Node.h
include/plist/Node.h
+6
-3
Real.h
include/plist/Real.h
+2
-2
String.h
include/plist/String.h
+2
-2
Structure.h
include/plist/Structure.h
+2
-2
Utils.h
include/plist/Utils.h
+1
-0
Array.cpp
src/Array.cpp
+8
-99
Boolean.cpp
src/Boolean.cpp
+2
-2
Data.cpp
src/Data.cpp
+2
-2
Date.cpp
src/Date.cpp
+2
-2
Dictionary.cpp
src/Dictionary.cpp
+7
-99
Integer.cpp
src/Integer.cpp
+2
-2
Node.cpp
src/Node.cpp
+15
-3
Real.cpp
src/Real.cpp
+2
-2
String.cpp
src/String.cpp
+2
-2
Structure.cpp
src/Structure.cpp
+2
-2
Utils.cpp
src/Utils.cpp
+44
-9
No files found.
include/plist/Array.h
View file @
c1363bea
...
@@ -31,8 +31,8 @@ namespace PList
...
@@ -31,8 +31,8 @@ namespace PList
class
Array
:
public
Structure
class
Array
:
public
Structure
{
{
public
:
public
:
Array
(
);
Array
(
Node
*
parent
=
NULL
);
Array
(
plist_t
node
);
Array
(
plist_t
node
,
Node
*
parent
=
NULL
);
Array
(
Array
&
a
);
Array
(
Array
&
a
);
Array
&
operator
=
(
Array
&
a
);
Array
&
operator
=
(
Array
&
a
);
virtual
~
Array
();
virtual
~
Array
();
...
...
include/plist/Boolean.h
View file @
c1363bea
...
@@ -30,8 +30,8 @@ namespace PList
...
@@ -30,8 +30,8 @@ namespace PList
class
Boolean
:
public
Node
class
Boolean
:
public
Node
{
{
public
:
public
:
Boolean
(
);
Boolean
(
Node
*
parent
=
NULL
);
Boolean
(
plist_t
node
);
Boolean
(
plist_t
node
,
Node
*
parent
=
NULL
);
Boolean
(
Boolean
&
b
);
Boolean
(
Boolean
&
b
);
Boolean
&
operator
=
(
Boolean
&
b
);
Boolean
&
operator
=
(
Boolean
&
b
);
Boolean
(
bool
b
);
Boolean
(
bool
b
);
...
...
include/plist/Data.h
View file @
c1363bea
...
@@ -31,8 +31,8 @@ namespace PList
...
@@ -31,8 +31,8 @@ namespace PList
class
Data
:
public
Node
class
Data
:
public
Node
{
{
public
:
public
:
Data
(
);
Data
(
Node
*
parent
=
NULL
);
Data
(
plist_t
node
);
Data
(
plist_t
node
,
Node
*
parent
=
NULL
);
Data
(
Data
&
d
);
Data
(
Data
&
d
);
Data
&
operator
=
(
Data
&
d
);
Data
&
operator
=
(
Data
&
d
);
Data
(
const
std
::
vector
<
char
>&
buff
);
Data
(
const
std
::
vector
<
char
>&
buff
);
...
...
include/plist/Date.h
View file @
c1363bea
...
@@ -31,8 +31,8 @@ namespace PList
...
@@ -31,8 +31,8 @@ namespace PList
class
Date
:
public
Node
class
Date
:
public
Node
{
{
public
:
public
:
Date
(
);
Date
(
Node
*
parent
=
NULL
);
Date
(
plist_t
node
);
Date
(
plist_t
node
,
Node
*
parent
=
NULL
);
Date
(
Date
&
d
);
Date
(
Date
&
d
);
Date
&
operator
=
(
Date
&
d
);
Date
&
operator
=
(
Date
&
d
);
Date
(
timeval
t
);
Date
(
timeval
t
);
...
...
include/plist/Dictionary.h
View file @
c1363bea
...
@@ -32,8 +32,8 @@ namespace PList
...
@@ -32,8 +32,8 @@ namespace PList
class
Dictionary
:
public
Structure
class
Dictionary
:
public
Structure
{
{
public
:
public
:
Dictionary
(
);
Dictionary
(
Node
*
parent
=
NULL
);
Dictionary
(
plist_t
node
);
Dictionary
(
plist_t
node
,
Node
*
parent
=
NULL
);
Dictionary
(
Dictionary
&
d
);
Dictionary
(
Dictionary
&
d
);
Dictionary
&
operator
=
(
Dictionary
&
d
);
Dictionary
&
operator
=
(
Dictionary
&
d
);
virtual
~
Dictionary
();
virtual
~
Dictionary
();
...
...
include/plist/Integer.h
View file @
c1363bea
...
@@ -30,8 +30,8 @@ namespace PList
...
@@ -30,8 +30,8 @@ namespace PList
class
Integer
:
public
Node
class
Integer
:
public
Node
{
{
public
:
public
:
Integer
(
);
Integer
(
Node
*
parent
=
NULL
);
Integer
(
plist_t
node
);
Integer
(
plist_t
node
,
Node
*
parent
=
NULL
);
Integer
(
Integer
&
i
);
Integer
(
Integer
&
i
);
Integer
&
operator
=
(
Integer
&
i
);
Integer
&
operator
=
(
Integer
&
i
);
Integer
(
uint64_t
i
);
Integer
(
uint64_t
i
);
...
...
include/plist/Node.h
View file @
c1363bea
...
@@ -33,15 +33,18 @@ class Node
...
@@ -33,15 +33,18 @@ class Node
virtual
~
Node
();
virtual
~
Node
();
virtual
Node
*
Clone
()
=
0
;
virtual
Node
*
Clone
()
=
0
;
Node
*
GetParent
();
void
SetParent
(
Node
*
parent
);
plist_type
GetType
();
plist_type
GetType
();
plist_t
GetPlist
();
plist_t
GetPlist
();
protected
:
protected
:
Node
(
);
Node
(
Node
*
parent
=
NULL
);
Node
(
plist_t
node
);
Node
(
plist_t
node
,
Node
*
parent
=
NULL
);
Node
(
plist_type
type
);
Node
(
plist_type
type
,
Node
*
parent
=
NULL
);
plist_t
_node
;
plist_t
_node
;
Node
*
_parent
;
};
};
};
};
...
...
include/plist/Real.h
View file @
c1363bea
...
@@ -30,8 +30,8 @@ namespace PList
...
@@ -30,8 +30,8 @@ namespace PList
class
Real
:
public
Node
class
Real
:
public
Node
{
{
public
:
public
:
Real
(
);
Real
(
Node
*
parent
=
NULL
);
Real
(
plist_t
node
);
Real
(
plist_t
node
,
Node
*
parent
=
NULL
);
Real
(
Real
&
d
);
Real
(
Real
&
d
);
Real
&
operator
=
(
Real
&
d
);
Real
&
operator
=
(
Real
&
d
);
Real
(
double
d
);
Real
(
double
d
);
...
...
include/plist/String.h
View file @
c1363bea
...
@@ -31,8 +31,8 @@ namespace PList
...
@@ -31,8 +31,8 @@ namespace PList
class
String
:
public
Node
class
String
:
public
Node
{
{
public
:
public
:
String
(
);
String
(
Node
*
parent
=
NULL
);
String
(
plist_t
node
);
String
(
plist_t
node
,
Node
*
parent
=
NULL
);
String
(
String
&
s
);
String
(
String
&
s
);
String
&
operator
=
(
String
&
s
);
String
&
operator
=
(
String
&
s
);
String
(
const
std
::
string
&
s
);
String
(
const
std
::
string
&
s
);
...
...
include/plist/Structure.h
View file @
c1363bea
...
@@ -40,8 +40,8 @@ class Structure : public Node
...
@@ -40,8 +40,8 @@ class Structure : public Node
std
::
vector
<
char
>
ToBin
();
std
::
vector
<
char
>
ToBin
();
protected
:
protected
:
Structure
(
);
Structure
(
Node
*
parent
=
NULL
);
Structure
(
plist_type
type
);
Structure
(
plist_type
type
,
Node
*
parent
=
NULL
);
private
:
private
:
Structure
(
Structure
&
s
);
Structure
(
Structure
&
s
);
...
...
include/plist/Utils.h
View file @
c1363bea
...
@@ -30,6 +30,7 @@ namespace PList
...
@@ -30,6 +30,7 @@ namespace PList
class
Utils
class
Utils
{
{
public
:
public
:
static
Node
*
FromPlist
(
plist_t
node
,
Node
*
parent
=
NULL
);
static
Structure
*
FromXml
(
const
std
::
string
&
in
);
static
Structure
*
FromXml
(
const
std
::
string
&
in
);
static
Structure
*
FromBin
(
const
std
::
vector
<
char
>&
in
);
static
Structure
*
FromBin
(
const
std
::
vector
<
char
>&
in
);
...
...
src/Array.cpp
View file @
c1363bea
...
@@ -20,23 +20,17 @@
...
@@ -20,23 +20,17 @@
#include <stdlib.h>
#include <stdlib.h>
#include <plist/Array.h>
#include <plist/Array.h>
#include <plist/Dictionary.h>
#include <plist/Utils.h>
#include <plist/Boolean.h>
#include <plist/Integer.h>
#include <plist/Real.h>
#include <plist/String.h>
#include <plist/Date.h>
#include <plist/Data.h>
namespace
PList
namespace
PList
{
{
Array
::
Array
(
)
:
Structure
(
PLIST_ARRAY
)
Array
::
Array
(
Node
*
parent
)
:
Structure
(
PLIST_ARRAY
,
parent
)
{
{
_array
.
clear
();
_array
.
clear
();
}
}
Array
::
Array
(
plist_t
node
)
:
Structure
(
)
Array
::
Array
(
plist_t
node
,
Node
*
parent
)
:
Structure
(
parent
)
{
{
_node
=
node
;
_node
=
node
;
uint32_t
size
=
plist_array_get_size
(
_node
);
uint32_t
size
=
plist_array_get_size
(
_node
);
...
@@ -44,36 +38,7 @@ Array::Array(plist_t node) : Structure()
...
@@ -44,36 +38,7 @@ Array::Array(plist_t node) : Structure()
for
(
uint32_t
i
=
0
;
i
<
size
;
i
++
)
for
(
uint32_t
i
=
0
;
i
<
size
;
i
++
)
{
{
plist_t
subnode
=
plist_array_get_item
(
_node
,
i
);
plist_t
subnode
=
plist_array_get_item
(
_node
,
i
);
plist_type
subtype
=
plist_get_node_type
(
subnode
);
_array
.
push_back
(
Utils
::
FromPlist
(
subnode
,
this
)
);
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
:
_array
.
push_back
(
new
Boolean
(
subnode
)
);
break
;
case
PLIST_UINT
:
_array
.
push_back
(
new
Integer
(
subnode
)
);
break
;
case
PLIST_REAL
:
_array
.
push_back
(
new
Real
(
subnode
)
);
break
;
case
PLIST_STRING
:
_array
.
push_back
(
new
String
(
subnode
)
);
break
;
case
PLIST_DATE
:
_array
.
push_back
(
new
Date
(
subnode
)
);
break
;
case
PLIST_DATA
:
_array
.
push_back
(
new
Data
(
subnode
)
);
break
;
default
:
break
;
}
}
}
}
}
...
@@ -86,36 +51,7 @@ Array::Array(PList::Array& a) : Structure()
...
@@ -86,36 +51,7 @@ Array::Array(PList::Array& a) : Structure()
for
(
uint32_t
i
=
0
;
i
<
size
;
i
++
)
for
(
uint32_t
i
=
0
;
i
<
size
;
i
++
)
{
{
plist_t
subnode
=
plist_array_get_item
(
_node
,
i
);
plist_t
subnode
=
plist_array_get_item
(
_node
,
i
);
plist_type
subtype
=
plist_get_node_type
(
subnode
);
_array
.
push_back
(
Utils
::
FromPlist
(
subnode
,
this
)
);
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
:
_array
.
push_back
(
new
Boolean
(
subnode
)
);
break
;
case
PLIST_UINT
:
_array
.
push_back
(
new
Integer
(
subnode
)
);
break
;
case
PLIST_REAL
:
_array
.
push_back
(
new
Real
(
subnode
)
);
break
;
case
PLIST_STRING
:
_array
.
push_back
(
new
String
(
subnode
)
);
break
;
case
PLIST_DATE
:
_array
.
push_back
(
new
Date
(
subnode
)
);
break
;
case
PLIST_DATA
:
_array
.
push_back
(
new
Data
(
subnode
)
);
break
;
default
:
break
;
}
}
}
}
}
...
@@ -134,36 +70,7 @@ Array& Array::operator=(PList::Array& a)
...
@@ -134,36 +70,7 @@ Array& Array::operator=(PList::Array& a)
for
(
uint32_t
i
=
0
;
i
<
size
;
i
++
)
for
(
uint32_t
i
=
0
;
i
<
size
;
i
++
)
{
{
plist_t
subnode
=
plist_array_get_item
(
_node
,
i
);
plist_t
subnode
=
plist_array_get_item
(
_node
,
i
);
plist_type
subtype
=
plist_get_node_type
(
subnode
);
_array
.
push_back
(
Utils
::
FromPlist
(
subnode
,
this
)
);
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
:
_array
.
push_back
(
new
Boolean
(
subnode
)
);
break
;
case
PLIST_UINT
:
_array
.
push_back
(
new
Integer
(
subnode
)
);
break
;
case
PLIST_REAL
:
_array
.
push_back
(
new
Real
(
subnode
)
);
break
;
case
PLIST_STRING
:
_array
.
push_back
(
new
String
(
subnode
)
);
break
;
case
PLIST_DATE
:
_array
.
push_back
(
new
Date
(
subnode
)
);
break
;
case
PLIST_DATA
:
_array
.
push_back
(
new
Data
(
subnode
)
);
break
;
default
:
break
;
}
}
}
}
}
...
@@ -191,6 +98,7 @@ void Array::Append(Node* node)
...
@@ -191,6 +98,7 @@ void Array::Append(Node* node)
if
(
node
)
if
(
node
)
{
{
Node
*
clone
=
node
->
Clone
();
Node
*
clone
=
node
->
Clone
();
clone
->
SetParent
(
this
);
plist_array_append_item
(
_node
,
clone
->
GetPlist
());
plist_array_append_item
(
_node
,
clone
->
GetPlist
());
_array
.
push_back
(
clone
);
_array
.
push_back
(
clone
);
}
}
...
@@ -201,6 +109,7 @@ void Array::Insert(Node* node, unsigned int pos)
...
@@ -201,6 +109,7 @@ void Array::Insert(Node* node, unsigned int pos)
if
(
node
)
if
(
node
)
{
{
Node
*
clone
=
node
->
Clone
();
Node
*
clone
=
node
->
Clone
();
clone
->
SetParent
(
this
);
plist_array_insert_item
(
_node
,
clone
->
GetPlist
(),
pos
);
plist_array_insert_item
(
_node
,
clone
->
GetPlist
(),
pos
);
std
::
vector
<
Node
*>::
iterator
it
=
_array
.
begin
();
std
::
vector
<
Node
*>::
iterator
it
=
_array
.
begin
();
it
+=
pos
;
it
+=
pos
;
...
...
src/Boolean.cpp
View file @
c1363bea
...
@@ -24,11 +24,11 @@
...
@@ -24,11 +24,11 @@
namespace
PList
namespace
PList
{
{
Boolean
::
Boolean
(
)
:
Node
(
PLIST_BOOLEAN
)
Boolean
::
Boolean
(
Node
*
parent
)
:
Node
(
PLIST_BOOLEAN
,
parent
)
{
{
}
}
Boolean
::
Boolean
(
plist_t
node
)
:
Node
(
node
)
Boolean
::
Boolean
(
plist_t
node
,
Node
*
parent
)
:
Node
(
node
,
parent
)
{
{
}
}
...
...
src/Data.cpp
View file @
c1363bea
...
@@ -24,11 +24,11 @@
...
@@ -24,11 +24,11 @@
namespace
PList
namespace
PList
{
{
Data
::
Data
(
)
:
Node
(
PLIST_DATA
)
Data
::
Data
(
Node
*
parent
)
:
Node
(
PLIST_DATA
,
parent
)
{
{
}
}
Data
::
Data
(
plist_t
node
)
:
Node
(
node
)
Data
::
Data
(
plist_t
node
,
Node
*
parent
)
:
Node
(
node
,
parent
)
{
{
}
}
...
...
src/Date.cpp
View file @
c1363bea
...
@@ -24,11 +24,11 @@
...
@@ -24,11 +24,11 @@
namespace
PList
namespace
PList
{
{
Date
::
Date
(
)
:
Node
(
PLIST_DATE
)
Date
::
Date
(
Node
*
parent
)
:
Node
(
PLIST_DATE
,
parent
)
{
{
}
}
Date
::
Date
(
plist_t
node
)
:
Node
(
node
)
Date
::
Date
(
plist_t
node
,
Node
*
parent
)
:
Node
(
node
,
parent
)
{
{
}
}
...
...
src/Dictionary.cpp
View file @
c1363bea
...
@@ -20,22 +20,16 @@
...
@@ -20,22 +20,16 @@
#include <stdlib.h>
#include <stdlib.h>
#include <plist/Dictionary.h>
#include <plist/Dictionary.h>
#include <plist/Array.h>
#include <plist/Utils.h>
#include <plist/Boolean.h>
#include <plist/Integer.h>
#include <plist/Real.h>
#include <plist/String.h>
#include <plist/Date.h>
#include <plist/Data.h>
namespace
PList
namespace
PList
{
{
Dictionary
::
Dictionary
(
)
:
Structure
(
PLIST_DICT
)
Dictionary
::
Dictionary
(
Node
*
parent
)
:
Structure
(
PLIST_DICT
,
parent
)
{
{
}
}
Dictionary
::
Dictionary
(
plist_t
node
)
:
Structure
(
)
Dictionary
::
Dictionary
(
plist_t
node
,
Node
*
parent
)
:
Structure
(
parent
)
{
{
_node
=
node
;
_node
=
node
;
plist_dict_iter
it
=
NULL
;
plist_dict_iter
it
=
NULL
;
...
@@ -46,36 +40,7 @@ Dictionary::Dictionary(plist_t node) : Structure()
...
@@ -46,36 +40,7 @@ Dictionary::Dictionary(plist_t node) : Structure()
plist_dict_next_item
(
_node
,
it
,
&
key
,
&
subnode
);
plist_dict_next_item
(
_node
,
it
,
&
key
,
&
subnode
);
while
(
subnode
)
while
(
subnode
)
{
{
plist_type
subtype
=
plist_get_node_type
(
subnode
);
_map
[
std
::
string
(
key
)]
=
Utils
::
FromPlist
(
subnode
,
this
);
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
:
_map
[
std
::
string
(
key
)]
=
new
Boolean
(
subnode
);
break
;
case
PLIST_UINT
:
_map
[
std
::
string
(
key
)]
=
new
Integer
(
subnode
);
break
;
case
PLIST_REAL
:
_map
[
std
::
string
(
key
)]
=
new
Real
(
subnode
);
break
;
case
PLIST_STRING
:
_map
[
std
::
string
(
key
)]
=
new
String
(
subnode
);
break
;
case
PLIST_DATE
:
_map
[
std
::
string
(
key
)]
=
new
Date
(
subnode
);
break
;
case
PLIST_DATA
:
_map
[
std
::
string
(
key
)]
=
new
Data
(
subnode
);
break
;
default
:
break
;
}
subnode
=
NULL
;
subnode
=
NULL
;
free
(
key
);
free
(
key
);
...
@@ -103,36 +68,7 @@ Dictionary::Dictionary(PList::Dictionary& d) : Structure()
...
@@ -103,36 +68,7 @@ Dictionary::Dictionary(PList::Dictionary& d) : Structure()
plist_dict_next_item
(
_node
,
it
,
&
key
,
&
subnode
);
plist_dict_next_item
(
_node
,
it
,
&
key
,
&
subnode
);
while
(
subnode
)
while
(
subnode
)
{
{
plist_type
subtype
=
plist_get_node_type
(
subnode
);
_map
[
std
::
string
(
key
)]
=
Utils
::
FromPlist
(
subnode
,
this
);
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
:
_map
[
std
::
string
(
key
)]
=
new
Boolean
(
subnode
);
break
;
case
PLIST_UINT
:
_map
[
std
::
string
(
key
)]
=
new
Integer
(
subnode
);
break
;
case
PLIST_REAL
:
_map
[
std
::
string
(
key
)]
=
new
Real
(
subnode
);
break
;
case
PLIST_STRING
:
_map
[
std
::
string
(
key
)]
=
new
String
(
subnode
);
break
;
case
PLIST_DATE
:
_map
[
std
::
string
(
key
)]
=
new
Date
(
subnode
);
break
;
case
PLIST_DATA
:
_map
[
std
::
string
(
key
)]
=
new
Data
(
subnode
);
break
;
default
:
break
;
}
subnode
=
NULL
;
subnode
=
NULL
;
free
(
key
);
free
(
key
);
...
@@ -160,36 +96,7 @@ Dictionary& Dictionary::operator=(PList::Dictionary& d)
...
@@ -160,36 +96,7 @@ Dictionary& Dictionary::operator=(PList::Dictionary& d)
plist_dict_next_item
(
_node
,
it
,
&
key
,
&
subnode
);
plist_dict_next_item
(
_node
,
it
,
&
key
,
&
subnode
);
while
(
subnode
)
while
(
subnode
)
{
{
plist_type
subtype
=
plist_get_node_type
(
subnode
);
_map
[
std
::
string
(
key
)]
=
Utils
::
FromPlist
(
subnode
,
this
);
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
:
_map
[
std
::
string
(
key
)]
=
new
Boolean
(
subnode
);
break
;
case
PLIST_UINT
:
_map
[
std
::
string
(
key
)]
=
new
Integer
(
subnode
);
break
;
case
PLIST_REAL
:
_map
[
std
::
string
(
key
)]
=
new
Real
(
subnode
);
break
;
case
PLIST_STRING
:
_map
[
std
::
string
(
key
)]
=
new
String
(
subnode
);
break
;
case
PLIST_DATE
:
_map
[
std
::
string
(
key
)]
=
new
Date
(
subnode
);
break
;
case
PLIST_DATA
:
_map
[
std
::
string
(
key
)]
=
new
Data
(
subnode
);
break
;
default
:
break
;
}
subnode
=
NULL
;
subnode
=
NULL
;
free
(
key
);
free
(
key
);
...
@@ -239,6 +146,7 @@ Dictionary::iterator Dictionary::Insert(const std::string& key, Node* node)
...
@@ -239,6 +146,7 @@ Dictionary::iterator Dictionary::Insert(const std::string& key, Node* node)
if
(
node
)
if
(
node
)
{
{
Node
*
clone
=
node
->
Clone
();
Node
*
clone
=
node
->
Clone
();
clone
->
SetParent
(
this
);
plist_dict_insert_item
(
_node
,
key
.
c_str
(),
clone
->
GetPlist
());
plist_dict_insert_item
(
_node
,
key
.
c_str
(),
clone
->
GetPlist
());
delete
_map
[
key
];
delete
_map
[
key
];
_map
[
key
]
=
clone
;
_map
[
key
]
=
clone
;
...
...
src/Integer.cpp
View file @
c1363bea
...
@@ -24,11 +24,11 @@
...
@@ -24,11 +24,11 @@
namespace
PList
namespace
PList
{
{
Integer
::
Integer
(
)
:
Node
(
PLIST_UINT
)
Integer
::
Integer
(
Node
*
parent
)
:
Node
(
PLIST_UINT
,
parent
)
{
{
}
}
Integer
::
Integer
(
plist_t
node
)
:
Node
(
node
)
Integer
::
Integer
(
plist_t
node
,
Node
*
parent
)
:
Node
(
node
,
parent
)
{
{
}
}
...
...
src/Node.cpp
View file @
c1363bea
...
@@ -24,15 +24,15 @@
...
@@ -24,15 +24,15 @@
namespace
PList
namespace
PList
{
{
Node
::
Node
()
Node
::
Node
(
Node
*
parent
)
:
_parent
(
parent
)
{
{
}
}
Node
::
Node
(
plist_t
node
)
:
_node
(
node
)
Node
::
Node
(
plist_t
node
,
Node
*
parent
)
:
_node
(
node
),
_parent
(
parent
)
{
{
}
}
Node
::
Node
(
plist_type
type
)
Node
::
Node
(
plist_type
type
,
Node
*
parent
)
:
_parent
(
parent
)
{
{
_node
=
NULL
;
_node
=
NULL
;
...
@@ -72,6 +72,7 @@ Node::~Node()
...
@@ -72,6 +72,7 @@ Node::~Node()
{
{
plist_free
(
_node
);
plist_free
(
_node
);
_node
=
NULL
;
_node
=
NULL
;
_parent
=
NULL
;
}
}
plist_type
Node
::
GetType
()
plist_type
Node
::
GetType
()
...
@@ -86,4 +87,15 @@ plist_t Node::GetPlist()
...
@@ -86,4 +87,15 @@ plist_t Node::GetPlist()
{
{
return
_node
;
return
_node
;
}
}
Node
*
Node
::
GetParent
()
{
return
_parent
;
}
void
Node
::
SetParent
(
Node
*
parent
)
{
_parent
=
parent
;
}
};
};
src/Real.cpp
View file @
c1363bea
...
@@ -24,11 +24,11 @@
...
@@ -24,11 +24,11 @@
namespace
PList
namespace
PList
{
{
Real
::
Real
(
)
:
Node
(
PLIST_REAL
)
Real
::
Real
(
Node
*
parent
)
:
Node
(
PLIST_REAL
,
parent
)
{
{
}
}
Real
::
Real
(
plist_t
node
)
:
Node
(
node
)
Real
::
Real
(
plist_t
node
,
Node
*
parent
)
:
Node
(
node
,
parent
)
{
{
}
}
...
...
src/String.cpp
View file @
c1363bea
...
@@ -24,11 +24,11 @@
...
@@ -24,11 +24,11 @@
namespace
PList
namespace
PList
{
{
String
::
String
(
)
:
Node
(
PLIST_STRING
)
String
::
String
(
Node
*
parent
)
:
Node
(
PLIST_STRING
,
parent
)
{
{
}
}
String
::
String
(
plist_t
node
)
:
Node
(
node
)
String
::
String
(
plist_t
node
,
Node
*
parent
)
:
Node
(
node
,
parent
)
{
{
}
}
...
...
src/Structure.cpp
View file @
c1363bea
...
@@ -24,10 +24,10 @@
...
@@ -24,10 +24,10 @@
namespace
PList
namespace
PList
{
{
Structure
::
Structure
(
)
:
Node
(
)
Structure
::
Structure
(
Node
*
parent
)
:
Node
(
parent
)
{
{
}
}
Structure
::
Structure
(
plist_type
type
)
:
Node
(
type
)
Structure
::
Structure
(
plist_type
type
,
Node
*
parent
)
:
Node
(
type
,
parent
)
{
{
}
}
...
...
src/Utils.cpp
View file @
c1363bea
...
@@ -22,44 +22,79 @@
...
@@ -22,44 +22,79 @@
#include <plist/Utils.h>
#include <plist/Utils.h>
#include <plist/Dictionary.h>
#include <plist/Dictionary.h>
#include <plist/Array.h>
#include <plist/Array.h>
#include <plist/Boolean.h>
#include <plist/Integer.h>
#include <plist/Real.h>
#include <plist/String.h>
#include <plist/Data.h>
#include <plist/Date.h>
namespace
PList
namespace
PList
{
{
static
Structure
*
FromPlist
(
plist_t
roo
t
)
Node
*
Utils
::
FromPlist
(
plist_t
node
,
Node
*
paren
t
)
{
{
Structur
e
*
ret
=
NULL
;
Nod
e
*
ret
=
NULL
;
if
(
root
)
if
(
node
)
{
{
plist_type
type
=
plist_get_node_type
(
root
);
plist_type
type
=
plist_get_node_type
(
node
);
switch
(
type
)
switch
(
type
)
{
{
case
PLIST_DICT
:
case
PLIST_DICT
:
ret
=
new
Dictionary
(
roo
t
);
ret
=
new
Dictionary
(
node
,
paren
t
);
break
;
break
;
case
PLIST_ARRAY
:
case
PLIST_ARRAY
:
ret
=
new
Array
(
roo
t
);
ret
=
new
Array
(
node
,
paren
t
);
break
;
break
;
case
PLIST_BOOLEAN
:
case
PLIST_BOOLEAN
:
ret
=
new
Boolean
(
node
,
parent
);
break
;
case
PLIST_UINT
:
case
PLIST_UINT
:
ret
=
new
Integer
(
node
,
parent
);
break
;
case
PLIST_REAL
:
case
PLIST_REAL
:
ret
=
new
Real
(
node
,
parent
);
break
;
case
PLIST_STRING
:
case
PLIST_STRING
:
ret
=
new
String
(
node
,
parent
);
break
;
case
PLIST_DATE
:
case
PLIST_DATE
:
ret
=
new
Date
(
node
,
parent
);
break
;
case
PLIST_DATA
:
case
PLIST_DATA
:
ret
=
new
Data
(
node
,
parent
);
break
;
default
:
default
:
plist_free
(
root
);
plist_free
(
node
);
break
;
break
;
}
}
}
}
return
ret
;
return
ret
;
}
}
static
Structure
*
ImportStruct
(
plist_t
root
)
{
Structure
*
ret
=
NULL
;
plist_type
type
=
plist_get_node_type
(
root
);
if
(
PLIST_ARRAY
==
type
||
PLIST_DICT
==
type
)
{
ret
=
static_cast
<
Structure
*>
(
Utils
::
FromPlist
(
root
));
}
else
{
plist_free
(
root
);
}
return
ret
;
}
Structure
*
Utils
::
FromXml
(
const
std
::
string
&
in
)
Structure
*
Utils
::
FromXml
(
const
std
::
string
&
in
)
{
{
plist_t
root
=
NULL
;
plist_t
root
=
NULL
;
plist_from_xml
(
in
.
c_str
(),
in
.
size
(),
&
root
);
plist_from_xml
(
in
.
c_str
(),
in
.
size
(),
&
root
);
return
FromPlis
t
(
root
);
return
ImportStruc
t
(
root
);
}
}
Structure
*
Utils
::
FromBin
(
const
std
::
vector
<
char
>&
in
)
Structure
*
Utils
::
FromBin
(
const
std
::
vector
<
char
>&
in
)
...
@@ -67,7 +102,7 @@ Structure* Utils::FromBin(const std::vector<char>& in)
...
@@ -67,7 +102,7 @@ Structure* Utils::FromBin(const std::vector<char>& in)
plist_t
root
=
NULL
;
plist_t
root
=
NULL
;
plist_from_bin
(
&
in
[
0
],
in
.
size
(),
&
root
);
plist_from_bin
(
&
in
[
0
],
in
.
size
(),
&
root
);
return
FromPlis
t
(
root
);
return
ImportStruc
t
(
root
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment