MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / parse

Method parse

src/Common/Config/YAMLParser.cpp:145–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143
144
145Poco::AutoPtr<Poco::XML::Document> YAMLParser::parse(const String& path)
146{
147 YAML::Node node_yml;
148 try
149 {
150 node_yml = YAML::LoadFile(path);
151 }
152 catch (const YAML::ParserException& e)
153 {
154 /// yaml-cpp cannot parse the file because its contents are incorrect
155 throw Exception(ErrorCodes::CANNOT_PARSE_YAML, "Unable to parse YAML configuration file {}, {}", path, e.what());
156 }
157 catch (const YAML::BadFile&)
158 {
159 /// yaml-cpp cannot open the file even though it exists
160 throw Exception(ErrorCodes::CANNOT_OPEN_FILE, "Unable to open YAML configuration file {}", path);
161 }
162 Poco::AutoPtr<Poco::XML::Document> xml = new Document;
163 Poco::AutoPtr<Poco::XML::Element> root_node = xml->createElement("clickhouse");
164 xml->appendChild(root_node);
165 try
166 {
167 processNode(node_yml, *root_node);
168 }
169 catch (const YAML::TypedBadConversion<std::string>&)
170 {
171 throw Exception(ErrorCodes::CANNOT_PARSE_YAML,
172 "YAMLParser has encountered node with key "
173 "or value which cannot be represented as string and cannot continue parsing of the file");
174 }
175 return xml;
176}
177
178}
179#else

Callers 4

parseConfigMethod · 0.45
TESTFunction · 0.45
makeCodecFunction · 0.45

Calls 5

processNodeFunction · 0.85
createElementMethod · 0.80
ExceptionClass · 0.50
whatMethod · 0.45
appendChildMethod · 0.45

Tested by 2

TESTFunction · 0.36
makeCodecFunction · 0.36