ConfDataWriter Class Reference
[Formatted file I/O]

#include <ConfDataWriter.hpp>

Inheritance diagram for ConfDataWriter:

Inheritance graph
[legend]
Collaboration diagram for ConfDataWriter:

Collaboration graph
[legend]
List of all members.

Detailed Description

This is a class to write configuration data files.

A typical way to use this class follows:

      // Declare a ConfDataReader object
   ConfDataWriter confWriter;

      // Open and parse configuration file
   confWriter.open("configuration.txt");
   
   confWriter.writeVariable(cutOffElevation,
         10.0,
         "minimum allowed satellite elevation",
         "in degrees");

The configuration file follows the following format:

Definition at line 88 of file ConfDataWriter.hpp.

Public Member Functions

 ConfDataWriter ()
 Default constructor.
 ConfDataWriter (const char *file)
 Common constructor.
 ConfDataWriter (const string &file)
 Common constructor.
virtual void open (const char *fn)
 Method to open a configuration data file to be written.
virtual void open (const string &fn)
 Method to open a configuration data file to be written.
virtual void writeHeader ()
 Write a common header for all of the configuration data files written by this class.
void writeCommentLine (const string &comment)
 Write a comment line start by '#'.
void writeSeparatorLine (const string &s="-", const int &n=130)
 Write a comment line as a separator line.
void writeBlankLine (const int &n=1)
 Write several blank lines default write one line.
void writeVariable (const string &var, const string &val, const string &varComment="", const string &valComment="")
 Write a string variable with general format.
void writeVariable (const string &var, const int &val, const string &varComment="", const string &valComment="")
 Write a integer variable with general format.
void writeVariable (const string &var, const double &val, const string &varComment="", const string &valComment="")
 Write a double variable with general format.
void writeVariableList (const string &var, const string valList[], const int &n, const string &varComment="", const string &valComment="")
 Write a string variable list with general format.
void writeVariableList (const string &var, vector< string > valList, const string &varComment="", const string &valComment="")
 Write a string variable list with general format.
void writeVariableList (const string &var, const int valList[], const int &n, const string &varComment="", const string &valComment="")
 Write a int variable list with general format.
void writeVariableList (const string &var, const double valList[], const int &n, const string &varComment="", const string &valComment="")
 Write a double variable list with general format.
void writeSection (const string &name, const string &comment="")
 Write a new section with some comment.
void writeEnd ()
 Write a common tailer for all of the configuration data files written by this class.
void setVariableWidth (const int width=0)
 Method to set the variable name with to make the output looks more neat and beauty.
void setValuePrecision (const int precision=6)
 Method to set the precision of double variable's value to make the output looks the output looks more neat and beauty.

Protected Member Functions

void formattedPutLine (const string &sline)
 Write a string line to the file.

Protected Attributes

int variableWidth
int valuePrecison


Constructor & Destructor Documentation

ConfDataWriter  )  [inline]
 

Default constructor.

Definition at line 93 of file ConfDataWriter.hpp.

ConfDataWriter const char *  file  )  [inline]
 

Common constructor.

It will always open 'file' for read and will configuration data in one pass.

Parameters:
file Configuration data file to read

Definition at line 102 of file ConfDataWriter.hpp.

ConfDataWriter const string &  file  )  [inline]
 

Common constructor.

It will always open 'fn' for read and will configuration data in one pass.

Parameters:
file Configuration data file to read

Definition at line 113 of file ConfDataWriter.hpp.


Member Function Documentation

void formattedPutLine const string &  sline  )  [protected]
 

Write a string line to the file.

Definition at line 283 of file ConfDataWriter.cpp.

Referenced by ConfDataWriter::writeBlankLine(), ConfDataWriter::writeCommentLine(), ConfDataWriter::writeSection(), ConfDataWriter::writeVariable(), and ConfDataWriter::writeVariableList().

virtual void open const string &  fn  )  [inline, virtual]
 

Method to open a configuration data file to be written.

Definition at line 123 of file ConfDataWriter.hpp.

void open const char *  fn  )  [virtual]
 

Method to open a configuration data file to be written.

Definition at line 39 of file ConfDataWriter.cpp.

References ConfDataWriter::writeHeader().

void setValuePrecision const int  precision = 6  )  [inline]
 

Method to set the precision of double variable's value to make the output looks the output looks more neat and beauty.

Definition at line 261 of file ConfDataWriter.hpp.

Referenced by ConfData::save().

void setVariableWidth const int  width = 0  )  [inline]
 

Method to set the variable name with to make the output looks more neat and beauty.

Definition at line 256 of file ConfDataWriter.hpp.

Referenced by ConfData::save().

void writeBlankLine const int &  n = 1  ) 
 

Write several blank lines default write one line.

Definition at line 79 of file ConfDataWriter.cpp.

References ConfDataWriter::formattedPutLine().

Referenced by ConfData::save(), and ConfDataWriter::writeEnd().

void writeCommentLine const string &  comment  ) 
 

Write a comment line start by '#'.

Definition at line 63 of file ConfDataWriter.cpp.

References ConfDataWriter::formattedPutLine().

Referenced by ConfData::save(), ConfDataWriter::writeEnd(), ConfDataWriter::writeSection(), and ConfDataWriter::writeSeparatorLine().

void writeEnd  ) 
 

Write a common tailer for all of the configuration data files written by this class.

Definition at line 272 of file ConfDataWriter.cpp.

References ConfDataWriter::writeBlankLine(), ConfDataWriter::writeCommentLine(), and ConfDataWriter::writeSeparatorLine().

Referenced by ConfData::save().

void writeHeader  )  [virtual]
 

Write a common header for all of the configuration data files written by this class.

Definition at line 49 of file ConfDataWriter.cpp.

Referenced by ConfDataWriter::open().

void writeSection const string &  name,
const string &  comment = ""
 

Write a new section with some comment.

Parameters:
name name of the section to be written
comment comment of the section to be written

Definition at line 251 of file ConfDataWriter.cpp.

References ConfDataWriter::formattedPutLine(), ConfDataWriter::writeCommentLine(), and ConfDataWriter::writeSeparatorLine().

Referenced by ConfData::save().

void writeSeparatorLine const string &  s = "-",
const int &  n = 130
 

Write a comment line as a separator line.

Parameters:
s char of the separator line
n size of the separator line

Definition at line 72 of file ConfDataWriter.cpp.

References ConfDataWriter::writeCommentLine().

Referenced by ConfData::save(), ConfDataWriter::writeEnd(), and ConfDataWriter::writeSection().

void writeVariable const string &  var,
const double &  val,
const string &  varComment = "",
const string &  valComment = ""
 

Write a double variable with general format.

Parameters:
var variable name
val variable value
varComment variable comment
valComment value comment

Definition at line 121 of file ConfDataWriter.cpp.

References ConfDataWriter::valuePrecison, and ConfDataWriter::writeVariable().

void writeVariable const string &  var,
const int &  val,
const string &  varComment = "",
const string &  valComment = ""
[inline]
 

Write a integer variable with general format.

Parameters:
var variable name
val variable value
varComment variable comment
valComment value comment

Definition at line 163 of file ConfDataWriter.hpp.

void writeVariable const string &  var,
const string &  val,
const string &  varComment = "",
const string &  valComment = ""
 

Write a string variable with general format.

Parameters:
var variable name
val variable value
varComment variable comment
valComment value comment

Definition at line 95 of file ConfDataWriter.cpp.

References ConfDataWriter::formattedPutLine(), gpstk::StringUtils::leftJustify(), and ConfDataWriter::variableWidth.

Referenced by ConfData::save(), and ConfDataWriter::writeVariable().

void writeVariableList const string &  var,
const double  valList[],
const int &  n,
const string &  varComment = "",
const string &  valComment = ""
 

Write a double variable list with general format.

Parameters:
var variable name
valList variable list values
n size of the variable list
varComment variable comment
valComment value comment

Definition at line 230 of file ConfDataWriter.cpp.

References ConfDataWriter::valuePrecison, and ConfDataWriter::writeVariableList().

void writeVariableList const string &  var,
const int  valList[],
const int &  n,
const string &  varComment = "",
const string &  valComment = ""
 

Write a int variable list with general format.

Parameters:
var variable name
valList variable list values
n size of the variable list
varComment variable comment
valComment value comment

Definition at line 207 of file ConfDataWriter.cpp.

References ConfDataWriter::writeVariableList().

void writeVariableList const string &  var,
vector< string >  valList,
const string &  varComment = "",
const string &  valComment = ""
 

Write a string variable list with general format.

Parameters:
var variable name
valList variable list values by std::vector
varComment variable comment
valComment value comment

Definition at line 171 of file ConfDataWriter.cpp.

References ConfDataWriter::formattedPutLine(), gpstk::StringUtils::leftJustify(), and ConfDataWriter::variableWidth.

void writeVariableList const string &  var,
const string  valList[],
const int &  n,
const string &  varComment = "",
const string &  valComment = ""
 

Write a string variable list with general format.

Parameters:
var variable name
valList variable list values
n size of the variable list
varComment variable comment
valComment value comment

Definition at line 140 of file ConfDataWriter.cpp.

References ConfDataWriter::formattedPutLine(), gpstk::StringUtils::leftJustify(), and ConfDataWriter::variableWidth.

Referenced by ConfDataWriter::writeVariableList().


Member Data Documentation

int valuePrecison [protected]
 

Definition at line 271 of file ConfDataWriter.hpp.

Referenced by ConfDataWriter::writeVariable(), and ConfDataWriter::writeVariableList().

int variableWidth [protected]
 

Definition at line 269 of file ConfDataWriter.hpp.

Referenced by ConfDataWriter::writeVariable(), and ConfDataWriter::writeVariableList().


The documentation for this class was generated from the following files:
Generated on Wed Feb 8 03:31:36 2012 for GPS ToolKit Software Library by  doxygen 1.3.9.1