2 * Copyright 2020 AT&T Intellectual Property
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 // Created by adi ENZEL on 4/5/20.
27 #include "pugixml/src/pugixml.hpp"
34 void buildXmlData(vector<string> &repValues, unsigned char *buffer) {
35 pugi::xml_document doc;
37 pugi::xml_parse_result result = doc.load_string((const char *) buffer);
39 unsigned int index = 0;
40 for (auto tool : doc.child("E2AP-PDU")
41 .child("initiatingMessage")
43 .child("E2setupRequest")
45 .children("E2setupRequestIEs")) {
46 for (auto n : tool.child("value").child("RANfunctions-List").child(
47 "ProtocolIE-SingleContainer").children()) {
48 //ProtocolIE-SingleContainer
49 //cout << "\t1 " << n.name() << endl;
50 if (strcmp(n.name(), "value") == 0) {
51 for (auto l : tool.child("value").children()) {
52 //cout << "\t\t2 " << l.name() << endl;
53 for (auto f : l.children()) {
54 //cout << "\t\t\t3 " << f.name() << endl;
55 for (auto g : f.child("value").children()) {
56 //cout << "\t\t\t\t4 " << g.name() << endl;
57 for (auto a : g.children()) {
58 if (strcmp(a.name(), "ranFunctionDefinition") == 0) {
59 if (repValues.size() > index) {
61 string val = repValues.at(index++);
62 // here we get vector with counter
63 a.append_child(pugi::node_pcdata).set_value(val.c_str());
67 //cout << "\t\t\t\t\t5 " << a.name() << " " << a.child_value() << endl;
76 streambuf *oldCout = cout.rdbuf();
77 ostringstream memCout;
79 cout.rdbuf(memCout.rdbuf());
81 //return to the normal cout
83 memcpy(buffer, memCout.str().c_str(), memCout.str().length());
87 #endif //E2_BUILDXML_H