Skip to content

Commit a889e54

Browse files
committed
Merge branch 'develop'
2 parents b0c37e5 + ae3d107 commit a889e54

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

parse/jsd_generic_parser.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace JSON
1818

1919
PropertyTree(boost::property_tree::ptree tree = {});
2020
};
21+
2122
PropertyTree parse_json(std::istream& stream);
2223
PropertyTree parse_json(std::string const& str);
2324
boost::optional<PropertyTree> parse_auto(std::istream& stream);

utility/xml_converter.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include "xml_converter.h"
2+
#include "../parse/jsd_generic_parser.h"
3+
4+
#include <boost/property_tree/xml_parser.hpp>
5+
6+
#include <iostream>
7+
8+
namespace JSON
9+
{
10+
std::ostream& convertJsonToXml(std::ostream& ostream, std::istream& istream)
11+
{
12+
auto tree = parse_json(istream);
13+
14+
boost::property_tree::write_xml(ostream, tree.tree);
15+
16+
return ostream;
17+
}
18+
}

utility/xml_converter.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#ifndef XML_CONVERTER_H_INCLUDED
2+
#define XML_CONVERTER_H_INCLUDED
3+
4+
#include <iosfwd>
5+
6+
namespace JSON
7+
{
8+
/**
9+
* Converts the json istream contents to xml and writes it to the ostream.
10+
* It is not defined, what happens when streams overlap.
11+
*
12+
* @param ostream A stream to write to
13+
* @param istream A stream to read from
14+
*
15+
* @return The ostream passed as parameter;
16+
*/
17+
std::ostream& convertJsonToXml(std::ostream& ostream, std::istream& istream);
18+
}
19+
20+
#endif // XML_CONVERTER_H_INCLUDED

0 commit comments

Comments
 (0)