40int main(
int argc,
char **argv) {
41 string filter, file, path, print;
42 bool short_output =
false;
43 bool with_path =
false;
46 namespace po = boost::program_options;
49 po::options_description desc(
"Allowed options");
50 desc.add_options()(
"help",
"produce this help message")(
51 "path", po::value<string>(&path)->default_value(
""),
52 "path to part of the xml file to print")(
53 "filter", po::value<string>(&filter)->default_value(
""),
54 "list option values that match given criteria")(
55 "print", po::value<string>(&print)->default_value(
"."),
56 "specifies which children or root to print")(
57 "file", po::value<string>(&file),
"xml file to parse")(
58 "short",
"short version of output")(
"with-path",
59 "include path of node in output");
64 po::store(po::parse_command_line(argc, argv, desc), vm);
66 }
catch (po::error &err) {
67 cout <<
"error parsing command line: " << err.what() << endl;
71 if (vm.count(
"help")) {
77 if (!vm.count(
"file")) {
78 cout <<
"please specify file\n";
82 if (vm.count(
"short")) {
85 if (vm.count(
"with-path")) {
97 tok = tokenizer.
begin();
98 if (tok == tokenizer.
end()) {
99 throw std::invalid_argument(
"error, specified invalid filter");
104 if (tok == tokenizer.
end()) {
105 throw std::invalid_argument(
"error, specified invalid filter");
109 if (!
wildcmp(value, prop->get(field).value())) {
114 std::vector<Property *> printvalues;
118 printvalues.push_back(&(prop->get(print)));
120 printvalues = prop->Select(print);
125 if (!short_output && with_path) {
126 cout << p2->path() <<
".";
129 cout << p2->name() <<
" = ";
135 }
catch (std::exception &error) {
136 cerr <<
"Warning from parsing xml file '" << file <<
"':\n"
137 << error.what() << endl;