Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
cf06b9ae
Commit
cf06b9ae
authored
12 years ago
by
Tristan Matthews
Browse files
Options
Downloads
Patches
Plain Diff
* #9782: yamlnode: fixed iterator usage
parent
23f38176
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
daemon/src/config/yamlnode.cpp
+16
-30
16 additions, 30 deletions
daemon/src/config/yamlnode.cpp
daemon/src/config/yamlnode.h
+23
-22
23 additions, 22 deletions
daemon/src/config/yamlnode.h
with
39 additions
and
52 deletions
daemon/src/config/yamlnode.cpp
+
16
−
30
View file @
cf06b9ae
...
...
@@ -34,28 +34,25 @@
namespace
Conf
{
void
YamlDocument
::
addNode
(
YamlNode
*
node
)
{
Sequence
::
iterator
it
=
doc
.
end
();
doc
.
insert
(
it
,
node
);
Sequence
::
iterator
it
=
doc
_
.
end
();
doc
_
.
insert
(
it
,
node
);
}
YamlNode
*
YamlDocument
::
popNode
()
{
YamlNode
*
node
=
doc
.
front
();
YamlNode
*
node
=
doc
_
.
front
();
//removed element's destructor is called
doc
.
pop_front
();
doc
_
.
pop_front
();
return
node
;
}
void
YamlDocument
::
deleteChildNodes
()
{
Sequence
::
iterator
it
=
doc
.
begin
();
while
(
it
!=
doc
.
end
())
{
for
(
Sequence
::
iterator
it
=
doc_
.
begin
();
it
!=
doc_
.
end
();
++
it
)
{
YamlNode
*
yamlNode
=
static_cast
<
YamlNode
*>
(
*
it
);
switch
(
yamlNode
->
getType
())
{
...
...
@@ -84,36 +81,31 @@ void YamlDocument::deleteChildNodes()
default
:
break
;
}
it
++
;
}
}
void
MappingNode
::
addNode
(
YamlNode
*
node
)
{
Mapping
::
iterator
it
=
map
.
end
();
map
.
insert
(
it
,
std
::
pair
<
std
::
string
,
YamlNode
*>
(
tmpKey
,
node
));
setKeyValue
(
tmpKey_
,
node
);
}
void
MappingNode
::
setKeyValue
(
const
std
::
string
&
key
,
YamlNode
*
value
)
{
Mapping
::
iterator
it
=
map
.
end
();
map
.
insert
(
it
,
std
::
pair
<
std
::
string
,
YamlNode
*>
(
key
,
value
));
Mapping
::
iterator
it
=
map
_
.
end
();
map
_
.
insert
(
it
,
std
::
pair
<
std
::
string
,
YamlNode
*>
(
key
,
value
));
}
void
MappingNode
::
removeKeyValue
(
const
std
::
string
&
key
)
{
Mapping
::
iterator
it
=
map
.
find
(
key
);
map
.
erase
(
it
);
Mapping
::
iterator
it
=
map_
.
find
(
key
);
map_
.
erase
(
it
);
}
YamlNode
*
MappingNode
::
getValue
(
const
std
::
string
&
key
)
const
{
Mapping
::
const_iterator
it
=
map
.
find
(
key
);
Mapping
::
const_iterator
it
=
map
_
.
find
(
key
);
if
(
it
!=
map
.
end
())
{
if
(
it
!=
map
_
.
end
())
{
return
it
->
second
;
}
else
{
DEBUG
(
"MappingNode: Could not find %s"
,
key
.
c_str
());
...
...
@@ -124,7 +116,6 @@ YamlNode *MappingNode::getValue(const std::string &key) const
void
MappingNode
::
getValue
(
const
std
::
string
&
key
,
bool
*
b
)
const
{
ScalarNode
*
node
=
static_cast
<
ScalarNode
*>
(
getValue
(
key
));
if
(
!
node
)
return
;
...
...
@@ -154,9 +145,7 @@ void MappingNode::getValue(const std::string &key, std::string *v) const
void
MappingNode
::
deleteChildNodes
()
{
Mapping
::
iterator
it
;
for
(
it
=
map
.
begin
();
it
!=
map
.
end
();
++
it
)
{
for
(
Mapping
::
iterator
it
=
map_
.
begin
();
it
!=
map_
.
end
();
++
it
)
{
YamlNode
*
yamlNode
=
static_cast
<
YamlNode
*>
(
it
->
second
);
if
(
!
yamlNode
)
...
...
@@ -193,16 +182,13 @@ void MappingNode::deleteChildNodes()
void
SequenceNode
::
addNode
(
YamlNode
*
node
)
{
Sequence
::
iterator
it
=
seq
.
end
();
seq
.
insert
(
it
,
node
);
Sequence
::
iterator
it
=
seq
_
.
end
();
seq
_
.
insert
(
it
,
node
);
}
void
SequenceNode
::
deleteChildNodes
()
{
Sequence
::
iterator
it
;
for
(
it
=
seq
.
begin
();
it
!=
seq
.
end
();
++
it
)
{
for
(
Sequence
::
iterator
it
=
seq_
.
begin
();
it
!=
seq_
.
end
();
++
it
)
{
YamlNode
*
yamlNode
=
static_cast
<
YamlNode
*>
(
*
it
);
switch
(
yamlNode
->
getType
())
{
...
...
This diff is collapsed.
Click to expand it.
daemon/src/config/yamlnode.h
+
23
−
22
View file @
cf06b9ae
...
...
@@ -48,51 +48,51 @@ enum NodeType { DOCUMENT, SCALAR, MAPPING, SEQUENCE };
class
YamlNode
{
public:
YamlNode
(
NodeType
t
,
YamlNode
*
top
=
NULL
)
:
type
(
t
),
topNode
(
top
)
{}
YamlNode
(
NodeType
t
,
YamlNode
*
top
=
NULL
)
:
type
_
(
t
),
topNode
_
(
top
)
{}
virtual
~
YamlNode
()
{}
NodeType
getType
()
const
{
return
type
;
return
type
_
;
}
YamlNode
*
getTopNode
()
{
return
topNode
;
return
topNode
_
;
}
virtual
void
deleteChildNodes
()
=
0
;
private
:
NON_COPYABLE
(
YamlNode
);
NodeType
type
;
YamlNode
*
topNode
;
NodeType
type
_
;
YamlNode
*
topNode
_
;
};
class
YamlDocument
:
public
YamlNode
{
public:
YamlDocument
(
YamlNode
*
top
=
NULL
)
:
YamlNode
(
DOCUMENT
,
top
),
doc
()
{}
YamlDocument
(
YamlNode
*
top
=
NULL
)
:
YamlNode
(
DOCUMENT
,
top
),
doc
_
()
{}
void
addNode
(
YamlNode
*
node
);
YamlNode
*
popNode
();
Sequence
*
getSequence
()
{
return
&
doc
;
return
&
doc
_
;
}
virtual
void
deleteChildNodes
();
private
:
Sequence
doc
;
Sequence
doc
_
;
};
class
SequenceNode
:
public
YamlNode
{
public:
SequenceNode
(
YamlNode
*
top
)
:
YamlNode
(
SEQUENCE
,
top
),
seq
()
{}
SequenceNode
(
YamlNode
*
top
)
:
YamlNode
(
SEQUENCE
,
top
),
seq
_
()
{}
Sequence
*
getSequence
()
{
return
&
seq
;
return
&
seq
_
;
}
void
addNode
(
YamlNode
*
node
);
...
...
@@ -100,25 +100,26 @@ class SequenceNode : public YamlNode {
virtual
void
deleteChildNodes
();
private
:
Sequence
seq
;
Sequence
seq
_
;
};
class
MappingNode
:
public
YamlNode
{
public:
MappingNode
(
YamlNode
*
top
)
:
YamlNode
(
MAPPING
,
top
),
map
(),
tmpKey
()
{}
MappingNode
(
YamlNode
*
top
)
:
YamlNode
(
MAPPING
,
top
),
map_
(),
tmpKey_
()
{}
Mapping
*
getMapping
()
{
return
&
map
;
return
&
map
_
;
}
void
addNode
(
YamlNode
*
node
);
void
setTmpKey
(
std
::
string
key
)
{
tmpKey
=
key
;
tmpKey
_
=
key
;
}
void
setKeyValue
(
const
std
::
string
&
key
,
YamlNode
*
value
);
void
setKeyValue
(
const
std
::
string
&
key
,
YamlNode
*
value
);
void
removeKeyValue
(
const
std
::
string
&
key
);
...
...
@@ -130,27 +131,27 @@ class MappingNode : public YamlNode {
virtual
void
deleteChildNodes
();
private
:
Mapping
map
;
std
::
string
tmpKey
;
Mapping
map
_
;
std
::
string
tmpKey
_
;
};
class
ScalarNode
:
public
YamlNode
{
public:
ScalarNode
(
std
::
string
s
=
""
,
YamlNode
*
top
=
NULL
)
:
YamlNode
(
SCALAR
,
top
),
str
(
s
)
{}
ScalarNode
(
bool
b
,
YamlNode
*
top
=
NULL
)
:
YamlNode
(
SCALAR
,
top
),
str
(
b
?
"true"
:
"false"
)
{}
ScalarNode
(
std
::
string
s
=
""
,
YamlNode
*
top
=
NULL
)
:
YamlNode
(
SCALAR
,
top
),
str
_
(
s
)
{}
ScalarNode
(
bool
b
,
YamlNode
*
top
=
NULL
)
:
YamlNode
(
SCALAR
,
top
),
str
_
(
b
?
"true"
:
"false"
)
{}
const
std
::
string
&
getValue
()
const
{
return
str
;
return
str
_
;
}
void
setValue
(
const
std
::
string
&
s
)
{
str
=
s
;
str
_
=
s
;
}
virtual
void
deleteChildNodes
()
{}
private
:
std
::
string
str
;
std
::
string
str
_
;
};
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment