Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
Kea
Commits
f3a880b0
Commit
f3a880b0
authored
Jan 24, 2017
by
Tomek Mrugalski
🛰
Browse files
[5019] SimpleParser methods are now public (used in global parsers)
parent
80257db8
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/cc/simple_parser.cc
View file @
f3a880b0
...
...
@@ -19,10 +19,12 @@ std::string
SimpleParser
::
getString
(
isc
::
data
::
ConstElementPtr
scope
,
const
std
::
string
&
name
)
{
ConstElementPtr
x
=
scope
->
get
(
name
);
if
(
!
x
)
{
isc_throw
(
BadValue
,
"Element "
<<
name
<<
" not found"
);
isc_throw
(
BadValue
,
"String parameter "
<<
name
<<
" not found"
<<
"("
<<
scope
->
getPosition
()
<<
")"
);
}
if
(
x
->
getType
()
!=
Element
::
string
)
{
isc_throw
(
BadValue
,
"Element "
<<
name
<<
" found, but is not a string"
);
isc_throw
(
BadValue
,
"Element "
<<
name
<<
" found, but is not a string"
<<
"("
<<
x
->
getPosition
()
<<
")"
);
}
return
(
x
->
stringValue
());
...
...
@@ -32,10 +34,12 @@ int64_t
SimpleParser
::
getInteger
(
isc
::
data
::
ConstElementPtr
scope
,
const
std
::
string
&
name
)
{
ConstElementPtr
x
=
scope
->
get
(
name
);
if
(
!
x
)
{
isc_throw
(
BadValue
,
"Element "
<<
name
<<
" not found"
);
isc_throw
(
BadValue
,
"Integer parameter "
<<
name
<<
" not found "
<<
"("
<<
scope
->
getPosition
()
<<
")"
);
}
if
(
x
->
getType
()
!=
Element
::
integer
)
{
isc_throw
(
BadValue
,
"Element "
<<
name
<<
" found, but is not an integer"
);
isc_throw
(
BadValue
,
"Element "
<<
name
<<
" found, but is not an integer"
<<
"("
<<
x
->
getPosition
()
<<
")"
);
}
return
(
x
->
intValue
());
...
...
@@ -45,10 +49,13 @@ bool
SimpleParser
::
getBoolean
(
isc
::
data
::
ConstElementPtr
scope
,
const
std
::
string
&
name
)
{
ConstElementPtr
x
=
scope
->
get
(
name
);
if
(
!
x
)
{
isc_throw
(
BadValue
,
"Element "
<<
name
<<
" not found"
);
isc_throw
(
BadValue
,
"Boolean element "
<<
name
<<
" not found "
<<
"("
<<
scope
->
getPosition
()
<<
")"
);
}
if
(
x
->
getType
()
!=
Element
::
boolean
)
{
isc_throw
(
BadValue
,
"Element "
<<
name
<<
" found, but is not a boolean"
);
isc_throw
(
BadValue
,
"Element "
<<
name
<<
" found, but is not a boolean"
<<
"("
<<
x
->
getPosition
()
<<
")"
);
}
return
(
x
->
boolValue
());
...
...
src/lib/cc/simple_parser.h
View file @
f3a880b0
...
...
@@ -113,8 +113,6 @@ class SimpleParser {
static
const
data
::
Element
::
Position
&
getPosition
(
const
std
::
string
&
name
,
const
data
::
ConstElementPtr
parent
);
protected:
/// @brief Returns a string parameter from a scope
///
/// Unconditionally returns a parameter. If the parameter is not there or
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment