NLMISC::CConfigFile::CVar Struct Reference

CVar class. More...

#include <config_file.h>

List of all members.

Public Member Functions

 CVar ()
bool operator== (const CVar &var) const
bool operator!= (const CVar &var) const
void add (const CVar &var)
uint size () const
Access to the variable content.



int asInt (int index=0) const
 Get the content of the variable as an integer.
double asDouble (int index=0) const
 Get the content of the variable as a double.
float asFloat (int index=0) const
 Get the content of the variable as a float.
std::string asString (int index=0) const
 Get the content of the variable as a STL string.
bool asBool (int index=0) const
 Get the content of the variable as a boolean.
Set the variable content.

If the index is the size of the array, the value will be append at the end.



void setAsInt (int val, int index=0)
 Set the content of the variable as an integer.
void setAsDouble (double val, int index=0)
 Set the content of the variable as a double.
void setAsFloat (float val, int index=0)
 Set the content of the variable as a float.
void setAsString (const std::string &val, int index=0)
 Set the content of the variable as a STL string.
void forceAsInt (int val)
 Force the content of the variable to be a single integer.
void forceAsDouble (double val)
 Force the content of the variable to be a single double.
void forceAsString (const std::string &val)
 Force the content of the variable to be a single string.
void setAsInt (const std::vector< int > &vals)
 Set the content of the aray variable as an integer.
void setAsDouble (const std::vector< double > &vals)
 Set the content of the aray variable as a double.
void setAsFloat (const std::vector< float > &vals)
 Set the content of the aray variable as a float.
void setAsString (const std::vector< std::string > &vals)
 Set the content of the aray variable as a string.

Internal use



enum  TVarType {
  T_UNKNOWN, T_INT, T_STRING, T_REAL,
  T_BOOL
}
static const char * TypeName [] = { "Integer", "String", "Float", "Boolean" }
std::string Name
TVarType Type
bool Root
bool Comp
bool FromLocalFile
std::vector< intIntValues
std::vector< doubleRealValues
std::vector< std::string > StrValues
int SaveWrap
void(* Callback )(CVar &var)

Detailed Description

CVar class.

Used by CConfigFile. A CVar is returned when you want to have a variable.

Example: see the CConfigFile example

Author:
Vianney Lecroart
Nevrax France
Date:
2000

Definition at line 130 of file config_file.h.


Member Enumeration Documentation

Enumerator:
T_UNKNOWN 
T_INT 
T_STRING 
T_REAL 
T_BOOL 

Definition at line 193 of file config_file.h.


Constructor & Destructor Documentation

NLMISC::CConfigFile::CVar::CVar (  )  [inline]

Definition at line 134 of file config_file.h.


Member Function Documentation

void NLMISC::CConfigFile::CVar::add ( const CVar var  ) 

Definition at line 269 of file config_file.cpp.

References IntValues, RealValues, StrValues, T_INT, T_REAL, T_STRING, and Type.

bool NLMISC::CConfigFile::CVar::asBool ( int  index = 0  )  const

Get the content of the variable as a boolean.

Definition at line 116 of file config_file.cpp.

References IntValues, Name, RealValues, StrValues, T_REAL, T_STRING, and Type.

double NLMISC::CConfigFile::CVar::asDouble ( int  index = 0  )  const

Get the content of the variable as a double.

Definition at line 77 of file config_file.cpp.

References IntValues, Name, RealValues, StrValues, T_INT, T_REAL, T_STRING, and Type.

Referenced by asFloat().

float NLMISC::CConfigFile::CVar::asFloat ( int  index = 0  )  const

Get the content of the variable as a float.

Definition at line 94 of file config_file.cpp.

References asDouble().

Referenced by NLLIGO::CLigoConfig::readConfigFile().

int NLMISC::CConfigFile::CVar::asInt ( int  index = 0  )  const
std::string NLMISC::CConfigFile::CVar::asString ( int  index = 0  )  const
void NLMISC::CConfigFile::CVar::forceAsDouble ( double  val  ) 

Force the content of the variable to be a single double.

Definition at line 195 of file config_file.cpp.

References IntValues, RealValues, Root, StrValues, T_REAL, and Type.

void NLMISC::CConfigFile::CVar::forceAsInt ( int  val  ) 

Force the content of the variable to be a single integer.

Definition at line 185 of file config_file.cpp.

References IntValues, RealValues, Root, StrValues, T_INT, and Type.

void NLMISC::CConfigFile::CVar::forceAsString ( const std::string &  val  ) 

Force the content of the variable to be a single string.

Definition at line 205 of file config_file.cpp.

References IntValues, RealValues, Root, StrValues, T_STRING, and Type.

bool NLMISC::CConfigFile::CVar::operator!= ( const CVar var  )  const

Definition at line 264 of file config_file.cpp.

bool NLMISC::CConfigFile::CVar::operator== ( const CVar var  )  const

Definition at line 249 of file config_file.cpp.

References IntValues, RealValues, StrValues, T_INT, T_REAL, T_STRING, and Type.

void NLMISC::CConfigFile::CVar::setAsDouble ( const std::vector< double > &  vals  ) 

Set the content of the aray variable as a double.

Definition at line 222 of file config_file.cpp.

References Name, RealValues, Root, T_REAL, and Type.

void NLMISC::CConfigFile::CVar::setAsDouble ( double  val,
int  index = 0 
)

Set the content of the variable as a double.

Definition at line 162 of file config_file.cpp.

References Name, RealValues, Root, T_REAL, and Type.

Referenced by setAsFloat().

void NLMISC::CConfigFile::CVar::setAsFloat ( const std::vector< float > &  vals  ) 

Set the content of the aray variable as a float.

Definition at line 229 of file config_file.cpp.

References Name, RealValues, Root, T_REAL, and Type.

void NLMISC::CConfigFile::CVar::setAsFloat ( float  val,
int  index = 0 
)

Set the content of the variable as a float.

Definition at line 171 of file config_file.cpp.

References setAsDouble().

void NLMISC::CConfigFile::CVar::setAsInt ( const std::vector< int > &  vals  ) 

Set the content of the aray variable as an integer.

Definition at line 215 of file config_file.cpp.

References IntValues, Name, Root, T_INT, and Type.

void NLMISC::CConfigFile::CVar::setAsInt ( int  val,
int  index = 0 
)

Set the content of the variable as an integer.

Definition at line 153 of file config_file.cpp.

References IntValues, Name, Root, T_INT, and Type.

void NLMISC::CConfigFile::CVar::setAsString ( const std::vector< std::string > &  vals  ) 

Set the content of the aray variable as a string.

Definition at line 242 of file config_file.cpp.

References Name, Root, StrValues, T_STRING, and Type.

void NLMISC::CConfigFile::CVar::setAsString ( const std::string &  val,
int  index = 0 
)

Set the content of the variable as a STL string.

Definition at line 176 of file config_file.cpp.

References Name, Root, StrValues, T_STRING, and Type.

uint NLMISC::CConfigFile::CVar::size (  )  const

Member Data Documentation

Definition at line 198 of file config_file.h.

Referenced by NLMISC::CConfigFile::setCallback().

Definition at line 199 of file config_file.h.

Definition at line 204 of file config_file.h.

std::vector<std::string> NLMISC::CConfigFile::CVar::StrValues
const char * NLMISC::CConfigFile::CVar::TypeName = { "Integer", "String", "Float", "Boolean" } [static]

Definition at line 191 of file config_file.h.

Referenced by NLMISC::EBadType::EBadType().


The documentation for this struct was generated from the following files:

Generated on Thu Jan 7 08:30:17 2010 for NeL by  doxygen 1.6.1