-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNetconfResponse.cc
37 lines (32 loc) · 920 Bytes
/
NetconfResponse.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "YdbStr.hh"
#include "DomUtils.hh"
#include "NetconfIdentities.hh"
#include "NetconfResponse.hh"
using namespace xercesc;
NetconfResponse::NetconfResponse(DomUtils& domUtils, DOMNode* rpc) :
_domUtils(domUtils),
_rpc(rpc)
{
}
std::string
NetconfResponse::getOk(xercesc::DOMNode* node) const
{
DOMDocument* document = _domUtils.newDocument();
DOMNode* rpcReply = createRpcReply(document);
if (node != nullptr) {
DOMNode* dataNode = document->importNode(node, true);
rpcReply->appendChild(dataNode);
}
std::string result = _domUtils.serialize(rpcReply);
document->release();
return result;
}
DOMNode*
NetconfResponse::createRpcReply(xercesc::DOMDocument* document) const
{
DOMNode* reply = document->importNode(_rpc, false);
document->renameNode(reply,
NetconfIdentities::NETCONF_XMLNS.xmlCh(),
NetconfIdentities::RPC_REPLY.xmlCh());
return reply;
}