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
32be8ec3
Commit
32be8ec3
authored
Oct 16, 2009
by
Jonathan Beck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Node lifecycle and change argument as reference to const reference.
parent
8aeef4dd
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
179 additions
and
65 deletions
+179
-65
Array.h
include/plist/Array.h
+4
-2
Boolean.h
include/plist/Boolean.h
+4
-0
Data.h
include/plist/Data.h
+6
-2
Date.h
include/plist/Date.h
+4
-0
Dictionary.h
include/plist/Dictionary.h
+7
-5
Integer.h
include/plist/Integer.h
+4
-0
Node.h
include/plist/Node.h
+4
-4
Real.h
include/plist/Real.h
+4
-0
String.h
include/plist/String.h
+6
-2
Utils.h
include/plist/Utils.h
+2
-2
Array.cpp
src/Array.cpp
+18
-18
Boolean.cpp
src/Boolean.cpp
+16
-0
Data.cpp
src/Data.cpp
+19
-2
Date.cpp
src/Date.cpp
+15
-0
Dictionary.cpp
src/Dictionary.cpp
+13
-7
Integer.cpp
src/Integer.cpp
+16
-0
Node.cpp
src/Node.cpp
+1
-17
Real.cpp
src/Real.cpp
+16
-0
String.cpp
src/String.cpp
+18
-2
Utils.cpp
src/Utils.cpp
+2
-2
No files found.
include/plist/Array.h
View file @
32be8ec3
...
...
@@ -34,9 +34,11 @@ class Array : public Structure
Array
();
Array
(
plist_t
node
);
Array
(
Array
&
a
);
Array
&
operator
=
(
const
Array
&
a
);
Array
&
operator
=
(
Array
&
a
);
virtual
~
Array
();
Node
*
Clone
();
Node
*
operator
[](
unsigned
int
index
);
void
Append
(
Node
*
node
);
void
Insert
(
Node
*
node
,
unsigned
int
pos
);
...
...
include/plist/Boolean.h
View file @
32be8ec3
...
...
@@ -32,9 +32,13 @@ class Boolean : public Node
public
:
Boolean
();
Boolean
(
plist_t
node
);
Boolean
(
Boolean
&
b
);
Boolean
&
operator
=
(
Boolean
&
b
);
Boolean
(
bool
b
);
virtual
~
Boolean
();
Node
*
Clone
();
void
SetValue
(
bool
b
);
bool
GetValue
();
};
...
...
include/plist/Data.h
View file @
32be8ec3
...
...
@@ -33,10 +33,14 @@ class Data : public Node
public
:
Data
();
Data
(
plist_t
node
);
Data
(
std
::
vector
<
char
>&
buff
);
Data
(
Data
&
d
);
Data
&
operator
=
(
Data
&
d
);
Data
(
const
std
::
vector
<
char
>&
buff
);
virtual
~
Data
();
void
SetValue
(
std
::
vector
<
char
>&
buff
);
Node
*
Clone
();
void
SetValue
(
const
std
::
vector
<
char
>&
buff
);
std
::
vector
<
char
>
GetValue
();
};
...
...
include/plist/Date.h
View file @
32be8ec3
...
...
@@ -32,9 +32,13 @@ class Date : public Node
public
:
Date
();
Date
(
plist_t
node
);
Date
(
Date
&
d
);
Date
&
operator
=
(
Date
&
d
);
Date
(
uint64_t
i
);
virtual
~
Date
();
Node
*
Clone
();
void
SetValue
(
uint64_t
i
);
uint64_t
GetValue
();
};
...
...
include/plist/Dictionary.h
View file @
32be8ec3
...
...
@@ -35,17 +35,19 @@ class Dictionary : public Structure
Dictionary
();
Dictionary
(
plist_t
node
);
Dictionary
(
Dictionary
&
d
);
Dictionary
&
operator
=
(
const
Dictionary
&
d
);
Dictionary
&
operator
=
(
Dictionary
&
d
);
virtual
~
Dictionary
();
Node
*
Clone
();
typedef
std
::
map
<
std
::
string
,
Node
*>::
iterator
iterator
;
Node
*
operator
[](
std
::
string
&
key
);
Node
*
operator
[](
const
std
::
string
&
key
);
iterator
Begin
();
iterator
End
();
void
Insert
(
std
::
string
&
key
,
Node
*
node
);
void
Insert
(
const
std
::
string
&
key
,
Node
*
node
);
void
Remove
(
Node
*
node
);
void
Remove
(
std
::
string
&
key
);
void
Remove
(
const
std
::
string
&
key
);
private
:
std
::
map
<
std
::
string
,
Node
*>
_map
;
...
...
include/plist/Integer.h
View file @
32be8ec3
...
...
@@ -32,9 +32,13 @@ class Integer : public Node
public
:
Integer
();
Integer
(
plist_t
node
);
Integer
(
Integer
&
i
);
Integer
&
operator
=
(
Integer
&
i
);
Integer
(
uint64_t
i
);
virtual
~
Integer
();
Node
*
Clone
();
void
SetValue
(
uint64_t
i
);
uint64_t
GetValue
();
};
...
...
include/plist/Node.h
View file @
32be8ec3
...
...
@@ -31,11 +31,11 @@ class Node
{
public
:
virtual
~
Node
();
Node
(
Node
&
node
);
Node
&
operator
=
(
const
Node
&
node
)
;
virtual
Node
*
Clone
()
=
0
;
plist_type
GetType
();
plist_t
GetPlist
()
const
;
plist_t
GetPlist
();
protected
:
Node
();
...
...
include/plist/Real.h
View file @
32be8ec3
...
...
@@ -32,9 +32,13 @@ class Real : public Node
public
:
Real
();
Real
(
plist_t
node
);
Real
(
Real
&
d
);
Real
&
operator
=
(
Real
&
d
);
Real
(
double
d
);
virtual
~
Real
();
Node
*
Clone
();
void
SetValue
(
double
d
);
double
GetValue
();
};
...
...
include/plist/String.h
View file @
32be8ec3
...
...
@@ -33,10 +33,14 @@ class String : public Node
public
:
String
();
String
(
plist_t
node
);
String
(
std
::
string
&
s
);
String
(
String
&
s
);
String
&
operator
=
(
String
&
s
);
String
(
const
std
::
string
&
s
);
virtual
~
String
();
void
SetValue
(
std
::
string
&
s
);
Node
*
Clone
();
void
SetValue
(
const
std
::
string
&
s
);
std
::
string
GetValue
();
};
...
...
include/plist/Utils.h
View file @
32be8ec3
...
...
@@ -30,8 +30,8 @@ namespace PList
class
Utils
{
public
:
static
Structure
*
FromXml
(
std
::
string
&
in
);
static
Structure
*
FromBin
(
std
::
vector
<
char
>&
in
);
static
Structure
*
FromXml
(
const
std
::
string
&
in
);
static
Structure
*
FromBin
(
const
std
::
vector
<
char
>&
in
);
private
:
Utils
();
...
...
src/Array.cpp
View file @
32be8ec3
...
...
@@ -77,15 +77,9 @@ Array::Array(plist_t node) : Structure()
}
}
Array
::
Array
(
Array
&
a
)
Array
::
Array
(
PList
::
Array
&
a
)
:
Structure
(
)
{
plist_free
(
_node
);
for
(
int
it
=
0
;
it
<
_array
.
size
();
it
++
)
{
delete
_array
.
at
(
it
);
}
_array
.
clear
();
_node
=
plist_copy
(
a
.
GetPlist
());
uint32_t
size
=
plist_array_get_size
(
_node
);
...
...
@@ -125,7 +119,7 @@ Array::Array(Array& a)
}
}
Array
&
Array
::
operator
=
(
const
Array
&
a
)
Array
&
Array
::
operator
=
(
PList
::
Array
&
a
)
{
plist_free
(
_node
);
for
(
int
it
=
0
;
it
<
_array
.
size
();
it
++
)
...
...
@@ -175,12 +169,16 @@ Array& Array::operator=(const Array& a)
Array
::~
Array
()
{
plist_free
(
_node
);
for
(
int
it
=
0
;
it
<
_array
.
size
();
it
++
)
{
delete
_array
.
at
(
it
);
}
_array
.
clear
();
for
(
int
it
=
0
;
it
<
_array
.
size
();
it
++
)
{
delete
(
_array
.
at
(
it
));
}
_array
.
clear
();
}
Node
*
Array
::
Clone
()
{
return
new
Array
(
*
this
);
}
Node
*
Array
::
operator
[](
unsigned
int
index
)
...
...
@@ -192,8 +190,9 @@ void Array::Append(Node* node)
{
if
(
node
)
{
plist_array_append_item
(
_node
,
node
->
GetPlist
());
_array
.
push_back
(
node
);
Node
*
clone
=
node
->
Clone
();
plist_array_append_item
(
_node
,
clone
->
GetPlist
());
_array
.
push_back
(
clone
);
}
}
...
...
@@ -201,10 +200,11 @@ void Array::Insert(Node* node, unsigned int pos)
{
if
(
node
)
{
plist_array_insert_item
(
_node
,
node
->
GetPlist
(),
pos
);
Node
*
clone
=
node
->
Clone
();
plist_array_insert_item
(
_node
,
clone
->
GetPlist
(),
pos
);
std
::
vector
<
Node
*>::
iterator
it
=
_array
.
begin
();
it
+=
pos
;
_array
.
insert
(
it
,
nod
e
);
_array
.
insert
(
it
,
clon
e
);
}
}
...
...
src/Boolean.cpp
View file @
32be8ec3
...
...
@@ -32,6 +32,17 @@ Boolean::Boolean(plist_t node) : Node(node)
{
}
Boolean
::
Boolean
(
PList
::
Boolean
&
b
)
:
Node
(
PLIST_BOOLEAN
)
{
plist_set_bool_val
(
_node
,
b
.
GetValue
());
}
Boolean
&
Boolean
::
operator
=
(
PList
::
Boolean
&
b
)
{
plist_free
(
_node
);
_node
=
plist_copy
(
b
.
GetPlist
());
}
Boolean
::
Boolean
(
bool
b
)
:
Node
(
PLIST_BOOLEAN
)
{
plist_set_bool_val
(
_node
,
b
);
...
...
@@ -41,6 +52,11 @@ Boolean::~Boolean()
{
}
Node
*
Boolean
::
Clone
()
{
return
new
Boolean
(
*
this
);
}
void
Boolean
::
SetValue
(
bool
b
)
{
plist_set_bool_val
(
_node
,
b
);
...
...
src/Data.cpp
View file @
32be8ec3
...
...
@@ -32,7 +32,19 @@ Data::Data(plist_t node) : Node(node)
{
}
Data
::
Data
(
std
::
vector
<
char
>&
buff
)
:
Node
(
PLIST_DATA
)
Data
::
Data
(
PList
::
Data
&
d
)
:
Node
(
PLIST_DATA
)
{
std
::
vector
<
char
>
b
=
d
.
GetValue
();
plist_set_data_val
(
_node
,
&
b
[
0
],
b
.
size
());
}
Data
&
Data
::
operator
=
(
PList
::
Data
&
b
)
{
plist_free
(
_node
);
_node
=
plist_copy
(
b
.
GetPlist
());
}
Data
::
Data
(
const
std
::
vector
<
char
>&
buff
)
:
Node
(
PLIST_DATA
)
{
plist_set_data_val
(
_node
,
&
buff
[
0
],
buff
.
size
());
}
...
...
@@ -41,7 +53,12 @@ Data::~Data()
{
}
void
Data
::
SetValue
(
std
::
vector
<
char
>&
buff
)
Node
*
Data
::
Clone
()
{
return
new
Data
(
*
this
);
}
void
Data
::
SetValue
(
const
std
::
vector
<
char
>&
buff
)
{
plist_set_data_val
(
_node
,
&
buff
[
0
],
buff
.
size
());
}
...
...
src/Date.cpp
View file @
32be8ec3
...
...
@@ -32,6 +32,16 @@ Date::Date(plist_t node) : Node(node)
{
}
Date
::
Date
(
Date
&
d
)
:
Node
(
PLIST_DATE
)
{
//TODO
}
Date
&
Date
::
operator
=
(
PList
::
Date
&
b
)
{
//TODO
}
Date
::
Date
(
uint64_t
i
)
:
Node
(
PLIST_DATE
)
{
plist_set_date_val
(
_node
,
i
,
0
);
...
...
@@ -41,6 +51,11 @@ Date::~Date()
{
}
Node
*
Date
::
Clone
()
{
return
new
Date
(
*
this
);
}
void
Date
::
SetValue
(
uint64_t
i
)
{
plist_set_date_val
(
_node
,
i
,
0
);
...
...
src/Dictionary.cpp
View file @
32be8ec3
...
...
@@ -85,7 +85,7 @@ Dictionary::Dictionary(plist_t node) : Structure()
free
(
it
);
}
Dictionary
::
Dictionary
(
Dictionary
&
d
)
Dictionary
::
Dictionary
(
PList
::
Dictionary
&
d
)
:
Structure
(
)
{
for
(
Dictionary
::
iterator
it
=
_map
.
begin
();
it
!=
_map
.
end
();
it
++
)
{
...
...
@@ -142,7 +142,7 @@ Dictionary::Dictionary(Dictionary& d)
free
(
it
);
}
Dictionary
&
Dictionary
::
operator
=
(
const
Dictionary
&
d
)
Dictionary
&
Dictionary
::
operator
=
(
PList
::
Dictionary
&
d
)
{
for
(
Dictionary
::
iterator
it
=
_map
.
begin
();
it
!=
_map
.
end
();
it
++
)
{
...
...
@@ -209,7 +209,12 @@ Dictionary::~Dictionary()
_map
.
clear
();
}
Node
*
Dictionary
::
operator
[](
std
::
string
&
key
)
Node
*
Dictionary
::
Clone
()
{
return
new
Dictionary
(
*
this
);
}
Node
*
Dictionary
::
operator
[](
const
std
::
string
&
key
)
{
return
_map
[
key
];
}
...
...
@@ -224,13 +229,14 @@ Dictionary::iterator Dictionary::End()
return
_map
.
end
();
}
void
Dictionary
::
Insert
(
std
::
string
&
key
,
Node
*
node
)
void
Dictionary
::
Insert
(
const
std
::
string
&
key
,
Node
*
node
)
{
if
(
node
)
{
plist_dict_insert_item
(
_node
,
key
.
c_str
(),
node
->
GetPlist
());
Node
*
clone
=
node
->
Clone
();
plist_dict_insert_item
(
_node
,
key
.
c_str
(),
clone
->
GetPlist
());
delete
_map
[
key
];
_map
[
key
]
=
nod
e
;
_map
[
key
]
=
clon
e
;
}
}
...
...
@@ -247,7 +253,7 @@ void Dictionary::Remove(Node* node)
}
}
void
Dictionary
::
Remove
(
std
::
string
&
key
)
void
Dictionary
::
Remove
(
const
std
::
string
&
key
)
{
plist_dict_remove_item
(
_node
,
key
.
c_str
());
delete
_map
[
key
];
...
...
src/Integer.cpp
View file @
32be8ec3
...
...
@@ -32,6 +32,17 @@ Integer::Integer(plist_t node) : Node(node)
{
}
Integer
::
Integer
(
PList
::
Integer
&
i
)
:
Node
(
PLIST_UINT
)
{
plist_set_uint_val
(
_node
,
i
.
GetValue
());
}
Integer
&
Integer
::
operator
=
(
PList
::
Integer
&
i
)
{
plist_free
(
_node
);
_node
=
plist_copy
(
i
.
GetPlist
());
}
Integer
::
Integer
(
uint64_t
i
)
:
Node
(
PLIST_UINT
)
{
plist_set_uint_val
(
_node
,
i
);
...
...
@@ -41,6 +52,11 @@ Integer::~Integer()
{
}
Node
*
Integer
::
Clone
()
{
return
new
Integer
(
*
this
);
}
void
Integer
::
SetValue
(
uint64_t
i
)
{
plist_set_uint_val
(
_node
,
i
);
...
...
src/Node.cpp
View file @
32be8ec3
...
...
@@ -74,22 +74,6 @@ Node::~Node()
_node
=
NULL
;
}
Node
::
Node
(
Node
&
node
)
{
plist_free
(
_node
);
_node
=
NULL
;
_node
=
plist_copy
(
_node
);
}
Node
&
Node
::
operator
=
(
const
Node
&
node
)
{
plist_free
(
_node
);
_node
=
NULL
;
_node
=
plist_copy
(
_node
);
}
plist_type
Node
::
GetType
()
{
if
(
_node
)
...
...
@@ -98,7 +82,7 @@ plist_type Node::GetType()
}
}
plist_t
Node
::
GetPlist
()
const
plist_t
Node
::
GetPlist
()
{
return
_node
;
}
...
...
src/Real.cpp
View file @
32be8ec3
...
...
@@ -32,6 +32,17 @@ Real::Real(plist_t node) : Node(node)
{
}
Real
::
Real
(
PList
::
Real
&
d
)
:
Node
(
PLIST_UINT
)
{
plist_set_real_val
(
_node
,
d
.
GetValue
());
}
Real
&
Real
::
operator
=
(
PList
::
Real
&
d
)
{
plist_free
(
_node
);
_node
=
plist_copy
(
d
.
GetPlist
());
}
Real
::
Real
(
double
d
)
:
Node
(
PLIST_REAL
)
{
plist_set_real_val
(
_node
,
d
);
...
...
@@ -41,6 +52,11 @@ Real::~Real()
{
}
Node
*
Real
::
Clone
()
{
return
new
Real
(
*
this
);
}
void
Real
::
SetValue
(
double
d
)
{
plist_set_real_val
(
_node
,
d
);
...
...
src/String.cpp
View file @
32be8ec3
...
...
@@ -32,7 +32,18 @@ String::String(plist_t node) : Node(node)
{
}
String
::
String
(
std
::
string
&
s
)
:
Node
(
PLIST_STRING
)
String
::
String
(
PList
::
String
&
s
)
:
Node
(
PLIST_UINT
)
{
plist_set_string_val
(
_node
,
s
.
GetValue
().
c_str
());
}
String
&
String
::
operator
=
(
PList
::
String
&
s
)
{
plist_free
(
_node
);
_node
=
plist_copy
(
s
.
GetPlist
());
}
String
::
String
(
const
std
::
string
&
s
)
:
Node
(
PLIST_STRING
)
{
plist_set_string_val
(
_node
,
s
.
c_str
());
}
...
...
@@ -41,7 +52,12 @@ String::~String()
{
}
void
String
::
SetValue
(
std
::
string
&
s
)
Node
*
String
::
Clone
()
{
return
new
String
(
*
this
);
}
void
String
::
SetValue
(
const
std
::
string
&
s
)
{
plist_set_string_val
(
_node
,
s
.
c_str
());
}
...
...
src/Utils.cpp
View file @
32be8ec3
...
...
@@ -54,7 +54,7 @@ static Structure* FromPlist(plist_t root)
return
ret
;
}
Structure
*
Utils
::
FromXml
(
std
::
string
&
in
)
Structure
*
Utils
::
FromXml
(
const
std
::
string
&
in
)
{
plist_t
root
=
NULL
;
plist_from_xml
(
in
.
c_str
(),
in
.
size
(),
&
root
);
...
...
@@ -62,7 +62,7 @@ Structure* Utils::FromXml(std::string& in)
return
FromPlist
(
root
);
}
Structure
*
Utils
::
FromBin
(
std
::
vector
<
char
>&
in
)
Structure
*
Utils
::
FromBin
(
const
std
::
vector
<
char
>&
in
)
{
plist_t
root
=
NULL
;
plist_from_bin
(
&
in
[
0
],
in
.
size
(),
&
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