MCPcopy Create free account
hub / github.com/OpenDDS/OpenDDS / get_parser

Function get_parser

dds/DCPS/security/AccessControl/XmlUtils.cpp:71–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71bool get_parser(ParserPtr& parser, const std::string& filename, const std::string& xml)
72{
73 try {
74 xercesc::XMLPlatformUtils::Initialize();
75
76 } catch (const xercesc::XMLException& ex) {
77 if (security_debug.access_error) {
78 ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: {access_error} get_parser: "
79 "XMLPlatformUtils::Initialize XMLException: %C\n",
80 to_string(ex).c_str()));
81 }
82 parser.reset();
83 return false;
84 }
85
86 parser.reset(new xercesc::XercesDOMParser());
87
88 parser->setDoNamespaces(true);
89 parser->setIncludeIgnorableWhitespace(false);
90 parser->setCreateCommentNodes(false);
91
92 ErrorHandler error_handler;
93 parser->setErrorHandler(&error_handler);
94
95 xercesc::MemBufInputSource contentbuf(
96 reinterpret_cast<const XMLByte*>(xml.c_str()), xml.size(), filename.c_str());
97
98 try {
99 parser->parse(contentbuf);
100
101 } catch (const xercesc::XMLException& ex) {
102 if (security_debug.access_error) {
103 ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: {access_error} get_parser: "
104 "XMLException while parsing \"%C\": %C\n",
105 filename.c_str(), to_string(ex).c_str()));
106 }
107 parser.reset();
108 return false;
109
110 } catch (const xercesc::DOMException& ex) {
111 if (security_debug.access_error) {
112 ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: {access_error} get_parser: "
113 "DOMException while parsing \"%C\": %C\n",
114 filename.c_str(), to_string(ex).c_str()));
115 }
116 parser.reset();
117 return false;
118
119 } catch (...) {
120 if (security_debug.access_error) {
121 ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: {access_error} get_parser: "
122 "Unexpected exception while parsing \"%C\"",
123 filename.c_str()));
124 }
125 parser.reset();
126 return false;
127 }
128

Callers 3

loadMethod · 0.85
loadMethod · 0.85
TESTFunction · 0.85

Calls 5

InitializeFunction · 0.85
to_stringFunction · 0.70
resetMethod · 0.45
sizeMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected