开发者

YAML ofstream emitter

开发者 https://www.devze.com 2023-03-12 11:05 出处:网络
I find this example: ofstream ofstr(\"output.yaml\"); YAML::Emitter out(ofstr); out << some_large_document;

I find this example:

ofstream ofstr("output.yaml");
YAML::Emitter out(ofstr);
out << some_large_document;

// not necessary anymore:
// ofstr << out.c_str()

But when i try use it, i have:

D:\work\C\map.cpp||In function `int main()':|
D:\work\C\map.cpp|24|error: no matching function for call to `YAML::Emitter::Emitter(std::ofstream&)'|
D:\work\C\yaml-cpp\em开发者_运维技巧itter.h|23|note: candidates are: YAML::Emitter::Emitter(YAML::Emitter&)|
D:\work\C\yaml-cpp\emitter.h|25|note:                 YAML::Emitter::Emitter()|
||=== Build finished: 1 errors, 0 warnings ===|


There's no constructor to YAML::Emitter that takes a stream. (Where did you find that example?)

Instead, you do need to use the commented out line:

ofstream ofstr("output.yaml");
YAML::Emitter out;
out << some_large_document;
ofstr << out.c_str(); // is necessary!
0

精彩评论

暂无评论...
验证码 换一张
取 消