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 87 of file ConfDataWriter.hpp.

Public Member Functions

 ConfDataWriter ()
 Default constructor.
 ConfDataWriter (const char *file)
 Common constructor.
 ConfDataWriter (const std::string &file)
 Common constructor.
virtual void open (const char *fn)
 Method to open a configuration data file to be written.
virtual void open (const std::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 std::string &comment)
 Write a comment line start by '#'.
void writeSeparatorLine (const std::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 std::string &var, const std::string &val, const std::string &varComment="", const std::string &valComment="")
 Write a string variable with general format.
void writeVariable (const std::string &var, const int &val, const std::string &varComment="", const std::string &valComment="")
 Write a integer variable with general format.
void writeVariable (const std::string &var, const double &val, const std::string &varComment="", const std::string &valComment="")
 Write a double variable with general format.
void writeVariableList (const std::string &var, const std::string valList[], const int &n, const std::string &varComment="", const std::string &valComment="")
 Write a string variable list with general format.
void writeVariableList (const std::string &var, std::vector< std::string > valList, const std::string &varComment="", const std::string &valComment="")
 Write a string variable list with general format.
void writeVariableList (const std::string &var, const int valList[], const int &n, const std::string &varComment="", const std::string &valComment="")
 Write a int variable list with general format.
void writeVariableList (const std::string &var, const double valList[], const int &n, const std::string &varComment="", const std::string &valComment="")
 Write a double variable list with general format.
void writeSection (const std::string &name, const std::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 std::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 92 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 101 of file ConfDataWriter.hpp.

ConfDataWriter const std::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 112 of file ConfDataWriter.hpp.


Member Function Documentation

void formattedPutLine const std::string &  sline  )  [protected]
 

Write a string line to the file.

Definition at line 284 of file ConfDataWriter.cpp.

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

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

Method to open a configuration data file to be written.

Definition at line 122 of file ConfDataWriter.hpp.

void open const char *  fn  )  [virtual]
 

Method to open a configuration data file to be written.

Definition at line 40 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 260 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 255 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 80 of file ConfDataWriter.cpp.

References ConfDataWriter::formattedPutLine().

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

void writeCommentLine const std::string &  comment  ) 
 

Write a comment line start by '#'.

Definition at line 64 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 273 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 50 of file ConfDataWriter.cpp.

Referenced by ConfDataWriter::open().

void writeSection const std::string &  name,
const std::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 252 of file ConfDataWriter.cpp.

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

Referenced by ConfData::save().

void writeSeparatorLine const std::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 73 of file ConfDataWriter.cpp.

References ConfDataWriter::writeCommentLine().

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

void writeVariable const std::string &  var,
const double &  val,
const std::string &  varComment = "",
const std::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 122 of file ConfDataWriter.cpp.

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

void writeVariable const std::string &  var,
const int &  val,
const std::string &  varComment = "",
const std::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 162 of file ConfDataWriter.hpp.

void writeVariable const std::string &  var,
const std::string &  val,
const std::string &  varComment = "",
const std::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 96 of file ConfDataWriter.cpp.

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

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

void writeVariableList const std::string &  var,
const double  valList[],
const int &  n,
const std::string &  varComment = "",
const std::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 231 of file ConfDataWriter.cpp.

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

void writeVariableList const std::string &  var,
const int  valList[],
const int &  n,
const std::string &  varComment = "",
const std::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 208 of file ConfDataWriter.cpp.

References ConfDataWriter::writeVariableList().

void writeVariableList const std::string &  var,
std::vector< std::string >  valList,
const std::string &  varComment = "",
const std::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

void writeVariableList const std::string &  var,
const std::string  valList[],
const int &  n,
const std::string &  varComment = "",
const std::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 141 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 270 of file ConfDataWriter.hpp.

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

int variableWidth [protected]
 

Definition at line 268 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 May 22 03:31:53 2013 for GPS ToolKit Software Library by  doxygen 1.3.9.1