I have following code:
YAML::Emitter out;
out << YAML::BeginMap;
out << YAML::Key << "data" << YAML::Value << YAML::Literal << "hello\nworld\n\n";
out << YAML::EndMap;
std::string tmp(out.c_str());
size_t tmp_cnt = std::count(tmp.begin(), tmp.end(), '\n');
std::cout << "lf count before save: " << tmp_cnt << std::endl;
auto node = YAML::Load(tmp);
auto result = node["data"].as<std::string>();
size_t cnt = std::count(result.begin(), result.end(), '\n');
std::cout << "lf count after load: " << cnt << std::endl;
and I expect 3 LF's in result string but it contains only 2.
I think it happens because yaml-cpp uses | instead of |+ for the literal content.
AFAIK, this problem is fixed in master branch but there is no new release that contains fix.
So, I decided to switch to the master version of yamp-cpp to get this update.
But in the master, we have another issues related to LF at the end.
Here is description of issues and code sample:
- If
literal_value equals to helloworld, LF count is 0 after load, it's OK
- If
literal_value equals to "helloworld\n" LF count is 0 after load, it's NOT OK (count should be 1)
- If
literal_value equals to helloworld\n\n LF count is 1 after load, it's NOT OK (count should be 2)
For some obscure reasons, yaml-cpp removes one LF when data is readed back through YAML::Load.
Here is code:
YAML::Emitter out;
std::string literal_value = "helloworld\n\n";
out << YAML::BeginMap;
out << YAML::Key << "data" << YAML::Value << YAML::Literal << literal_value;
out << YAML::EndMap;
std::string tmp(out.c_str());
size_t tmp_cnt = std::count(tmp.begin(), tmp.end(), '\n');
std::cout << "LF count before save: " << tmp_cnt << std::endl;
auto node = YAML::Load(tmp);
auto result = node["data"].as<std::string>();
size_t cnt = std::count(result.begin(), result.end(), '\n');
std::cout << "LF count after load: " << cnt << std::endl;
std::cout << tmp;
So, currently I need both functionality:
- Block Chomping Indicator
- Correct LF count at the end
I apologize for asking, but my project deadline is approaching, and I would like to know roughly when to expect a new version of the library that addresses these issues (or at least fix in master branch). If the release fits within my deadline, I will wait; otherwise, I will switch to a different library to ensure I can complete my tasks on time.
Thanks in advance for your reply.
I have following code:
and I expect 3 LF's in
resultstring but it contains only 2.I think it happens because
yaml-cppuses | instead of |+ for the literal content.AFAIK, this problem is fixed in
masterbranch but there is no new release that contains fix.So, I decided to switch to the
masterversion ofyamp-cppto get this update.But in the
master, we have another issues related toLFat the end.Here is description of issues and code sample:
literal_valueequals tohelloworld, LF count is 0 after load, it's OKliteral_valueequals to"helloworld\n"LF count is 0 after load, it's NOT OK (count should be 1)literal_valueequals tohelloworld\n\nLF count is 1 after load, it's NOT OK (count should be 2)For some obscure reasons, yaml-cpp removes one LF when data is readed back through
YAML::Load.Here is code:
So, currently I need both functionality:
I apologize for asking, but my project deadline is approaching, and I would like to know roughly when to expect a new version of the library that addresses these issues (or at least fix in
masterbranch). If the release fits within my deadline, I will wait; otherwise, I will switch to a different library to ensure I can complete my tasks on time.Thanks in advance for your reply.