"git@developer.sourcefind.cn:gaoqiong/composable_kernel.git" did not exist on "68e3bb6d2bc34b8da61ace977711c0966d6e4ce3"
Commit 174f2c1f authored by Jesse Beder's avatar Jesse Beder
Browse files

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

parent 11f98f1c
...@@ -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