开发者

YAML ofstream emitter

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜