Skip to content

Commit

Permalink
add getJsonString and getXmlString to Export class
Browse files Browse the repository at this point in the history
issue #30
  • Loading branch information
Valentin Noel committed Aug 12, 2013
1 parent 36d417b commit c195bed
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
19 changes: 17 additions & 2 deletions libraries/report/src/Export/Export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,30 @@ Export::Export( const bpt::ptree& report )
{
}

void Export::writeJson( const std::string& filename )
void Export::writeJsonFile( const std::string& filename )
{
write_json( filename, _report );
}

void Export::writeXml( const std::string& filename, bool compact )

void Export::writeXmlFile( const std::string& filename, bool compact )
{
bpt::xml_writer_settings< char > settings( '\t', compact ? 0 : 1 );
write_xml( filename, _report, std::locale(), settings );
}

std::string Export::getJsonString() // @ todo : add compacity option
{
std::ostringstream jsonStream;
write_json( jsonStream, _report );
return jsonStream.str();
}

std::string Export::getXmlString() // @ todo : add compacity option
{
std::ostringstream xmlStream;
write_xml( xmlStream, _report );
return xmlStream.str();
}

}
6 changes: 4 additions & 2 deletions libraries/report/src/Export/Export.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ class Export
public:
Export( const bpt::ptree& report );

void writeJson( const std::string& filename );
void writeXml ( const std::string& filename, bool compact = false );
void writeJsonFile( const std::string& filename );
void writeXmlFile ( const std::string& filename, bool compact = false );
std::string getJsonString();
std::string getXmlString();

private:
bpt::ptree _report;
Expand Down

0 comments on commit c195bed

Please sign in to comment.