Loading backends/yaml/yamlconf.cpp +50 −13 Original line number Diff line number Diff line Loading @@ -85,6 +85,8 @@ void confplus::Yaml::loadConfig(const char* path, Config* conf) { std::unique_ptr<YamlStack> ystack = nullptr; bool seq = false; bool seqMapping = false; int seqIndex = 0; std::string key, value; int pos = 0; do { Loading @@ -94,16 +96,37 @@ void confplus::Yaml::loadConfig(const char* path, Config* conf) { switch (event.type) { case YAML_MAPPING_START_EVENT: { if (seq && !seqMapping) { // First mapping inside a sequence: sequence-of-mappings mode seqMapping = true; seqIndex = 0; std::unique_ptr<YamlStack> cystack(new YamlStack); cystack->prevel = std::move(ystack); ystack = std::move(cystack); ystack->anchor = key; key.clear(); value.clear(); } else if (seqMapping) { // Subsequent mapping in the sequence key.clear(); value.clear(); } else { std::unique_ptr<YamlStack> cystack(new YamlStack); cystack->prevel = std::move(ystack); ystack = std::move(cystack); ystack->anchor = key; key = value; value.clear(); } }break; case YAML_MAPPING_END_EVENT: { if (ystack->prevel) { if (seqMapping) { // Don't pop stack; increment index for next mapping ++seqIndex; key.clear(); value.clear(); } else if (ystack && ystack->prevel) { ystack = std::move(ystack->prevel); } }break; Loading @@ -121,6 +144,14 @@ void confplus::Yaml::loadConfig(const char* path, Config* conf) { }break; case YAML_SEQUENCE_END_EVENT: { if (seqMapping) { // Pop the stack that was pushed for the first mapping if (ystack && ystack->prevel) { ystack = std::move(ystack->prevel); } seqMapping = false; seqIndex = 0; } seq = false; key = value; pos = 0; Loading Loading @@ -158,6 +189,11 @@ void confplus::Yaml::loadConfig(const char* path, Config* conf) { Config::ConfigData* ckey = conf->setKey(cname); if (seqMapping) { conf->setValue(ckey, seqIndex, value); value.clear(); key.clear(); } else { conf->setValue(ckey, pos, value); value.clear(); if (!seq) { Loading @@ -167,6 +203,7 @@ void confplus::Yaml::loadConfig(const char* path, Config* conf) { ++pos; } } } type = event.type; yaml_event_delete(&event); } while (type != YAML_STREAM_END_EVENT); Loading Loading
backends/yaml/yamlconf.cpp +50 −13 Original line number Diff line number Diff line Loading @@ -85,6 +85,8 @@ void confplus::Yaml::loadConfig(const char* path, Config* conf) { std::unique_ptr<YamlStack> ystack = nullptr; bool seq = false; bool seqMapping = false; int seqIndex = 0; std::string key, value; int pos = 0; do { Loading @@ -94,16 +96,37 @@ void confplus::Yaml::loadConfig(const char* path, Config* conf) { switch (event.type) { case YAML_MAPPING_START_EVENT: { if (seq && !seqMapping) { // First mapping inside a sequence: sequence-of-mappings mode seqMapping = true; seqIndex = 0; std::unique_ptr<YamlStack> cystack(new YamlStack); cystack->prevel = std::move(ystack); ystack = std::move(cystack); ystack->anchor = key; key.clear(); value.clear(); } else if (seqMapping) { // Subsequent mapping in the sequence key.clear(); value.clear(); } else { std::unique_ptr<YamlStack> cystack(new YamlStack); cystack->prevel = std::move(ystack); ystack = std::move(cystack); ystack->anchor = key; key = value; value.clear(); } }break; case YAML_MAPPING_END_EVENT: { if (ystack->prevel) { if (seqMapping) { // Don't pop stack; increment index for next mapping ++seqIndex; key.clear(); value.clear(); } else if (ystack && ystack->prevel) { ystack = std::move(ystack->prevel); } }break; Loading @@ -121,6 +144,14 @@ void confplus::Yaml::loadConfig(const char* path, Config* conf) { }break; case YAML_SEQUENCE_END_EVENT: { if (seqMapping) { // Pop the stack that was pushed for the first mapping if (ystack && ystack->prevel) { ystack = std::move(ystack->prevel); } seqMapping = false; seqIndex = 0; } seq = false; key = value; pos = 0; Loading Loading @@ -158,6 +189,11 @@ void confplus::Yaml::loadConfig(const char* path, Config* conf) { Config::ConfigData* ckey = conf->setKey(cname); if (seqMapping) { conf->setValue(ckey, seqIndex, value); value.clear(); key.clear(); } else { conf->setValue(ckey, pos, value); value.clear(); if (!seq) { Loading @@ -167,6 +203,7 @@ void confplus::Yaml::loadConfig(const char* path, Config* conf) { ++pos; } } } type = event.type; yaml_event_delete(&event); } while (type != YAML_STREAM_END_EVENT); Loading