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
|
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
|
#ifndef _eoFileMonitor_h
|
||||||
#define _eoFileMonitor_h
|
#define _eoFileMonitor_h
|
||||||
|
|
@ -38,17 +42,32 @@
|
||||||
class eoFileMonitor : public eoMonitor
|
class eoFileMonitor : public eoMonitor
|
||||||
{
|
{
|
||||||
public :
|
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()(void);
|
||||||
|
|
||||||
eoMonitor& operator()(std::ostream& os);
|
eoMonitor& operator()(std::ostream& os);
|
||||||
|
|
||||||
void printHeader(void);
|
void printHeader(void);
|
||||||
virtual void printHeader(std::ostream& os);
|
virtual void printHeader(std::ostream& os);
|
||||||
|
virtual string getFileName() // for eoGnuPlot
|
||||||
|
{ return filename;}
|
||||||
private :
|
private :
|
||||||
std::string filename;
|
std::string filename;
|
||||||
std::string delim;
|
std::string delim;
|
||||||
|
bool keep; // should we append or create a new file
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Reference in a new issue