OpenDDS  Snapshot(2023/04/28-20:55)
XmlUtils.h
Go to the documentation of this file.
1 /*
2  * Distributed under the OpenDDS License.
3  * See: http://www.OpenDDS.org/license.html
4  */
5 
6 #ifndef OPENDDS_DCPS_SECURITY_ACCESS_CONTROL_XML_UTILS_H
7 #define OPENDDS_DCPS_SECURITY_ACCESS_CONTROL_XML_UTILS_H
8 
9 #include "DomainIdSet.h"
10 
13 #include <dds/DCPS/unique_ptr.h>
15 
16 #include <ace/XML_Utils/XercesString.h>
17 
18 #include <xercesc/dom/DOM.hpp>
19 #include <xercesc/util/XMLDateTime.hpp>
20 #include <xercesc/parsers/XercesDOMParser.hpp>
21 #include <xercesc/sax/SAXParseException.hpp>
22 
23 #include <string>
24 #include <ctime>
25 
27 
28 namespace OpenDDS {
29 namespace Security {
30 namespace XmlUtils {
31 
33 
35 bool get_parser(ParserPtr& parser, const std::string& filename, const std::string& xml);
36 
38 std::string to_string(const XMLCh* in);
39 
41 bool parse_bool(const XMLCh* in, bool& value);
42 
44 bool parse_time(const XMLCh* in, time_t& value);
45 
47 std::string to_string(const xercesc::SAXParseException& ex);
48 
49 inline std::string to_string(const xercesc::XMLException& ex)
50 {
51  return to_string(ex.getMessage());
52 }
53 
54 inline std::string to_string(const xercesc::DOMException& ex)
55 {
56  return to_string(ex.getMessage());
57 }
58 
59 inline std::string to_string(const xercesc::DOMNode* node)
60 {
61  return to_string(node->getTextContent());
62 }
63 
64 inline bool parse_bool(const xercesc::DOMNode* node, bool& value)
65 {
66  return parse_bool(node->getTextContent(), value);
67 }
68 
69 inline bool parse_time(const xercesc::DOMNode* node, time_t& value)
70 {
71  return parse_time(node->getTextContent(), value);
72 }
73 
74 /**
75  * Convert a node that's a DomainIdSet in the permissions and governance XML
76  * Schema in the security spec to a std::set of domain ids.
77  */
79 bool parse_domain_id_set(const xercesc::DOMNode* node, Security::DomainIdSet& domain_id_set);
80 
81 inline bool is_element(const xercesc::DOMNode* node)
82 {
83  return node->getNodeType() == xercesc::DOMNode::ELEMENT_NODE;
84 }
85 
86 } // namespace XMLUtils
87 } // namespace Security
88 } // namespace OpenDDS
89 
91 
92 #endif
bool parse_domain_id_set(const xercesc::DOMNode *node, Security::DomainIdSet &domain_id_set)
Definition: XmlUtils.cpp:445
const LogLevel::Value value
Definition: debug.cpp:61
DCPS::unique_ptr< xercesc::XercesDOMParser > ParserPtr
Definition: XmlUtils.h:32
bool is_element(const xercesc::DOMNode *node)
Definition: XmlUtils.h:81
#define OpenDDS_Security_Export
bool parse_bool(const XMLCh *in, bool &value)
Definition: XmlUtils.cpp:150
bool get_parser(ParserPtr &parser, const std::string &filename, const std::string &xml)
Definition: XmlUtils.cpp:71
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
bool parse_time(const XMLCh *in, time_t &value)
Definition: XmlUtils.cpp:245
std::string to_string(const xercesc::SAXParseException &ex)
Definition: XmlUtils.cpp:30
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28