Coverage Report

Created: 2022-08-24 06:19

/src/Fast-DDS/src/cpp/rtps/xmlparser/XMLElementParser.cpp
Line
Count
Source (jump to first uncovered line)
1
// Copyright 2017 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//     http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
//
15
#include <cstring>
16
#include <regex>
17
#include <tinyxml2.h>
18
#include <fastrtps/xmlparser/XMLParserCommon.h>
19
#include <fastrtps/xmlparser/XMLParser.h>
20
#include <fastrtps/xmlparser/XMLProfileManager.h>
21
#include <fastrtps/utils/IPLocator.h>
22
#include <fastdds/dds/log/Log.hpp>
23
24
using namespace eprosima::fastrtps;
25
using namespace eprosima::fastrtps::rtps;
26
using namespace eprosima::fastrtps::xmlparser;
27
28
XMLP_ret XMLParser::getXMLParticipantAllocationAttributes(
29
        tinyxml2::XMLElement* elem,
30
        rtps::RTPSParticipantAllocationAttributes& allocation,
31
        uint8_t ident)
32
581
{
33
    /*
34
        <xs:complexType name="rtpsParticipantAllocationAttributesType">
35
            <xs:all minOccurs="0">
36
                <xs:element name="remote_locators" type="remoteLocatorsAllocationConfigType" minOccurs="0"/>
37
                <xs:element name="total_participants" type="containerAllocationConfigType" minOccurs="0"/>
38
                <xs:element name="total_readers" type="containerAllocationConfigType" minOccurs="0"/>
39
                <xs:element name="total_writers" type="containerAllocationConfigType" minOccurs="0"/>
40
                <xs:element name="send_buffers" type="sendBuffersAllocationConfigType" minOccurs="0"/>
41
                <xs:element name="max_properties" type="uint32Type" minOccurs="0"/>
42
                <xs:element name="max_user_data" type="uint32Type" minOccurs="0"/>
43
                <xs:element name="max_partitions" type="uint32Type" minOccurs="0"/>
44
            </xs:all>
45
        </xs:complexType>
46
     */
47
48
581
    tinyxml2::XMLElement* p_aux0 = nullptr;
49
581
    const char* name = nullptr;
50
581
    uint32_t tmp;
51
581
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
52
0
    {
53
0
        name = p_aux0->Name();
54
0
        if (strcmp(name, REMOTE_LOCATORS) == 0)
55
0
        {
56
            // leaseDuration - durationType
57
0
            if (XMLP_ret::XML_OK != getXMLRemoteLocatorsAllocationAttributes(p_aux0, allocation.locators, ident))
58
0
            {
59
0
                return XMLP_ret::XML_ERROR;
60
0
            }
61
0
        }
62
0
        else if (strcmp(name, TOTAL_PARTICIPANTS) == 0)
63
0
        {
64
            // total_participants - containerAllocationConfigType
65
0
            if (XMLP_ret::XML_OK != getXMLContainerAllocationConfig(p_aux0, allocation.participants, ident))
66
0
            {
67
0
                return XMLP_ret::XML_ERROR;
68
0
            }
69
0
        }
70
0
        else if (strcmp(name, TOTAL_READERS) == 0)
71
0
        {
72
            // total_readers - containerAllocationConfigType
73
0
            if (XMLP_ret::XML_OK != getXMLContainerAllocationConfig(p_aux0, allocation.readers, ident))
74
0
            {
75
0
                return XMLP_ret::XML_ERROR;
76
0
            }
77
0
        }
78
0
        else if (strcmp(name, TOTAL_WRITERS) == 0)
79
0
        {
80
            // total_writers - containerAllocationConfigType
81
0
            if (XMLP_ret::XML_OK != getXMLContainerAllocationConfig(p_aux0, allocation.writers, ident))
82
0
            {
83
0
                return XMLP_ret::XML_ERROR;
84
0
            }
85
0
        }
86
0
        else if (strcmp(name, SEND_BUFFERS) == 0)
87
0
        {
88
            // send_buffers - sendBuffersAllocationConfigType
89
0
            if (XMLP_ret::XML_OK != getXMLSendBuffersAllocationAttributes(p_aux0, allocation.send_buffers, ident))
90
0
            {
91
0
                return XMLP_ret::XML_ERROR;
92
0
            }
93
0
        }
94
0
        else if (strcmp(name, MAX_PROPERTIES) == 0)
95
0
        {
96
            // max number of properties in incoming message - uint32Type
97
0
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &tmp, ident))
98
0
            {
99
0
                return XMLP_ret::XML_ERROR;
100
0
            }
101
0
            allocation.data_limits.max_properties = tmp;
102
0
        }
103
0
        else if (strcmp(name, MAX_USER_DATA) == 0)
104
0
        {
105
            // max number of user data in incoming message - uint32Type
106
0
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &tmp, ident))
107
0
            {
108
0
                return XMLP_ret::XML_ERROR;
109
0
            }
110
0
            allocation.data_limits.max_user_data = tmp;
111
0
        }
112
0
        else if (strcmp(name, MAX_PARTITIONS) == 0)
113
0
        {
114
            // max number of user data in incoming message - uint32Type
115
0
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &tmp, ident))
116
0
            {
117
0
                return XMLP_ret::XML_ERROR;
118
0
            }
119
0
            allocation.data_limits.max_partitions = tmp;
120
0
        }
121
0
        else
122
0
        {
123
0
            logError(XMLPARSER, "Invalid element found into 'rtpsParticipantAllocationAttributesType'. Name: " << name);
124
0
            return XMLP_ret::XML_ERROR;
125
0
        }
126
0
    }
127
128
581
    return XMLP_ret::XML_OK;
129
581
}
130
131
XMLP_ret XMLParser::getXMLRemoteLocatorsAllocationAttributes(
132
        tinyxml2::XMLElement* elem,
133
        rtps::RemoteLocatorsAllocationAttributes& allocation,
134
        uint8_t ident)
135
0
{
136
    /*
137
        <xs:complexType name="remoteLocatorsAllocationConfigType">
138
            <xs:all minOccurs="0">
139
                <xs:element name="max_unicast_locators" type="uint32Type" minOccurs="0"/>
140
                <xs:element name="max_multicast_locators" type="uint32Type" minOccurs="0"/>
141
            </xs:all>
142
        </xs:complexType>
143
     */
144
145
0
    tinyxml2::XMLElement* p_aux0 = nullptr;
146
0
    const char* name = nullptr;
147
0
    uint32_t tmp;
148
0
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
149
0
    {
150
0
        name = p_aux0->Name();
151
0
        if (strcmp(name, MAX_UNICAST_LOCATORS) == 0)
152
0
        {
153
            // max_unicast_locators - uint32Type
154
0
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &tmp, ident))
155
0
            {
156
0
                return XMLP_ret::XML_ERROR;
157
0
            }
158
0
            allocation.max_unicast_locators = tmp;
159
0
        }
160
0
        else if (strcmp(name, MAX_MULTICAST_LOCATORS) == 0)
161
0
        {
162
            // max_multicast_locators - uint32Type
163
0
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &tmp, ident))
164
0
            {
165
0
                return XMLP_ret::XML_ERROR;
166
0
            }
167
0
            allocation.max_multicast_locators = tmp;
168
0
        }
169
0
        else
170
0
        {
171
0
            logError(XMLPARSER, "Invalid element found into 'remoteLocatorsAllocationConfigType'. Name: " << name);
172
0
            return XMLP_ret::XML_ERROR;
173
0
        }
174
0
    }
175
176
0
    return XMLP_ret::XML_OK;
177
0
}
178
179
XMLP_ret XMLParser::getXMLSendBuffersAllocationAttributes(
180
        tinyxml2::XMLElement* elem,
181
        rtps::SendBuffersAllocationAttributes& allocation,
182
        uint8_t ident)
183
0
{
184
    /*
185
        <xs:complexType name="sendBuffersAllocationConfigType">
186
            <xs:all minOccurs="0">
187
                <xs:element name="preallocated_number" type="uint32Type" minOccurs="0"/>
188
                <xs:element name="dynamic" type="boolType" minOccurs="0"/>
189
            </xs:all>
190
        </xs:complexType>
191
     */
192
193
0
    tinyxml2::XMLElement* p_aux0 = nullptr;
194
0
    const char* name = nullptr;
195
0
    uint32_t tmp;
196
0
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
197
0
    {
198
0
        name = p_aux0->Name();
199
0
        if (strcmp(name, PREALLOCATED_NUMBER) == 0)
200
0
        {
201
            // preallocated_number - uint32Type
202
0
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &tmp, ident))
203
0
            {
204
0
                return XMLP_ret::XML_ERROR;
205
0
            }
206
0
            allocation.preallocated_number = tmp;
207
0
        }
208
0
        else if (strcmp(name, DYNAMIC_LC) == 0)
209
0
        {
210
            // dynamic - boolType
211
0
            bool tmp_bool = false;
212
0
            if (XMLP_ret::XML_OK != getXMLBool(p_aux0, &tmp_bool, ident))
213
0
            {
214
0
                return XMLP_ret::XML_ERROR;
215
0
            }
216
0
            allocation.dynamic = tmp_bool;
217
0
        }
218
0
        else
219
0
        {
220
0
            logError(XMLPARSER, "Invalid element found into 'sendBuffersAllocationConfigType'. Name: " << name);
221
0
            return XMLP_ret::XML_ERROR;
222
0
        }
223
0
    }
224
225
0
    return XMLP_ret::XML_OK;
226
0
}
227
228
XMLP_ret XMLParser::getXMLDiscoverySettings(
229
        tinyxml2::XMLElement* elem,
230
        rtps::DiscoverySettings& settings,
231
        uint8_t ident)
232
8.20k
{
233
    /*
234
       <xs:complexType name="discoverySettingsType">
235
        <xs:all minOccurs="0">
236
            <xs:element name="discoveryProtocol" type="DiscoveryProtocol" minOccurs="0"/>
237
            <xs:element name="ignoreParticipantFlags" type="ParticipantFlags" minOccurs="0"/>
238
            <xs:element name="EDP" type="EDPType" minOccurs="0"/>
239
            <xs:element name="leaseDuration" type="durationType" minOccurs="0"/>
240
            <xs:element name="leaseAnnouncement" type="durationType" minOccurs="0"/>
241
            <xs:element name="simpleEDP" type="simpleEDPType" minOccurs="0"/>
242
            <xs:element name="clientAnnouncementPeriod" type="durationType" minOccurs="0"/>
243
            <xs:element name="discoveryServersList" type="DiscoveryServerList" minOccurs="0"/>
244
            <xs:element name="staticEndpointXMLFilename" type="stringType" minOccurs="0"/>
245
            <xs:element name="static_edp_xml_config" type="stringType" minOccurs="0"/>
246
        </xs:all>
247
       </xs:complexType>
248
     */
249
250
8.20k
    tinyxml2::XMLElement* p_aux0 = nullptr, * p_aux1 = nullptr;
251
8.20k
    const char* name = nullptr;
252
13.4k
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
253
12.5k
    {
254
12.5k
        name = p_aux0->Name();
255
12.5k
        if (strcmp(name, RTPS_PDP_TYPE) == 0)
256
533
        {
257
            // discoveryProtocol - DiscoveryProtocol
258
533
            if (XMLP_ret::XML_OK != getXMLEnum(p_aux0, &settings.discoveryProtocol, ident))
259
533
            {
260
533
                return XMLP_ret::XML_ERROR;
261
533
            }
262
533
        }
263
12.0k
        else if (strcmp(name, IGNORE_PARTICIPANT_FLAGS) == 0)
264
127
        {
265
            // ignoreParticipantFlags - ParticipantFlags
266
127
            if (XMLP_ret::XML_OK != getXMLEnum(p_aux0, &settings.ignoreParticipantFlags, ident))
267
127
            {
268
127
                return XMLP_ret::XML_ERROR;
269
127
            }
270
127
        }
271
11.9k
        else if (strcmp(name, _EDP) == 0)
272
752
        {
273
            /*
274
                <xs:simpleType name="EDPType">
275
                    <xs:restriction base="xs:string">
276
                        <xs:enumeration value="SIMPLE"/>
277
                        <xs:enumeration value="STATIC"/>
278
                    </xs:restriction>
279
                </xs:simpleType>
280
             */
281
752
            const char* text = p_aux0->GetText();
282
752
            if (nullptr == text)
283
752
            {
284
752
                logError(XMLPARSER, "Node '" << _EDP << "' without content");
285
752
                return XMLP_ret::XML_ERROR;
286
752
            }
287
0
            else if (strcmp(text, SIMPLE) == 0)
288
0
            {
289
0
                settings.use_SIMPLE_EndpointDiscoveryProtocol = true;
290
0
                settings.use_STATIC_EndpointDiscoveryProtocol = false;
291
0
            }
292
0
            else if (strcmp(text, STATIC) == 0)
293
0
            {
294
0
                settings.use_SIMPLE_EndpointDiscoveryProtocol = false;
295
0
                settings.use_STATIC_EndpointDiscoveryProtocol = true;
296
0
            }
297
0
            else
298
0
            {
299
0
                logError(XMLPARSER, "Node '" << _EDP << "' with bad content");
300
0
                return XMLP_ret::XML_ERROR;
301
0
            }
302
752
        }
303
11.1k
        else if (strcmp(name, LEASEDURATION) == 0)
304
7.15k
        {
305
            // leaseDuration - durationType
306
7.15k
            if (XMLP_ret::XML_OK != getXMLDuration(p_aux0, settings.leaseDuration, ident))
307
2.43k
            {
308
2.43k
                return XMLP_ret::XML_ERROR;
309
2.43k
            }
310
7.15k
        }
311
3.99k
        else if (strcmp(name, LEASE_ANNOUNCE) == 0)
312
468
        {
313
            // leaseAnnouncement - durationType
314
468
            if (XMLP_ret::XML_OK != getXMLDuration(p_aux0, settings.leaseDuration_announcementperiod, ident))
315
468
            {
316
468
                return XMLP_ret::XML_ERROR;
317
468
            }
318
468
        }
319
3.52k
        else if (strcmp(name, INITIAL_ANNOUNCEMENTS) == 0)
320
213
        {
321
            // initialAnnouncements - initialAnnouncementsType
322
213
            if (XMLP_ret::XML_OK !=
323
213
                    getXMLInitialAnnouncementsConfig(p_aux0, settings.initial_announcements, ident))
324
0
            {
325
0
                return XMLP_ret::XML_ERROR;
326
0
            }
327
213
        }
328
3.31k
        else if (strcmp(name, SIMPLE_EDP) == 0)
329
297
        {
330
            // simpleEDP
331
297
            for (p_aux1 = p_aux0->FirstChildElement(); p_aux1 != nullptr; p_aux1 = p_aux1->NextSiblingElement())
332
0
            {
333
0
                name = p_aux1->Name();
334
0
                if (strcmp(name, PUBWRITER_SUBREADER) == 0)
335
0
                {
336
                    // PUBWRITER_SUBREADER - boolType
337
0
                    if (XMLP_ret::XML_OK !=
338
0
                            getXMLBool(p_aux1, &settings.m_simpleEDP.use_PublicationWriterANDSubscriptionReader,
339
0
                            ident + 1))
340
0
                    {
341
0
                        return XMLP_ret::XML_ERROR;
342
0
                    }
343
0
                }
344
0
                else if (strcmp(name, PUBREADER_SUBWRITER) == 0)
345
0
                {
346
                    // PUBREADER_SUBWRITER - boolType
347
0
                    if (XMLP_ret::XML_OK !=
348
0
                            getXMLBool(p_aux1, &settings.m_simpleEDP.use_PublicationReaderANDSubscriptionWriter,
349
0
                            ident + 1))
350
0
                    {
351
0
                        return XMLP_ret::XML_ERROR;
352
0
                    }
353
0
                }
354
0
                else
355
0
                {
356
0
                    logError(XMLPARSER, "Invalid element found into 'simpleEDP'. Name: " << name);
357
0
                    return XMLP_ret::XML_ERROR;
358
0
                }
359
0
            }
360
297
        }
361
3.01k
        else if (strcmp(name, CLIENTANNOUNCEMENTPERIOD) == 0)
362
354
        {
363
            // clientAnnouncementPeriod - durationType
364
354
            if (XMLP_ret::XML_OK != getXMLDuration(p_aux0, settings.discoveryServer_client_syncperiod, ident))
365
354
            {
366
354
                return XMLP_ret::XML_ERROR;
367
354
            }
368
354
        }
369
2.66k
        else if (strcmp(name, SERVER_LIST) == 0)
370
86
        {
371
            // discoverServersList - DiscoveryServerList
372
86
            if (XMLP_ret::XML_OK != getXMLList(p_aux0, settings.m_DiscoveryServers, ident))
373
86
            {
374
86
                return XMLP_ret::XML_ERROR;
375
86
            }
376
86
        }
377
2.57k
        else if (strcmp(name, STATIC_ENDPOINT_XML) == 0)
378
314
        {
379
            // staticEndpointXMLFilename - stringType
380
314
            std::string s = "";
381
314
            if (XMLP_ret::XML_OK != getXMLString(p_aux0, &s, ident))
382
314
            {
383
314
                return XMLP_ret::XML_ERROR;
384
314
            }
385
0
            std::string file_name = "file://" + s;
386
0
            settings.static_edp_xml_config(file_name.c_str());
387
0
        }
388
2.26k
        else if (strcmp(name, STATIC_ENDPOINT_XML_URI) == 0)
389
588
        {
390
            // staticEndpointXMLFilename - stringType
391
588
            std::string s = "";
392
588
            if (XMLP_ret::XML_OK != getXMLString(p_aux0, &s, ident))
393
588
            {
394
588
                return XMLP_ret::XML_ERROR;
395
588
            }
396
0
            settings.static_edp_xml_config(s.c_str());
397
0
        }
398
1.67k
        else
399
1.67k
        {
400
1.67k
            logError(XMLPARSER, "Invalid element found into 'discoverySettingsType'. Name: " << name);
401
1.67k
            return XMLP_ret::XML_ERROR;
402
1.67k
        }
403
12.5k
    }
404
405
875
    return XMLP_ret::XML_OK;
406
407
8.20k
}
408
409
XMLP_ret XMLParser::getXMLBuiltinAttributes(
410
        tinyxml2::XMLElement* elem,
411
        BuiltinAttributes& builtin,
412
        uint8_t ident)
413
12.0k
{
414
    /*
415
       <xs:complexType name="builtinAttributesType">
416
        <xs:all minOccurs="0">
417
            <xs:element name="discovery_config" type="discoverySettingsType" minOccurs="0"/>
418
            <xs:element name="use_WriterLivelinessProtocol" type="boolType" minOccurs="0"/>
419
            <xs:element name="metatrafficUnicastLocatorList" type="locatorListType" minOccurs="0"/>
420
            <xs:element name="metatrafficMulticastLocatorList" type="locatorListType" minOccurs="0"/>
421
            <xs:element name="initialPeersList" type="locatorListType" minOccurs="0"/>
422
            <xs:element name="readerHistoryMemoryPolicy" type="historyMemoryPolicyType" minOccurs="0"/>
423
            <xs:element name="writerHistoryMemoryPolicy" type="historyMemoryPolicyType" minOccurs="0"/>
424
            <xs:element name="mutation_tries" type="uint32Type" minOccurs="0"/>
425
        </xs:all>
426
       </xs:complexType>
427
     */
428
429
12.0k
    tinyxml2::XMLElement* p_aux0 = nullptr;
430
12.0k
    const char* name = nullptr;
431
12.9k
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
432
11.7k
    {
433
11.7k
        name = p_aux0->Name();
434
11.7k
        if (strcmp(name, DISCOVERY_SETTINGS) == 0)
435
8.20k
        {
436
            // discovery_config - DiscoverySettings
437
8.20k
            if (XMLP_ret::XML_OK != getXMLDiscoverySettings(p_aux0, builtin.discovery_config, ident))
438
7.32k
            {
439
7.32k
                return XMLP_ret::XML_ERROR;
440
7.32k
            }
441
8.20k
        }
442
3.54k
        else if (strcmp(name, WRITER_LVESS_PROTOCOL) == 0)
443
112
        {
444
            // use_WriterLivelinessProtocol - boolType
445
112
            if (XMLP_ret::XML_OK != getXMLBool(p_aux0, &builtin.use_WriterLivelinessProtocol, ident))
446
112
            {
447
112
                return XMLP_ret::XML_ERROR;
448
112
            }
449
112
        }
450
3.43k
        else if (strcmp(name, META_UNI_LOC_LIST) == 0)
451
76
        {
452
            // metatrafficUnicastLocatorList
453
76
            if (XMLP_ret::XML_OK != getXMLLocatorList(p_aux0, builtin.metatrafficUnicastLocatorList, ident))
454
76
            {
455
76
                return XMLP_ret::XML_ERROR;
456
76
            }
457
76
        }
458
3.35k
        else if (strcmp(name, META_MULTI_LOC_LIST) == 0)
459
61
        {
460
            // metatrafficMulticastLocatorList
461
61
            if (XMLP_ret::XML_OK != getXMLLocatorList(p_aux0, builtin.metatrafficMulticastLocatorList, ident))
462
61
            {
463
61
                return XMLP_ret::XML_ERROR;
464
61
            }
465
61
        }
466
3.29k
        else if (strcmp(name, INIT_PEERS_LIST) == 0)
467
387
        {
468
            // initialPeersList
469
387
            if (XMLP_ret::XML_OK != getXMLLocatorList(p_aux0, builtin.initialPeersList, ident))
470
387
            {
471
387
                return XMLP_ret::XML_ERROR;
472
387
            }
473
387
        }
474
2.91k
        else if (strcmp(name, READER_HIST_MEM_POLICY) == 0)
475
129
        {
476
            // readerhistoryMemoryPolicy
477
129
            if (XMLP_ret::XML_OK != getXMLHistoryMemoryPolicy(p_aux0, builtin.readerHistoryMemoryPolicy, ident))
478
129
            {
479
129
                return XMLP_ret::XML_ERROR;
480
129
            }
481
129
        }
482
2.78k
        else if (strcmp(name, WRITER_HIST_MEM_POLICY) == 0)
483
69
        {
484
            // writerhistoryMemoryPolicy
485
69
            if (XMLP_ret::XML_OK != getXMLHistoryMemoryPolicy(p_aux0, builtin.writerHistoryMemoryPolicy, ident))
486
69
            {
487
69
                return XMLP_ret::XML_ERROR;
488
69
            }
489
69
        }
490
2.71k
        else if (strcmp(name, READER_PAYLOAD_SIZE) == 0)
491
71
        {
492
            // readerPayloadSize
493
71
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &builtin.readerPayloadSize, ident))
494
71
            {
495
71
                return XMLP_ret::XML_ERROR;
496
71
            }
497
71
        }
498
2.64k
        else if (strcmp(name, WRITER_PAYLOAD_SIZE) == 0)
499
37
        {
500
            // readerPayloadSize
501
37
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &builtin.writerPayloadSize, ident))
502
37
            {
503
37
                return XMLP_ret::XML_ERROR;
504
37
            }
505
37
        }
506
2.60k
        else if (strcmp(name, MUTATION_TRIES) == 0)
507
345
        {
508
            // mutation_tries - uint32Type
509
345
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &builtin.mutation_tries, ident))
510
345
            {
511
345
                return XMLP_ret::XML_ERROR;
512
345
            }
513
345
        }
514
2.26k
        else if (strcmp(name, AVOID_BUILTIN_MULTICAST) == 0)
515
403
        {
516
            // avoid_builtin_multicast - boolType
517
403
            if (XMLP_ret::XML_OK != getXMLBool(p_aux0, &builtin.avoid_builtin_multicast, ident))
518
403
            {
519
403
                return XMLP_ret::XML_ERROR;
520
403
            }
521
403
        }
522
1.85k
        else
523
1.85k
        {
524
1.85k
            logError(XMLPARSER, "Invalid element found into 'builtinAttributesType'. Name: " << name);
525
1.85k
            return XMLP_ret::XML_ERROR;
526
1.85k
        }
527
11.7k
    }
528
529
1.17k
    return XMLP_ret::XML_OK;
530
12.0k
}
531
532
XMLP_ret XMLParser::getXMLInitialAnnouncementsConfig(
533
        tinyxml2::XMLElement* elem,
534
        InitialAnnouncementConfig& config,
535
        uint8_t ident)
536
213
{
537
    /*
538
        <xs:complexType name="initialAnnouncementsType">
539
            <xs:all minOccurs="0">
540
                <xs:element name="count" type="uint32Type" minOccurs="0"/>
541
                <xs:element name="period" type="durationType" minOccurs="0"/>
542
            </xs:all>
543
        </xs:complexType>
544
     */
545
213
    tinyxml2::XMLElement* p_aux0 = nullptr;
546
213
    const char* name = nullptr;
547
213
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
548
0
    {
549
0
        name = p_aux0->Name();
550
0
        if (strcmp(name, COUNT) == 0)
551
0
        {
552
            // portBase - uint16Type
553
0
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &config.count, ident))
554
0
            {
555
0
                return XMLP_ret::XML_ERROR;
556
0
            }
557
0
        }
558
0
        else if (strcmp(name, PERIOD) == 0)
559
0
        {
560
            // domainIDGain - uint16Type
561
0
            if (XMLP_ret::XML_OK != getXMLDuration(p_aux0, config.period, ident))
562
0
            {
563
0
                return XMLP_ret::XML_ERROR;
564
0
            }
565
0
        }
566
0
        else
567
0
        {
568
0
            logError(XMLPARSER, "Invalid element found into 'portType'. Name: " << name);
569
0
            return XMLP_ret::XML_ERROR;
570
0
        }
571
0
    }
572
213
    return XMLP_ret::XML_OK;
573
213
}
574
575
XMLP_ret XMLParser::getXMLPortParameters(
576
        tinyxml2::XMLElement* elem,
577
        PortParameters& port,
578
        uint8_t ident)
579
249
{
580
    /*
581
        <xs:complexType name="portType">
582
            <xs:all minOccurs="0">
583
                <xs:element name="portBase" type="uint16Type" minOccurs="0"/>
584
                <xs:element name="domainIDGain" type="uint16Type" minOccurs="0"/>
585
                <xs:element name="participantIDGain" type="uint16Type" minOccurs="0"/>
586
                <xs:element name="offsetd0" type="uint16Type" minOccurs="0"/>
587
                <xs:element name="offsetd1" type="uint16Type" minOccurs="0"/>
588
                <xs:element name="offsetd2" type="uint16Type" minOccurs="0"/>
589
                <xs:element name="offsetd3" type="uint16Type" minOccurs="0"/>
590
            </xs:all>
591
        </xs:complexType>
592
     */
593
594
249
    tinyxml2::XMLElement* p_aux0 = nullptr;
595
249
    const char* name = nullptr;
596
249
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
597
0
    {
598
0
        name = p_aux0->Name();
599
0
        if (strcmp(name, PORT_BASE) == 0)
600
0
        {
601
            // portBase - uint16Type
602
0
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &port.portBase, ident))
603
0
            {
604
0
                return XMLP_ret::XML_ERROR;
605
0
            }
606
0
        }
607
0
        else if (strcmp(name, DOMAIN_ID_GAIN) == 0)
608
0
        {
609
            // domainIDGain - uint16Type
610
0
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &port.domainIDGain, ident))
611
0
            {
612
0
                return XMLP_ret::XML_ERROR;
613
0
            }
614
0
        }
615
0
        else if (strcmp(name, PARTICIPANT_ID_GAIN) == 0)
616
0
        {
617
            // participantIDGain - uint16Type
618
0
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &port.participantIDGain, ident))
619
0
            {
620
0
                return XMLP_ret::XML_ERROR;
621
0
            }
622
0
        }
623
0
        else if (strcmp(name, OFFSETD0) == 0)
624
0
        {
625
            // offsetd0 - uint16Type
626
0
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &port.offsetd0, ident))
627
0
            {
628
0
                return XMLP_ret::XML_ERROR;
629
0
            }
630
0
        }
631
0
        else if (strcmp(name, OFFSETD1) == 0)
632
0
        {
633
            // offsetd1 - uint16Type
634
0
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &port.offsetd1, ident))
635
0
            {
636
0
                return XMLP_ret::XML_ERROR;
637
0
            }
638
0
        }
639
0
        else if (strcmp(name, OFFSETD2) == 0)
640
0
        {
641
            // offsetd2 - uint16Type
642
0
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &port.offsetd2, ident))
643
0
            {
644
0
                return XMLP_ret::XML_ERROR;
645
0
            }
646
0
        }
647
0
        else if (strcmp(name, OFFSETD3) == 0)
648
0
        {
649
            // offsetd3 - uint16Type
650
0
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &port.offsetd3, ident))
651
0
            {
652
0
                return XMLP_ret::XML_ERROR;
653
0
            }
654
0
        }
655
0
        else
656
0
        {
657
0
            logError(XMLPARSER, "Invalid element found into 'portType'. Name: " << name);
658
0
            return XMLP_ret::XML_ERROR;
659
0
        }
660
0
    }
661
249
    return XMLP_ret::XML_OK;
662
249
}
663
664
XMLP_ret XMLParser::getXMLTransports(
665
        tinyxml2::XMLElement* elem,
666
        std::vector<std::shared_ptr<TransportDescriptorInterface>>& transports,
667
        uint8_t /*ident*/)
668
328
{
669
    /*
670
        <xs:complexType name="stringListType">
671
            <xs:sequence>
672
                <xs:element name="id" type="stringType" minOccurs="0" maxOccurs="unbounded"/>
673
            </xs:sequence>
674
        </xs:complexType>
675
     */
676
677
328
    tinyxml2::XMLElement* p_aux0 = nullptr;
678
328
    p_aux0 = elem->FirstChildElement(TRANSPORT_ID);
679
328
    if (nullptr == p_aux0)
680
328
    {
681
328
        logError(XMLPARSER, "Node '" << elem->Value() << "' without content");
682
328
        return XMLP_ret::XML_ERROR;
683
328
    }
684
685
0
    while (nullptr != p_aux0)
686
0
    {
687
0
        const char* text = p_aux0->GetText();
688
0
        if (nullptr == text)
689
0
        {
690
0
            logError(XMLPARSER, "Node '" << TRANSPORT_ID << "' without content");
691
0
            return XMLP_ret::XML_ERROR;
692
0
        }
693
0
        else
694
0
        {
695
0
            std::shared_ptr<TransportDescriptorInterface> pDescriptor = XMLProfileManager::getTransportById(text);
696
0
            if (pDescriptor != nullptr)
697
0
            {
698
0
                transports.emplace_back(pDescriptor);
699
0
            }
700
0
            else
701
0
            {
702
0
                logError(XMLPARSER, "Transport Node not found. Given ID: " << text);
703
0
                return XMLP_ret::XML_ERROR;
704
0
            }
705
0
        }
706
0
        p_aux0 = p_aux0->NextSiblingElement(TRANSPORT_ID);
707
0
    }
708
709
0
    return XMLP_ret::XML_OK;
710
0
}
711
712
XMLP_ret XMLParser::getXMLThroughputController(
713
        tinyxml2::XMLElement* elem,
714
        ThroughputControllerDescriptor& throughputController,
715
        uint8_t ident)
716
438
{
717
    /*
718
        <xs:complexType name="throughputControllerType">
719
            <xs:all minOccurs="0">
720
                <xs:element name="bytesPerPeriod" type="uint32Type" minOccurs="0"/>
721
                <xs:element name="periodMillisecs" type="uint32Type" minOccurs="0"/>
722
            </xs:all>
723
        </xs:complexType>
724
     */
725
726
438
    tinyxml2::XMLElement* p_aux0 = nullptr;
727
438
    const char* name = nullptr;
728
438
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
729
0
    {
730
0
        name = p_aux0->Name();
731
0
        if (strcmp(name, BYTES_PER_SECOND) == 0)
732
0
        {
733
            // bytesPerPeriod - uint32Type
734
0
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &throughputController.bytesPerPeriod, ident))
735
0
            {
736
0
                return XMLP_ret::XML_ERROR;
737
0
            }
738
0
        }
739
0
        else if (strcmp(name, PERIOD_MILLISECS) == 0)
740
0
        {
741
            // periodMillisecs - uint32Type
742
0
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &throughputController.periodMillisecs, ident))
743
0
            {
744
0
                return XMLP_ret::XML_ERROR;
745
0
            }
746
0
        }
747
0
        else
748
0
        {
749
0
            logError(XMLPARSER, "Invalid element found into 'portType'. Name: " << name);
750
0
            return XMLP_ret::XML_ERROR;
751
0
        }
752
0
    }
753
438
    return XMLP_ret::XML_OK;
754
438
}
755
756
XMLP_ret XMLParser::getXMLTopicAttributes(
757
        tinyxml2::XMLElement* elem,
758
        TopicAttributes& topic,
759
        uint8_t ident)
760
14.3k
{
761
    /*
762
        <xs:complexType name="topicAttributesType">
763
            <xs:all minOccurs="0">
764
                <xs:element name="kind" type="topicKindType" minOccurs="0"/>
765
                <xs:element name="name" type="stringType" minOccurs="0"/>
766
                <xs:element name="dataType" type="stringType" minOccurs="0"/>
767
                <xs:element name="historyQos" type="historyQosPolicyType" minOccurs="0"/>
768
                <xs:element name="resourceLimitsQos" type="resourceLimitsQosPolicyType" minOccurs="0"/>
769
            </xs:all>
770
        </xs:complexType>
771
     */
772
14.3k
    tinyxml2::XMLElement* p_aux0 = nullptr;
773
14.3k
    const char* name = nullptr;
774
18.3k
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
775
7.09k
    {
776
7.09k
        name = p_aux0->Name();
777
7.09k
        if (strcmp(name, KIND) == 0)
778
1.86k
        {
779
            // kind
780
            /*
781
                <xs:simpleType name="topicKindType">
782
                    <xs:restriction base="xs:string">
783
                        <xs:enumeration value="NO_KEY"/>
784
                        <xs:enumeration value="WITH_KEY"/>
785
                    </xs:restriction>
786
                </xs:simpleType>
787
             */
788
1.86k
            const char* text = p_aux0->GetText();
789
1.86k
            if (nullptr == text)
790
417
            {
791
417
                logError(XMLPARSER, "Node '" << KIND << "' without content");
792
417
                return XMLP_ret::XML_ERROR;
793
417
            }
794
1.45k
            if (strcmp(text, _NO_KEY) == 0)
795
598
            {
796
598
                topic.topicKind = TopicKind_t::NO_KEY;
797
598
            }
798
852
            else if (strcmp(text, _WITH_KEY) == 0)
799
394
            {
800
394
                topic.topicKind = TopicKind_t::WITH_KEY;
801
394
            }
802
458
            else
803
458
            {
804
458
                logError(XMLPARSER, "Node '" << KIND << "' with bad content");
805
458
                return XMLP_ret::XML_ERROR;
806
458
            }
807
1.45k
        }
808
5.23k
        else if (strcmp(name, NAME) == 0)
809
1.92k
        {
810
            // name - stringType
811
1.92k
            const char* text;
812
1.92k
            if (nullptr == (text = p_aux0->GetText()))
813
239
            {
814
239
                logError(XMLPARSER, "<" << p_aux0->Value() << "> getXMLString XML_ERROR!");
815
239
                return XMLP_ret::XML_ERROR;
816
239
            }
817
1.68k
            topic.topicName = text;
818
1.68k
        }
819
3.30k
        else if (strcmp(name, DATA_TYPE) == 0)
820
557
        {
821
            // dataType - stringType
822
557
            const char* text;
823
557
            if (nullptr == (text = p_aux0->GetText()))
824
273
            {
825
273
                logError(XMLPARSER, "<" << p_aux0->Value() << "> getXMLString XML_ERROR!");
826
273
                return XMLP_ret::XML_ERROR;
827
273
            }
828
284
            topic.topicDataType = text;
829
284
        }
830
2.74k
        else if (strcmp(name, HISTORY_QOS) == 0)
831
1.63k
        {
832
            // historyQos
833
1.63k
            if (XMLP_ret::XML_OK != getXMLHistoryQosPolicy(p_aux0, topic.historyQos, ident))
834
768
            {
835
768
                return XMLP_ret::XML_ERROR;
836
768
            }
837
1.63k
        }
838
1.11k
        else if (strcmp(name, RES_LIMITS_QOS) == 0)
839
215
        {
840
            // resourceLimitsQos
841
215
            if (XMLP_ret::XML_OK != getXMLResourceLimitsQos(p_aux0, topic.resourceLimitsQos, ident))
842
0
            {
843
0
                return XMLP_ret::XML_ERROR;
844
0
            }
845
215
        }
846
903
        else
847
903
        {
848
903
            logError(XMLPARSER, "Invalid element found into 'topicAttributesType'. Name: " << name);
849
903
            return XMLP_ret::XML_ERROR;
850
903
        }
851
7.09k
    }
852
11.2k
    return XMLP_ret::XML_OK;
853
14.3k
}
854
855
XMLP_ret XMLParser::getXMLResourceLimitsQos(
856
        tinyxml2::XMLElement* elem,
857
        ResourceLimitsQosPolicy& resourceLimitsQos,
858
        uint8_t ident)
859
215
{
860
    /*
861
        <xs:complexType name="resourceLimitsQosPolicyType">
862
            <xs:all minOccurs="0">
863
                <xs:element name="max_samples" type="int32Type" minOccurs="0"/>
864
                <xs:element name="max_instances" type="int32Type" minOccurs="0"/>
865
                <xs:element name="max_samples_per_instance" type="int32Type" minOccurs="0"/>
866
                <xs:element name="allocated_samples" type="int32Type" minOccurs="0"/>
867
                <xs:element name="extra_samples" type="int32Type" minOccurs="0"/>
868
            </xs:all>
869
        </xs:complexType>
870
     */
871
872
215
    tinyxml2::XMLElement* p_aux0 = nullptr;
873
215
    const char* name = nullptr;
874
215
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
875
0
    {
876
0
        name = p_aux0->Name();
877
0
        if (strcmp(name, MAX_SAMPLES) == 0)
878
0
        {
879
            // max_samples - int32Type
880
0
            if (XMLP_ret::XML_OK != getXMLInt(p_aux0, &resourceLimitsQos.max_samples, ident))
881
0
            {
882
0
                return XMLP_ret::XML_ERROR;
883
0
            }
884
0
        }
885
0
        else if (strcmp(name, MAX_INSTANCES) == 0)
886
0
        {
887
            // max_instances - int32Type
888
0
            if (XMLP_ret::XML_OK != getXMLInt(p_aux0, &resourceLimitsQos.max_instances, ident))
889
0
            {
890
0
                return XMLP_ret::XML_ERROR;
891
0
            }
892
0
        }
893
0
        else if (strcmp(name, MAX_SAMPLES_INSTANCE) == 0)
894
0
        {
895
            // max_samples_per_instance - int32Type
896
0
            if (XMLP_ret::XML_OK != getXMLInt(p_aux0, &resourceLimitsQos.max_samples_per_instance, ident))
897
0
            {
898
0
                return XMLP_ret::XML_ERROR;
899
0
            }
900
0
        }
901
0
        else if (strcmp(name, ALLOCATED_SAMPLES) == 0)
902
0
        {
903
            // allocated_samples - int32Type
904
0
            if (XMLP_ret::XML_OK != getXMLInt(p_aux0, &resourceLimitsQos.allocated_samples, ident))
905
0
            {
906
0
                return XMLP_ret::XML_ERROR;
907
0
            }
908
0
        }
909
0
        else if (strcmp(name, EXTRA_SAMPLES) == 0)
910
0
        {
911
            // extra_samples - int32Type
912
0
            if (XMLP_ret::XML_OK != getXMLInt(p_aux0, &resourceLimitsQos.extra_samples, ident))
913
0
            {
914
0
                return XMLP_ret::XML_ERROR;
915
0
            }
916
0
        }
917
0
        else
918
0
        {
919
0
            logError(XMLPARSER, "Invalid element found into 'resourceLimitsQosPolicyType'. Name: " << name);
920
0
            return XMLP_ret::XML_ERROR;
921
0
        }
922
0
    }
923
924
215
    return XMLP_ret::XML_OK;
925
215
}
926
927
XMLP_ret XMLParser::getXMLContainerAllocationConfig(
928
        tinyxml2::XMLElement* elem,
929
        ResourceLimitedContainerConfig& allocation_config,
930
        uint8_t ident)
931
428
{
932
    /*
933
        <xs:complexType name="containerAllocationConfigType">
934
            <xs:all minOccurs="0">
935
                <xs:element name="initial" type="uint32Type" minOccurs="0"/>
936
                <xs:element name="maximum" type="uint32Type" minOccurs="0"/>
937
                <xs:element name="increment" type="uint32Type" minOccurs="0"/>
938
            </xs:all>
939
        </xs:complexType>
940
     */
941
942
    // First set default values
943
428
    allocation_config = ResourceLimitedContainerConfig();
944
945
    // Then parse XML
946
428
    uint32_t aux_value;
947
428
    tinyxml2::XMLElement* p_aux0 = nullptr;
948
428
    const char* name = nullptr;
949
428
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
950
0
    {
951
0
        name = p_aux0->Name();
952
0
        if (strcmp(name, INITIAL) == 0)
953
0
        {
954
            // initial - uint32Type
955
0
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &aux_value, ident))
956
0
            {
957
0
                return XMLP_ret::XML_ERROR;
958
0
            }
959
0
            allocation_config.initial = static_cast<size_t>(aux_value);
960
0
        }
961
0
        else if (strcmp(name, MAXIMUM) == 0)
962
0
        {
963
            // maximum - uint32Type
964
0
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &aux_value, ident))
965
0
            {
966
0
                return XMLP_ret::XML_ERROR;
967
0
            }
968
0
            allocation_config.maximum = (aux_value == 0u) ?
969
0
                    std::numeric_limits<size_t>::max() : static_cast<size_t>(aux_value);
970
0
        }
971
0
        else if (strcmp(name, INCREMENT) == 0)
972
0
        {
973
            // increment - uint32Type
974
0
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &aux_value, ident))
975
0
            {
976
0
                return XMLP_ret::XML_ERROR;
977
0
            }
978
0
            allocation_config.increment = static_cast<size_t>(aux_value);
979
0
        }
980
0
        else
981
0
        {
982
0
            logError(XMLPARSER, "Invalid element found into 'containerAllocationConfigType'. Name: " << name);
983
0
            return XMLP_ret::XML_ERROR;
984
0
        }
985
0
    }
986
987
    // Check results
988
428
    if (allocation_config.initial > allocation_config.maximum)
989
0
    {
990
0
        logError(XMLPARSER,
991
0
                "Parsing 'containerAllocationConfigType': Field 'initial' cannot be greater than 'maximum'.");
992
0
        return XMLP_ret::XML_ERROR;
993
0
    }
994
428
    else if ((allocation_config.increment == 0) && (allocation_config.initial != allocation_config.maximum))
995
0
    {
996
0
        logError(XMLPARSER, "Parsing 'containerAllocationConfigType': Field 'increment' cannot be zero.");
997
0
        return XMLP_ret::XML_ERROR;
998
0
    }
999
1000
428
    return XMLP_ret::XML_OK;
1001
428
}
1002
1003
XMLP_ret XMLParser::getXMLHistoryQosPolicy(
1004
        tinyxml2::XMLElement* elem,
1005
        HistoryQosPolicy& historyQos,
1006
        uint8_t ident)
1007
1.63k
{
1008
    /*
1009
        <xs:complexType name="historyQosPolicyType">
1010
            <xs:all minOccurs="0">
1011
                <xs:element name="kind" type="historyQosKindType" minOccurs="0"/>
1012
                <xs:element name="depth" type="int32Type" minOccurs="0"/>
1013
            </xs:all>
1014
        </xs:complexType>
1015
     */
1016
1017
1.63k
    tinyxml2::XMLElement* p_aux0 = nullptr;
1018
1.63k
    const char* name = nullptr;
1019
2.64k
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
1020
1.78k
    {
1021
1.78k
        name = p_aux0->Name();
1022
1.78k
        if (strcmp(name, KIND) == 0)
1023
573
        {
1024
            // kind
1025
            /*
1026
                <xs:simpleType name="historyQosKindType">
1027
                    <xs:restriction base="xs:string">
1028
                        <xs:enumeration value="KEEP_LAST"/>
1029
                        <xs:enumeration value="KEEP_ALL"/>
1030
                    </xs:restriction>
1031
                </xs:simpleType>
1032
             */
1033
573
            const char* text = p_aux0->GetText();
1034
573
            if (nullptr == text)
1035
76
            {
1036
76
                logError(XMLPARSER, "Node '" << KIND << "' without content");
1037
76
                return XMLP_ret::XML_ERROR;
1038
76
            }
1039
497
            if (strcmp(text, KEEP_LAST) == 0)
1040
96
            {
1041
96
                historyQos.kind = HistoryQosPolicyKind::KEEP_LAST_HISTORY_QOS;
1042
96
            }
1043
401
            else if (strcmp(text, KEEP_ALL) == 0)
1044
96
            {
1045
96
                historyQos.kind = HistoryQosPolicyKind::KEEP_ALL_HISTORY_QOS;
1046
96
            }
1047
305
            else
1048
305
            {
1049
305
                logError(XMLPARSER, "Node '" << KIND << "' with bad content");
1050
305
                return XMLP_ret::XML_ERROR;
1051
305
            }
1052
497
        }
1053
1.21k
        else if (strcmp(name, DEPTH) == 0)
1054
861
        {
1055
            // depth - uint32Type
1056
861
            if (XMLP_ret::XML_OK != getXMLInt(p_aux0, &historyQos.depth, ident))
1057
35
            {
1058
35
                return XMLP_ret::XML_ERROR;
1059
35
            }
1060
861
        }
1061
352
        else
1062
352
        {
1063
352
            logError(XMLPARSER, "Invalid element found into 'historyQosPolicyType'. Name: " << name);
1064
352
            return XMLP_ret::XML_ERROR;
1065
352
        }
1066
1.78k
    }
1067
1068
863
    return XMLP_ret::XML_OK;
1069
1.63k
}
1070
1071
XMLP_ret XMLParser::getXMLWriterQosPolicies(
1072
        tinyxml2::XMLElement* elem,
1073
        WriterQos& qos,
1074
        uint8_t ident)
1075
6.00k
{
1076
    /*
1077
        <xs:complexType name="writerQosPoliciesType">
1078
            <xs:all minOccurs="0">
1079
                <xs:element name="durability" type="durabilityQosPolicyType" minOccurs="0"/>
1080
                <xs:element name="durabilityService" type="durabilityServiceQosPolicyType" minOccurs="0"/>
1081
                <xs:element name="deadline" type="deadlineQosPolicyType" minOccurs="0"/>
1082
                <xs:element name="latencyBudget" type="latencyBudgetQosPolicyType" minOccurs="0"/>
1083
                <xs:element name="liveliness" type="livelinessQosPolicyType" minOccurs="0"/>
1084
                <xs:element name="reliability" type="reliabilityQosPolicyType" minOccurs="0"/>
1085
                <xs:element name="lifespan" type="lifespanQosPolicyType" minOccurs="0"/>
1086
                <xs:element name="userData" type="userDataQosPolicyType" minOccurs="0"/>
1087
                <xs:element name="timeBasedFilter" type="timeBasedFilterQosPolicyType" minOccurs="0"/>
1088
                <xs:element name="ownership" type="ownershipQosPolicyType" minOccurs="0"/>
1089
                <xs:element name="ownershipStrength" type="ownershipStrengthQosPolicyType" minOccurs="0"/>
1090
                <xs:element name="destinationOrder" type="destinationOrderQosPolicyType" minOccurs="0"/>
1091
                <xs:element name="presentation" type="presentationQosPolicyType" minOccurs="0"/>
1092
                <xs:element name="partition" type="partitionQosPolicyType" minOccurs="0"/>
1093
                <xs:element name="topicData" type="topicDataQosPolicyType" minOccurs="0"/>
1094
                <xs:element name="groupData" type="groupDataQosPolicyType" minOccurs="0"/>
1095
                <xs:element name="publishMode" type="publishModeQosPolicyType" minOccurs="0"/>
1096
                <xs:element name="data_sharing" type="dataSharingQosPolicyType" minOccurs="0"/>
1097
                <xs:element name="disablePositiveAcks" type="disablePositiveAcksQosPolicyType" minOccurs="0"/>
1098
                <xs:element name="disable_heartbeat_piggyback" type="boolType" minOccurs="0"/>
1099
            </xs:all>
1100
        </xs:complexType>
1101
     */
1102
1103
6.00k
    tinyxml2::XMLElement* p_aux0 = nullptr;
1104
6.00k
    const char* name = nullptr;
1105
9.27k
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
1106
8.22k
    {
1107
8.22k
        name = p_aux0->Name();
1108
8.22k
        if (strcmp(name, DURABILITY) == 0)
1109
195
        {
1110
            // durability
1111
195
            if (XMLP_ret::XML_OK != getXMLDurabilityQos(p_aux0, qos.m_durability, ident))
1112
195
            {
1113
195
                return XMLP_ret::XML_ERROR;
1114
195
            }
1115
195
        }
1116
8.02k
        else if (strcmp(name, LIVELINESS) == 0)
1117
347
        {
1118
            // liveliness
1119
347
            if (XMLP_ret::XML_OK != getXMLLivelinessQos(p_aux0, qos.m_liveliness, ident))
1120
0
            {
1121
0
                return XMLP_ret::XML_ERROR;
1122
0
            }
1123
347
        }
1124
7.67k
        else if (strcmp(name, RELIABILITY) == 0)
1125
1.06k
        {
1126
            // reliability
1127
1.06k
            if (XMLP_ret::XML_OK != getXMLReliabilityQos(p_aux0, qos.m_reliability, ident))
1128
776
            {
1129
776
                return XMLP_ret::XML_ERROR;
1130
776
            }
1131
1.06k
        }
1132
6.61k
        else if (strcmp(name, PARTITION) == 0)
1133
416
        {
1134
            // partition
1135
416
            if (XMLP_ret::XML_OK != getXMLPartitionQos(p_aux0, qos.m_partition, ident))
1136
416
            {
1137
416
                return XMLP_ret::XML_ERROR;
1138
416
            }
1139
416
        }
1140
6.19k
        else if (strcmp(name, PUB_MODE) == 0)
1141
263
        {
1142
            // publishMode
1143
263
            if (XMLP_ret::XML_OK != getXMLPublishModeQos(p_aux0, qos.m_publishMode, ident))
1144
263
            {
1145
263
                return XMLP_ret::XML_ERROR;
1146
263
            }
1147
263
        }
1148
5.93k
        else if (strcmp(name, DEADLINE) == 0)
1149
75
        {
1150
            // deadline
1151
75
            if (XMLP_ret::XML_OK != getXMLDeadlineQos(p_aux0, qos.m_deadline, ident))
1152
75
            {
1153
75
                return XMLP_ret::XML_ERROR;
1154
75
            }
1155
75
        }
1156
5.86k
        else if (strcmp(name, LIFESPAN) == 0)
1157
68
        {
1158
            // lifespan
1159
68
            if (XMLP_ret::XML_OK != getXMLLifespanQos(p_aux0, qos.m_lifespan, ident))
1160
68
            {
1161
68
                return XMLP_ret::XML_ERROR;
1162
68
            }
1163
68
        }
1164
5.79k
        else if (strcmp(name, DISABLE_POSITIVE_ACKS) == 0)
1165
235
        {
1166
            // Disable positive acks
1167
235
            if (XMLP_ret::XML_OK != getXMLDisablePositiveAcksQos(p_aux0, qos.m_disablePositiveACKs, ident))
1168
0
            {
1169
0
                return XMLP_ret::XML_ERROR;
1170
0
            }
1171
235
        }
1172
5.55k
        else if (strcmp(name, LATENCY_BUDGET) == 0)
1173
195
        {
1174
            //Latency Budget
1175
195
            if (XMLP_ret::XML_OK != getXMLLatencyBudgetQos(p_aux0, qos.m_latencyBudget, ident))
1176
195
            {
1177
195
                return XMLP_ret::XML_ERROR;
1178
195
            }
1179
195
        }
1180
5.36k
        else if (strcmp(name, DURABILITY_SRV) == 0 ||
1181
5.36k
                strcmp(name, TIME_FILTER) == 0 || strcmp(name, OWNERSHIP) == 0 ||
1182
5.36k
                strcmp(name, OWNERSHIP_STRENGTH) == 0 || strcmp(name, DEST_ORDER) == 0 ||
1183
5.36k
                strcmp(name, PRESENTATION) == 0)
1184
1.56k
        {
1185
            // TODO: Do not supported for now
1186
            //if (nullptr != (p_aux = elem->FirstChildElement(    DURABILITY_SRV))) getXMLDurabilityServiceQos(p_aux, ident);
1187
            //if (nullptr != (p_aux = elem->FirstChildElement(       TIME_FILTER))) getXMLTimeBasedFilterQos(p_aux, ident);
1188
            //if (nullptr != (p_aux = elem->FirstChildElement(         OWNERSHIP))) getXMLOwnershipQos(p_aux, ident);
1189
            //if (nullptr != (p_aux = elem->FirstChildElement(OWNERSHIP_STRENGTH))) getXMLOwnershipStrengthQos(p_aux, ident);
1190
            //if (nullptr != (p_aux = elem->FirstChildElement(        DEST_ORDER))) getXMLDestinationOrderQos(p_aux, ident);
1191
            //if (nullptr != (p_aux = elem->FirstChildElement(      PRESENTATION))) getXMLPresentationQos(p_aux, ident);
1192
1.56k
            logError(XMLPARSER, "Quality of Service '" << p_aux0->Value() << "' do not supported for now");
1193
1.56k
        }
1194
3.80k
        else if (strcmp(name, DATA_SHARING) == 0)
1195
354
        {
1196
            //data sharing
1197
354
            if (XMLP_ret::XML_OK != getXMLDataSharingQos(p_aux0, qos.data_sharing, ident))
1198
354
            {
1199
354
                return XMLP_ret::XML_ERROR;
1200
354
            }
1201
354
        }
1202
3.44k
        else if (strcmp(name, DISABLE_HEARTBEAT_PIGGYBACK) == 0)
1203
316
        {
1204
            // Disable heartbeat piggyback
1205
316
            if (XMLP_ret::XML_OK != getXMLBool(p_aux0, &qos.disable_heartbeat_piggyback, ident))
1206
316
            {
1207
316
                return XMLP_ret::XML_ERROR;
1208
316
            }
1209
316
        }
1210
3.13k
        else if (0 == strcmp(name, USER_DATA))
1211
390
        {
1212
            // userData
1213
390
            if (XMLP_ret::XML_OK != getXMLOctetVector(p_aux0, qos.m_userData.data_vec(), ident))
1214
0
            {
1215
0
                return XMLP_ret::XML_ERROR;
1216
0
            }
1217
390
        }
1218
2.74k
        else if (0 == strcmp(name, TOPIC_DATA))
1219
226
        {
1220
            // userData
1221
226
            if (XMLP_ret::XML_OK != getXMLOctetVector(p_aux0, qos.m_topicData.data_vec(), ident))
1222
0
            {
1223
0
                return XMLP_ret::XML_ERROR;
1224
0
            }
1225
226
        }
1226
2.51k
        else if (0 == strcmp(name, GROUP_DATA))
1227
221
        {
1228
            // userData
1229
221
            if (XMLP_ret::XML_OK != getXMLOctetVector(p_aux0, qos.m_groupData.data_vec(), ident))
1230
0
            {
1231
0
                return XMLP_ret::XML_ERROR;
1232
0
            }
1233
221
        }
1234
2.29k
        else
1235
2.29k
        {
1236
2.29k
            logError(XMLPARSER, "Invalid element found into 'writerQosPoliciesType'. Name: " << name);
1237
2.29k
            return XMLP_ret::XML_ERROR;
1238
2.29k
        }
1239
8.22k
    }
1240
1.04k
    return XMLP_ret::XML_OK;
1241
6.00k
}
1242
1243
XMLP_ret XMLParser::getXMLReaderQosPolicies(
1244
        tinyxml2::XMLElement* elem,
1245
        ReaderQos& qos,
1246
        uint8_t ident)
1247
4.74k
{
1248
    /*
1249
        <xs:complexType name="readerQosPoliciesType">
1250
            <xs:all minOccurs="0">
1251
                <xs:element name="durability" type="durabilityQosPolicyType" minOccurs="0"/>
1252
                <xs:element name="durabilityService" type="durabilityServiceQosPolicyType" minOccurs="0"/>
1253
                <xs:element name="deadline" type="deadlineQosPolicyType" minOccurs="0"/>
1254
                <xs:element name="latencyBudget" type="latencyBudgetQosPolicyType" minOccurs="0"/>
1255
                <xs:element name="liveliness" type="livelinessQosPolicyType" minOccurs="0"/>
1256
                <xs:element name="reliability" type="reliabilityQosPolicyType" minOccurs="0"/>
1257
                <xs:element name="lifespan" type="lifespanQosPolicyType" minOccurs="0"/>
1258
                <xs:element name="userData" type="userDataQosPolicyType" minOccurs="0"/>
1259
                <xs:element name="timeBasedFilter" type="timeBasedFilterQosPolicyType" minOccurs="0"/>
1260
                <xs:element name="ownership" type="ownershipQosPolicyType" minOccurs="0"/>
1261
                <xs:element name="destinationOrder" type="destinationOrderQosPolicyType" minOccurs="0"/>
1262
                <xs:element name="presentation" type="presentationQosPolicyType" minOccurs="0"/>
1263
                <xs:element name="partition" type="partitionQosPolicyType" minOccurs="0"/>
1264
                <xs:element name="topicData" type="topicDataQosPolicyType" minOccurs="0"/>
1265
                <xs:element name="groupData" type="groupDataQosPolicyType" minOccurs="0"/>
1266
                <xs:element name="data_sharing" type="dataSharingQosPolicyType" minOccurs="0"/>
1267
                <xs:element name="disablePositiveAcks" type="disablePositiveAcksQosPolicyType" minOccurs="0"/>
1268
            </xs:all>
1269
        </xs:complexType>
1270
     */
1271
1272
4.74k
    tinyxml2::XMLElement* p_aux0 = nullptr;
1273
4.74k
    const char* name = nullptr;
1274
8.11k
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
1275
7.34k
    {
1276
7.34k
        name = p_aux0->Name();
1277
7.34k
        if (strcmp(name, DURABILITY) == 0)
1278
195
        {
1279
            // durability
1280
195
            if (XMLP_ret::XML_OK != getXMLDurabilityQos(p_aux0, qos.m_durability, ident))
1281
195
            {
1282
195
                return XMLP_ret::XML_ERROR;
1283
195
            }
1284
195
        }
1285
7.14k
        else if (strcmp(name, LIVELINESS) == 0)
1286
234
        {
1287
            // liveliness
1288
234
            if (XMLP_ret::XML_OK != getXMLLivelinessQos(p_aux0, qos.m_liveliness, ident))
1289
0
            {
1290
0
                return XMLP_ret::XML_ERROR;
1291
0
            }
1292
234
        }
1293
6.91k
        else if (strcmp(name, RELIABILITY) == 0)
1294
1.25k
        {
1295
            // reliability
1296
1.25k
            if (XMLP_ret::XML_OK != getXMLReliabilityQos(p_aux0, qos.m_reliability, ident))
1297
860
            {
1298
860
                return XMLP_ret::XML_ERROR;
1299
860
            }
1300
1.25k
        }
1301
5.66k
        else if (strcmp(name, PARTITION) == 0)
1302
209
        {
1303
            // partition
1304
209
            if (XMLP_ret::XML_OK != getXMLPartitionQos(p_aux0, qos.m_partition, ident))
1305
209
            {
1306
209
                return XMLP_ret::XML_ERROR;
1307
209
            }
1308
209
        }
1309
5.45k
        else if (strcmp(name, DEADLINE) == 0)
1310
364
        {
1311
            // deadline
1312
364
            if (XMLP_ret::XML_OK != getXMLDeadlineQos(p_aux0, qos.m_deadline, ident))
1313
364
            {
1314
364
                return XMLP_ret::XML_ERROR;
1315
364
            }
1316
364
        }
1317
5.08k
        else if (strcmp(name, LIFESPAN) == 0)
1318
83
        {
1319
83
            if (XMLP_ret::XML_OK != getXMLLifespanQos(p_aux0, qos.m_lifespan, ident))
1320
83
            {
1321
83
                return XMLP_ret::XML_ERROR;
1322
83
            }
1323
83
        }
1324
5.00k
        else if (strcmp(name, DISABLE_POSITIVE_ACKS) == 0)
1325
88
        {
1326
            // Disable positive acks
1327
88
            if (XMLP_ret::XML_OK != getXMLDisablePositiveAcksQos(p_aux0, qos.m_disablePositiveACKs, ident))
1328
0
            {
1329
0
                return XMLP_ret::XML_ERROR;
1330
0
            }
1331
88
        }
1332
4.91k
        else if (strcmp(name, LATENCY_BUDGET) == 0)
1333
204
        {
1334
            //Latency Budget
1335
204
            if (XMLP_ret::XML_OK != getXMLLatencyBudgetQos(p_aux0, qos.m_latencyBudget, ident))
1336
204
            {
1337
204
                return XMLP_ret::XML_ERROR;
1338
204
            }
1339
204
        }
1340
4.71k
        else if (strcmp(name, DURABILITY_SRV) == 0 ||
1341
4.71k
                strcmp(name, TIME_FILTER) == 0 || strcmp(name, OWNERSHIP) == 0 ||
1342
4.71k
                strcmp(name, OWNERSHIP_STRENGTH) == 0 || strcmp(name, DEST_ORDER) == 0 ||
1343
4.71k
                strcmp(name, PRESENTATION) == 0)
1344
1.43k
        {
1345
            // TODO: Do not supported for now
1346
            //if (nullptr != (p_aux = elem->FirstChildElement(    DURABILITY_SRV))) getXMLDurabilityServiceQos(p_aux, ident);
1347
            //if (nullptr != (p_aux = elem->FirstChildElement(       TIME_FILTER))) getXMLTimeBasedFilterQos(p_aux, ident);
1348
            //if (nullptr != (p_aux = elem->FirstChildElement(         OWNERSHIP))) getXMLOwnershipQos(p_aux, ident);
1349
            //if (nullptr != (p_aux = elem->FirstChildElement(        DEST_ORDER))) getXMLDestinationOrderQos(p_aux, ident);
1350
            //if (nullptr != (p_aux = elem->FirstChildElement(      PRESENTATION))) getXMLPresentationQos(p_aux, ident);
1351
1.43k
            logError(XMLPARSER, "Quality of Service '" << p_aux0->Value() << "' do not supported for now");
1352
1.43k
        }
1353
3.27k
        else if (strcmp(name, DATA_SHARING) == 0)
1354
213
        {
1355
            //data sharing
1356
213
            if (XMLP_ret::XML_OK != getXMLDataSharingQos(p_aux0, qos.data_sharing, ident))
1357
213
            {
1358
213
                return XMLP_ret::XML_ERROR;
1359
213
            }
1360
213
        }
1361
3.06k
        else if (0 == strcmp(name, USER_DATA))
1362
333
        {
1363
            // userData
1364
333
            if (XMLP_ret::XML_OK != getXMLOctetVector(p_aux0, qos.m_userData.data_vec(), ident))
1365
0
            {
1366
0
                return XMLP_ret::XML_ERROR;
1367
0
            }
1368
333
        }
1369
2.72k
        else if (0 == strcmp(name, TOPIC_DATA))
1370
572
        {
1371
            // userData
1372
572
            if (XMLP_ret::XML_OK != getXMLOctetVector(p_aux0, qos.m_topicData.data_vec(), ident))
1373
0
            {
1374
0
                return XMLP_ret::XML_ERROR;
1375
0
            }
1376
572
        }
1377
2.15k
        else if (0 == strcmp(name, GROUP_DATA))
1378
306
        {
1379
            // userData
1380
306
            if (XMLP_ret::XML_OK != getXMLOctetVector(p_aux0, qos.m_groupData.data_vec(), ident))
1381
0
            {
1382
0
                return XMLP_ret::XML_ERROR;
1383
0
            }
1384
306
        }
1385
1.85k
        else
1386
1.85k
        {
1387
1.85k
            logError(XMLPARSER, "Invalid element found into 'readerQosPoliciesType'. Name: " << name);
1388
1.85k
            return XMLP_ret::XML_ERROR;
1389
1.85k
        }
1390
7.34k
    }
1391
769
    return XMLP_ret::XML_OK;
1392
4.74k
}
1393
1394
XMLP_ret XMLParser::getXMLDurabilityQos(
1395
        tinyxml2::XMLElement* elem,
1396
        DurabilityQosPolicy& durability,
1397
        uint8_t /*ident*/)
1398
390
{
1399
    /*
1400
        <xs:complexType name="durabilityQosPolicyType">
1401
            <xs:all>
1402
                <xs:element name="kind" type="durabilityQosKindType"/>
1403
            </xs:all>
1404
        </xs:complexType>
1405
     */
1406
1407
390
    tinyxml2::XMLElement* p_aux0 = nullptr;
1408
390
    const char* name = nullptr;
1409
390
    bool bKindDefined = false;
1410
390
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
1411
0
    {
1412
0
        name = p_aux0->Name();
1413
0
        if (strcmp(name, KIND) == 0)
1414
0
        {
1415
            // kind
1416
            /*
1417
                <xs:simpleType name="durabilityQosKindType">
1418
                    <xs:restriction base="xs:string">
1419
                        <xs:enumeration value="VOLATILE"/>
1420
                        <xs:enumeration value="TRANSIENT_LOCAL"/>
1421
                        <xs:enumeration value="TRANSIENT"/>
1422
                        <xs:enumeration value="PERSISTENT"/>
1423
                    </xs:restriction>
1424
                </xs:simpleType>
1425
             */
1426
0
            const char* text = p_aux0->GetText();
1427
0
            if (nullptr == text)
1428
0
            {
1429
0
                logError(XMLPARSER, "Node '" << KIND << "' without content");
1430
0
                return XMLP_ret::XML_ERROR;
1431
0
            }
1432
0
            bKindDefined = true;
1433
0
            if (strcmp(text, _VOLATILE) == 0)
1434
0
            {
1435
0
                durability.kind = DurabilityQosPolicyKind::VOLATILE_DURABILITY_QOS;
1436
0
            }
1437
0
            else if (strcmp(text, _TRANSIENT_LOCAL) == 0)
1438
0
            {
1439
0
                durability.kind = DurabilityQosPolicyKind::TRANSIENT_LOCAL_DURABILITY_QOS;
1440
0
            }
1441
0
            else if (strcmp(text, _TRANSIENT) == 0)
1442
0
            {
1443
0
                durability.kind = DurabilityQosPolicyKind::TRANSIENT_DURABILITY_QOS;
1444
0
            }
1445
0
            else if (strcmp(text, _PERSISTENT) == 0)
1446
0
            {
1447
0
                durability.kind = DurabilityQosPolicyKind::PERSISTENT_DURABILITY_QOS;
1448
0
            }
1449
0
            else
1450
0
            {
1451
0
                logError(XMLPARSER, "Node '" << KIND << "' with bad content");
1452
0
                return XMLP_ret::XML_ERROR;
1453
0
            }
1454
0
        }
1455
0
        else
1456
0
        {
1457
0
            logError(XMLPARSER, "Invalid element found into 'durabilityQosPolicyType'. Name: " << name);
1458
0
            return XMLP_ret::XML_ERROR;
1459
0
        }
1460
0
    }
1461
390
    if (!bKindDefined)
1462
390
    {
1463
390
        logError(XMLPARSER, "Node 'durabilityQosPolicyType' without content");
1464
390
        return XMLP_ret::XML_ERROR;
1465
390
    }
1466
1467
0
    return XMLP_ret::XML_OK;
1468
390
}
1469
1470
// TODO Implement DurabilityServiceQos
1471
/*
1472
   XMLP_ret XMLParser::getXMLDurabilityServiceQos(
1473
        tinyxml2::XMLElement* elem,
1474
        DurabilityServiceQosPolicy& durabilityService,
1475
        uint8_t ident)
1476
   {
1477
1478
    //    <xs:complexType name="durabilityServiceQosPolicyType">
1479
    //        <xs:all minOccurs="0">
1480
    //            <xs:element name="service_cleanup_delay" type="durationType" minOccurs="0"/>
1481
    //            <xs:element name="history_kind" type="historyQosKindType" minOccurs="0"/>
1482
    //            <xs:element name="history_depth" type="uint32Type" minOccurs="0"/>
1483
    //            <xs:element name="max_samples" type="uint32Type" minOccurs="0"/>
1484
    //            <xs:element name="max_instances" type="uint32Type" minOccurs="0"/>
1485
    //            <xs:element name="max_samples_per_instance" type="uint32Type" minOccurs="0"/>
1486
    //        </xs:all>
1487
    //    </xs:complexType>
1488
1489
1490
    tinyxml2::XMLElement* p_aux0 = nullptr;
1491
    const char* name = nullptr;
1492
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
1493
    {
1494
        name = p_aux0->Name();
1495
        if (strcmp(name, SRV_CLEAN_DELAY) == 0)
1496
        {
1497
            // service_cleanup_delay - durationType
1498
            if (XMLP_ret::XML_OK != getXMLDuration(p_aux0, durabilityService.service_cleanup_delay, ident))
1499
            {
1500
                return XMLP_ret::XML_ERROR;
1501
            }
1502
        }
1503
        else if (strcmp(name, HISTORY_KIND) == 0)
1504
        {
1505
            // history_kind
1506
            //
1507
            //    <xs:simpleType name="historyQosKindType">
1508
            //        <xs:restriction base="xs:string">
1509
            //            <xs:enumeration value="KEEP_LAST"/>
1510
            //            <xs:enumeration value="KEEP_ALL"/>
1511
            //        </xs:restriction>
1512
            //    </xs:simpleType>
1513
            //
1514
            const char* text = p_aux0->GetText();
1515
            if (nullptr == text)
1516
            {
1517
                logError(XMLPARSER, "Node '" << HISTORY_KIND << "' without content");
1518
                return XMLP_ret::XML_ERROR;
1519
            }
1520
            if (strcmp(text, KEEP_LAST) == 0)
1521
            {
1522
                durabilityService.history_kind = HistoryQosPolicyKind::KEEP_LAST_HISTORY_QOS;
1523
            }
1524
            else if (strcmp(text, KEEP_ALL) == 0)
1525
            {
1526
                durabilityService.history_kind = HistoryQosPolicyKind::KEEP_ALL_HISTORY_QOS;
1527
            }
1528
            else
1529
            {
1530
                logError(XMLPARSER, "Node '" << HISTORY_KIND << "' with bad content");
1531
                return XMLP_ret::XML_ERROR;
1532
            }
1533
        }
1534
        else if (strcmp(name, HISTORY_DEPTH) == 0)
1535
        {
1536
            // history_depth - uint32Type
1537
            if (XMLP_ret::XML_OK != getXMLInt(p_aux0, &durabilityService.history_depth, ident))
1538
            {
1539
                return XMLP_ret::XML_ERROR;
1540
            }
1541
        }
1542
        else if (strcmp(name, MAX_SAMPLES) == 0)
1543
        {
1544
            // max_samples - uint32Type
1545
            if (XMLP_ret::XML_OK != getXMLInt(p_aux0, &durabilityService.max_samples, ident))
1546
            {
1547
                return XMLP_ret::XML_ERROR;
1548
            }
1549
        }
1550
        else if (strcmp(name, MAX_INSTANCES) == 0)
1551
        {
1552
            // max_instances - uint32Type
1553
            if (XMLP_ret::XML_OK != getXMLInt(p_aux0, &durabilityService.max_instances, ident))
1554
            {
1555
                return XMLP_ret::XML_ERROR;
1556
            }
1557
        }
1558
        else if (strcmp(name, MAX_SAMPLES_INSTANCE) == 0)
1559
        {
1560
            // max_samples_per_instance - uint32Type
1561
            if (XMLP_ret::XML_OK != getXMLInt(p_aux0, &durabilityService.max_samples_per_instance, ident))
1562
            {
1563
                return XMLP_ret::XML_ERROR;
1564
            }
1565
        }
1566
        else
1567
        {
1568
            logError(XMLPARSER, "Invalid element found into 'durabilityServiceQosPolicyType'. Name: " << name);
1569
            return XMLP_ret::XML_ERROR;
1570
        }
1571
    }
1572
    return XMLP_ret::XML_OK;
1573
   }
1574
 */
1575
1576
XMLP_ret XMLParser::getXMLDeadlineQos(
1577
        tinyxml2::XMLElement* elem,
1578
        DeadlineQosPolicy& deadline,
1579
        uint8_t ident)
1580
439
{
1581
    /*
1582
        <xs:complexType name="deadlineQosPolicyType">
1583
            <xs:all>
1584
                <xs:element name="period" type="durationType"/>
1585
            </xs:all>
1586
        </xs:complexType>
1587
     */
1588
439
    tinyxml2::XMLElement* p_aux0 = nullptr;
1589
439
    const char* name = nullptr;
1590
439
    bool bPeriodDefined = false;
1591
439
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
1592
0
    {
1593
0
        name = p_aux0->Name();
1594
0
        if (strcmp(name, PERIOD) == 0)
1595
0
        {
1596
0
            bPeriodDefined = true;
1597
0
            if (XMLP_ret::XML_OK != getXMLDuration(p_aux0, deadline.period, ident))
1598
0
            {
1599
0
                return XMLP_ret::XML_ERROR;
1600
0
            }
1601
0
        }
1602
0
        else
1603
0
        {
1604
0
            logError(XMLPARSER, "Invalid element found into 'deadlineQosPolicyType'. Name: " << name);
1605
0
            return XMLP_ret::XML_ERROR;
1606
0
        }
1607
0
    }
1608
1609
439
    if (!bPeriodDefined)
1610
439
    {
1611
439
        logError(XMLPARSER, "Node 'deadlineQosPolicyType' without content");
1612
439
        return XMLP_ret::XML_ERROR;
1613
439
    }
1614
1615
0
    return XMLP_ret::XML_OK;
1616
439
}
1617
1618
XMLP_ret XMLParser::getXMLLatencyBudgetQos(
1619
        tinyxml2::XMLElement* elem,
1620
        LatencyBudgetQosPolicy& latencyBudget,
1621
        uint8_t ident)
1622
399
{
1623
    /*
1624
        <xs:complexType name="latencyBudgetQosPolicyType">
1625
            <xs:all>
1626
                <xs:element name="duration" type="durationType"/>
1627
            </xs:all>
1628
        </xs:complexType>
1629
     */
1630
1631
399
    tinyxml2::XMLElement* p_aux0 = nullptr;
1632
399
    const char* name = nullptr;
1633
399
    bool bDurationDefined = false;
1634
399
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
1635
0
    {
1636
0
        name = p_aux0->Name();
1637
0
        if (strcmp(name, DURATION) == 0)
1638
0
        {
1639
0
            bDurationDefined = true;
1640
0
            if (XMLP_ret::XML_OK != getXMLDuration(p_aux0, latencyBudget.duration, ident))
1641
0
            {
1642
0
                return XMLP_ret::XML_ERROR;
1643
0
            }
1644
0
        }
1645
0
        else
1646
0
        {
1647
0
            logError(XMLPARSER, "Invalid element found into 'latencyBudgetQosPolicyType'. Name: " << name);
1648
0
            return XMLP_ret::XML_ERROR;
1649
0
        }
1650
0
    }
1651
1652
399
    if (!bDurationDefined)
1653
399
    {
1654
399
        logError(XMLPARSER, "Node 'latencyBudgetQosPolicyType' without content");
1655
399
        return XMLP_ret::XML_ERROR;
1656
399
    }
1657
0
    return XMLP_ret::XML_OK;
1658
399
}
1659
1660
XMLP_ret XMLParser::getXMLLivelinessQos(
1661
        tinyxml2::XMLElement* elem,
1662
        LivelinessQosPolicy& liveliness,
1663
        uint8_t ident)
1664
581
{
1665
    /*
1666
        <xs:complexType name="livelinessQosPolicyType">
1667
            <xs:all minOccurs="0">
1668
                <xs:element name="kind" type="livelinessQosKindType" minOccurs="0"/>
1669
                <xs:element name="leaseDuration" type="durationType" minOccurs="0"/>
1670
                <xs:element name="announcement_period" type="durationType" minOccurs="0"/>
1671
            </xs:all>
1672
        </xs:complexType>
1673
     */
1674
1675
581
    tinyxml2::XMLElement* p_aux0 = nullptr;
1676
581
    const char* name = nullptr;
1677
581
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
1678
0
    {
1679
0
        name = p_aux0->Name();
1680
0
        if (strcmp(name, KIND) == 0)
1681
0
        {
1682
            // kind
1683
            /*
1684
                <xs:simpleType name="livelinessQosKindType">
1685
                    <xs:restriction base="xs:string">
1686
                        <xs:enumeration value="AUTOMATIC"/>
1687
                        <xs:enumeration value="MANUAL_BY_PARTICIPANT"/>
1688
                        <xs:enumeration value="MANUAL_BY_TOPIC"/>
1689
                    </xs:restriction>
1690
                </xs:simpleType>
1691
             */
1692
0
            const char* text = p_aux0->GetText();
1693
0
            if (nullptr == text)
1694
0
            {
1695
0
                logError(XMLPARSER, "Node '" << KIND << "' without content");
1696
0
                return XMLP_ret::XML_ERROR;
1697
0
            }
1698
0
            if (strcmp(text, AUTOMATIC) == 0)
1699
0
            {
1700
0
                liveliness.kind = LivelinessQosPolicyKind::AUTOMATIC_LIVELINESS_QOS;
1701
0
            }
1702
0
            else if (strcmp(text, MANUAL_BY_PARTICIPANT) == 0)
1703
0
            {
1704
0
                liveliness.kind = LivelinessQosPolicyKind::MANUAL_BY_PARTICIPANT_LIVELINESS_QOS;
1705
0
            }
1706
0
            else if (strcmp(text, MANUAL_BY_TOPIC) == 0)
1707
0
            {
1708
0
                liveliness.kind = LivelinessQosPolicyKind::MANUAL_BY_TOPIC_LIVELINESS_QOS;
1709
0
            }
1710
0
            else
1711
0
            {
1712
0
                logError(XMLPARSER, "Node '" << KIND << "' with bad content");
1713
0
                return XMLP_ret::XML_ERROR;
1714
0
            }
1715
0
        }
1716
0
        else if (strcmp(name, LEASE_DURATION) == 0)
1717
0
        {
1718
            // lease_duration
1719
0
            if (XMLP_ret::XML_OK != getXMLDuration(p_aux0, liveliness.lease_duration, ident))
1720
0
            {
1721
0
                return XMLP_ret::XML_ERROR;
1722
0
            }
1723
0
        }
1724
0
        else if (strcmp(name, ANNOUNCE_PERIOD) == 0)
1725
0
        {
1726
            // announcement_period
1727
0
            if (XMLP_ret::XML_OK != getXMLDuration(p_aux0, liveliness.announcement_period, ident))
1728
0
            {
1729
0
                return XMLP_ret::XML_ERROR;
1730
0
            }
1731
0
        }
1732
0
        else
1733
0
        {
1734
0
            logError(XMLPARSER, "Invalid element found into 'livelinessQosPolicyType'. Name: " << name);
1735
0
            return XMLP_ret::XML_ERROR;
1736
0
        }
1737
0
    }
1738
1739
581
    return XMLP_ret::XML_OK;
1740
581
}
1741
1742
XMLP_ret XMLParser::getXMLReliabilityQos(
1743
        tinyxml2::XMLElement* elem,
1744
        ReliabilityQosPolicy& reliability,
1745
        uint8_t ident)
1746
2.31k
{
1747
    /*
1748
        <xs:complexType name="reliabilityQosPolicyType">
1749
            <xs:all>
1750
                <xs:element name="kind" type="reliabilityQosKindType" minOccurs="0"/>
1751
                <xs:element name="max_blocking_time" type="durationType" minOccurs="0"/>
1752
            </xs:all>
1753
        </xs:complexType>
1754
     */
1755
1756
2.31k
    tinyxml2::XMLElement* p_aux0 = nullptr;
1757
2.31k
    const char* name = nullptr;
1758
2.82k
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
1759
2.13k
    {
1760
2.13k
        name = p_aux0->Name();
1761
2.13k
        if (strcmp(name, KIND) == 0)
1762
1.21k
        {
1763
            // kind
1764
            /*
1765
                <xs:simpleType name="reliabilityQosKindType">
1766
                    <xs:restriction base="xs:string">
1767
                        <xs:enumeration value="BEST_EFFORT"/>
1768
                        <xs:enumeration value="RELIABLE"/>
1769
                    </xs:restriction>
1770
                </xs:simpleType>
1771
             */
1772
1.21k
            const char* text = p_aux0->GetText();
1773
1.21k
            if (nullptr == text)
1774
377
            {
1775
377
                logError(XMLPARSER, "Node '" << KIND << "' without content");
1776
377
                return XMLP_ret::XML_ERROR;
1777
377
            }
1778
840
            if (strcmp(text, _BEST_EFFORT) == 0)
1779
269
            {
1780
269
                reliability.kind = ReliabilityQosPolicyKind::BEST_EFFORT_RELIABILITY_QOS;
1781
269
            }
1782
571
            else if (strcmp(text, _RELIABLE) == 0)
1783
234
            {
1784
234
                reliability.kind = ReliabilityQosPolicyKind::RELIABLE_RELIABILITY_QOS;
1785
234
            }
1786
337
            else
1787
337
            {
1788
337
                logError(XMLPARSER, "Node '" << KIND << "' with bad content");
1789
337
                return XMLP_ret::XML_ERROR;
1790
337
            }
1791
840
        }
1792
922
        else if (strcmp(name, MAX_BLOCK_TIME) == 0)
1793
355
        {
1794
            // max_blocking_time
1795
355
            if (XMLP_ret::XML_OK != getXMLDuration(p_aux0, reliability.max_blocking_time, ident))
1796
355
            {
1797
355
                return XMLP_ret::XML_ERROR;
1798
355
            }
1799
355
        }
1800
567
        else
1801
567
        {
1802
567
            logError(XMLPARSER, "Invalid element found into 'reliabilityQosPolicyType'. Name: " << name);
1803
567
            return XMLP_ret::XML_ERROR;
1804
567
        }
1805
2.13k
    }
1806
683
    return XMLP_ret::XML_OK;
1807
2.31k
}
1808
1809
XMLP_ret XMLParser::getXMLLifespanQos(
1810
        tinyxml2::XMLElement* elem,
1811
        LifespanQosPolicy& lifespan,
1812
        uint8_t ident)
1813
151
{
1814
    /*
1815
        <xs:complexType name="lifespanQosPolicyType">
1816
            <xs:all>
1817
                <xs:element name="duration" type="durationType"/>
1818
            </xs:all>
1819
        </xs:complexType>
1820
     */
1821
1822
151
    tinyxml2::XMLElement* p_aux0 = nullptr;
1823
151
    bool bDurationDefined = false;
1824
151
    const char* name = nullptr;
1825
151
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
1826
0
    {
1827
0
        name = p_aux0->Name();
1828
0
        if (strcmp(name, DURATION) == 0)
1829
0
        {
1830
0
            bDurationDefined = true;
1831
0
            if (XMLP_ret::XML_OK != getXMLDuration(p_aux0, lifespan.duration, ident))
1832
0
            {
1833
0
                return XMLP_ret::XML_ERROR;
1834
0
            }
1835
0
        }
1836
0
        else
1837
0
        {
1838
0
            logError(XMLPARSER, "Invalid element found into 'lifespanQosPolicyType'. Name: " << name);
1839
0
            return XMLP_ret::XML_ERROR;
1840
0
        }
1841
0
    }
1842
1843
151
    if (!bDurationDefined)
1844
151
    {
1845
151
        logError(XMLPARSER, "Node 'lifespanQosPolicyType' without content");
1846
151
        return XMLP_ret::XML_ERROR;
1847
151
    }
1848
1849
0
    return XMLP_ret::XML_OK;
1850
151
}
1851
1852
XMLP_ret XMLParser::getXMLDisablePositiveAcksQos(
1853
        tinyxml2::XMLElement* elem,
1854
        DisablePositiveACKsQosPolicy& disablePositiveAcks,
1855
        uint8_t ident)
1856
323
{
1857
    /*
1858
        <xs:complexType name="disablePositiveAcksQosPolicyType">
1859
            <xs:all>
1860
                <xs:element name="enabled" type="boolType"/>
1861
                <xs:element name="duration" type="durationType"/>
1862
            </xs:all>
1863
        </xs:complexType>
1864
     */
1865
1866
323
    tinyxml2::XMLElement* p_aux0 = nullptr;
1867
323
    const char* name = nullptr;
1868
323
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
1869
0
    {
1870
0
        name = p_aux0->Name();
1871
0
        if (strcmp(name, ENABLED) == 0)
1872
0
        {
1873
0
            if (XMLP_ret::XML_OK != getXMLBool(p_aux0, &disablePositiveAcks.enabled, ident))
1874
0
            {
1875
0
                return XMLP_ret::XML_ERROR;
1876
0
            }
1877
0
        }
1878
0
        else if (strcmp(name, DURATION) == 0)
1879
0
        {
1880
0
            if (XMLP_ret::XML_OK != getXMLDuration(p_aux0, disablePositiveAcks.duration, ident))
1881
0
            {
1882
0
                return XMLP_ret::XML_ERROR;
1883
0
            }
1884
0
        }
1885
0
        else
1886
0
        {
1887
0
            logError(XMLPARSER, "Node 'disablePositiveAcksQosPolicyType' with unknown content");
1888
0
            return XMLP_ret::XML_ERROR;
1889
0
        }
1890
0
    }
1891
1892
323
    return XMLP_ret::XML_OK;
1893
323
}
1894
1895
XMLP_ret XMLParser::getXMLDataSharingQos(
1896
        tinyxml2::XMLElement* elem,
1897
        DataSharingQosPolicy& data_sharing,
1898
        uint8_t ident)
1899
567
{
1900
    /*
1901
        <xs:complexType name="dataSharingQosPolicyType">
1902
            <xs:all>
1903
                <xs:element name="kind" type="datasharingQosKindType" minOccurs="1"/>
1904
                <xs:element name="shared_dir" type="stringType" minOccurs="0"/>
1905
                <xs:element name="domain_ids" type="domainIdVectorType" minOccurs="0"/>
1906
                <xs:element name="max_domains" type="uint32Type" minOccurs="0"/>
1907
            </xs:all>
1908
        </xs:complexType>
1909
     */
1910
567
    bool kind_found = false;
1911
567
    DataSharingKind kind = DataSharingKind::AUTO;
1912
567
    std::string shm_directory = "";
1913
567
    int32_t max_domains = 0;
1914
567
    std::vector<uint16_t> domain_ids;
1915
1916
567
    tinyxml2::XMLElement* p_aux0 = nullptr;
1917
567
    const char* name = nullptr;
1918
567
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
1919
0
    {
1920
0
        name = p_aux0->Name();
1921
0
        if (strcmp(name, KIND) == 0)
1922
0
        {
1923
            /*
1924
                <xs:simpleType name="datasharingQosKindType">
1925
                    <xs:restriction base="xs:string">
1926
                        <xs:enumeration value="ON"/>
1927
                        <xs:enumeration value="OFF"/>
1928
                        <xs:enumeration value="DEFAULT"/>
1929
                    </xs:restriction>
1930
                </xs:simpleType>
1931
             */
1932
0
            const char* text = p_aux0->GetText();
1933
0
            if (nullptr == text)
1934
0
            {
1935
0
                logError(XMLPARSER, "Node '" << KIND << "' without content");
1936
0
                return XMLP_ret::XML_ERROR;
1937
0
            }
1938
0
            if (strcmp(text, ON) == 0)
1939
0
            {
1940
0
                kind = DataSharingKind::ON;
1941
0
            }
1942
0
            else if (strcmp(text, OFF) == 0)
1943
0
            {
1944
0
                kind = DataSharingKind::OFF;
1945
0
            }
1946
0
            else if (strcmp(text, AUTOMATIC) == 0)
1947
0
            {
1948
0
                kind = DataSharingKind::AUTO;
1949
0
            }
1950
0
            else
1951
0
            {
1952
0
                logError(XMLPARSER, "Node '" << KIND << "' with bad content");
1953
0
                return XMLP_ret::XML_ERROR;
1954
0
            }
1955
0
            kind_found = true;
1956
0
        }
1957
0
        else if (strcmp(name, SHARED_DIR) == 0)
1958
0
        {
1959
0
            if (XMLP_ret::XML_OK != getXMLString(p_aux0, &shm_directory, ident))
1960
0
            {
1961
0
                return XMLP_ret::XML_ERROR;
1962
0
            }
1963
0
        }
1964
0
        else if (strcmp(name, MAX_DOMAINS) == 0)
1965
0
        {
1966
0
            if (XMLP_ret::XML_OK != getXMLInt(p_aux0, &max_domains, ident))
1967
0
            {
1968
0
                return XMLP_ret::XML_ERROR;
1969
0
            }
1970
0
            if (max_domains < 0)
1971
0
            {
1972
0
                logError(XMLPARSER, "max domains cannot be negative");
1973
0
                return XMLP_ret::XML_ERROR;
1974
0
            }
1975
1976
0
        }
1977
0
        else if (strcmp(name, DOMAIN_IDS) == 0)
1978
0
        {
1979
            /*
1980
                <xs:complexType name="domainIdVectorType">
1981
                    <xs:sequence>
1982
                        <xs:element name="domainId" type="uint16Type" maxOccurs="unbounded"/>
1983
                    </xs:sequence>
1984
                </xs:complexType>
1985
             */
1986
1987
0
            tinyxml2::XMLElement* p_aux1;
1988
0
            const char* name1 = nullptr;
1989
0
            bool domain_id_found = false;
1990
0
            for (p_aux1 = p_aux0->FirstChildElement(); p_aux1 != NULL; p_aux1 = p_aux1->NextSiblingElement())
1991
0
            {
1992
0
                name1 = p_aux1->Name();
1993
0
                if (strcmp(name1, DOMAIN_ID) == 0)
1994
0
                {
1995
0
                    uint16_t id;
1996
0
                    if (XMLP_ret::XML_OK != getXMLUint(p_aux1, &id, ident))
1997
0
                    {
1998
0
                        return XMLP_ret::XML_ERROR;
1999
0
                    }
2000
0
                    domain_ids.push_back(id);
2001
0
                    domain_id_found = true;
2002
0
                }
2003
0
                else
2004
0
                {
2005
0
                    logError(XMLPARSER, "Invalid element found in 'domain_ids'. Name: " << name1);
2006
0
                    return XMLP_ret::XML_ERROR;
2007
0
                }
2008
0
            }
2009
2010
0
            if (!domain_id_found)
2011
0
            {
2012
                // Not even one
2013
0
                logError(XMLPARSER, "Node '" << DOMAIN_IDS << "' without content");
2014
0
                return XMLP_ret::XML_ERROR;
2015
0
            }
2016
0
        }
2017
0
        else
2018
0
        {
2019
0
            logError(XMLPARSER, "Invalid element found in 'data_sharing'. Name: " << name);
2020
0
            return XMLP_ret::XML_ERROR;
2021
0
        }
2022
0
    }
2023
2024
567
    if (!kind_found)
2025
567
    {
2026
567
        logError(XMLPARSER, "Node 'data_sharing' without kind");
2027
567
        return XMLP_ret::XML_ERROR;
2028
567
    }
2029
2030
0
    if (max_domains != 0 && domain_ids.size() > static_cast<uint32_t>(max_domains))
2031
0
    {
2032
0
        logError(XMLPARSER, "Node 'data_sharing' defines a maximum of " << max_domains
2033
0
                                                                        << " domain IDs but also define " << domain_ids.size() <<
2034
0
                " domain IDs");
2035
0
        return XMLP_ret::XML_ERROR;
2036
0
    }
2037
2038
0
    data_sharing.set_max_domains(static_cast<uint32_t>(max_domains));
2039
2040
0
    switch (kind)
2041
0
    {
2042
0
        case DataSharingKind::ON:
2043
0
            data_sharing.on(shm_directory, domain_ids);
2044
0
            break;
2045
2046
0
        case DataSharingKind::AUTO:
2047
0
            data_sharing.automatic(shm_directory, domain_ids);
2048
0
            break;
2049
2050
0
        case DataSharingKind::OFF:
2051
0
            data_sharing.off();
2052
0
            break;
2053
2054
0
        default:
2055
0
            break;
2056
0
    }
2057
2058
0
    return XMLP_ret::XML_OK;
2059
0
}
2060
2061
// TODO Implement TimeBasedFilterQos
2062
/*
2063
   XMLP_ret XMLParser::getXMLTimeBasedFilterQos(
2064
        tinyxml2::XMLElement* elem,
2065
        TimeBasedFilterQosPolicy& timeBasedFilter,
2066
        uint8_t ident)
2067
   {
2068
2069
    //    <xs:complexType name="timeBasedFilterQosPolicyType">
2070
    //        <xs:all>
2071
    //          <xs:element name="minimum_separation" type="durationType"/>
2072
    //        </xs:all>
2073
    //    </xs:complexType>
2074
2075
2076
    tinyxml2::XMLElement* p_aux0 = nullptr;
2077
    bool bSeparationDefined = false;
2078
    const char* name = nullptr;
2079
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
2080
    {
2081
        name = p_aux0->Name();
2082
        if (strcmp(name, MIN_SEPARATION) == 0)
2083
        {
2084
            bSeparationDefined = true;
2085
            if (XMLP_ret::XML_OK != getXMLDuration(p_aux0, timeBasedFilter.minimum_separation, ident))
2086
            {
2087
                return XMLP_ret::XML_ERROR;
2088
            }
2089
        }
2090
        else
2091
        {
2092
            logError(XMLPARSER, "Invalid element found into 'timeBasedFilterQosPolicyType'. Name: " << name);
2093
            return XMLP_ret::XML_ERROR;
2094
        }
2095
    }
2096
2097
    if (!bSeparationDefined)
2098
    {
2099
        logError(XMLPARSER, "Node 'timeBasedFilterQosPolicyType' without content");
2100
        return XMLP_ret::XML_ERROR;
2101
    }
2102
    return XMLP_ret::XML_OK;
2103
   }
2104
 */
2105
2106
// TODO Implement OwnershipQos
2107
/*
2108
   XMLP_ret XMLParser::getXMLOwnershipQos(
2109
        tinyxml2::XMLElement* elem,
2110
        OwnershipQosPolicy& ownership,
2111
        uint8_t ident)
2112
   {
2113
2114
    //    <xs:complexType name="ownershipQosPolicyType">
2115
    //        <xs:all>
2116
    //            <xs:element name="kind" type="ownershipQosKindType"/>
2117
    //        </xs:all>
2118
    //    </xs:complexType>
2119
2120
    tinyxml2::XMLElement* p_aux0 = nullptr;
2121
    bool bKindDefined = false;
2122
    const char* name = nullptr;
2123
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
2124
    {
2125
        name = p_aux0->Name();
2126
        if (strcmp(name, KIND) == 0)
2127
        {
2128
2129
            //    <xs:simpleType name="ownershipQosKindType">
2130
            //        <xs:restriction base="xs:string">
2131
            //            <xs:enumeration value="SHARED"/>
2132
            //            <xs:enumeration value="EXCLUSIVE"/>
2133
            //        </xs:restriction>
2134
            //    </xs:simpleType>
2135
2136
            bKindDefined = true;
2137
            const char* text = p_aux0->GetText();
2138
            if (nullptr == text)
2139
            {
2140
                logError(XMLPARSER, "Node '" << KIND << "' without content");
2141
                return XMLP_ret::XML_ERROR;
2142
            }
2143
            if (strcmp(text, SHARED) == 0)
2144
            {
2145
                ownership.kind = OwnershipQosPolicyKind::SHARED_OWNERSHIP_QOS;
2146
            }
2147
            else if (strcmp(text, EXCLUSIVE) == 0)
2148
            {
2149
                ownership.kind = OwnershipQosPolicyKind::EXCLUSIVE_OWNERSHIP_QOS;
2150
            }
2151
            else
2152
            {
2153
                logError(XMLPARSER, "Node '" << KIND << "' with bad content");
2154
                return XMLP_ret::XML_ERROR;
2155
            }
2156
        }
2157
        else
2158
        {
2159
            logError(XMLPARSER, "Invalid element found into 'ownershipQosPolicyType'. Name: " << name);
2160
            return XMLP_ret::XML_ERROR;
2161
        }
2162
    }
2163
2164
    if (!bKindDefined)
2165
    {
2166
        logError(XMLPARSER, "Node 'ownershipQosPolicyType' without content");
2167
        return XMLP_ret::XML_ERROR;
2168
    }
2169
2170
    return XMLP_ret::
2171
    XML_OK;
2172
   }
2173
 */
2174
2175
// TODO Implement OwnershipStrengthQos
2176
/*
2177
   XMLP_ret XMLParser::getXMLOwnershipStrengthQos(
2178
        tinyxml2::XMLElement* elem,
2179
        OwnershipStrengthQosPolicy& ownershipStrength,
2180
        uint8_t ident)
2181
   {
2182
2183
    //    <xs:complexType name="ownershipStrengthQosPolicyType">
2184
    //        <xs:all>
2185
    //            <xs:element name="value" type="uint32Type"/>
2186
    //        </xs:all>
2187
    //    </xs:complexType>
2188
2189
    tinyxml2::XMLElement* p_aux0 = nullptr;
2190
    bool bValueDefined = false;
2191
    const char* name = nullptr;
2192
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
2193
    {
2194
        name = p_aux0->Name();
2195
        if (strcmp(name, VALUE) == 0)
2196
        {
2197
            bValueDefined = true;
2198
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &ownershipStrength.value, ident))
2199
            {
2200
                return XMLP_ret::XML_ERROR;
2201
            }
2202
        }
2203
        else
2204
        {
2205
            logError(XMLPARSER, "Invalid element found into 'ownershipStrengthQosPolicyType'. Name: " << name);
2206
            return XMLP_ret::XML_ERROR;
2207
        }
2208
    }
2209
2210
    if (!bValueDefined)
2211
    {
2212
        logError(XMLPARSER, "Node 'ownershipStrengthQosPolicyType' without content");
2213
        return XMLP_ret::XML_ERROR;
2214
    }
2215
2216
    return XMLP_ret::XML_OK;
2217
   }
2218
 */
2219
2220
2221
// TODO Implement DestinationOrderQos
2222
/*
2223
   XMLP_ret XMLParser::getXMLDestinationOrderQos(
2224
        tinyxml2::XMLElement* elem,
2225
        DestinationOrderQosPolicy& destinationOrder,
2226
        uint8_t ident)
2227
   {
2228
2229
    //    <xs:complexType name="destinationOrderQosPolicyType">
2230
    //        <xs:all>
2231
    //            <xs:element name="kind" type="destinationOrderQosKindType"/>
2232
    //        </xs:all>
2233
    //    </xs:complexType>
2234
2235
2236
    tinyxml2::XMLElement* p_aux0 = nullptr;
2237
    bool bKindDefined = false;
2238
    const char* name = nullptr;
2239
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
2240
    {
2241
        name = p_aux0->Name();
2242
        if (strcmp(name, KIND) == 0)
2243
        {
2244
2245
            //    <xs:simpleType name="destinationOrderQosKindType">
2246
            //        <xs:restriction base="xs:string">
2247
            //            <xs:enumeration value="BY_RECEPTION_TIMESTAMP"/>
2248
            //            <xs:enumeration value="BY_SOURCE_TIMESTAMP"/>
2249
            //        </xs:restriction>
2250
            //    </xs:simpleType>
2251
2252
            bKindDefined = true;
2253
            const char* text = p_aux0->GetText();
2254
            if (nullptr == text)
2255
            {
2256
                logError(XMLPARSER, "Node '" << KIND << "' without content");
2257
                return XMLP_ret::XML_ERROR;
2258
            }
2259
            if (strcmp(text, BY_RECEPTION_TIMESTAMP) == 0)
2260
            {
2261
                destinationOrder.kind = DestinationOrderQosPolicyKind::BY_RECEPTION_TIMESTAMP_DESTINATIONORDER_QOS;
2262
            }
2263
            else if (strcmp(text, BY_SOURCE_TIMESTAMP) == 0)
2264
            {
2265
                destinationOrder.kind = DestinationOrderQosPolicyKind::BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS;
2266
            }
2267
            else
2268
            {
2269
                logError(XMLPARSER, "Node '" << KIND << "' bad content");
2270
                return XMLP_ret::XML_ERROR;
2271
            }
2272
        }
2273
        else
2274
        {
2275
            logError(XMLPARSER, "Invalid element found into 'destinationOrderQosPolicyType'. Name: " << name);
2276
            return XMLP_ret::XML_ERROR;
2277
        }
2278
    }
2279
2280
    if (!bKindDefined)
2281
    {
2282
        logError(XMLPARSER, "Node 'destinationOrderQosPolicyType' without content");
2283
        return XMLP_ret::XML_ERROR;
2284
    }
2285
2286
    return XMLP_ret::XML_OK;
2287
   }
2288
 */
2289
2290
// TODO Implement PresentationQos
2291
/*
2292
   XMLP_ret XMLParser::getXMLPresentationQos(
2293
        tinyxml2::XMLElement* elem,
2294
        PresentationQosPolicy& presentation,
2295
        uint8_t ident)
2296
   {
2297
2298
    //    <xs:complexType name="presentationQosPolicyType">
2299
    //        <xs:all minOccurs="0">
2300
    //            <xs:element name="access_scope" type="presentationQosKindType" minOccurs="0"/>
2301
    //            <xs:element name="coherent_access" type="boolType" minOccurs="0"/>
2302
    //            <xs:element name="ordered_access" type="boolType" minOccurs="0"/>
2303
    //        </xs:all>
2304
    //    </xs:complexType>
2305
2306
2307
    tinyxml2::XMLElement* p_aux0 = nullptr;
2308
    const char* name = nullptr;
2309
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
2310
    {
2311
        name = p_aux0->Name();
2312
        if (strcmp(name, ACCESS_SCOPE) == 0)
2313
        {
2314
            // access_scope
2315
2316
            //    <xs:simpleType name="presentationQosKindType">
2317
            //        <xs:restriction base="xs:string">
2318
            //            <xs:enumeration value="INSTANCE"/>
2319
            //            <xs:enumeration value="TOPIC"/>
2320
            //            <xs:enumeration value="GROUP"/>
2321
            //        </xs:restriction>
2322
            //    </xs:simpleType>
2323
2324
            const char* text = p_aux0->GetText();
2325
            if (nullptr == text)
2326
            {
2327
                logError(XMLPARSER, "Node '" << ACCESS_SCOPE << "' without content");
2328
                return XMLP_ret::XML_ERROR;
2329
            }
2330
            if (strcmp(text, INSTANCE) == 0)
2331
            {
2332
                presentation.access_scope = PresentationQosPolicyAccessScopeKind::INSTANCE_PRESENTATION_QOS;
2333
            }
2334
            else if (strcmp(text, TOPIC) == 0)
2335
            {
2336
                presentation.access_scope = PresentationQosPolicyAccessScopeKind::TOPIC_PRESENTATION_QOS;
2337
            }
2338
            else if (strcmp(text, GROUP) == 0)
2339
            {
2340
                presentation.access_scope = PresentationQosPolicyAccessScopeKind::GROUP_PRESENTATION_QOS;
2341
            }
2342
            else
2343
            {
2344
                logError(XMLPARSER, "Node '" << ACCESS_SCOPE << "' bad content");
2345
                return XMLP_ret::XML_ERROR;
2346
            }
2347
        }
2348
        else if (strcmp(name, COHERENT_ACCESS) == 0)
2349
        {
2350
            // coherent_access - boolType
2351
            if (XMLP_ret::XML_OK != getXMLBool(p_aux0, &presentation.coherent_access, ident))
2352
            {
2353
                return XMLP_ret::XML_ERROR;
2354
            }
2355
        }
2356
        else if (strcmp(name, ORDERED_ACCESS) == 0)
2357
        {
2358
            // ordered_access - boolType
2359
            if (XMLP_ret::XML_OK != getXMLBool(p_aux0, &presentation.ordered_access, ident))
2360
            {
2361
                return XMLP_ret::XML_ERROR;
2362
            }
2363
        }
2364
        else
2365
        {
2366
            logError(XMLPARSER, "Invalid element found into 'presentationQosPolicyType'. Name: " << name);
2367
            return XMLP_ret::XML_ERROR;
2368
        }
2369
    }
2370
    return XMLP_ret::XML_OK;
2371
   }
2372
 */
2373
2374
XMLP_ret XMLParser::getXMLPartitionQos(
2375
        tinyxml2::XMLElement* elem,
2376
        PartitionQosPolicy& partition,
2377
        uint8_t ident)
2378
625
{
2379
    /*
2380
        <xs:complexType name="partitionQosPolicyType">
2381
            <xs:all>
2382
                <xs:element name="names" type="nameVectorType"/>
2383
            </xs:all>
2384
        </xs:complexType>
2385
     */
2386
2387
625
    tinyxml2::XMLElement* p_aux0 = nullptr, * p_aux1 = nullptr;
2388
625
    bool bNamesDefined = false;
2389
625
    const char* name = nullptr;
2390
625
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
2391
0
    {
2392
0
        name = p_aux0->Name();
2393
0
        if (strcmp(name, NAMES) == 0)
2394
0
        {
2395
0
            bNamesDefined = true;
2396
0
            p_aux1 = p_aux0->FirstChildElement(NAME);
2397
0
            if (nullptr == p_aux1)
2398
0
            {
2399
                // Not even one
2400
0
                logError(XMLPARSER, "Node '" << NAMES << "' without content");
2401
0
                return XMLP_ret::XML_ERROR;
2402
0
            }
2403
2404
0
            std::vector<std::string> names;
2405
0
            while (nullptr != p_aux1)
2406
0
            {
2407
0
                std::string sName = "";
2408
0
                if (XMLP_ret::XML_OK != getXMLString(p_aux1, &sName, ident))
2409
0
                {
2410
0
                    return XMLP_ret::XML_ERROR;
2411
0
                }
2412
0
                names.push_back(sName);
2413
0
                p_aux1 = p_aux1->NextSiblingElement(NAME);
2414
0
            }
2415
0
            partition.names(names);
2416
0
        }
2417
0
        else
2418
0
        {
2419
0
            logError(XMLPARSER, "Invalid element found into 'partitionQosPolicyType'. Name: " << name);
2420
0
            return XMLP_ret::XML_ERROR;
2421
0
        }
2422
0
    }
2423
2424
625
    if (!bNamesDefined)
2425
625
    {
2426
625
        logError(XMLPARSER, "Node 'partitionQosPolicyType' without content");
2427
625
        return XMLP_ret::XML_ERROR;
2428
625
    }
2429
2430
0
    return XMLP_ret::XML_OK;
2431
625
}
2432
2433
XMLP_ret XMLParser::getXMLPublishModeQos(
2434
        tinyxml2::XMLElement* elem,
2435
        PublishModeQosPolicy& publishMode,
2436
        uint8_t /*ident*/)
2437
263
{
2438
    /*
2439
        <xs:complexType name="publishModeQosPolicyType">
2440
            <xs:all>
2441
                <xs:element name="kind" type="publishModeQosKindType"/>
2442
            </xs:all>
2443
        </xs:complexType>
2444
     */
2445
263
    tinyxml2::XMLElement* p_aux0 = nullptr;
2446
263
    bool bKindDefined = false;
2447
263
    const char* name = nullptr;
2448
263
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
2449
0
    {
2450
0
        name = p_aux0->Name();
2451
0
        if (strcmp(name, KIND) == 0)
2452
0
        {
2453
            /*
2454
                <xs:simpleType name="publishModeQosKindType">
2455
                    <xs:restriction base="xs:string">
2456
                        <xs:enumeration value="SYNCHRONOUS"/>
2457
                        <xs:enumeration value="ASYNCHRONOUS"/>
2458
                    </xs:restriction>
2459
                </xs:simpleType>
2460
             */
2461
0
            bKindDefined = true;
2462
0
            const char* text = p_aux0->GetText();
2463
0
            if (nullptr == text)
2464
0
            {
2465
0
                logError(XMLPARSER, "Node '" << KIND << "' without content");
2466
0
                return XMLP_ret::XML_ERROR;
2467
0
            }
2468
0
            if (strcmp(text, SYNCHRONOUS) == 0)
2469
0
            {
2470
0
                publishMode.kind = PublishModeQosPolicyKind::SYNCHRONOUS_PUBLISH_MODE;
2471
0
            }
2472
0
            else if (strcmp(text, ASYNCHRONOUS) == 0)
2473
0
            {
2474
0
                publishMode.kind = PublishModeQosPolicyKind::ASYNCHRONOUS_PUBLISH_MODE;
2475
0
            }
2476
0
            else
2477
0
            {
2478
0
                logError(XMLPARSER, "Node '" << KIND << "' bad content");
2479
0
                return XMLP_ret::XML_ERROR;
2480
0
            }
2481
0
        }
2482
0
        else
2483
0
        {
2484
0
            logError(XMLPARSER, "Invalid element found into 'publishModeQosPolicyType'. Name: " << name);
2485
0
            return XMLP_ret::XML_ERROR;
2486
0
        }
2487
0
    }
2488
2489
263
    if (!bKindDefined)
2490
263
    {
2491
263
        logError(XMLPARSER, "Node 'publishModeQosPolicyType' without content");
2492
263
        return XMLP_ret::XML_ERROR;
2493
263
    }
2494
2495
0
    return XMLP_ret::XML_OK;
2496
263
}
2497
2498
XMLP_ret XMLParser::getXMLDuration(
2499
        tinyxml2::XMLElement* elem,
2500
        Duration_t& duration,
2501
        uint8_t ident)
2502
10.4k
{
2503
    /*
2504
       <xs:complexType name="durationType" mixed="true">
2505
       <xs:sequence>
2506
        <xs:choice minOccurs="0">
2507
         <xs:sequence>
2508
          <xs:element name="sec" type="nonNegativeInteger_Duration_SEC" default="0" minOccurs="1" maxOccurs="1"/>
2509
          <xs:element name="nanosec" type="nonNegativeInteger_Duration_NSEC" default="0" minOccurs="0" maxOccurs="1"/>
2510
         </xs:sequence>
2511
         <xs:sequence>
2512
          <xs:element name="nanosec" type="nonNegativeInteger_Duration_NSEC" default="0" minOccurs="1" maxOccurs="1"/>
2513
          <xs:element name="sec" type="nonNegativeInteger_Duration_SEC" default="0" minOccurs="0" maxOccurs="1"/>
2514
        </xs:sequence>
2515
       </xs:choice>
2516
       </xs:sequence>
2517
       </xs:complexType>
2518
     */
2519
2520
    // set default values
2521
10.4k
    duration.seconds = 0;
2522
10.4k
    duration.nanosec = 0;
2523
2524
    // it's mandatory to provide a sec or nanocsec child item
2525
10.4k
    bool empty = true;
2526
2527
    // First we check if it matches the schema pattern
2528
10.4k
    std::regex infinite(DURATION_INFINITY);
2529
10.4k
    std::regex infinite_sec(DURATION_INFINITE_SEC);
2530
10.4k
    std::regex infinite_nsec(DURATION_INFINITE_NSEC);
2531
10.4k
    const char* text = elem->GetText();
2532
2533
10.4k
    if (text != nullptr && std::regex_match(text, infinite))
2534
458
    {
2535
458
        empty = false;
2536
458
        duration = c_TimeInfinite;
2537
2538
458
        if (elem->FirstChildElement() != nullptr)
2539
67
        {
2540
67
            logError(XMLPARSER, "If a Duration_t type element is defined as DURATION_INFINITY it cannot have <sec> or"
2541
67
                    " <nanosec> subelements.");
2542
67
            return XMLP_ret::XML_ERROR;
2543
67
        }
2544
458
    }
2545
2546
10.3k
    tinyxml2::XMLElement* p_aux0 = nullptr;
2547
10.3k
    const char* name = nullptr;
2548
15.5k
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
2549
6.10k
    {
2550
        // there is at least a child element
2551
6.10k
        empty = false;
2552
2553
6.10k
        name = p_aux0->Name();
2554
6.10k
        if (strcmp(name, SECONDS) == 0)
2555
5.75k
        {
2556
            /*
2557
               <xs:simpleType name="nonNegativeInteger_Duration_SEC">
2558
                    <xs:union>
2559
                        <xs:simpleType>
2560
                            <xs:restriction base="xs:string">
2561
                                <xs:pattern value="\s*(DURATION_INFINITY|DURATION_INFINITE_SEC)\s*"/>
2562
                            </xs:restriction>
2563
                        </xs:simpleType>
2564
                        <xs:simpleType>
2565
                            <xs:restriction base="xs:unsignedInt"/>
2566
                        </xs:simpleType>
2567
                    </xs:union>
2568
                </xs:simpleType>
2569
             */
2570
5.75k
            text = p_aux0->GetText();
2571
5.75k
            if (nullptr == text)
2572
36
            {
2573
36
                logError(XMLPARSER, "Node 'SECONDS' without content");
2574
36
                return XMLP_ret::XML_ERROR;
2575
36
            }
2576
5.72k
            else if (std::regex_match(text, infinite_sec))
2577
136
            {
2578
                // if either SECONDS or NANOSECONDS is set to infinity then all of it is
2579
136
                duration = c_TimeInfinite;
2580
136
                return XMLP_ret::XML_OK;
2581
136
            }
2582
5.58k
            else if (XMLP_ret::XML_OK != getXMLInt(p_aux0, &duration.seconds, ident))
2583
369
            {
2584
369
                logError(XMLPARSER, "<" << elem->Value() << "> getXMLInt XML_ERROR!");
2585
369
                return XMLP_ret::XML_ERROR;
2586
369
            }
2587
5.75k
        }
2588
352
        else if (strcmp(name, NANOSECONDS) == 0)
2589
142
        {
2590
            /*
2591
                <xs:simpleType name="nonNegativeInteger_Duration_NSEC">
2592
                    <xs:union>
2593
                        <xs:simpleType>
2594
                            <xs:restriction base="xs:string">
2595
                                <xs:pattern value="\s*(DURATION_INFINITY|DURATION_INFINITE_NSEC)\s*"/>
2596
                            </xs:restriction>
2597
                        </xs:simpleType>
2598
                        <xs:simpleType>
2599
                            <xs:restriction base="xs:unsignedInt"/>
2600
                        </xs:simpleType>
2601
                    </xs:union>
2602
                </xs:simpleType>
2603
             */
2604
142
            text = p_aux0->GetText();
2605
142
            if (nullptr == text)
2606
142
            {
2607
142
                logError(XMLPARSER, "Node 'NANOSECONDS' without content");
2608
142
                return XMLP_ret::XML_ERROR;
2609
142
            }
2610
0
            else if (std::regex_match(text, infinite_nsec))
2611
0
            {
2612
                // if either SECONDS or NANOSECONDS is set to infinity then all of it is
2613
0
                duration = c_TimeInfinite;
2614
0
                return XMLP_ret::XML_OK;
2615
0
            }
2616
0
            else if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &duration.nanosec, ident))
2617
0
            {
2618
0
                logError(XMLPARSER, "<" << elem->Value() << "> getXMLInt XML_ERROR!");
2619
0
                return XMLP_ret::XML_ERROR;
2620
0
            }
2621
142
        }
2622
210
        else
2623
210
        {
2624
210
            logError(XMLPARSER, "Invalid element found into 'durationType'. Name: " << name);
2625
210
            return XMLP_ret::XML_ERROR;
2626
210
        }
2627
6.10k
    }
2628
2629
    // An empty Duration_t xml is forbidden
2630
9.44k
    if (empty)
2631
4.86k
    {
2632
4.86k
        logError(XMLPARSER, "'durationType' elements cannot be empty."
2633
4.86k
                "At least second or nanoseconds should be provided");
2634
4.86k
        return XMLP_ret::XML_ERROR;
2635
4.86k
    }
2636
2637
4.58k
    return XMLP_ret::XML_OK;
2638
9.44k
}
2639
2640
XMLP_ret XMLParser::getXMLWriterTimes(
2641
        tinyxml2::XMLElement* elem,
2642
        WriterTimes& times,
2643
        uint8_t ident)
2644
3.79k
{
2645
    /*
2646
        <xs:complexType name="writerTimesType">
2647
            <xs:all minOccurs="0">
2648
                <xs:element name="initialHeartbeatDelay" type="durationType" minOccurs="0"/>
2649
                <xs:element name="heartbeatPeriod" type="durationType" minOccurs="0"/>
2650
                <xs:element name="nackResponseDelay" type="durationType" minOccurs="0"/>
2651
                <xs:element name="nackSupressionDuration" type="durationType" minOccurs="0"/>
2652
            </xs:all>
2653
        </xs:complexType>
2654
     */
2655
3.79k
    tinyxml2::XMLElement* p_aux0 = nullptr;
2656
3.79k
    const char* name = nullptr;
2657
3.79k
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
2658
3.34k
    {
2659
3.34k
        name = p_aux0->Name();
2660
3.34k
        if (strcmp(name, INIT_HEARTB_DELAY) == 0)
2661
238
        {
2662
            // initialHeartbeatDelay
2663
238
            if (XMLP_ret::XML_OK != getXMLDuration(p_aux0, times.initialHeartbeatDelay, ident))
2664
238
            {
2665
238
                return XMLP_ret::XML_ERROR;
2666
238
            }
2667
238
        }
2668
3.10k
        else if (strcmp(name, HEARTB_PERIOD) == 0)
2669
1.09k
        {
2670
            // heartbeatPeriod
2671
1.09k
            if (XMLP_ret::XML_OK != getXMLDuration(p_aux0, times.heartbeatPeriod, ident))
2672
1.09k
            {
2673
1.09k
                return XMLP_ret::XML_ERROR;
2674
1.09k
            }
2675
1.09k
        }
2676
2.00k
        else if (strcmp(name, NACK_RESP_DELAY) == 0)
2677
233
        {
2678
            // nackResponseDelay
2679
233
            if (XMLP_ret::XML_OK != getXMLDuration(p_aux0, times.nackResponseDelay, ident))
2680
233
            {
2681
233
                return XMLP_ret::XML_ERROR;
2682
233
            }
2683
233
        }
2684
1.77k
        else if (strcmp(name, NACK_SUPRESSION) == 0)
2685
512
        {
2686
            // nackSupressionDuration
2687
512
            if (XMLP_ret::XML_OK != getXMLDuration(p_aux0, times.nackSupressionDuration, ident))
2688
512
            {
2689
512
                return XMLP_ret::XML_ERROR;
2690
512
            }
2691
512
        }
2692
1.26k
        else
2693
1.26k
        {
2694
1.26k
            logError(XMLPARSER, "Invalid element found into 'writerTimesType'. Name: " << name);
2695
1.26k
            return XMLP_ret::XML_ERROR;
2696
1.26k
        }
2697
3.34k
    }
2698
2699
453
    return XMLP_ret::XML_OK;
2700
3.79k
}
2701
2702
XMLP_ret XMLParser::getXMLReaderTimes(
2703
        tinyxml2::XMLElement* elem,
2704
        ReaderTimes& times,
2705
        uint8_t ident)
2706
413
{
2707
    /*
2708
        <xs:complexType name="readerTimesType">
2709
            <xs:all minOccurs="0">
2710
                <xs:element name="initialAcknackDelay" type="durationType" minOccurs="0"/>
2711
                <xs:element name="heartbeatResponseDelay" type="durationType" minOccurs="0"/>
2712
            </xs:all>
2713
        </xs:complexType>
2714
     */
2715
2716
413
    tinyxml2::XMLElement* p_aux0 = nullptr;
2717
413
    const char* name = nullptr;
2718
413
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
2719
345
    {
2720
345
        name = p_aux0->Name();
2721
345
        if (strcmp(name, INIT_ACKNACK_DELAY) == 0)
2722
0
        {
2723
            // initialAcknackDelay
2724
0
            if (XMLP_ret::XML_OK != getXMLDuration(p_aux0, times.initialAcknackDelay, ident))
2725
0
            {
2726
0
                return XMLP_ret::XML_ERROR;
2727
0
            }
2728
0
        }
2729
345
        else if (strcmp(name, HEARTB_RESP_DELAY) == 0)
2730
0
        {
2731
            // heartbeatResponseDelay
2732
0
            if (XMLP_ret::XML_OK != getXMLDuration(p_aux0, times.heartbeatResponseDelay, ident))
2733
0
            {
2734
0
                return XMLP_ret::XML_ERROR;
2735
0
            }
2736
0
        }
2737
345
        else
2738
345
        {
2739
345
            logError(XMLPARSER, "Invalid element found into 'readerTimesType'. Name: " << name);
2740
345
            return XMLP_ret::XML_ERROR;
2741
345
        }
2742
345
    }
2743
2744
68
    return XMLP_ret::XML_OK;
2745
413
}
2746
2747
XMLP_ret XMLParser::getXMLLocatorUDPv4(
2748
        tinyxml2::XMLElement* elem,
2749
        rtps::Locator_t& locator,
2750
        uint8_t ident)
2751
0
{
2752
    /*
2753
        <xs:complexType name="udpv4LocatorType">
2754
            <xs:all minOccurs="0">
2755
                <xs:element name="port" type="uint32Type" minOccurs="0"/>
2756
                <xs:element name="address" type="stringType" minOccurs="0"/>
2757
            </xs:all>
2758
        </xs:complexType>
2759
     */
2760
2761
0
    locator.kind = LOCATOR_KIND_UDPv4;
2762
0
    tinyxml2::XMLElement* p_aux0 = nullptr;
2763
0
    const char* name = nullptr;
2764
0
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
2765
0
    {
2766
0
        name = p_aux0->Name();
2767
0
        if (strcmp(name, PORT) == 0)
2768
0
        {
2769
            // port - uint32Type
2770
0
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &locator.port, ident + 1))
2771
0
            {
2772
0
                return XMLP_ret::XML_ERROR;
2773
0
            }
2774
0
        }
2775
0
        else if (strcmp(name, ADDRESS) == 0)
2776
0
        {
2777
            // address - stringType
2778
0
            std::string s = "";
2779
0
            if (XMLP_ret::XML_OK != getXMLString(p_aux0, &s, ident + 1))
2780
0
            {
2781
0
                return XMLP_ret::XML_ERROR;
2782
0
            }
2783
            // Check whether the address is IPv4
2784
0
            if (!IPLocator::isIPv4(s))
2785
0
            {
2786
0
                auto response = rtps::IPLocator::resolveNameDNS(s);
2787
2788
                // Add the first valid IPv4 address that we can find
2789
0
                if (response.first.size() > 0)
2790
0
                {
2791
0
                    s = response.first.begin()->data();
2792
0
                }
2793
0
                else
2794
0
                {
2795
0
                    logError(XMLPARSER,
2796
0
                            "DNS server did not return any IPv4 address for: '" << s << "'. Name: " << name);
2797
0
                    return XMLP_ret::XML_ERROR;
2798
0
                }
2799
0
            }
2800
0
            IPLocator::setIPv4(locator, s);
2801
0
        }
2802
0
        else
2803
0
        {
2804
0
            logError(XMLPARSER, "Invalid element found into 'udpv4LocatorType'. Name: " << name);
2805
0
            return XMLP_ret::XML_ERROR;
2806
0
        }
2807
0
    }
2808
0
    return XMLP_ret::XML_OK;
2809
0
}
2810
2811
XMLP_ret XMLParser::getXMLLocatorUDPv6(
2812
        tinyxml2::XMLElement* elem,
2813
        rtps::Locator_t& locator,
2814
        uint8_t ident)
2815
0
{
2816
    /*
2817
        <xs:complexType name="udpv6LocatorType">
2818
            <xs:all minOccurs="0">
2819
                <xs:element name="port" type="uint32Type" minOccurs="0"/>
2820
                <xs:element name="address" type="stringType" minOccurs="0"/>
2821
            </xs:all>
2822
        </xs:complexType>
2823
     */
2824
2825
0
    locator.kind = LOCATOR_KIND_UDPv6;
2826
0
    tinyxml2::XMLElement* p_aux0 = nullptr;
2827
0
    const char* name = nullptr;
2828
0
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
2829
0
    {
2830
0
        name = p_aux0->Name();
2831
0
        if (strcmp(name, PORT) == 0)
2832
0
        {
2833
            // port - uint32Type
2834
0
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &locator.port, ident + 1))
2835
0
            {
2836
0
                return XMLP_ret::XML_ERROR;
2837
0
            }
2838
0
        }
2839
0
        else if (strcmp(name, ADDRESS) == 0)
2840
0
        {
2841
            // address - stringType
2842
0
            std::string s = "";
2843
0
            if (XMLP_ret::XML_OK != getXMLString(p_aux0, &s, ident + 1))
2844
0
            {
2845
0
                return XMLP_ret::XML_ERROR;
2846
0
            }
2847
            // Check whether the address is IPv6
2848
0
            if (!IPLocator::isIPv6(s))
2849
0
            {
2850
0
                auto response = rtps::IPLocator::resolveNameDNS(s);
2851
2852
                // Add the first valid IPv6 address that we can find
2853
0
                if (response.second.size() > 0)
2854
0
                {
2855
0
                    s = response.second.begin()->data();
2856
0
                }
2857
0
                else
2858
0
                {
2859
0
                    logError(XMLPARSER,
2860
0
                            "DNS server did not return any IPv6 address for: '" << s << "'. Name: " << name);
2861
0
                    return XMLP_ret::XML_ERROR;
2862
0
                }
2863
0
            }
2864
0
            IPLocator::setIPv6(locator, s);
2865
0
        }
2866
0
        else
2867
0
        {
2868
0
            logError(XMLPARSER, "Invalid element found into 'udpv6LocatorType'. Name: " << name);
2869
0
            return XMLP_ret::XML_ERROR;
2870
0
        }
2871
0
    }
2872
0
    return XMLP_ret::XML_OK;
2873
0
}
2874
2875
XMLP_ret XMLParser::getXMLLocatorTCPv4(
2876
        tinyxml2::XMLElement* elem,
2877
        rtps::Locator_t& locator,
2878
        uint8_t ident)
2879
0
{
2880
    /*
2881
        <xs:complexType name="tcpv4LocatorType">
2882
            <xs:all minOccurs="0">
2883
                <xs:element name="port" type="uint16Type" minOccurs="0"/>
2884
                <xs:element name="physical_port" type="uint16Type" minOccurs="0"/>
2885
                <xs:element name="address" type="stringType" minOccurs="0"/>
2886
                <xs:element name="wan_address" type="stringType" minOccurs="0"/>
2887
                <xs:element name="unique_lan_id" type="stringType" minOccurs="0"/>
2888
            </xs:all>
2889
        </xs:complexType>
2890
     */
2891
2892
0
    locator.kind = LOCATOR_KIND_TCPv4;
2893
0
    tinyxml2::XMLElement* p_aux0 = nullptr;
2894
0
    const char* name = nullptr;
2895
0
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
2896
0
    {
2897
0
        name = p_aux0->Name();
2898
0
        if (strcmp(name, PORT) == 0)
2899
0
        {
2900
            // port - uint16Type
2901
0
            uint16_t port(0);
2902
0
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &port, ident + 1))
2903
0
            {
2904
0
                return XMLP_ret::XML_ERROR;
2905
0
            }
2906
0
            IPLocator::setLogicalPort(locator, port);
2907
0
        }
2908
0
        else if (strcmp(name, PHYSICAL_PORT) == 0)
2909
0
        {
2910
            // physical_port - uint16Type
2911
0
            uint16_t port(0);
2912
0
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &port, ident + 1))
2913
0
            {
2914
0
                return XMLP_ret::XML_ERROR;
2915
0
            }
2916
0
            IPLocator::setPhysicalPort(locator, port);
2917
0
        }
2918
0
        else if (strcmp(name, ADDRESS) == 0)
2919
0
        {
2920
            // address - stringType
2921
0
            std::string s = "";
2922
0
            if (XMLP_ret::XML_OK != getXMLString(p_aux0, &s, ident + 1))
2923
0
            {
2924
0
                return XMLP_ret::XML_ERROR;
2925
0
            }
2926
0
            IPLocator::setIPv4(locator, s);
2927
0
        }
2928
0
        else if (strcmp(name, WAN_ADDRESS) == 0)
2929
0
        {
2930
            // address - stringType
2931
0
            std::string s = "";
2932
0
            if (XMLP_ret::XML_OK != getXMLString(p_aux0, &s, ident + 1))
2933
0
            {
2934
0
                return XMLP_ret::XML_ERROR;
2935
0
            }
2936
0
            IPLocator::setWan(locator, s);
2937
0
        }
2938
0
        else if (strcmp(name, UNIQUE_LAN_ID) == 0)
2939
0
        {
2940
            // address - stringType
2941
0
            std::string s = "";
2942
0
            if (XMLP_ret::XML_OK != getXMLString(p_aux0, &s, ident + 1))
2943
0
            {
2944
0
                return XMLP_ret::XML_ERROR;
2945
0
            }
2946
0
            IPLocator::setLanID(locator, s);
2947
0
        }
2948
0
        else
2949
0
        {
2950
0
            logError(XMLPARSER, "Invalid element found into 'tcpv4LocatorType'. Name: " << name);
2951
0
            return XMLP_ret::XML_ERROR;
2952
0
        }
2953
0
    }
2954
0
    return XMLP_ret::XML_OK;
2955
0
}
2956
2957
XMLP_ret XMLParser::getXMLLocatorTCPv6(
2958
        tinyxml2::XMLElement* elem,
2959
        rtps::Locator_t& locator,
2960
        uint8_t ident)
2961
0
{
2962
    /*
2963
        <xs:complexType name="tcpv6LocatorType">
2964
            <xs:choice>
2965
                <xs:element name="port" type="uint16Type" minOccurs="0"/>
2966
                <xs:element name="physical_port" type="uint16Type" minOccurs="0"/>
2967
                <xs:element name="address" type="stringType" minOccurs="0"/>
2968
            </xs:choice>
2969
        </xs:complexType>
2970
     */
2971
2972
0
    locator.kind = LOCATOR_KIND_TCPv6;
2973
0
    tinyxml2::XMLElement* p_aux0 = nullptr;
2974
0
    const char* name = nullptr;
2975
0
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != NULL; p_aux0 = p_aux0->NextSiblingElement())
2976
0
    {
2977
0
        name = p_aux0->Name();
2978
0
        if (strcmp(name, PORT) == 0)
2979
0
        {
2980
            // port - uint16Type
2981
0
            uint16_t port(0);
2982
0
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &port, ident + 1))
2983
0
            {
2984
0
                return XMLP_ret::XML_ERROR;
2985
0
            }
2986
0
            IPLocator::setLogicalPort(locator, port);
2987
0
        }
2988
0
        else if (strcmp(name, PHYSICAL_PORT) == 0)
2989
0
        {
2990
            // physical_port - uint16Type
2991
0
            uint16_t port(0);
2992
0
            if (XMLP_ret::XML_OK != getXMLUint(p_aux0, &port, ident + 1))
2993
0
            {
2994
0
                return XMLP_ret::XML_ERROR;
2995
0
            }
2996
0
            IPLocator::setPhysicalPort(locator, port);
2997
0
        }
2998
0
        else if (strcmp(name, ADDRESS) == 0)
2999
0
        {
3000
            // address - stringType
3001
0
            std::string s = "";
3002
0
            if (XMLP_ret::XML_OK != getXMLString(p_aux0, &s, ident + 1))
3003
0
            {
3004
0
                return XMLP_ret::XML_ERROR;
3005
0
            }
3006
0
            IPLocator::setIPv6(locator, s);
3007
0
        }
3008
0
        else
3009
0
        {
3010
0
            logError(XMLPARSER, "Invalid element found into 'tcpv6LocatorType'. Name: " << name);
3011
0
            return XMLP_ret::XML_ERROR;
3012
0
        }
3013
0
    }
3014
0
    return XMLP_ret::XML_OK;
3015
0
}
3016
3017
XMLP_ret XMLParser::getXMLLocatorList(
3018
        tinyxml2::XMLElement* elem,
3019
        LocatorList_t& locatorList,
3020
        uint8_t ident)
3021
2.70k
{
3022
    /*
3023
        <xs:complexType name="locatorListType">
3024
            <xs:sequence>
3025
                <xs:element name="locator" type="locatorType" minOccurs="0" maxOccurs="unbounded"/>
3026
            </xs:sequence>
3027
        </xs:complexType>
3028
     */
3029
2.70k
    tinyxml2::XMLElement* p_aux0 = nullptr, * p_aux1 = nullptr;
3030
2.70k
    p_aux0 = elem->FirstChildElement(LOCATOR);
3031
2.70k
    if (nullptr == p_aux0)
3032
2.70k
    {
3033
2.70k
        logError(XMLPARSER, "Node '" << elem->Value() << "' without content");
3034
2.70k
        return XMLP_ret::XML_ERROR;
3035
2.70k
    }
3036
3037
0
    while (nullptr != p_aux0)
3038
0
    {
3039
        /*
3040
            <xs:complexType name="locatorType">
3041
                <xs:choice>
3042
                    <xs:element name="udpv4" type="udpv4LocatorType"/>
3043
                    <xs:element name="udpv6" type="udpv6LocatorType"/>
3044
                    <xs:element name="tcpv4" type="tcpv4LocatorType"/>
3045
                    <xs:element name="tcpv6" type="tcpv6LocatorType"/>
3046
                </xs:choice>
3047
            </xs:complexType>
3048
         */
3049
0
        Locator_t loc;
3050
0
        if (nullptr != (p_aux1 = p_aux0->FirstChildElement(UDPv4_LOCATOR)))
3051
0
        {
3052
0
            if (XMLP_ret::XML_OK != getXMLLocatorUDPv4(p_aux1, loc, ident + 1))
3053
0
            {
3054
0
                return XMLP_ret::XML_ERROR;
3055
0
            }
3056
0
        }
3057
0
        else if (nullptr != (p_aux1 = p_aux0->FirstChildElement(UDPv6_LOCATOR)))
3058
0
        {
3059
0
            if (XMLP_ret::XML_OK != getXMLLocatorUDPv6(p_aux1, loc, ident + 1))
3060
0
            {
3061
0
                return XMLP_ret::XML_ERROR;
3062
0
            }
3063
0
        }
3064
0
        else if (nullptr != (p_aux1 = p_aux0->FirstChildElement(TCPv4_LOCATOR)))
3065
0
        {
3066
0
            if (XMLP_ret::XML_OK != getXMLLocatorTCPv4(p_aux1, loc, ident + 1))
3067
0
            {
3068
0
                return XMLP_ret::XML_ERROR;
3069
0
            }
3070
0
        }
3071
0
        else if (nullptr != (p_aux1 = p_aux0->FirstChildElement(TCPv6_LOCATOR)))
3072
0
        {
3073
0
            if (XMLP_ret::XML_OK != getXMLLocatorTCPv6(p_aux1, loc, ident + 1))
3074
0
            {
3075
0
                return XMLP_ret::XML_ERROR;
3076
0
            }
3077
0
        }
3078
0
        else if (nullptr != (p_aux1 = p_aux0->FirstChildElement()))
3079
0
        {
3080
0
            logError(XMLPARSER, "Invalid element found into 'locatorType'. Name: " << p_aux1->Name());
3081
0
            return XMLP_ret::XML_ERROR;
3082
0
        }
3083
3084
0
        locatorList.push_back(loc);
3085
0
        p_aux0 = p_aux0->NextSiblingElement(LOCATOR);
3086
0
    }
3087
3088
0
    return XMLP_ret::XML_OK;
3089
0
}
3090
3091
XMLP_ret XMLParser::getXMLHistoryMemoryPolicy(
3092
        tinyxml2::XMLElement* elem,
3093
        MemoryManagementPolicy_t& historyMemoryPolicy,
3094
        uint8_t /*ident*/)
3095
2.32k
{
3096
    /*
3097
        <xs:simpleType name="historyMemoryPolicyType">
3098
            <xs:restriction base="xs:string">
3099
                <xs:enumeration value="PREALLOCATED"/>
3100
                <xs:enumeration value="PREALLOCATED_WITH_REALLOC"/>
3101
                <xs:enumeration value="DYNAMIC"/>
3102
                <xs:enumeration value="DYNAMIC_REUSABLE"/>
3103
            </xs:restriction>
3104
        </xs:simpleType>
3105
     */
3106
2.32k
    const char* text = elem->GetText();
3107
2.32k
    if (nullptr == text)
3108
302
    {
3109
302
        logError(XMLPARSER, "Node '" << KIND << "' without content");
3110
302
        return XMLP_ret::XML_ERROR;
3111
302
    }
3112
2.02k
    if (strcmp(text, PREALLOCATED) == 0)
3113
232
    {
3114
232
        historyMemoryPolicy = MemoryManagementPolicy::PREALLOCATED_MEMORY_MODE;
3115
232
    }
3116
1.78k
    else if (strcmp(text, PREALLOCATED_WITH_REALLOC) == 0)
3117
368
    {
3118
368
        historyMemoryPolicy = MemoryManagementPolicy::PREALLOCATED_WITH_REALLOC_MEMORY_MODE;
3119
368
    }
3120
1.42k
    else if (strcmp(text, DYNAMIC) == 0)
3121
99
    {
3122
99
        historyMemoryPolicy = MemoryManagementPolicy::DYNAMIC_RESERVE_MEMORY_MODE;
3123
99
    }
3124
1.32k
    else if (strcmp(text, DYNAMIC_REUSABLE) == 0)
3125
75
    {
3126
75
        historyMemoryPolicy = MemoryManagementPolicy::DYNAMIC_REUSABLE_MEMORY_MODE;
3127
75
    }
3128
1.24k
    else
3129
1.24k
    {
3130
1.24k
        logError(XMLPARSER, "Node '" << KIND << "' bad content");
3131
1.24k
        return XMLP_ret::XML_ERROR;
3132
1.24k
    }
3133
3134
774
    return XMLP_ret::XML_OK;
3135
2.02k
}
3136
3137
XMLP_ret XMLParser::getXMLPropertiesPolicy(
3138
        tinyxml2::XMLElement* elem,
3139
        PropertyPolicy& propertiesPolicy,
3140
        uint8_t ident)
3141
729
{
3142
    /*
3143
        <xs:complexType name="propertyPolicyType">
3144
            <xs:all minOccurs="0">
3145
                <xs:element name="properties" type="propertyVectorType" minOccurs="0"/>
3146
                <xs:element name="binary_properties" type="binaryPropertyVectorType" minOccurs="0"/>
3147
            </xs:all>
3148
        </xs:complexType>
3149
     */
3150
3151
729
    tinyxml2::XMLElement* p_aux0 = nullptr, * p_aux1 = nullptr, * p_aux2 = nullptr;
3152
729
    const char* name = nullptr;
3153
729
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != nullptr; p_aux0 = p_aux0->NextSiblingElement())
3154
0
    {
3155
0
        name = p_aux0->Name();
3156
0
        if (strcmp(name, PROPERTIES) == 0)
3157
0
        {
3158
0
            p_aux1 = p_aux0->FirstChildElement(PROPERTY);
3159
0
            if (nullptr == p_aux1)
3160
0
            {
3161
0
                logError(XMLPARSER, "Node '" << PROPERTIES << "' without content");
3162
0
                return XMLP_ret::XML_ERROR;
3163
0
            }
3164
3165
0
            while (nullptr != p_aux1)
3166
0
            {
3167
                /*
3168
                    <xs:complexType name="propertyType">
3169
                        <xs:all>
3170
                            <xs:element name="name" type="stringType"/>
3171
                            <xs:element name="value" type="stringType"/>
3172
                            <xs:element name="propagate" type="boolType"/>
3173
                        </xs:all>
3174
                    </xs:complexType>
3175
                 */
3176
3177
0
                const char* sub_name = nullptr;
3178
0
                Property prop;
3179
0
                for (p_aux2 = p_aux1->FirstChildElement(); p_aux2 != NULL; p_aux2 = p_aux2->NextSiblingElement())
3180
0
                {
3181
0
                    sub_name = p_aux2->Name();
3182
0
                    if (strcmp(sub_name, NAME) == 0)
3183
0
                    {
3184
                        // name - stringType
3185
0
                        std::string s = "";
3186
0
                        if (XMLP_ret::XML_OK != getXMLString(p_aux2, &s, ident + 2))
3187
0
                        {
3188
0
                            return XMLP_ret::XML_ERROR;
3189
0
                        }
3190
0
                        prop.name(s);
3191
0
                    }
3192
0
                    else if (strcmp(sub_name, VALUE) == 0)
3193
0
                    {
3194
                        // value - stringType
3195
0
                        std::string s = "";
3196
0
                        if (XMLP_ret::XML_OK != getXMLString(p_aux2, &s, ident + 2))
3197
0
                        {
3198
0
                            return XMLP_ret::XML_ERROR;
3199
0
                        }
3200
0
                        prop.value(s);
3201
0
                    }
3202
0
                    else if (strcmp(sub_name, PROPAGATE) == 0)
3203
0
                    {
3204
                        // propagate - boolType
3205
0
                        bool b = false;
3206
0
                        if (XMLP_ret::XML_OK != getXMLBool(p_aux2, &b, ident + 2))
3207
0
                        {
3208
0
                            return XMLP_ret::XML_ERROR;
3209
0
                        }
3210
0
                        prop.propagate(b);
3211
0
                    }
3212
0
                }
3213
0
                propertiesPolicy.properties().push_back(prop);
3214
0
                p_aux1 = p_aux1->NextSiblingElement(PROPERTY);
3215
0
            }
3216
0
        }
3217
0
        else if (strcmp(name, BIN_PROPERTIES) == 0)
3218
0
        {
3219
            // TODO: The value will be std::vector<uint8_t>
3220
0
            p_aux1 = p_aux0->FirstChildElement(PROPERTY);
3221
0
            if (nullptr == p_aux1)
3222
0
            {
3223
0
                logError(XMLPARSER, "Node '" << BIN_PROPERTIES << "' without content");
3224
0
                return XMLP_ret::XML_ERROR;
3225
0
            }
3226
3227
0
            while (nullptr != p_aux1)
3228
0
            {
3229
                /*
3230
                    <xs:complexType name="binaryPropertyType">
3231
                        <xs:all>
3232
                            <xs:element name="name" type="stringType"/>
3233
                            <xs:element name="value" type="stringType"/><!-- std::vector<uint8_t> -->
3234
                            <xs:element name="propagate" type="boolType"/>
3235
                        </xs:all>
3236
                    </xs:complexType>
3237
                 */
3238
0
                const char* sub_name = nullptr;
3239
0
                BinaryProperty bin_prop;
3240
0
                for (p_aux2 = p_aux1->FirstChildElement(); p_aux2 != NULL; p_aux2 = p_aux2->NextSiblingElement())
3241
0
                {
3242
0
                    sub_name = p_aux2->Name();
3243
0
                    if (strcmp(sub_name, NAME) == 0)
3244
0
                    {
3245
                        // name - stringType
3246
0
                        std::string s = "";
3247
0
                        if (XMLP_ret::XML_OK != getXMLString(p_aux2, &s, ident + 2))
3248
0
                        {
3249
0
                            return XMLP_ret::XML_ERROR;
3250
0
                        }
3251
0
                        bin_prop.name(s);
3252
0
                    }
3253
0
                    else if (strcmp(sub_name, VALUE) == 0)
3254
0
                    {
3255
                        // TODO:
3256
                        // value - stringType
3257
0
                        logError(XMLPARSER, "Tag '" << p_aux2->Value() << "' do not supported for now");
3258
                        /*std::string s = "";
3259
                           if (XMLP_ret::XML_OK != getXMLString(p_aux2, &s, ident + 2)) return XMLP_ret::XML_ERROR;
3260
                           bin_prop.value(s);*/
3261
0
                    }
3262
0
                    else if (strcmp(sub_name, PROPAGATE) == 0)
3263
0
                    {
3264
                        // propagate - boolType
3265
0
                        bool b = false;
3266
0
                        if (XMLP_ret::XML_OK != getXMLBool(p_aux2, &b, ident + 2))
3267
0
                        {
3268
0
                            return XMLP_ret::XML_ERROR;
3269
0
                        }
3270
0
                        bin_prop.propagate(b);
3271
0
                    }
3272
0
                }
3273
0
                propertiesPolicy.binary_properties().push_back(bin_prop);
3274
0
                p_aux1 = p_aux1->NextSiblingElement(PROPERTY);
3275
0
            }
3276
0
        }
3277
0
        else
3278
0
        {
3279
0
            logError(XMLPARSER, "Invalid element found into 'propertyPolicyType'. Name: " << name);
3280
0
            return XMLP_ret::XML_ERROR;
3281
0
        }
3282
0
    }
3283
729
    return XMLP_ret::XML_OK;
3284
729
}
3285
3286
XMLP_ret XMLParser::getXMLOctetVector(
3287
        tinyxml2::XMLElement* elem,
3288
        std::vector<octet>& octet_vector,
3289
        uint8_t /*ident*/)
3290
2.25k
{
3291
2.25k
    if (nullptr == elem)
3292
0
    {
3293
0
        logError(XMLPARSER, "preconditions error");
3294
0
        return XMLP_ret::XML_ERROR;
3295
0
    }
3296
3297
2.25k
    tinyxml2::XMLElement* p_aux0 = nullptr;
3298
2.25k
    XMLP_ret ret_value = XMLP_ret::XML_OK;
3299
2.25k
    size_t num_elems = 0;
3300
3301
2.25k
    for (p_aux0 = elem->FirstChildElement(); nullptr != p_aux0; p_aux0 = p_aux0->NextSiblingElement())
3302
0
    {
3303
0
        if (1 < ++num_elems)
3304
0
        {
3305
0
            logError(XMLPARSER, "More than one tag on " << p_aux0->GetLineNum());
3306
0
            ret_value = XMLP_ret::XML_ERROR;
3307
0
        }
3308
0
        if (0 == strcmp(p_aux0->Name(), VALUE))
3309
0
        {
3310
0
            std::string text = p_aux0->GetText();
3311
0
            std::istringstream ss(text);
3312
3313
0
            ss >> std::hex;
3314
3315
0
            while (!ss.eof())
3316
0
            {
3317
0
                uint16_t o = 0;
3318
0
                ss >> o;
3319
3320
0
                if (!ss || std::numeric_limits<octet>::max() < o)
3321
0
                {
3322
0
                    logError(XMLPARSER, "Expected an octet value on line " << p_aux0->GetLineNum());
3323
0
                    ret_value = XMLP_ret::XML_ERROR;
3324
0
                    break;
3325
0
                }
3326
3327
                // Add octet in vector.
3328
0
                octet_vector.push_back(static_cast<octet>(o));
3329
3330
0
                if (!ss.eof())
3331
0
                {
3332
0
                    char c = 0;
3333
0
                    ss >> c;
3334
3335
0
                    if (!ss || '.' != c)
3336
0
                    {
3337
0
                        logError(XMLPARSER, "Expected a '.' separator on line " << p_aux0->GetLineNum());
3338
0
                        ret_value = XMLP_ret::XML_ERROR;
3339
0
                        break;
3340
0
                    }
3341
0
                }
3342
0
            }
3343
0
        }
3344
0
        else
3345
0
        {
3346
0
            logError(XMLPARSER, "Invalid tag with name of " << p_aux0->Name() << " on line " << p_aux0->GetLineNum());
3347
0
            ret_value = XMLP_ret::XML_ERROR;
3348
0
        }
3349
0
    }
3350
3351
2.25k
    return ret_value;
3352
2.25k
}
3353
3354
XMLP_ret XMLParser::getXMLInt(
3355
        tinyxml2::XMLElement* elem,
3356
        int* in,
3357
        uint8_t /*ident*/)
3358
7.87k
{
3359
7.87k
    if (nullptr == elem || nullptr == in)
3360
0
    {
3361
0
        logError(XMLPARSER, "nullptr when getXMLUint XML_ERROR!");
3362
0
        return XMLP_ret::XML_ERROR;
3363
0
    }
3364
7.87k
    else if (tinyxml2::XMLError::XML_SUCCESS != elem->QueryIntText(in))
3365
1.83k
    {
3366
1.83k
        logError(XMLPARSER, "<" << elem->Value() << "> getXMLInt XML_ERROR!");
3367
1.83k
        return XMLP_ret::XML_ERROR;
3368
1.83k
    }
3369
6.04k
    return XMLP_ret::XML_OK;
3370
7.87k
}
3371
3372
XMLP_ret XMLParser::getXMLUint(
3373
        tinyxml2::XMLElement* elem,
3374
        unsigned int* ui,
3375
        uint8_t /*ident*/)
3376
1.42k
{
3377
1.42k
    if (nullptr == elem || nullptr == ui)
3378
0
    {
3379
0
        logError(XMLPARSER, "nullptr when getXMLUint XML_ERROR!");
3380
0
        return XMLP_ret::XML_ERROR;
3381
0
    }
3382
1.42k
    else if (tinyxml2::XMLError::XML_SUCCESS != elem->QueryUnsignedText(ui))
3383
1.20k
    {
3384
1.20k
        logError(XMLPARSER, "<" << elem->Value() << "> getXMLUint XML_ERROR!");
3385
1.20k
        return XMLP_ret::XML_ERROR;
3386
1.20k
    }
3387
224
    return XMLP_ret::XML_OK;
3388
1.42k
}
3389
3390
XMLP_ret XMLParser::getXMLUint(
3391
        tinyxml2::XMLElement* elem,
3392
        uint16_t* ui16,
3393
        uint8_t /*ident*/)
3394
0
{
3395
0
    unsigned int ui = 0u;
3396
0
    if (nullptr == elem || nullptr == ui16)
3397
0
    {
3398
0
        logError(XMLPARSER, "nullptr when getXMLUint XML_ERROR!");
3399
0
        return XMLP_ret::XML_ERROR;
3400
0
    }
3401
0
    else if (tinyxml2::XMLError::XML_SUCCESS != elem->QueryUnsignedText(&ui) ||
3402
0
            ui >= 65536)
3403
0
    {
3404
0
        logError(XMLPARSER, "<" << elem->Value() << "> getXMLUint XML_ERROR!");
3405
0
        return XMLP_ret::XML_ERROR;
3406
0
    }
3407
0
    *ui16 = static_cast<uint16_t>(ui);
3408
0
    return XMLP_ret::XML_OK;
3409
0
}
3410
3411
XMLP_ret XMLParser::getXMLBool(
3412
        tinyxml2::XMLElement* elem,
3413
        bool* b,
3414
        uint8_t /*ident*/)
3415
1.22k
{
3416
1.22k
    if (nullptr == elem || nullptr == b)
3417
0
    {
3418
0
        logError(XMLPARSER, "nullptr when getXMLUint XML_ERROR!");
3419
0
        return XMLP_ret::XML_ERROR;
3420
0
    }
3421
1.22k
    else if (tinyxml2::XMLError::XML_SUCCESS != elem->QueryBoolText(b))
3422
1.22k
    {
3423
1.22k
        logError(XMLPARSER, "<" << elem->Value() << "> getXMLBool XML_ERROR!");
3424
1.22k
        return XMLP_ret::XML_ERROR;
3425
1.22k
    }
3426
0
    return XMLP_ret::XML_OK;
3427
1.22k
}
3428
3429
XMLP_ret XMLParser::getXMLEnum(
3430
        tinyxml2::XMLElement* elem,
3431
        IntraprocessDeliveryType* e,
3432
        uint8_t /*ident*/)
3433
0
{
3434
    //<xs:simpleType name="IntraprocessDeliveryType">
3435
    //    <xs:restriction base="xs:string">
3436
    //        <xs:enumeration value="OFF"/>
3437
    //        <xs:enumeration value="USER_DATA_ONLY"/>
3438
    //        <xs:enumeration value="FULL"/>
3439
    //    </xs:restriction>
3440
    //</xs:simpleType>
3441
3442
0
    const char* text = nullptr;
3443
3444
0
    if (nullptr == elem || nullptr == e)
3445
0
    {
3446
0
        logError(XMLPARSER, "nullptr when getXMLEnum XML_ERROR!");
3447
0
        return XMLP_ret::XML_ERROR;
3448
0
    }
3449
0
    else if (nullptr == (text = elem->GetText()))
3450
0
    {
3451
0
        logError(XMLPARSER, "<" << elem->Value() << "> getXMLEnum XML_ERROR!");
3452
0
        return XMLP_ret::XML_ERROR;
3453
0
    }
3454
0
    else if (strcmp(text, OFF) == 0)
3455
0
    {
3456
0
        *e = IntraprocessDeliveryType::INTRAPROCESS_OFF;
3457
0
    }
3458
0
    else if (strcmp(text, USER_DATA_ONLY) == 0)
3459
0
    {
3460
0
        *e = IntraprocessDeliveryType::INTRAPROCESS_USER_DATA_ONLY;
3461
0
    }
3462
0
    else if (strcmp(text, FULL) == 0)
3463
0
    {
3464
0
        *e = IntraprocessDeliveryType::INTRAPROCESS_FULL;
3465
0
    }
3466
0
    else
3467
0
    {
3468
0
        logError(XMLPARSER, "Node '" << INTRAPROCESS_DELIVERY << "' with bad content");
3469
0
        return XMLP_ret::XML_ERROR;
3470
0
    }
3471
3472
0
    return XMLP_ret::XML_OK;
3473
0
}
3474
3475
XMLP_ret XMLParser::getXMLEnum(
3476
        tinyxml2::XMLElement* elem,
3477
        DiscoveryProtocol_t* e,
3478
        uint8_t /*ident*/)
3479
533
{
3480
    /*
3481
        <xs:simpleType name="DiscoveryProtocol">
3482
            <xs:restriction base="xs:string">
3483
                <xs:enumeration value="NONE"/>
3484
                <xs:enumeration value="SIMPLE"/>
3485
                <xs:enumeration value="CLIENT"/>
3486
                <xs:enumeration value="SERVER"/>
3487
                <xs:enumeration value="BACKUP"/>
3488
                <xs:enumeration value="SUPER_CLIENT"/>
3489
            </xs:restriction>
3490
        </xs:simpleType>
3491
     */
3492
3493
533
    const char* text = nullptr;
3494
3495
533
    if (nullptr == elem || nullptr == e)
3496
0
    {
3497
0
        logError(XMLPARSER, "nullptr when getXMLEnum XML_ERROR!");
3498
0
        return XMLP_ret::XML_ERROR;
3499
0
    }
3500
533
    else if (nullptr == (text = elem->GetText()))
3501
533
    {
3502
533
        logError(XMLPARSER, "<" << elem->Value() << "> getXMLEnum XML_ERROR!");
3503
533
        return XMLP_ret::XML_ERROR;
3504
533
    }
3505
0
    else if (strcmp(text, NONE) == 0)
3506
0
    {
3507
0
        *e = DiscoveryProtocol_t::NONE;
3508
0
    }
3509
0
    else if (strcmp(text, SIMPLE) == 0)
3510
0
    {
3511
0
        *e = DiscoveryProtocol_t::SIMPLE;
3512
0
    }
3513
0
    else if (strcmp(text, CLIENT) == 0)
3514
0
    {
3515
0
        *e = DiscoveryProtocol_t::CLIENT;
3516
0
    }
3517
0
    else if (strcmp(text, SERVER) == 0)
3518
0
    {
3519
0
        *e = DiscoveryProtocol_t::SERVER;
3520
0
    }
3521
0
    else if (strcmp(text, BACKUP) == 0)
3522
0
    {
3523
0
        *e = DiscoveryProtocol_t::BACKUP;
3524
0
    }
3525
0
    else if (strcmp(text, SUPER_CLIENT) == 0)
3526
0
    {
3527
0
        *e = DiscoveryProtocol_t::SUPER_CLIENT;
3528
0
    }
3529
0
    else
3530
0
    {
3531
0
        logError(XMLPARSER, "Node '" << RTPS_PDP_TYPE << "' with bad content");
3532
0
        return XMLP_ret::XML_ERROR;
3533
0
    }
3534
3535
0
    return XMLP_ret::XML_OK;
3536
533
}
3537
3538
XMLP_ret XMLParser::getXMLEnum(
3539
        tinyxml2::XMLElement* elem,
3540
        ParticipantFilteringFlags_t* e,
3541
        uint8_t /*ident*/)
3542
127
{
3543
    /*
3544
        <xs:simpleType name="ParticipantFlags">
3545
            <xs:restriction base="xs:string">
3546
                <xs:pattern value="((FILTER_DIFFERENT_HOST|FILTER_DIFFERENT_PROCESS|FILTER_SAME_PROCESS)(\||\s)*)*" />
3547
            </xs:restriction>
3548
        </xs:simpleType>
3549
     */
3550
3551
127
    const char* text = nullptr;
3552
3553
127
    if (nullptr == elem || nullptr == e)
3554
0
    {
3555
0
        logError(XMLPARSER, "nullptr when getXMLEnum XML_ERROR!");
3556
0
        return XMLP_ret::XML_ERROR;
3557
0
    }
3558
127
    else if (nullptr == (text = elem->GetText()))
3559
127
    {
3560
127
        logError(XMLPARSER, "<" << elem->Value() << "> getXMLEnum XML_ERROR!");
3561
127
        return XMLP_ret::XML_ERROR;
3562
127
    }
3563
3564
    // First we check if it matches the schema pattern
3565
0
    std::regex schema("((FILTER_DIFFERENT_HOST|FILTER_DIFFERENT_PROCESS|FILTER_SAME_PROCESS|NO_FILTER)*(\\||\\s)*)*");
3566
3567
0
    if (!std::regex_match(text, schema))
3568
0
    {
3569
0
        logError(XMLPARSER, "provided flags doesn't match expected ParticipantFilteringFlags!");
3570
0
        return XMLP_ret::XML_ERROR;
3571
0
    }
3572
3573
    // Lets parse the flags, we assume the flags argument has been already flushed
3574
0
    std::regex flags("FILTER_DIFFERENT_HOST|FILTER_DIFFERENT_PROCESS|FILTER_SAME_PROCESS");
3575
0
    std::cregex_iterator it(text, text + strlen(text), flags);
3576
0
    uint32_t newflags = *e;
3577
3578
0
    while (it != std::cregex_iterator())
3579
0
    {
3580
0
        std::string flag(it++->str());
3581
3582
0
        if (flag == FILTER_DIFFERENT_HOST )
3583
0
        {
3584
0
            newflags |= ParticipantFilteringFlags_t::FILTER_DIFFERENT_HOST;
3585
0
        }
3586
0
        else if (flag == FILTER_DIFFERENT_PROCESS )
3587
0
        {
3588
0
            newflags |= ParticipantFilteringFlags_t::FILTER_DIFFERENT_PROCESS;
3589
0
        }
3590
0
        else if (flag == FILTER_SAME_PROCESS )
3591
0
        {
3592
0
            newflags |= ParticipantFilteringFlags_t::FILTER_SAME_PROCESS;
3593
0
        }
3594
0
    }
3595
3596
0
    *e = static_cast<ParticipantFilteringFlags_t>(newflags);
3597
3598
0
    return XMLP_ret::XML_OK;
3599
0
}
3600
3601
XMLP_ret XMLParser::getXMLRemoteServer(
3602
        tinyxml2::XMLElement* elem,
3603
        eprosima::fastdds::rtps::RemoteServerAttributes& server,
3604
        uint8_t ident)
3605
0
{
3606
    /*
3607
        <xs:complexType name="RemoteServerAttributes">
3608
            <xs:all minOccurs="1">
3609
                <xs:element name="metatrafficUnicastLocatorList" type="locatorListType" minOccurs="0"/>
3610
                <xs:element name="metatrafficMulticastLocatorList" type="locatorListType" minOccurs="0"/>
3611
            </xs:all>
3612
            <xs:attribute name="guidPrefix" type="guid" use="required"/>
3613
        </xs:complexType>
3614
     */
3615
3616
0
    const char* Prefix = nullptr;
3617
0
    tinyxml2::XMLElement* pLU = nullptr, * pLM = nullptr;
3618
3619
0
    if (nullptr == elem )
3620
0
    {
3621
0
        logError(XMLPARSER, "nullptr when getXMLRemoteServer XML_ERROR!");
3622
0
        return XMLP_ret::XML_ERROR;
3623
0
    }
3624
0
    else if (nullptr == (Prefix = elem->Attribute(PREFIX)))
3625
0
    {
3626
0
        logError(XMLPARSER, "nullptr when getXMLRemoteServer try to recover server's guidPrefix XML_ERROR!");
3627
0
        return XMLP_ret::XML_ERROR;
3628
0
    }
3629
0
    else if (!server.ReadguidPrefix(Prefix))
3630
0
    {
3631
0
        logError(XMLPARSER, "getXMLRemoteServer found an invalid server's guidPrefix XML_ERROR!");
3632
0
        return XMLP_ret::XML_ERROR;
3633
0
    }
3634
3635
0
    pLU = elem->FirstChildElement(META_UNI_LOC_LIST);
3636
0
    pLM = elem->FirstChildElement(META_MULTI_LOC_LIST);
3637
3638
0
    if ( pLU == nullptr && pLM == nullptr )
3639
0
    {
3640
0
        logError(XMLPARSER, "getXMLRemoteServer couldn't find any server's locator XML_ERROR!");
3641
0
        return XMLP_ret::XML_ERROR;
3642
0
    }
3643
3644
0
    if (pLU && XMLP_ret::XML_OK != getXMLLocatorList(pLU, server.metatrafficUnicastLocatorList, ident))
3645
0
    {
3646
0
        logError(XMLPARSER,
3647
0
                "getXMLRemoteServer was given a misformatted server's " << META_UNI_LOC_LIST << " XML_ERROR!");
3648
0
        return XMLP_ret::XML_ERROR;
3649
0
    }
3650
3651
0
    if (pLM && XMLP_ret::XML_OK != getXMLLocatorList(pLM, server.metatrafficMulticastLocatorList, ident))
3652
0
    {
3653
0
        logError(XMLPARSER,
3654
0
                "getXMLRemoteServer was given a misformatted server's " << META_MULTI_LOC_LIST << " XML_ERROR!");
3655
0
        return XMLP_ret::XML_ERROR;
3656
0
    }
3657
3658
0
    return XMLP_ret::XML_OK;
3659
0
}
3660
3661
XMLP_ret XMLParser::getXMLList(
3662
        tinyxml2::XMLElement* elem,
3663
        eprosima::fastdds::rtps::RemoteServerList_t& list,
3664
        uint8_t ident)
3665
86
{
3666
    /*
3667
        <xs:complexType name="DiscoveryServerList">
3668
            <xs:sequence>
3669
                <xs:element name="RemoteServer" type="RemoteServerAttributes" minOccurs="0" maxOccurs="unbounded"/>
3670
            </xs:sequence>
3671
        </xs:complexType>
3672
     */
3673
3674
86
    tinyxml2::XMLElement* pS = nullptr;
3675
3676
86
    if (nullptr == elem)
3677
0
    {
3678
0
        logError(XMLPARSER, "nullptr when getXMLList XML_ERROR!");
3679
0
        return XMLP_ret::XML_ERROR;
3680
0
    }
3681
86
    else if (nullptr == (pS = elem->FirstChildElement(RSERVER)))
3682
86
    {
3683
86
        logError(XMLPARSER, "getXMLList couldn't find any RemoteServer XML_ERROR!");
3684
86
        return XMLP_ret::XML_ERROR;
3685
86
    }
3686
3687
0
    while (pS)
3688
0
    {
3689
0
        eprosima::fastdds::rtps::RemoteServerAttributes server;
3690
0
        if (XMLP_ret::XML_OK != getXMLRemoteServer(pS, server, ident))
3691
0
        {
3692
0
            logError(XMLPARSER, "getXMLList was given a misformatted RemoteServer XML_ERROR!");
3693
0
            return XMLP_ret::XML_ERROR;
3694
0
        }
3695
0
        list.push_back(std::move(server));
3696
3697
0
        pS = pS->NextSiblingElement(RSERVER);
3698
0
    }
3699
3700
0
    return XMLP_ret::XML_OK;
3701
3702
0
}
3703
3704
XMLP_ret XMLParser::getXMLString(
3705
        tinyxml2::XMLElement* elem,
3706
        std::string* s,
3707
        uint8_t /*ident*/)
3708
3.44k
{
3709
3.44k
    const char* text = nullptr;
3710
3711
3.44k
    if (nullptr == elem || nullptr == s)
3712
0
    {
3713
0
        logError(XMLPARSER, "nullptr when getXMLUint XML_ERROR!");
3714
0
        return XMLP_ret::XML_ERROR;
3715
0
    }
3716
3.44k
    else if (nullptr == (text = elem->GetText()))
3717
1.91k
    {
3718
1.91k
        logError(XMLPARSER, "<" << elem->Value() << "> getXMLString XML_ERROR!");
3719
1.91k
        return XMLP_ret::XML_ERROR;
3720
1.91k
    }
3721
1.52k
    *s = text;
3722
1.52k
    return XMLP_ret::XML_OK;
3723
3.44k
}
3724
3725
XMLP_ret XMLParser::getXMLguidPrefix(
3726
        tinyxml2::XMLElement* elem,
3727
        GuidPrefix_t& prefix,
3728
        uint8_t /*ident*/)
3729
196
{
3730
196
    const char* text = nullptr;
3731
3732
196
    if (nullptr == elem )
3733
0
    {
3734
0
        logError(XMLPARSER, "nullptr when getXMLguidPrefix XML_ERROR!");
3735
0
        return XMLP_ret::XML_ERROR;
3736
0
    }
3737
196
    else if (nullptr == (text = elem->GetText()))
3738
196
    {
3739
196
        logError(XMLPARSER, "<" << elem->Value() << "> getXMLguidPrefix XML_ERROR!");
3740
196
        return XMLP_ret::XML_ERROR;
3741
196
    }
3742
3743
0
    std::istringstream is(text);
3744
0
    return (is >> prefix ? XMLP_ret::XML_OK : XMLP_ret::XML_ERROR);
3745
3746
196
}
3747
3748
XMLP_ret XMLParser::getXMLPublisherAttributes(
3749
        tinyxml2::XMLElement* elem,
3750
        PublisherAttributes& publisher,
3751
        uint8_t ident)
3752
19.7k
{
3753
    /*
3754
        <xs:complexType name="publisherProfileType">
3755
            <xs:all minOccurs="0">
3756
                <xs:element name="topic" type="topicAttributesType" minOccurs="0"/>
3757
                <xs:element name="qos" type="writerQosPoliciesType" minOccurs="0"/>
3758
                <xs:element name="times" type="writerTimesType" minOccurs="0"/>
3759
                <xs:element name="unicastLocatorList" type="locatorListType" minOccurs="0"/>
3760
                <xs:element name="multicastLocatorList" type="locatorListType" minOccurs="0"/>
3761
                <xs:element name="throughputController" type="throughputControllerType" minOccurs="0"/>
3762
                <xs:element name="historyMemoryPolicy" type="historyMemoryPolicyType" minOccurs="0"/>
3763
                <xs:element name="propertiesPolicy" type="propertyPolicyType" minOccurs="0"/>
3764
                <xs:element name="userDefinedID" type="int16Type" minOccurs="0"/>
3765
                <xs:element name="entityID" type="int16Type" minOccurs="0"/>
3766
                <xs:element name="matchedSubscribersAllocation" type="containerAllocationConfigType" minOccurs="0"/>
3767
            </xs:all>
3768
            <xs:attribute name="profile_name" type="stringType" use="required"/>
3769
        </xs:complexType>
3770
     */
3771
3772
19.7k
    tinyxml2::XMLElement* p_aux0 = nullptr;
3773
19.7k
    const char* name = nullptr;
3774
22.4k
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != nullptr; p_aux0 = p_aux0->NextSiblingElement())
3775
14.2k
    {
3776
14.2k
        name = p_aux0->Name();
3777
14.2k
        if (strcmp(name, TOPIC) == 0)
3778
294
        {
3779
            // topic
3780
294
            if (XMLP_ret::XML_OK != getXMLTopicAttributes(p_aux0, publisher.topic, ident))
3781
69
            {
3782
69
                return XMLP_ret::XML_ERROR;
3783
69
            }
3784
294
        }
3785
13.9k
        else if (strcmp(name, QOS) == 0)
3786
6.00k
        {
3787
            // qos
3788
6.00k
            if (XMLP_ret::XML_OK != getXMLWriterQosPolicies(p_aux0, publisher.qos, ident))
3789
4.95k
            {
3790
4.95k
                return XMLP_ret::XML_ERROR;
3791
4.95k
            }
3792
6.00k
        }
3793
7.98k
        else if (strcmp(name, TIMES) == 0)
3794
3.79k
        {
3795
            // times
3796
3.79k
            if (XMLP_ret::XML_OK != getXMLWriterTimes(p_aux0, publisher.times, ident))
3797
3.34k
            {
3798
3.34k
                return XMLP_ret::XML_ERROR;
3799
3.34k
            }
3800
3.79k
        }
3801
4.19k
        else if (strcmp(name, UNI_LOC_LIST) == 0)
3802
223
        {
3803
            // unicastLocatorList
3804
223
            if (XMLP_ret::XML_OK != getXMLLocatorList(p_aux0, publisher.unicastLocatorList, ident))
3805
223
            {
3806
223
                return XMLP_ret::XML_ERROR;
3807
223
            }
3808
223
        }
3809
3.96k
        else if (strcmp(name, MULTI_LOC_LIST) == 0)
3810
195
        {
3811
            // multicastLocatorList
3812
195
            if (XMLP_ret::XML_OK != getXMLLocatorList(p_aux0, publisher.multicastLocatorList, ident))
3813
195
            {
3814
195
                return XMLP_ret::XML_ERROR;
3815
195
            }
3816
195
        }
3817
3.77k
        else if (strcmp(name, REM_LOC_LIST) == 0)
3818
244
        {
3819
            // remoteLocatorList
3820
244
            if (XMLP_ret::XML_OK != getXMLLocatorList(p_aux0, publisher.remoteLocatorList, ident))
3821
244
            {
3822
244
                return XMLP_ret::XML_ERROR;
3823
244
            }
3824
244
        }
3825
3.53k
        else if (strcmp(name, THROUGHPUT_CONT) == 0)
3826
222
        {
3827
            // throughputController
3828
222
            if (XMLP_ret::XML_OK !=
3829
222
                    getXMLThroughputController(p_aux0, publisher.throughputController, ident))
3830
0
            {
3831
0
                return XMLP_ret::XML_ERROR;
3832
0
            }
3833
222
        }
3834
3.30k
        else if (strcmp(name, HIST_MEM_POLICY) == 0)
3835
669
        {
3836
            // historyMemoryPolicy
3837
669
            if (XMLP_ret::XML_OK != getXMLHistoryMemoryPolicy(p_aux0, publisher.historyMemoryPolicy, ident))
3838
379
            {
3839
379
                return XMLP_ret::XML_ERROR;
3840
379
            }
3841
669
        }
3842
2.63k
        else if (strcmp(name, PROPERTIES_POLICY) == 0)
3843
255
        {
3844
            // propertiesPolicy
3845
255
            if (XMLP_ret::XML_OK != getXMLPropertiesPolicy(p_aux0, publisher.properties, ident))
3846
0
            {
3847
0
                return XMLP_ret::XML_ERROR;
3848
0
            }
3849
255
        }
3850
2.38k
        else if (strcmp(name, USER_DEF_ID) == 0)
3851
201
        {
3852
            // userDefinedID - int16type
3853
201
            int i = 0;
3854
201
            if (XMLP_ret::XML_OK != getXMLInt(p_aux0, &i, ident) || i > 255)
3855
201
            {
3856
201
                return XMLP_ret::XML_ERROR;
3857
201
            }
3858
0
            publisher.setUserDefinedID(static_cast<uint8_t>(i));
3859
0
        }
3860
2.18k
        else if (strcmp(name, ENTITY_ID) == 0)
3861
498
        {
3862
            // entityID - int16Type
3863
498
            int i = 0;
3864
498
            if (XMLP_ret::XML_OK != getXMLInt(p_aux0, &i, ident) || i > 255)
3865
498
            {
3866
498
                return XMLP_ret::XML_ERROR;
3867
498
            }
3868
0
            publisher.setEntityID(static_cast<uint8_t>(i));
3869
0
        }
3870
1.68k
        else if (strcmp(name, MATCHED_SUBSCRIBERS_ALLOCATION) == 0)
3871
228
        {
3872
            // matchedSubscribersAllocation - containerAllocationConfigType
3873
228
            if (XMLP_ret::XML_OK !=
3874
228
                    getXMLContainerAllocationConfig(p_aux0, publisher.matched_subscriber_allocation, ident))
3875
0
            {
3876
0
                return XMLP_ret::XML_ERROR;
3877
0
            }
3878
228
        }
3879
1.45k
        else
3880
1.45k
        {
3881
1.45k
            logError(XMLPARSER, "Invalid element found into 'publisherProfileType'. Name: " << name);
3882
1.45k
            return XMLP_ret::XML_ERROR;
3883
1.45k
        }
3884
14.2k
    }
3885
8.19k
    return XMLP_ret::XML_OK;
3886
19.7k
}
3887
3888
XMLP_ret XMLParser::getXMLSubscriberAttributes(
3889
        tinyxml2::XMLElement* elem,
3890
        SubscriberAttributes& subscriber,
3891
        uint8_t ident)
3892
16.1k
{
3893
    /*
3894
        <xs:complexType name="subscriberProfileType">
3895
            <xs:all minOccurs="0">
3896
                <xs:element name="topic" type="topicAttributesType" minOccurs="0"/>
3897
                <xs:element name="qos" type="readerQosPoliciesType" minOccurs="0"/>
3898
                <xs:element name="times" type="readerTimesType" minOccurs="0"/>
3899
                <xs:element name="unicastLocatorList" type="locatorListType" minOccurs="0"/>
3900
                <xs:element name="multicastLocatorList" type="locatorListType" minOccurs="0"/>
3901
                <xs:element name="expectsInlineQos" type="boolType" minOccurs="0"/>
3902
                <xs:element name="historyMemoryPolicy" type="historyMemoryPolicyType" minOccurs="0"/>
3903
                <xs:element name="propertiesPolicy" type="propertyPolicyType" minOccurs="0"/>
3904
                <xs:element name="userDefinedID" type="int16Type" minOccurs="0"/>
3905
                <xs:element name="entityID" type="int16Type" minOccurs="0"/>
3906
                <xs:element name="matchedPublishersAllocation" type="containerAllocationConfigType" minOccurs="0"/>
3907
            </xs:all>
3908
            <xs:attribute name="profile_name" type="stringType" use="required"/>
3909
        </xs:complexType>
3910
     */
3911
3912
16.1k
    tinyxml2::XMLElement* p_aux0 = nullptr;
3913
16.1k
    const char* name = nullptr;
3914
18.2k
    for (p_aux0 = elem->FirstChildElement(); p_aux0 != nullptr; p_aux0 = p_aux0->NextSiblingElement())
3915
11.0k
    {
3916
11.0k
        name = p_aux0->Name();
3917
11.0k
        if (strcmp(name, TOPIC) == 0)
3918
410
        {
3919
            // topic
3920
410
            if (XMLP_ret::XML_OK != getXMLTopicAttributes(p_aux0, subscriber.topic, ident))
3921
67
            {
3922
67
                return XMLP_ret::XML_ERROR;
3923
67
            }
3924
410
        }
3925
10.5k
        else if (strcmp(name, QOS) == 0)
3926
4.74k
        {
3927
            // qos
3928
4.74k
            if (XMLP_ret::XML_OK != getXMLReaderQosPolicies(p_aux0, subscriber.qos, ident))
3929
3.97k
            {
3930
3.97k
                return XMLP_ret::XML_ERROR;
3931
3.97k
            }
3932
4.74k
        }
3933
5.84k
        else if (strcmp(name, TIMES) == 0)
3934
413
        {
3935
            // times
3936
413
            if (XMLP_ret::XML_OK != getXMLReaderTimes(p_aux0, subscriber.times, ident))
3937
345
            {
3938
345
                return XMLP_ret::XML_ERROR;
3939
345
            }
3940
413
        }
3941
5.43k
        else if (strcmp(name, UNI_LOC_LIST) == 0)
3942
531
        {
3943
            // unicastLocatorList
3944
531
            if (XMLP_ret::XML_OK != getXMLLocatorList(p_aux0, subscriber.unicastLocatorList, ident))
3945
531
            {
3946
531
                return XMLP_ret::XML_ERROR;
3947
531
            }
3948
531
        }
3949
4.89k
        else if (strcmp(name, MULTI_LOC_LIST) == 0)
3950
249
        {
3951
            // multicastLocatorList
3952
249
            if (XMLP_ret::XML_OK != getXMLLocatorList(p_aux0, subscriber.multicastLocatorList, ident))
3953
249
            {
3954
249
                return XMLP_ret::XML_ERROR;
3955
249
            }
3956
249
        }
3957
4.65k
        else if (strcmp(name, REM_LOC_LIST) == 0)
3958
248
        {
3959
            // remote LocatorList
3960
248
            if (XMLP_ret::XML_OK != getXMLLocatorList(p_aux0, subscriber.remoteLocatorList, ident))
3961
248
            {
3962
248
                return XMLP_ret::XML_ERROR;
3963
248
            }
3964
248
        }
3965
4.40k
        else if (strcmp(name, EXP_INLINE_QOS) == 0)
3966
201
        {
3967
            // expectsInlineQos - boolType
3968
201
            if (XMLP_ret::XML_OK != getXMLBool(p_aux0, &subscriber.expectsInlineQos, ident))
3969
201
            {
3970
201
                return XMLP_ret::XML_ERROR;
3971
201
            }
3972
201
        }
3973
4.20k
        else if (strcmp(name, HIST_MEM_POLICY) == 0)
3974
1.45k
        {
3975
            // historyMemoryPolicy
3976
1.45k
            if (XMLP_ret::XML_OK != getXMLHistoryMemoryPolicy(
3977
1.45k
                        p_aux0,
3978
1.45k
                        subscriber.historyMemoryPolicy,
3979
1.45k
                        ident))
3980
972
            {
3981
972
                return XMLP_ret::XML_ERROR;
3982
972
            }
3983
1.45k
        }
3984
2.74k
        else if (strcmp(name, PROPERTIES_POLICY) == 0)
3985
235
        {
3986
            // propertiesPolicy
3987
235
            if (XMLP_ret::XML_OK != getXMLPropertiesPolicy(p_aux0, subscriber.properties, ident))
3988
0
            {
3989
0
                return XMLP_ret::XML_ERROR;
3990
0
            }
3991
235
        }
3992
2.51k
        else if (strcmp(name, USER_DEF_ID) == 0)
3993
196
        {
3994
            // userDefinedID - int16Type
3995
196
            int i = 0;
3996
196
            if (XMLP_ret::XML_OK != getXMLInt(p_aux0, &i, ident) || i > 255)
3997
196
            {
3998
196
                return XMLP_ret::XML_ERROR;
3999
196
            }
4000
0
            subscriber.setUserDefinedID(static_cast<uint8_t>(i));
4001
0
        }
4002
2.31k
        else if (strcmp(name, ENTITY_ID) == 0)
4003
331
        {
4004
            // entityID - int16Type
4005
331
            int i = 0;
4006
331
            if (XMLP_ret::XML_OK != getXMLInt(p_aux0, &i, ident) || i > 255)
4007
331
            {
4008
331
                return XMLP_ret::XML_ERROR;
4009
331
            }
4010
0
            subscriber.setEntityID(static_cast<uint8_t>(i));
4011
0
        }
4012
1.98k
        else if (strcmp(name, MATCHED_PUBLISHERS_ALLOCATION) == 0)
4013
200
        {
4014
            // matchedPublishersAllocation - containerAllocationConfigType
4015
200
            if (XMLP_ret::XML_OK != getXMLContainerAllocationConfig(
4016
200
                        p_aux0,
4017
200
                        subscriber.matched_publisher_allocation,
4018
200
                        ident))
4019
0
            {
4020
0
                return XMLP_ret::XML_ERROR;
4021
0
            }
4022
200
        }
4023
1.78k
        else
4024
1.78k
        {
4025
1.78k
            logError(XMLPARSER, "Invalid element found into 'subscriberProfileType'. Name: " << name);
4026
1.78k
            return XMLP_ret::XML_ERROR;
4027
1.78k
        }
4028
11.0k
    }
4029
4030
7.21k
    return XMLP_ret::XML_OK;
4031
16.1k
}