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
Sebastian Schrader
Kea
Commits
62b03a0f
Commit
62b03a0f
authored
Aug 25, 2010
by
JINMEI Tatuya
Browse files
merged trac
#310
: consity ElementPtr as much as possible.
git-svn-id:
svn://bind10.isc.org/svn/bind10/trunk@2803
e5f2f494-b856-4b98-b285-d166d9295462
parents
7b0c9a8d
3b4c9aa2
Changes
30
Hide whitespace changes
Inline
Side-by-side
src/bin/auth/auth_srv.cc
View file @
62b03a0f
...
...
@@ -68,7 +68,7 @@ private:
public:
AuthSrvImpl
(
const
bool
use_cache
,
AbstractXfroutClient
&
xfrout_client
);
~
AuthSrvImpl
();
isc
::
data
::
ElementPtr
setDbFile
(
const
isc
::
data
::
ElementPtr
config
);
isc
::
data
::
Const
ElementPtr
setDbFile
(
isc
::
data
::
Const
ElementPtr
config
);
bool
processNormalQuery
(
const
IOMessage
&
io_message
,
Message
&
message
,
MessageRenderer
&
response_renderer
);
...
...
@@ -426,7 +426,7 @@ AuthSrvImpl::processNotify(const IOMessage& io_message, Message& message,
static
const
string
command_template_end
=
"
\"
}]}"
;
try
{
ElementPtr
notify_command
=
Element
::
fromJSON
(
Const
ElementPtr
notify_command
=
Element
::
fromJSON
(
command_template_start
+
question
->
getName
().
toText
()
+
command_template_master
+
remote_ip_address
+
command_template_rrclass
+
question
->
getClass
().
toText
()
+
...
...
@@ -434,7 +434,7 @@ AuthSrvImpl::processNotify(const IOMessage& io_message, Message& message,
const
unsigned
int
seq
=
xfrin_session_
->
group_sendmsg
(
notify_command
,
"Zonemgr"
,
"*"
,
"*"
);
ElementPtr
env
,
answer
,
parsed_answer
;
Const
ElementPtr
env
,
answer
,
parsed_answer
;
xfrin_session_
->
group_recvmsg
(
env
,
answer
,
false
,
seq
);
int
rcode
;
parsed_answer
=
parseAnswer
(
rcode
,
answer
);
...
...
@@ -459,19 +459,17 @@ AuthSrvImpl::processNotify(const IOMessage& io_message, Message& message,
return
(
true
);
}
ElementPtr
AuthSrvImpl
::
setDbFile
(
const
isc
::
data
::
ElementPtr
config
)
{
ElementPtr
answer
=
isc
::
config
::
createAnswer
();
ElementPtr
final
;
ConstElementPtr
AuthSrvImpl
::
setDbFile
(
ConstElementPtr
config
)
{
ConstElementPtr
answer
=
isc
::
config
::
createAnswer
();
if
(
config
&&
config
->
contains
(
"database_file"
))
{
db_file_
=
config
->
get
(
"database_file"
)
->
stringValue
();
final
=
config
;
}
else
if
(
config_session_
!=
NULL
)
{
bool
is_default
;
string
item
(
"database_file"
);
ElementPtr
value
=
config_session_
->
getValue
(
is_default
,
item
);
final
=
Element
::
createMap
();
Const
ElementPtr
value
=
config_session_
->
getValue
(
is_default
,
item
);
ElementPtr
final
=
Element
::
createMap
();
// If the value is the default, and we are running from
// a specific directory ('from build'), we need to use
...
...
@@ -485,6 +483,7 @@ AuthSrvImpl::setDbFile(const isc::data::ElementPtr config) {
"/bind10_zones.sqlite3"
);
}
final
->
set
(
item
,
value
);
config
=
final
;
db_file_
=
value
->
stringValue
();
}
else
{
...
...
@@ -501,7 +500,7 @@ AuthSrvImpl::setDbFile(const isc::data::ElementPtr config) {
// fail, while acquiring resources in the RAII manner. We then perform
// delete and swap operations which should not fail.
DataSrcPtr
datasrc_ptr
(
DataSrcPtr
(
new
Sqlite3DataSrc
));
datasrc_ptr
->
init
(
final
);
datasrc_ptr
->
init
(
config
);
data_sources_
.
addDataSrc
(
datasrc_ptr
);
// The following code should be exception free.
...
...
@@ -513,15 +512,12 @@ AuthSrvImpl::setDbFile(const isc::data::ElementPtr config) {
return
(
answer
);
}
ElementPtr
AuthSrv
::
updateConfig
(
isc
::
data
::
ElementPtr
new_config
)
{
Const
ElementPtr
AuthSrv
::
updateConfig
(
Const
ElementPtr
new_config
)
{
try
{
// the ModuleCCSession has already checked if we have
// the correct ElementPtr type as specified in our .spec file
ElementPtr
answer
=
isc
::
config
::
createAnswer
();
answer
=
impl_
->
setDbFile
(
new_config
);
return
(
answer
);
return
(
impl_
->
setDbFile
(
new_config
));
}
catch
(
const
isc
::
Exception
&
error
)
{
if
(
impl_
->
verbose_mode_
)
{
cerr
<<
"[b10-auth] error: "
<<
error
.
what
()
<<
endl
;
...
...
src/bin/auth/auth_srv.h
View file @
62b03a0f
...
...
@@ -69,7 +69,7 @@ public:
isc
::
dns
::
MessageRenderer
&
response_renderer
);
void
setVerbose
(
bool
on
);
bool
getVerbose
()
const
;
isc
::
data
::
ElementPtr
updateConfig
(
isc
::
data
::
ElementPtr
config
);
isc
::
data
::
Const
ElementPtr
updateConfig
(
isc
::
data
::
Const
ElementPtr
config
);
isc
::
config
::
ModuleCCSession
*
configSession
()
const
;
void
setConfigSession
(
isc
::
config
::
ModuleCCSession
*
config_session
);
...
...
src/bin/auth/main.cc
View file @
62b03a0f
...
...
@@ -66,19 +66,19 @@ AuthSrv *auth_server;
asio_link
::
IOService
*
io_service
;
ElementPtr
my_config_handler
(
ElementPtr
new_config
)
{
Const
ElementPtr
my_config_handler
(
Const
ElementPtr
new_config
)
{
return
(
auth_server
->
updateConfig
(
new_config
));
}
ElementPtr
my_command_handler
(
const
string
&
command
,
c
onst
ElementPtr
args
)
{
ElementPtr
answer
=
createAnswer
();
Const
ElementPtr
my_command_handler
(
const
string
&
command
,
C
onstElementPtr
args
)
{
Const
ElementPtr
answer
=
createAnswer
();
if
(
command
==
"print_message"
)
{
cout
<<
args
<<
endl
;
/* let's add that message to our answer as well */
answer
->
get
(
"result"
)
->
add
(
args
);
answer
=
createAnswer
(
0
,
args
);
}
else
if
(
command
==
"shutdown"
)
{
io_service
->
stop
();
}
...
...
src/bin/auth/tests/auth_srv_unittest.cc
View file @
62b03a0f
...
...
@@ -85,26 +85,27 @@ private:
{}
virtual
void
establish
(
const
char
*
socket_file
);
virtual
void
disconnect
();
virtual
int
group_sendmsg
(
ElementPtr
msg
,
string
group
,
virtual
int
group_sendmsg
(
Const
ElementPtr
msg
,
string
group
,
string
instance
,
string
to
);
virtual
bool
group_recvmsg
(
ElementPtr
&
envelope
,
ElementPtr
&
msg
,
virtual
bool
group_recvmsg
(
ConstElementPtr
&
envelope
,
ConstElementPtr
&
msg
,
bool
nonblock
,
int
seq
);
virtual
void
subscribe
(
string
group
,
string
instance
);
virtual
void
unsubscribe
(
string
group
,
string
instance
);
virtual
void
startRead
(
boost
::
function
<
void
()
>
read_callback
);
virtual
int
reply
(
ElementPtr
&
envelope
,
ElementPtr
&
newmsg
);
virtual
bool
hasQueuedMsgs
();
virtual
int
reply
(
Const
ElementPtr
envelope
,
Const
ElementPtr
newmsg
);
virtual
bool
hasQueuedMsgs
()
const
;
virtual
void
setTimeout
(
size_t
timeout
UNUSED_PARAM
)
{};
virtual
size_t
getTimeout
()
const
{
return
0
;
};
void
setMessage
(
ElementPtr
msg
)
{
msg_
=
msg
;
}
void
setMessage
(
Const
ElementPtr
msg
)
{
msg_
=
msg
;
}
void
disableSend
()
{
send_ok_
=
false
;
}
void
disableReceive
()
{
receive_ok_
=
false
;
}
ElementPtr
sent_msg
;
Const
ElementPtr
sent_msg
;
string
msg_destination
;
private:
ElementPtr
msg_
;
Const
ElementPtr
msg_
;
bool
send_ok_
;
bool
receive_ok_
;
};
...
...
@@ -174,19 +175,19 @@ AuthSrvTest::MockSession::startRead(
{}
int
AuthSrvTest
::
MockSession
::
reply
(
ElementPtr
&
envelope
UNUSED_PARAM
,
ElementPtr
&
newmsg
UNUSED_PARAM
)
AuthSrvTest
::
MockSession
::
reply
(
Const
ElementPtr
envelope
UNUSED_PARAM
,
Const
ElementPtr
newmsg
UNUSED_PARAM
)
{
return
(
-
1
);
}
bool
AuthSrvTest
::
MockSession
::
hasQueuedMsgs
()
{
AuthSrvTest
::
MockSession
::
hasQueuedMsgs
()
const
{
return
(
false
);
}
int
AuthSrvTest
::
MockSession
::
group_sendmsg
(
ElementPtr
msg
,
string
group
,
AuthSrvTest
::
MockSession
::
group_sendmsg
(
Const
ElementPtr
msg
,
string
group
,
string
instance
UNUSED_PARAM
,
string
to
UNUSED_PARAM
)
{
...
...
@@ -200,8 +201,8 @@ AuthSrvTest::MockSession::group_sendmsg(ElementPtr msg, string group,
}
bool
AuthSrvTest
::
MockSession
::
group_recvmsg
(
ElementPtr
&
envelope
UNUSED_PARAM
,
ElementPtr
&
msg
,
AuthSrvTest
::
MockSession
::
group_recvmsg
(
Const
ElementPtr
&
envelope
UNUSED_PARAM
,
Const
ElementPtr
&
msg
,
bool
nonblock
UNUSED_PARAM
,
int
seq
UNUSED_PARAM
)
{
...
...
@@ -539,7 +540,8 @@ TEST_F(AuthSrvTest, notify) {
EXPECT_EQ
(
"Zonemgr"
,
notify_session
.
msg_destination
);
EXPECT_EQ
(
"notify"
,
notify_session
.
sent_msg
->
get
(
"command"
)
->
get
(
0
)
->
stringValue
());
ElementPtr
notify_args
=
notify_session
.
sent_msg
->
get
(
"command"
)
->
get
(
1
);
ConstElementPtr
notify_args
=
notify_session
.
sent_msg
->
get
(
"command"
)
->
get
(
1
);
EXPECT_EQ
(
"example.com."
,
notify_args
->
get
(
"zone_name"
)
->
stringValue
());
EXPECT_EQ
(
DEFAULT_REMOTE_ADDRESS
,
notify_args
->
get
(
"master"
)
->
stringValue
());
...
...
@@ -567,7 +569,8 @@ TEST_F(AuthSrvTest, notifyForCHClass) {
// Other conditions should be the same, so simply confirm the RR class is
// set correctly.
ElementPtr
notify_args
=
notify_session
.
sent_msg
->
get
(
"command"
)
->
get
(
1
);
ConstElementPtr
notify_args
=
notify_session
.
sent_msg
->
get
(
"command"
)
->
get
(
1
);
EXPECT_EQ
(
"CH"
,
notify_args
->
get
(
"zone_class"
)
->
stringValue
());
}
...
...
@@ -695,12 +698,12 @@ void
updateConfig
(
AuthSrv
*
server
,
const
char
*
const
dbfile
,
const
bool
expect_success
)
{
c
onst
ElementPtr
config_answer
=
C
onstElementPtr
config_answer
=
server
->
updateConfig
(
Element
::
fromJSON
(
dbfile
));
EXPECT_EQ
(
Element
::
map
,
config_answer
->
getType
());
EXPECT_TRUE
(
config_answer
->
contains
(
"result"
));
c
onst
ElementPtr
result
=
config_answer
->
get
(
"result"
);
C
onstElementPtr
result
=
config_answer
->
get
(
"result"
);
EXPECT_EQ
(
Element
::
list
,
result
->
getType
());
EXPECT_EQ
(
expect_success
?
0
:
1
,
result
->
get
(
0
)
->
intValue
());
}
...
...
src/lib/cc/data.cc
View file @
62b03a0f
...
...
@@ -20,6 +20,7 @@
#include
<cassert>
#include
<climits>
#include
<map>
#include
<cstdio>
#include
<iostream>
#include
<string>
...
...
@@ -35,21 +36,21 @@ namespace isc {
namespace
data
{
std
::
string
Element
::
str
()
{
Element
::
str
()
const
{
std
::
stringstream
ss
;
toJSON
(
ss
);
return
(
ss
.
str
());
}
std
::
string
Element
::
toWire
()
{
Element
::
toWire
()
const
{
std
::
stringstream
ss
;
toJSON
(
ss
);
return
(
ss
.
str
());
}
void
Element
::
toWire
(
std
::
ostream
&
ss
)
{
Element
::
toWire
(
std
::
ostream
&
ss
)
const
{
toJSON
(
ss
);
}
...
...
@@ -81,12 +82,12 @@ Element::getValue(std::string& t UNUSED_PARAM) {
}
bool
Element
::
getValue
(
std
::
vector
<
ElementPtr
>&
t
UNUSED_PARAM
)
{
Element
::
getValue
(
std
::
vector
<
Const
ElementPtr
>&
t
UNUSED_PARAM
)
{
return
(
false
);
}
bool
Element
::
getValue
(
std
::
map
<
std
::
string
,
ElementPtr
>&
t
UNUSED_PARAM
)
{
Element
::
getValue
(
std
::
map
<
std
::
string
,
Const
ElementPtr
>&
t
UNUSED_PARAM
)
{
return
(
false
);
}
...
...
@@ -111,27 +112,29 @@ Element::setValue(const std::string& v UNUSED_PARAM) {
}
bool
Element
::
setValue
(
const
std
::
vector
<
ElementPtr
>&
v
UNUSED_PARAM
)
{
Element
::
setValue
(
const
std
::
vector
<
Const
ElementPtr
>&
v
UNUSED_PARAM
)
{
return
(
false
);
}
bool
Element
::
setValue
(
const
std
::
map
<
std
::
string
,
ElementPtr
>&
v
UNUSED_PARAM
)
{
Element
::
setValue
(
const
std
::
map
<
std
::
string
,
ConstElementPtr
>&
v
UNUSED_PARAM
)
{
return
(
false
);
}
ElementPtr
Element
::
get
(
const
int
i
UNUSED_PARAM
)
{
Const
ElementPtr
Element
::
get
(
const
int
i
UNUSED_PARAM
)
const
{
isc_throw
(
TypeError
,
"get(int) called on a non-list Element"
);
}
void
Element
::
set
(
const
size_t
i
UNUSED_PARAM
,
ElementPtr
element
UNUSED_PARAM
)
{
Element
::
set
(
const
size_t
i
UNUSED_PARAM
,
Const
ElementPtr
element
UNUSED_PARAM
)
{
isc_throw
(
TypeError
,
"set(int, element) called on a non-list Element"
);
}
void
Element
::
add
(
ElementPtr
element
UNUSED_PARAM
)
{
Element
::
add
(
Const
ElementPtr
element
UNUSED_PARAM
)
{
isc_throw
(
TypeError
,
"add() called on a non-list Element"
);
}
...
...
@@ -141,18 +144,18 @@ Element::remove(const int i UNUSED_PARAM) {
}
size_t
Element
::
size
()
{
Element
::
size
()
const
{
isc_throw
(
TypeError
,
"size() called on a non-list Element"
);
}
ElementPtr
Element
::
get
(
const
std
::
string
&
name
UNUSED_PARAM
)
{
Const
ElementPtr
Element
::
get
(
const
std
::
string
&
name
UNUSED_PARAM
)
const
{
isc_throw
(
TypeError
,
"get(string) called on a non-map Element"
);
}
void
Element
::
set
(
const
std
::
string
&
name
UNUSED_PARAM
,
ElementPtr
element
UNUSED_PARAM
)
Const
ElementPtr
element
UNUSED_PARAM
)
{
isc_throw
(
TypeError
,
"set(name, element) called on a non-map Element"
);
}
...
...
@@ -163,18 +166,18 @@ Element::remove(const std::string& name UNUSED_PARAM) {
}
bool
Element
::
contains
(
const
std
::
string
&
name
UNUSED_PARAM
)
{
Element
::
contains
(
const
std
::
string
&
name
UNUSED_PARAM
)
const
{
isc_throw
(
TypeError
,
"contains(string) called on a non-map Element"
);
}
ElementPtr
Element
::
find
(
const
std
::
string
&
identifier
UNUSED_PARAM
)
{
Const
ElementPtr
Element
::
find
(
const
std
::
string
&
identifier
UNUSED_PARAM
)
const
{
isc_throw
(
TypeError
,
"find(string) called on a non-map Element"
);
}
bool
Element
::
find
(
const
std
::
string
&
identifier
UNUSED_PARAM
,
ElementPtr
&
t
UNUSED_PARAM
)
Const
ElementPtr
t
UNUSED_PARAM
)
const
{
return
(
false
);
}
...
...
@@ -189,12 +192,18 @@ throwJSONError(const std::string& error, const std::string& file, int line, int
}
}
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
isc
::
data
::
ElementPtr
&
e
)
{
return
(
out
<<
e
->
str
());
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
Element
&
e
)
{
return
(
out
<<
e
.
str
());
}
bool
operator
==
(
const
isc
::
data
::
ElementPtr
a
,
const
isc
::
data
::
ElementPtr
b
)
{
return
(
a
->
equals
(
b
));
bool
operator
==
(
const
Element
&
a
,
const
Element
&
b
)
{
return
(
a
.
equals
(
b
));
}
bool
operator
!=
(
const
Element
&
a
,
const
Element
&
b
)
{
return
(
!
a
.
equals
(
b
));
};
//
...
...
@@ -428,7 +437,7 @@ from_stringstream_list(std::istream &in, const std::string& file, int& line, int
{
char
c
=
0
;
ElementPtr
list
=
Element
::
createList
();
ElementPtr
cur_list_element
;
Const
ElementPtr
cur_list_element
;
skip_chars
(
in
,
"
\t\n
"
,
line
,
pos
);
while
(
c
!=
EOF
&&
c
!=
']'
)
{
...
...
@@ -462,7 +471,7 @@ from_stringstream_map(std::istream &in, const std::string& file, int& line,
in
.
get
();
pos
++
;
ElementPtr
value
=
Element
::
fromJSON
(
in
,
file
,
line
,
pos
);
Const
ElementPtr
value
=
Element
::
fromJSON
(
in
,
file
,
line
,
pos
);
map
->
set
(
key
,
value
);
skip_to
(
in
,
file
,
line
,
pos
,
",}"
,
"
\t\n
"
);
...
...
@@ -614,20 +623,17 @@ Element::fromJSON(const std::string &in) {
// to JSON format
void
IntElement
::
toJSON
(
std
::
ostream
&
ss
)
{
IntElement
::
toJSON
(
std
::
ostream
&
ss
)
const
{
ss
<<
intValue
();
}
void
DoubleElement
::
toJSON
(
std
::
ostream
&
ss
)
{
DoubleElement
::
toJSON
(
std
::
ostream
&
ss
)
const
{
ss
<<
doubleValue
();
}
void
BoolElement
::
toJSON
(
std
::
ostream
&
ss
)
{
BoolElement
::
toJSON
(
std
::
ostream
&
ss
)
const
{
if
(
boolValue
())
{
ss
<<
"true"
;
}
else
{
...
...
@@ -636,26 +642,23 @@ BoolElement::toJSON(std::ostream& ss)
}
void
NullElement
::
toJSON
(
std
::
ostream
&
ss
)
{
NullElement
::
toJSON
(
std
::
ostream
&
ss
)
const
{
ss
<<
"null"
;
}
void
StringElement
::
toJSON
(
std
::
ostream
&
ss
)
{
StringElement
::
toJSON
(
std
::
ostream
&
ss
)
const
{
ss
<<
"
\"
"
;
ss
<<
stringValue
();
ss
<<
"
\"
"
;
}
void
ListElement
::
toJSON
(
std
::
ostream
&
ss
)
{
ListElement
::
toJSON
(
std
::
ostream
&
ss
)
const
{
ss
<<
"[ "
;
const
std
::
vector
<
ElementPtr
>&
v
=
listValue
();
for
(
std
::
vector
<
ElementPtr
>::
const_iterator
it
=
v
.
begin
();
const
std
::
vector
<
Const
ElementPtr
>&
v
=
listValue
();
for
(
std
::
vector
<
Const
ElementPtr
>::
const_iterator
it
=
v
.
begin
();
it
!=
v
.
end
();
++
it
)
{
if
(
it
!=
v
.
begin
())
{
ss
<<
", "
;
...
...
@@ -666,12 +669,11 @@ ListElement::toJSON(std::ostream& ss)
}
void
MapElement
::
toJSON
(
std
::
ostream
&
ss
)
{
MapElement
::
toJSON
(
std
::
ostream
&
ss
)
const
{
ss
<<
"{ "
;
const
std
::
map
<
std
::
string
,
ElementPtr
>&
m
=
mapValue
();
for
(
std
::
map
<
std
::
string
,
ElementPtr
>::
const_iterator
it
=
m
.
begin
();
const
std
::
map
<
std
::
string
,
Const
ElementPtr
>&
m
=
mapValue
();
for
(
std
::
map
<
std
::
string
,
Const
ElementPtr
>::
const_iterator
it
=
m
.
begin
();
it
!=
m
.
end
();
++
it
)
{
if
(
it
!=
m
.
begin
())
{
ss
<<
", "
;
...
...
@@ -690,13 +692,13 @@ MapElement::toJSON(std::ostream& ss)
// we're looking for) is not a MapElement
// returns 0 if it could simply not be found
// should that also be an exception?
ElementPtr
MapElement
::
find
(
const
std
::
string
&
id
)
{
Const
ElementPtr
MapElement
::
find
(
const
std
::
string
&
id
)
const
{
const
size_t
sep
=
id
.
find
(
'/'
);
if
(
sep
==
std
::
string
::
npos
)
{
return
(
get
(
id
));
}
else
{
ElementPtr
ce
=
get
(
id
.
substr
(
0
,
sep
));
Const
ElementPtr
ce
=
get
(
id
.
substr
(
0
,
sep
));
if
(
ce
)
{
// ignore trailing slash
if
(
sep
+
1
!=
id
.
size
())
{
...
...
@@ -735,14 +737,14 @@ Element::fromWire(std::stringstream& in, int length) {
}
void
MapElement
::
set
(
const
std
::
string
&
key
,
ElementPtr
value
)
{
MapElement
::
set
(
const
std
::
string
&
key
,
Const
ElementPtr
value
)
{
m
[
key
]
=
value
;
}
bool
MapElement
::
find
(
const
std
::
string
&
id
,
ElementPtr
&
t
)
{
MapElement
::
find
(
const
std
::
string
&
id
,
Const
ElementPtr
t
)
const
{
try
{
ElementPtr
p
=
find
(
id
);
Const
ElementPtr
p
=
find
(
id
);
if
(
p
)
{
t
=
p
;
return
(
true
);
...
...
@@ -754,43 +756,43 @@ MapElement::find(const std::string& id, ElementPtr& t) {
}
bool
IntElement
::
equals
(
Element
Ptr
other
)
{
return
(
other
->
getType
()
==
Element
::
integer
)
&&
(
i
==
other
->
intValue
());
IntElement
::
equals
(
const
Element
&
other
)
const
{
return
(
other
.
getType
()
==
Element
::
integer
)
&&
(
i
==
other
.
intValue
());
}
bool
DoubleElement
::
equals
(
Element
Ptr
other
)
{
return
(
other
->
getType
()
==
Element
::
real
)
&&
(
d
==
other
->
doubleValue
());
DoubleElement
::
equals
(
const
Element
&
other
)
const
{
return
(
other
.
getType
()
==
Element
::
real
)
&&
(
d
==
other
.
doubleValue
());
}
bool
BoolElement
::
equals
(
Element
Ptr
other
)
{
return
(
other
->
getType
()
==
Element
::
boolean
)
&&
(
b
==
other
->
boolValue
());
BoolElement
::
equals
(
const
Element
&
other
)
const
{
return
(
other
.
getType
()
==
Element
::
boolean
)
&&
(
b
==
other
.
boolValue
());
}
bool
NullElement
::
equals
(
Element
Ptr
other
)
{
return
(
other
->
getType
()
==
Element
::
null
);
NullElement
::
equals
(
const
Element
&
other
)
const
{
return
(
other
.
getType
()
==
Element
::
null
);
}
bool
StringElement
::
equals
(
Element
Ptr
other
)
{
return
(
other
->
getType
()
==
Element
::
string
)
&&
(
s
==
other
->
stringValue
());
StringElement
::
equals
(
const
Element
&
other
)
const
{
return
(
other
.
getType
()
==
Element
::
string
)
&&
(
s
==
other
.
stringValue
());
}
bool
ListElement
::
equals
(
Element
Ptr
other
)
{
if
(
other
->
getType
()
==
Element
::
list
)
{
ListElement
::
equals
(
const
Element
&
other
)
const
{
if
(
other
.
getType
()
==
Element
::
list
)
{
const
int
s
=
size
();
if
(
s
!=
other
->
size
())
{
if
(
s
!=
other
.
size
())
{
return
(
false
);
}
for
(
int
i
=
0
;
i
<
s
;
++
i
)
{
if
(
!
get
(
i
)
->
equals
(
other
->
get
(
i
)))
{
if
(
!
get
(
i
)
->
equals
(
*
other
.
get
(
i
)))
{
return
(
false
);
}
}
...
...
@@ -801,13 +803,14 @@ ListElement::equals(ElementPtr other) {
}
bool
MapElement
::
equals
(
ElementPtr
other
)
{
if
(
other
->
getType
()
==
Element
::
map
)
{
std
::
map
<
std
::
string
,
ElementPtr
>
m
=
mapValue
();
for
(
std
::
map
<
std
::
string
,
ElementPtr
>::
const_iterator
it
=
m
.
begin
();
MapElement
::
equals
(
const
Element
&
other
)
const
{
if
(
other
.
getType
()
==
Element
::
map
)
{
const
std
::
map
<
std
::
string
,
ConstElementPtr
>&
m
=
mapValue
();
for
(
std
::
map
<
std
::
string
,
ConstElementPtr
>::
const_iterator
it
=
m
.
begin
();
it
!=
m
.
end
()
;
++
it
)
{
if
(
other
->
contains
((
*
it
).
first
))
{
if
(
!
get
((
*
it
).
first
)
->
equals
(
other
->
get
((
*
it
).
first
)))
{
if
(
other
.
contains
((
*
it
).
first
))
{
if
(
!
get
((
*
it
).
first
)
->
equals
(
*
other
.
get
((
*
it
).
first
)))
{
return
(
false
);
}
}
else
{
...
...
@@ -819,9 +822,10 @@ MapElement::equals(ElementPtr other) {
// compare those elements; if one of them is missing we
// differ (and if it's not missing the loop above has checked
// it)
m
=
other
->
mapValue
();
for
(
std
::
map
<
std
::
string
,
ElementPtr
>::
const_iterator
it
=
m
.
begin
();
it
!=
m
.
end
()
;
++
it
)
{
std
::
map
<
std
::
string
,
ConstElementPtr
>::
const_iterator
it
;
for
(
it
=
other
.
mapValue
().
begin
();
it
!=
other
.
mapValue
().
end
();
++
it
)
{
if
(
!
contains
((
*
it
).
first
))
{
return
(
false
);
}
...
...
@@ -833,12 +837,12 @@ MapElement::equals(ElementPtr other) {
}
bool
isNull
(
ElementPtr
p
)
{
isNull
(
Const
ElementPtr
p
)
{
return
(
!
p
);
}
void
removeIdentical
(
ElementPtr
a
,
c
onst
ElementPtr
b
)
{
removeIdentical
(
ElementPtr
a
,
C
onstElementPtr
b
)
{
if
(
!
b
)
{
return
;
}
...
...
@@ -846,26 +850,50 @@ removeIdentical(ElementPtr a, const ElementPtr b) {
isc_throw
(
TypeError
,
"Non-map Elements passed to removeIdentical"
);
}