Skip to content

Commit

Permalink
Allow output to stdout
Browse files Browse the repository at this point in the history
A previous closed issue mentioned using '-' to have wav2json output the
json results to stdout, but it does not seem to have been implemented.
This implements that feature.
  • Loading branch information
AvianFlu committed Aug 6, 2013
1 parent d8e36b7 commit dfc870c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@ int main(int argc, char* argv[])
using std::cout;
using std::cerr;

std::ofstream ofs(options.output_file_name.c_str());
std::ofstream output;
std::ostream ofs(std::cout.rdbuf());

// If the output file name provided is "-", use stdout. Otherwise open the filename provided.
if (strncmp(options.output_file_name.c_str(), "-", 1))
{
output.open(options.output_file_name.c_str());
ofs.rdbuf(output.rdbuf());
}


//it appears, that javascript is fine with scientific notation
//ofs << std::fixed; //explicitly use fixed notation
Expand Down

0 comments on commit dfc870c

Please sign in to comment.