"src/git@developer.sourcefind.cn:modelzoo/qwen_lmdeploy.git" did not exist on "4903d3cc9deeece7b28024971d1279f4f085d83e"
Commit 10b5961f authored by jbeder's avatar jbeder
Browse files

Set up the parse utility program to read from standard input if no file is specified

parent 6752e25b
...@@ -4,16 +4,17 @@ ...@@ -4,16 +4,17 @@
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
if(argc != 2) { std::ifstream fin;
std::cout << "Usage: " << argv[0] << " input-file\n"; if(argc > 1)
return 0; fin.open(argv[1]);
}
std::istream& input = (argc > 1 ? fin : std::cin);
std::ifstream fin(argv[1]);
try { try {
YAML::Parser parser(fin); YAML::Parser parser(input);
YAML::Node doc; while(parser) {
parser.GetNextDocument(doc); YAML::Node doc;
parser.GetNextDocument(doc);
}
} catch(const YAML::Exception& e) { } catch(const YAML::Exception& e) {
std::cerr << e.what() << "\n"; std::cerr << e.what() << "\n";
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment