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
84596548
Commit
84596548
authored
Nov 04, 2009
by
Jonathan Beck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add GetNodeIdex and GetNodeKey methods.
parent
c8c9cfa7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
0 deletions
+20
-0
Array.h
include/plist/Array.h
+1
-0
Dictionary.h
include/plist/Dictionary.h
+1
-0
Array.cpp
src/Array.cpp
+8
-0
Dictionary.cpp
src/Dictionary.cpp
+10
-0
No files found.
include/plist/Array.h
View file @
84596548
...
...
@@ -44,6 +44,7 @@ public :
void
Insert
(
Node
*
node
,
unsigned
int
pos
);
void
Remove
(
Node
*
node
);
void
Remove
(
unsigned
int
pos
);
unsigned
int
GetNodeIndex
(
Node
*
node
);
private
:
std
::
vector
<
Node
*>
_array
;
...
...
include/plist/Dictionary.h
View file @
84596548
...
...
@@ -49,6 +49,7 @@ public :
iterator
Insert
(
const
std
::
string
&
key
,
Node
*
node
);
void
Remove
(
Node
*
node
);
void
Remove
(
const
std
::
string
&
key
);
std
::
string
GetNodeKey
(
Node
*
key
);
private
:
std
::
map
<
std
::
string
,
Node
*>
_map
;
...
...
src/Array.cpp
View file @
84596548
...
...
@@ -22,6 +22,8 @@
#include <plist/Array.h>
#include <plist/Utils.h>
#include <algorithm>
namespace
PList
{
...
...
@@ -140,4 +142,10 @@ void Array::Remove(unsigned int pos)
_array
.
erase
(
it
);
}
unsigned
int
Array
::
GetNodeIndex
(
Node
*
node
)
{
std
::
vector
<
Node
*>::
iterator
it
=
std
::
find
(
_array
.
begin
(),
_array
.
end
(),
node
);
return
std
::
distance
(
_array
.
begin
(),
it
);
}
};
src/Dictionary.cpp
View file @
84596548
...
...
@@ -177,4 +177,14 @@ void Dictionary::Remove(const std::string& key)
_map
.
erase
(
key
);
}
std
::
string
Dictionary
::
GetNodeKey
(
Node
*
node
)
{
for
(
iterator
it
=
_map
.
begin
();
it
!=
_map
.
end
();
++
it
)
{
if
(
it
->
second
==
node
)
return
it
->
first
;
}
return
""
;
}
};
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