add printing methods
This commit is contained in:
parent
0107e367c4
commit
6b41dbe00a
@ -365,6 +365,40 @@ namespace imc
|
|||||||
<<"\"}";
|
<<"\"}";
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// print channel
|
||||||
|
void print(std::string filename, const char sep = ' ', int width = 25)
|
||||||
|
{
|
||||||
|
std::ofstream fou(filename);
|
||||||
|
|
||||||
|
// header
|
||||||
|
if ( sep == ' ' )
|
||||||
|
{
|
||||||
|
fou<<std::setw(width)<<std::left<<xname_
|
||||||
|
<<std::setw(width)<<std::left<<yname_<<"\n"
|
||||||
|
<<std::setw(width)<<std::left<<xunit_
|
||||||
|
<<std::setw(width)<<std::left<<yunit_<<"\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fou<<xname_<<sep<<yname_<<"\n"<<xunit_<<sep<<yunit_<<"\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( unsigned long int i = 0; i < xdata_.size(); i++ )
|
||||||
|
{
|
||||||
|
if ( sep == ' ' )
|
||||||
|
{
|
||||||
|
fou<<std::setw(width)<<std::left<<xdata_[i]
|
||||||
|
<<std::setw(width)<<std::left<<ydata_[i]<<"\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fou<<xdata_[i]<<sep<<ydata_[i]<<"\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fou.close();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#define IMCRAW
|
#define IMCRAW
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
// #include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
#include "hexshow.hpp"
|
#include "hexshow.hpp"
|
||||||
#include "imc_key.hpp"
|
#include "imc_key.hpp"
|
||||||
@ -324,6 +324,28 @@ namespace imc
|
|||||||
return channels;
|
return channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// print all channels in directory
|
||||||
|
void print_channels(std::string output)
|
||||||
|
{
|
||||||
|
// check for given directory
|
||||||
|
std::filesystem::path pd = output;
|
||||||
|
if ( std::filesystem::is_directory(pd) )
|
||||||
|
{
|
||||||
|
throw std::runtime_error("given directory does not exist");
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( std::map<std::string,imc::channel>::iterator it = channels_.begin();
|
||||||
|
it != channels_.end(); ++it)
|
||||||
|
{
|
||||||
|
// construct filename
|
||||||
|
std::string filenam = std::string("channel_") + it->first + std::string(".csv");
|
||||||
|
std::filesystem::path pf = pd / filenam;
|
||||||
|
|
||||||
|
// and print the channel
|
||||||
|
it->second.print(pf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user