MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / require_single_document

Function require_single_document

src/framework/io/yaml.cpp:172–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170};
171
172void require_single_document(std::string_view text) {
173 EventParser parser(text);
174 int documents = 0;
175 bool done = false;
176 while (!done) {
177 yaml_event_t event{};
178 if (!yaml_parser_parse(&parser.parser(), &event)) {
179 throw std::runtime_error(parser_error_message(parser.parser()));
180 }
181 const auto event_type = event.type;
182 yaml_event_delete(&event);
183 if (event_type == YAML_DOCUMENT_START_EVENT) {
184 ++documents;
185 if (documents > 1) {
186 throw std::runtime_error("yaml config must contain exactly one document");
187 }
188 } else if (event_type == YAML_STREAM_END_EVENT) {
189 done = true;
190 }
191 }
192}
193
194} // namespace
195

Callers 2

parse_scalar_mappingFunction · 0.85
parse_flattened_documentFunction · 0.85

Calls 3

yaml_parser_parseFunction · 0.85
parser_error_messageFunction · 0.85
yaml_event_deleteFunction · 0.85

Tested by

no test coverage detected