Coverage Report

Created: 2025-07-03 06:58

/src/Fast-DDS/src/cpp/xmlparser/XMLParserUtils.hpp
Line
Count
Source (jump to first uncovered line)
1
// Copyright 2023 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
#ifndef RTPS_XMLPARSER__XMLPARSERUTILS_HPP
16
#define RTPS_XMLPARSER__XMLPARSERUTILS_HPP
17
18
#include <string>
19
20
namespace tinyxml2 {
21
class XMLElement;
22
} // namespace tinyxml2
23
24
namespace eprosima {
25
namespace fastdds {
26
namespace xml {
27
namespace detail {
28
29
/**
30
 * @brief Get text from XML element.
31
 *
32
 * This method is equivalent to calling element->GetText() and constructing an std::string with the returned value.
33
 * It will perform processing of environmental variables.
34
 * This method will return an empty string in case of error.
35
 *
36
 * @param [in] element  XMLElement from where to extract its text.
37
 */
38
std::string get_element_text(
39
        tinyxml2::XMLElement* element);
40
41
/**
42
 * @brief Get text from XML element.
43
 *
44
 * This method is equivalent to calling element->GetText() and constructing an std::string with the returned value.
45
 * It will perform processing of environmental variables.
46
 * This method will return an empty string in case of error.
47
 *
48
 * @param [in]  element  XMLElement from where to extract its text.
49
 * @param [out] text     String where to store the resulting text.
50
 *
51
 * @return true on success.
52
 * @return false on error.
53
 */
54
inline bool get_element_text(
55
        tinyxml2::XMLElement* element,
56
        std::string& text)
57
0
{
58
0
    text = get_element_text(element);
59
0
    return !text.empty();
60
0
}
61
62
} // namespace detail
63
} // namespace xml
64
} // namespace fastdds
65
} // namespace eprosima
66
67
#endif  // RTPS_XMLPARSER__XMLPARSERUTILS_HPP