infoconv: add XML format
This commit is contained in:
@@ -2,5 +2,5 @@
|
||||
|
||||
This repository contains programs for working with [Boost INFO](https://www.boost.org/doc/libs/1_73_0/doc/html/property_tree/parsers.html#property_tree.parsers.info_parser) file format, as defined in Boost Property Tree library.
|
||||
|
||||
* [infoconv](infoconv.md) converts between INFO and JSON formats.
|
||||
* [infoconv](infoconv.md) converts between INFO and JSON/XML formats.
|
||||
* [infoedit](infoedit.md) programmatically edits an INFO file.
|
||||
|
||||
+27
-2
@@ -1,6 +1,7 @@
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/info_parser.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/xml_parser.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace pt = boost::property_tree;
|
||||
@@ -10,7 +11,9 @@ usage()
|
||||
{
|
||||
std::cerr << "USAGE\n"
|
||||
" infoconv info2json < config.info > config.json\n"
|
||||
" infoconv json2info < config.info > config.info\n";
|
||||
" infoconv json2info < config.info > config.info\n"
|
||||
" infoconv info2xml < config.info > config.xml\n"
|
||||
" infoconv xml2info < config.xml > config.info\n";
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -29,6 +32,22 @@ json2info()
|
||||
pt::info_parser::write_info(std::cout, tree);
|
||||
}
|
||||
|
||||
static void
|
||||
info2xml()
|
||||
{
|
||||
pt::ptree tree;
|
||||
pt::info_parser::read_info(std::cin, tree);
|
||||
pt::xml_parser::write_xml(std::cout, tree);
|
||||
}
|
||||
|
||||
static void
|
||||
xml2info()
|
||||
{
|
||||
pt::ptree tree;
|
||||
pt::xml_parser::read_xml(std::cin, tree);
|
||||
pt::info_parser::write_info(std::cout, tree);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
@@ -43,6 +62,12 @@ main(int argc, char** argv)
|
||||
else if (action == "json2info") {
|
||||
json2info();
|
||||
}
|
||||
else if (action == "info2xml") {
|
||||
info2xml();
|
||||
}
|
||||
else if (action == "xml2info") {
|
||||
xml2info();
|
||||
}
|
||||
else {
|
||||
usage();
|
||||
return 2;
|
||||
|
||||
+4
-2
@@ -1,6 +1,6 @@
|
||||
# infoconv: Convert between INFO and JSON
|
||||
# infoconv: Convert between INFO and JSON/XML
|
||||
|
||||
**infoconv** program allows converting between Boost INFO and JSON formats.
|
||||
**infoconv** program allows converting between Boost INFO and JSON/XML formats.
|
||||
One use case is to allow processing INFO files with JSON tools such as [jq](https://stedolan.github.io/jq/).
|
||||
|
||||
Usage:
|
||||
@@ -8,4 +8,6 @@ Usage:
|
||||
```
|
||||
infoconv info2json < config.info > config.json
|
||||
infoconv json2info < config.json > config.info
|
||||
infoconv info2xml < config.info > config.xml
|
||||
infoconv xml2info < config.xml > config.info
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user