Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Kea
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sebastian Schrader
Kea
Commits
04fa0d3f
Commit
04fa0d3f
authored
Nov 24, 2016
by
Tomek Mrugalski
🛰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[5014_phase2] ListElement can now be modified
It now contains vector of ElementPtr, rather than ConstElementPtr
parent
cbba4ee6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
25 deletions
+33
-25
src/lib/cc/data.cc
src/lib/cc/data.cc
+12
-7
src/lib/cc/data.h
src/lib/cc/data.h
+14
-11
src/lib/cc/tests/data_unittests.cc
src/lib/cc/tests/data_unittests.cc
+7
-7
No files found.
src/lib/cc/data.cc
View file @
04fa0d3f
...
...
@@ -86,7 +86,7 @@ Element::getValue(std::string&) const {
}
bool
Element
::
getValue
(
std
::
vector
<
Const
ElementPtr
>&
)
const
{
Element
::
getValue
(
std
::
vector
<
ElementPtr
>&
)
const
{
return
(
false
);
}
...
...
@@ -116,7 +116,7 @@ Element::setValue(const std::string&) {
}
bool
Element
::
setValue
(
const
std
::
vector
<
Const
ElementPtr
>&
)
{
Element
::
setValue
(
const
std
::
vector
<
ElementPtr
>&
)
{
return
(
false
);
}
...
...
@@ -130,13 +130,18 @@ Element::get(const int) const {
throwTypeError
(
"get(int) called on a non-list Element"
);
}
ElementPtr
Element
::
getNonConst
(
const
int
)
{
throwTypeError
(
"get(int) called on a non-list Element"
);
}
void
Element
::
set
(
const
size_t
,
Const
ElementPtr
)
{
Element
::
set
(
const
size_t
,
ElementPtr
)
{
throwTypeError
(
"set(int, element) called on a non-list Element"
);
}
void
Element
::
add
(
Const
ElementPtr
)
{
Element
::
add
(
ElementPtr
)
{
throwTypeError
(
"add() called on a non-list Element"
);
}
...
...
@@ -507,7 +512,7 @@ fromStringstreamList(std::istream& in, const std::string& file, int& line,
{
int
c
=
0
;
ElementPtr
list
=
Element
::
createList
(
Element
::
Position
(
file
,
line
,
pos
));
Const
ElementPtr
cur_list_element
;
ElementPtr
cur_list_element
;
skipChars
(
in
,
WHITESPACE
,
line
,
pos
);
while
(
c
!=
EOF
&&
c
!=
']'
)
{
...
...
@@ -805,8 +810,8 @@ void
ListElement
::
toJSON
(
std
::
ostream
&
ss
)
const
{
ss
<<
"[ "
;
const
std
::
vector
<
Const
ElementPtr
>&
v
=
listValue
();
for
(
std
::
vector
<
Const
ElementPtr
>::
const_iterator
it
=
v
.
begin
();
const
std
::
vector
<
ElementPtr
>&
v
=
listValue
();
for
(
std
::
vector
<
ElementPtr
>::
const_iterator
it
=
v
.
begin
();
it
!=
v
.
end
();
++
it
)
{
if
(
it
!=
v
.
begin
())
{
ss
<<
", "
;
...
...
src/lib/cc/data.h
View file @
04fa0d3f
...
...
@@ -216,7 +216,7 @@ public:
{
throwTypeError
(
"boolValue() called on non-Bool Element"
);
};
virtual
std
::
string
stringValue
()
const
{
throwTypeError
(
"stringValue() called on non-string Element"
);
};
virtual
const
std
::
vector
<
Const
ElementPtr
>&
listValue
()
const
{
virtual
const
std
::
vector
<
ElementPtr
>&
listValue
()
const
{
// replace with real exception or empty vector?
throwTypeError
(
"listValue() called on non-list Element"
);
};
...
...
@@ -239,7 +239,7 @@ public:
virtual
bool
getValue
(
double
&
t
)
const
;
virtual
bool
getValue
(
bool
&
t
)
const
;
virtual
bool
getValue
(
std
::
string
&
t
)
const
;
virtual
bool
getValue
(
std
::
vector
<
Const
ElementPtr
>&
t
)
const
;
virtual
bool
getValue
(
std
::
vector
<
ElementPtr
>&
t
)
const
;
virtual
bool
getValue
(
std
::
map
<
std
::
string
,
ConstElementPtr
>&
t
)
const
;
//@}
...
...
@@ -259,7 +259,7 @@ public:
virtual
bool
setValue
(
const
double
v
);
virtual
bool
setValue
(
const
bool
t
);
virtual
bool
setValue
(
const
std
::
string
&
v
);
virtual
bool
setValue
(
const
std
::
vector
<
Const
ElementPtr
>&
v
);
virtual
bool
setValue
(
const
std
::
vector
<
ElementPtr
>&
v
);
virtual
bool
setValue
(
const
std
::
map
<
std
::
string
,
ConstElementPtr
>&
v
);
//@}
...
...
@@ -277,15 +277,17 @@ public:
/// \param i The position of the ElementPtr to return
virtual
ConstElementPtr
get
(
const
int
i
)
const
;
virtual
ElementPtr
getNonConst
(
const
int
i
);
/// Sets the ElementPtr at the given index. If the index is out
/// of bounds, this function throws an std::out_of_range exception.
/// \param i The position of the ElementPtr to set
/// \param element The ElementPtr to set at the position
virtual
void
set
(
const
size_t
i
,
Const
ElementPtr
element
);
virtual
void
set
(
const
size_t
i
,
ElementPtr
element
);
/// Adds an ElementPtr to the list
/// \param element The ElementPtr to add
virtual
void
add
(
Const
ElementPtr
element
);
virtual
void
add
(
ElementPtr
element
);
/// Removes the element at the given position. If the index is out
/// of nothing happens.
...
...
@@ -603,29 +605,30 @@ public:
};
class
ListElement
:
public
Element
{
std
::
vector
<
Const
ElementPtr
>
l
;
std
::
vector
<
ElementPtr
>
l
;
public:
ListElement
(
const
Position
&
pos
=
ZERO_POSITION
())
:
Element
(
list
,
pos
)
{}
const
std
::
vector
<
Const
ElementPtr
>&
listValue
()
const
{
return
(
l
);
}
const
std
::
vector
<
ElementPtr
>&
listValue
()
const
{
return
(
l
);
}
using
Element
::
getValue
;
bool
getValue
(
std
::
vector
<
Const
ElementPtr
>&
t
)
const
{
bool
getValue
(
std
::
vector
<
ElementPtr
>&
t
)
const
{
t
=
l
;
return
(
true
);
}
using
Element
::
setValue
;
bool
setValue
(
const
std
::
vector
<
Const
ElementPtr
>&
v
)
{
bool
setValue
(
const
std
::
vector
<
ElementPtr
>&
v
)
{
l
=
v
;
return
(
true
);
}
using
Element
::
get
;
ConstElementPtr
get
(
int
i
)
const
{
return
(
l
.
at
(
i
));
}
ElementPtr
getNonConst
(
int
i
)
{
return
(
l
.
at
(
i
));
}
using
Element
::
set
;
void
set
(
size_t
i
,
Const
ElementPtr
e
)
{
void
set
(
size_t
i
,
ElementPtr
e
)
{
l
.
at
(
i
)
=
e
;
}
void
add
(
Const
ElementPtr
e
)
{
l
.
push_back
(
e
);
};
void
add
(
ElementPtr
e
)
{
l
.
push_back
(
e
);
};
using
Element
::
remove
;
void
remove
(
int
i
)
{
l
.
erase
(
l
.
begin
()
+
i
);
};
void
toJSON
(
std
::
ostream
&
ss
)
const
;
...
...
src/lib/cc/tests/data_unittests.cc
View file @
04fa0d3f
...
...
@@ -210,7 +210,7 @@ testGetValueInt() {
double
d
;
bool
b
;
std
::
string
s
;
std
::
vector
<
Const
ElementPtr
>
v
;
std
::
vector
<
ElementPtr
>
v
;
std
::
map
<
std
::
string
,
ConstElementPtr
>
m
;
el
=
Element
::
create
(
1
);
...
...
@@ -270,7 +270,7 @@ testGetValueDouble() {
double
d
;
bool
b
;
std
::
string
s
;
std
::
vector
<
Const
ElementPtr
>
v
;
std
::
vector
<
ElementPtr
>
v
;
std
::
map
<
std
::
string
,
ConstElementPtr
>
m
;
el
=
Element
::
create
(
1.1
);
...
...
@@ -297,7 +297,7 @@ testGetValueBool() {
double
d
;
bool
b
;
std
::
string
s
;
std
::
vector
<
Const
ElementPtr
>
v
;
std
::
vector
<
ElementPtr
>
v
;
std
::
map
<
std
::
string
,
ConstElementPtr
>
m
;
el
=
Element
::
create
(
true
);
...
...
@@ -324,7 +324,7 @@ testGetValueString() {
double
d
;
bool
b
;
std
::
string
s
;
std
::
vector
<
Const
ElementPtr
>
v
;
std
::
vector
<
ElementPtr
>
v
;
std
::
map
<
std
::
string
,
ConstElementPtr
>
m
;
el
=
Element
::
create
(
"foo"
);
...
...
@@ -351,7 +351,7 @@ testGetValueList() {
double
d
;
bool
b
;
std
::
string
s
;
std
::
vector
<
Const
ElementPtr
>
v
;
std
::
vector
<
ElementPtr
>
v
;
std
::
map
<
std
::
string
,
ConstElementPtr
>
m
;
el
=
Element
::
createList
();
...
...
@@ -378,7 +378,7 @@ testGetValueMap() {
double
d
;
bool
b
;
std
::
string
s
;
std
::
vector
<
Const
ElementPtr
>
v
;
std
::
vector
<
ElementPtr
>
v
;
std
::
map
<
std
::
string
,
ConstElementPtr
>
m
;
el
=
Element
::
createMap
();
...
...
@@ -406,7 +406,7 @@ TEST(Element, create_and_value_throws) {
double
d
=
0.0
;
bool
b
=
false
;
std
::
string
s
(
"asdf"
);
std
::
vector
<
Const
ElementPtr
>
v
;
std
::
vector
<
ElementPtr
>
v
;
std
::
map
<
std
::
string
,
ConstElementPtr
>
m
;
ConstElementPtr
tmp
;
...
...
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