Modified the contructor: the default value for the delimiter is now " "
and I added a boolean argument to indicate whether or not we want to
overwrite an existing file with same name (default is overwrite).
Added the getFileName accessor.
This commit is contained in:
parent
b39ebbed70
commit
bee8388a1e
1 changed files with 21 additions and 2 deletions
|
|
@ -23,6 +23,10 @@
|
|||
mkeijzer@dhi.dk
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Modified the default behavior, so that it erases existing files.
|
||||
Can be modified in the ctor.
|
||||
MS 25/11/00
|
||||
*/
|
||||
|
||||
#ifndef _eoFileMonitor_h
|
||||
#define _eoFileMonitor_h
|
||||
|
|
@ -38,17 +42,32 @@
|
|||
class eoFileMonitor : public eoMonitor
|
||||
{
|
||||
public :
|
||||
eoFileMonitor(std::string _filename, std::string _delim = ",") : filename(_filename), delim(_delim) {}
|
||||
eoFileMonitor(std::string _filename, std::string _delim = " ",
|
||||
bool _keep = false) :
|
||||
filename(_filename), delim(_delim), keep(keep)
|
||||
{
|
||||
if (! _keep)
|
||||
{
|
||||
ofstream os(filename.c_str());
|
||||
if (!os)
|
||||
{
|
||||
string str = "eoFileMonitor: Could not open " + filename;
|
||||
throw runtime_error(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
eoMonitor& operator()(void);
|
||||
|
||||
eoMonitor& operator()(std::ostream& os);
|
||||
|
||||
void printHeader(void);
|
||||
virtual void printHeader(std::ostream& os);
|
||||
|
||||
virtual string getFileName() // for eoGnuPlot
|
||||
{ return filename;}
|
||||
private :
|
||||
std::string filename;
|
||||
std::string delim;
|
||||
bool keep; // should we append or create a new file
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Reference in a new issue