ViSP  2.9.0
vpIoTools Class Reference

#include <vpIoTools.h>

Static Public Member Functions

static void getUserName (std::string &username)
 
static std::string getUserName ()
 
static std::string getenv (const char *env)
 
static std::string getenv (std::string &env)
 
static void getVersion (const std::string &version, unsigned int &major, unsigned int &minor, unsigned int &patch)
 
static bool checkDirectory (const char *dirname)
 
static bool checkDirectory (const std::string &dirname)
 
static bool checkFilename (const char *filename)
 
static bool checkFilename (const std::string &filename)
 
static bool copy (const char *src, const char *dst)
 
static bool copy (const std::string &src, const std::string &dst)
 
static void makeDirectory (const char *dirname)
 
static void makeDirectory (const std::string &dirname)
 
static bool remove (const char *filename)
 
static bool remove (const std::string &filename)
 
static bool rename (const char *oldfilename, const char *newfilename)
 
static bool rename (const std::string &oldfilename, const std::string &newfilename)
 
static std::string path (const char *pathname)
 
static std::string path (const std::string &pathname)
 
static bool loadConfigFile (const std::string &confFile)
 
static bool readConfigVar (const std::string &var, float &value)
 
static bool readConfigVar (const std::string &var, double &value)
 
static bool readConfigVar (const std::string &var, int &value)
 
static bool readConfigVar (const std::string &var, unsigned int &value)
 
static bool readConfigVar (const std::string &var, bool &value)
 
static bool readConfigVar (const std::string &var, std::string &value)
 
static bool readConfigVar (const std::string &var, vpColor &value)
 
static bool readConfigVar (const std::string &var, vpMatrix &value, const unsigned int &nCols=0, const unsigned int &nRows=0)
 
static void setBaseName (const std::string &s)
 
static void setBaseDir (const std::string &dir)
 
static void addNameElement (const std::string &strTrue, const bool &cond=true, const std::string &strFalse="")
 
static void addNameElement (const std::string &strTrue, const double &val)
 
static std::string getBaseName ()
 
static std::string getFullName ()
 
static void saveConfigFile (const bool &actuallySave=true)
 
static void createBaseNamePath (const bool &empty=false)
 

Static Protected Attributes

static std::string baseName = ""
 
static std::string baseDir = ""
 
static std::string configFile = ""
 
static std::vector< std::string > configVars = std::vector<std::string>()
 
static std::vector< std::string > configValues = std::vector<std::string>()
 

Detailed Description

File and directories basic tools.

The example below shows how to manipulate the functions of this class to create first a directory which name corresponds to the user name and then create a file in this directory.

#include <iostream>
#include <string>
#include <fstream>
#include <visp/vpIoTools.h>
int main()
{
std::string username;
// Test if a username directory exist. If no try to create it
if (vpIoTools::checkDirectory(username) == false) {
try {
// Create a directory with name "username"
}
catch (...) {
std::cout << "Cannot create " << username << " directory" << std::endl;
return false;
}
}
// Create a empty filename with name "username/file.txt"
std::ofstream f;
std::string filename = username + "/file.txt";
filename = vpIoTools::path(filename); // Under Windows converts the filename string into "username\\file.txt"
std::cout << "Create: " << filename << std::endl;
f.open(filename.c_str());
f.close();
// Rename the file
std::string newfilename = username + "/newfile.txt";
std::cout << "Rename: " << filename << " in: " << newfilename << std::endl;
if (vpIoTools::rename(filename, newfilename) == false)
std::cout << "Unable to rename: " << filename << std::endl;
// Remove the file
std::cout << "Remove: " << newfilename << std::endl;
if (vpIoTools::remove(newfilename) == false)
std::cout << "Unable to remove: " << newfilename << std::endl;
}

The example below shows how to read a configuration file and how to create a name for experiment files. We assume the following file "/home/user/demo/config.txt" :

expNumber 2
save 0
lambda 0.4
use2D 0
use3D 1
#include <iostream>
#include <string>
#include <visp/vpIoTools.h>
int main()
{
// reading configuration file
vpIoTools::loadConfigFile("/home/user/demo/config.txt");
std::string nExp;vpIoTools::readConfigVar("expNumber", nExp); // nExp <- "2"
double lambda;vpIoTools::readConfigVar("lambda", lambda); // lambda <- 0.4
bool use2D;vpIoTools::readConfigVar("use2D", use2D); // use2D <- false
bool use3D;vpIoTools::readConfigVar("use3D", use3D); // use3D <- true
bool doSave;vpIoTools::readConfigVar("save", doSave); // doSave <- false
// creating name for experiment files
vpIoTools::setBaseDir("/home/user/data");
vpIoTools::setBaseName("exp" + nExp); // full name <- "/home/user/data/exp2"
vpIoTools::addNameElement("2D", use2D); // full name <- "/home/user/data/exp2" since use2D==false
vpIoTools::addNameElement("3D", use3D); // full name <- "/home/user/data/exp2_3D"
vpIoTools::addNameElement("lambda", lambda); // full name <- "/home/user/data/exp2_3D_lambda0.4"
// saving file
vpIoTools::saveConfigFile(doSave); // would copy "/home/user/demo/config.txt" to "/home/user/data/exp2_3D_lambda0.4_config.txt" if doSave was true
// create sub directory
vpIoTools::createBaseNamePath(); // creates "/home/user/data/exp2_3D_lambda0.4/"
}

Definition at line 155 of file vpIoTools.h.

Member Function Documentation

void vpIoTools::addNameElement ( const std::string &  strTrue,
const bool &  cond = true,
const std::string &  strFalse = "" 
)
static

Augments the prefix of the experiment files by strTrue if cond is verified, and by strFalse otherwise.

Parameters
strTrue: String to add if cond is true
cond: Condition managing the file name
strFalse: String to add if cond is false (default "")

Definition at line 1016 of file vpIoTools.cpp.

References baseName.

void vpIoTools::addNameElement ( const std::string &  strTrue,
const double &  val 
)
static

Augments the prefix of the experiment files by strTrue followed by val.

Parameters
strTrue: String to add
val: Value to add

Definition at line 1031 of file vpIoTools.cpp.

References baseName.

bool vpIoTools::checkDirectory ( const char *  dirname)
static

Check if a directory exists.

Parameters
dirname: Directory to test if it exists. The directory name is converted to the current system's format; see path().
Returns
true : If the directory exists and is accessible with write access.
false : If dirname string is null, or is not a directory, or has no write access.
See also
checkDirectory(const std::string &)
Examples:
displayD3D.cpp, displayGTK.cpp, displayOpenCV.cpp, displayX.cpp, displayXMulti.cpp, histogram.cpp, imageDiskRW.cpp, servoAfma4Point2DArtVelocity.cpp, servoAfma4Point2DCamVelocity.cpp, servoAfma4Point2DCamVelocityKalman.cpp, servoAfma6FourPoints2DArtVelocity.cpp, servoAfma6FourPoints2DCamVelocityInteractionCurrent.cpp, servoAfma6FourPoints2DCamVelocityInteractionDesired.cpp, servoAfma6Point2DArtVelocity.cpp, servoAfma6Point2DCamVelocity.cpp, servoAfma6Segment2DCamVelocity.cpp, servoBiclopsPoint2DArtVelocity.cpp, servoSimu3D_cdMc_CamVelocity.cpp, servoSimu3D_cdMc_CamVelocityWithoutVpServo.cpp, servoSimu3D_cMcd_CamVelocity.cpp, servoSimu3D_cMcd_CamVelocityWithoutVpServo.cpp, servoSimuFourPoints2DPolarCamVelocityDisplay.cpp, servoViper650FourPoints2DArtVelocityInteractionCurrent.cpp, servoViper650FourPoints2DCamVelocityInteractionCurrent.cpp, servoViper650Point2DCamVelocity.cpp, servoViper850FourPoints2DArtVelocityInteractionCurrent.cpp, servoViper850FourPoints2DArtVelocityInteractionDesired.cpp, servoViper850FourPoints2DCamVelocityInteractionCurrent.cpp, servoViper850FourPointsKinect.cpp, servoViper850Point2DArtVelocity.cpp, servoViper850Point2DCamVelocity.cpp, servoViper850Point2DCamVelocityKalman.cpp, SickLDMRS-Process.cpp, sonarPioneerReader.cpp, testConversion.cpp, testCreateSubImage.cpp, testIoPGM.cpp, testIoPPM.cpp, testRobust.cpp, testUndistortImage.cpp, and testXmlParser.cpp.

Definition at line 335 of file vpIoTools.cpp.

References path().

Referenced by checkDirectory(), copy(), createBaseNamePath(), vpSimulatorAfma6::init(), vpSimulatorViper850::init(), vpSimulatorAfma6::initArms(), vpSimulatorViper850::initArms(), makeDirectory(), vpServoData::open(), remove(), and vpWireFrameSimulator::vpWireFrameSimulator().

bool vpIoTools::checkDirectory ( const std::string &  dirname)
static

Check if a directory exists.

Parameters
dirname: Directory to test if it exists. The directory name is converted to the current system's format; see path().
Returns
true : If the directory exists and is accessible with write access.
false : If dirname string is null, or is not a directory, or has no write access.
See also
checkDirectory(const char *)

Definition at line 385 of file vpIoTools.cpp.

References checkDirectory().

bool vpIoTools::checkFilename ( const char *  filename)
static

Check if a file exists.

Parameters
filename: Filename to test if it exists.
Returns
true : If the filename exists and is accessible with read access.
false : If filename string is null, or is not a filename, or has no read access.
See also
checkFilename(const std::string &)
Examples:
fernClassifier.cpp, and planarObjectDetector.cpp.

Definition at line 485 of file vpIoTools.cpp.

References path().

Referenced by checkFilename(), copy(), vpDot2::defineDots(), vpAROgre::init(), vpMbTracker::loadModel(), vpImageIo::read(), and remove().

bool vpIoTools::checkFilename ( const std::string &  filename)
static

Check if a file exists.

Parameters
filename: Filename to test if it exists.
Returns
true : If the filename exists and is accessible with read access.
false : If filename string is null, or is not a filename, or has no read access.
See also
checkFilename(const char *)

Definition at line 533 of file vpIoTools.cpp.

References checkFilename().

bool vpIoTools::copy ( const char *  src,
const char *  dst 
)
static

Copy a src file or directory in dst.

Parameters
src: Existing file or directory to copy.
dst: New copied file or directory.
Returns
true if the file or the directory was copied, false otherwise.
See also
copy(const std::string &, const std::string &)

Definition at line 551 of file vpIoTools.cpp.

References checkDirectory(), checkFilename(), and path().

Referenced by copy(), and saveConfigFile().

bool vpIoTools::copy ( const std::string &  src,
const std::string &  dst 
)
static

Copy a src file or directory in dst.

Parameters
src: Existing file or directory to copy.
dst: New copied file or directory.
Returns
true if the file or the directory was copied, false otherwise.
See also
copy(const char *, const char *)

Definition at line 601 of file vpIoTools.cpp.

References copy().

void vpIoTools::createBaseNamePath ( const bool &  empty = false)
static

Creates the directory baseDir/baseName. If already exists, empties it if empty is true. Useful to save the images corresponding to a particular experiment.

Parameters
empty: Indicates if the new directory has to be emptied

Definition at line 1051 of file vpIoTools.cpp.

References baseDir, baseName, checkDirectory(), makeDirectory(), and remove().

static std::string vpIoTools::getBaseName ( )
inlinestatic

Gets the base name (prefix) of the experiment files.

Returns
the base name of the experiment files.

Definition at line 216 of file vpIoTools.h.

std::string vpIoTools::getenv ( const char *  env)
static

Get the content of an environment variable.

Warning
Under windows, this function is not implemented yet.
Parameters
env: Environment variable name (HOME, LOGNAME...).
Returns
Value of the environment variable
Exceptions
vpException::notImplementedError: If this method is called under Windows.
vpIoException::cantGetenv: If an error occur while getting the environement variable value.
#include <iostream>
#include <string>
#include <visp/vpIoTools.h>
int main()
{
std::string envvalue;
try {
envvalue = vpIoTools::getenv("HOME");
std::cout << "$HOME = \"" << envvalue << "\"" << std::endl;
}
catch (...) {
std::cout << "Cannot get the environment variable value" << std::endl;
return -1;
}
return 0;
}
See also
getenv(std::string &)

Definition at line 208 of file vpIoTools.cpp.

References vpIoException::cantGetenv, vpException::notImplementedError, and vpERROR_TRACE.

Referenced by getenv(), getUserName(), vpSimulatorAfma6::init(), vpSimulatorViper850::init(), vpSimulatorAfma6::initArms(), vpSimulatorViper850::initArms(), and vpWireFrameSimulator::vpWireFrameSimulator().

std::string vpIoTools::getenv ( std::string &  env)
static

Get the content of an environment variable.

Warning
Under windows, this function is not implemented yet.
Parameters
env: Environment variable name (HOME, LOGNAME...).
Returns
Value of the environment variable
Exceptions
vpException::notImplementedError: If this method is called under Windows.
vpIoException::cantGetenv: If an error occur while getting the environement variable value.
#include <iostream>
#include <string>
#include <visp/vpIoTools.h>
int main()
{
std::string envvalue;
try {
std::string env = "HOME";
envvalue = vpIoTools::getenv(env);
std::cout << "$HOME = \"" << envvalue << "\"" << std::endl;
}
catch (...) {
std::cout << "Cannot get the environment variable value" << std::endl;
return -1;
}
return 0;
}
See also
getenv(const char *)

Definition at line 273 of file vpIoTools.cpp.

References getenv().

static std::string vpIoTools::getFullName ( )
inlinestatic

Gets the full path of the experiment files : baseDir/baseName

Returns
the full path of the experiment files.

Definition at line 222 of file vpIoTools.h.

void vpIoTools::getUserName ( std::string &  username)
static

Get the user name.

  • Under unix, get the content of the LOGNAME environment variable. For most purposes (especially in conjunction with crontab), it is more useful to use the environment variable LOGNAME to find out who the user is, rather than the getlogin() function. This is more flexible precisely because the user can set LOGNAME arbitrarily.
  • Under windows, uses the GetUserName() function.
Parameters
username: The user name.
Exceptions
vpIoException::cantGetUserName: If this method cannot get the user name.
See also
getUserName()

Definition at line 93 of file vpIoTools.cpp.

References vpIoException::cantGetUserName, getenv(), and vpERROR_TRACE.

std::string vpIoTools::getUserName ( )
static

Get the user name.

  • Under unix, get the content of the LOGNAME environment variable. For most purposes (especially in conjunction with crontab), it is more useful to use the environment variable LOGNAME to find out who the user is, rather than the getlogin() function. This is more flexible precisely because the user can set LOGNAME arbitrarily.
  • Under windows, uses the GetUserName() function.
Returns
The user name.
Exceptions
vpIoException::cantGetUserName: If this method cannot get the user name.
See also
getUserName(std::string &)
Examples:
displayD3D.cpp, displayGTK.cpp, displayOpenCV.cpp, displayX.cpp, displayXMulti.cpp, histogram.cpp, imageDiskRW.cpp, servoAfma4Point2DArtVelocity.cpp, servoAfma4Point2DCamVelocity.cpp, servoAfma4Point2DCamVelocityKalman.cpp, servoAfma6FourPoints2DArtVelocity.cpp, servoAfma6FourPoints2DCamVelocityInteractionCurrent.cpp, servoAfma6FourPoints2DCamVelocityInteractionDesired.cpp, servoAfma6Point2DArtVelocity.cpp, servoAfma6Point2DCamVelocity.cpp, servoAfma6Segment2DCamVelocity.cpp, servoBiclopsPoint2DArtVelocity.cpp, servoSimu3D_cdMc_CamVelocity.cpp, servoSimu3D_cdMc_CamVelocityWithoutVpServo.cpp, servoSimu3D_cMcd_CamVelocity.cpp, servoSimu3D_cMcd_CamVelocityWithoutVpServo.cpp, servoSimuFourPoints2DPolarCamVelocityDisplay.cpp, servoViper650FourPoints2DArtVelocityInteractionCurrent.cpp, servoViper650FourPoints2DCamVelocityInteractionCurrent.cpp, servoViper650Point2DCamVelocity.cpp, servoViper850FourPoints2DArtVelocityInteractionCurrent.cpp, servoViper850FourPoints2DArtVelocityInteractionDesired.cpp, servoViper850FourPoints2DCamVelocityInteractionCurrent.cpp, servoViper850FourPointsKinect.cpp, servoViper850Point2DArtVelocity.cpp, servoViper850Point2DCamVelocity.cpp, servoViper850Point2DCamVelocityKalman.cpp, sonarPioneerReader.cpp, test1394TwoGrabber.cpp, testConversion.cpp, testCreateSubImage.cpp, testIoPGM.cpp, testIoPPM.cpp, testRobust.cpp, testUndistortImage.cpp, and testXmlParser.cpp.

Definition at line 140 of file vpIoTools.cpp.

References vpIoException::cantGetUserName, getenv(), and vpERROR_TRACE.

void vpIoTools::getVersion ( const std::string &  version,
unsigned int &  major,
unsigned int &  minor,
unsigned int &  patch 
)
static

Extract major, minor and patch from a version given as "x.x.x". Ex: If version is "1.2.1", major will be 1, minor 2 and patch 1.

Parameters
version: String to extract the values.
major: Extracted major.
minor: Extracted minor.
patch: Extracted patch.

Definition at line 288 of file vpIoTools.cpp.

bool vpIoTools::loadConfigFile ( const std::string &  confFile)
static

Reads the configuration file and parses it.

Parameters
confFile: path to the file containing the configuration parameters to parse.
Returns
true if succeed, false otherwise.

Definition at line 760 of file vpIoTools.cpp.

References configFile, configValues, configVars, vpMath::minimum(), and path().

void vpIoTools::makeDirectory ( const char *  dirname)
static

Create a new directory.

Parameters
dirname: Directory to create. The directory name is converted to the current system's format; see path().
Exceptions
vpIoException::invalidDirectoryName: The dirname is invalid.
vpIoException::cantCreateDirectory: If the directory cannot be created.
See also
makeDirectory(const std::string &)
Examples:
displayD3D.cpp, displayGTK.cpp, displayOpenCV.cpp, displayX.cpp, displayXMulti.cpp, histogram.cpp, imageDiskRW.cpp, servoAfma4Point2DArtVelocity.cpp, servoAfma4Point2DCamVelocity.cpp, servoAfma4Point2DCamVelocityKalman.cpp, servoAfma6FourPoints2DArtVelocity.cpp, servoAfma6FourPoints2DCamVelocityInteractionCurrent.cpp, servoAfma6FourPoints2DCamVelocityInteractionDesired.cpp, servoAfma6Point2DArtVelocity.cpp, servoAfma6Point2DCamVelocity.cpp, servoAfma6Segment2DCamVelocity.cpp, servoBiclopsPoint2DArtVelocity.cpp, servoSimu3D_cdMc_CamVelocity.cpp, servoSimu3D_cdMc_CamVelocityWithoutVpServo.cpp, servoSimu3D_cMcd_CamVelocity.cpp, servoSimu3D_cMcd_CamVelocityWithoutVpServo.cpp, servoSimuFourPoints2DPolarCamVelocityDisplay.cpp, servoViper650FourPoints2DArtVelocityInteractionCurrent.cpp, servoViper650FourPoints2DCamVelocityInteractionCurrent.cpp, servoViper650Point2DCamVelocity.cpp, servoViper850FourPoints2DArtVelocityInteractionCurrent.cpp, servoViper850FourPoints2DArtVelocityInteractionDesired.cpp, servoViper850FourPoints2DCamVelocityInteractionCurrent.cpp, servoViper850FourPointsKinect.cpp, servoViper850Point2DArtVelocity.cpp, servoViper850Point2DCamVelocity.cpp, servoViper850Point2DCamVelocityKalman.cpp, SickLDMRS-Process.cpp, sonarPioneerReader.cpp, test1394TwoGrabber.cpp, testConversion.cpp, testCreateSubImage.cpp, testIoPGM.cpp, testIoPPM.cpp, testRobust.cpp, testUndistortImage.cpp, and testXmlParser.cpp.

Definition at line 404 of file vpIoTools.cpp.

References vpIoException::cantCreateDirectory, checkDirectory(), vpIoException::invalidDirectoryName, path(), vpDEBUG_TRACE, and vpERROR_TRACE.

Referenced by createBaseNamePath(), makeDirectory(), and vpServoData::open().

void vpIoTools::makeDirectory ( const std::string &  dirname)
static

Create a new directory.

Parameters
dirname: Directory to create. The directory name is converted to the current system's format; see path().
Exceptions
vpIoException::cantCreateDirectory: If the directory cannot be created.
See also
makeDirectory(const char *)

Definition at line 459 of file vpIoTools.cpp.

References vpIoException::cantCreateDirectory, makeDirectory(), and vpERROR_TRACE.

std::string vpIoTools::path ( const char *  pathname)
static

Converts a path name to the current system's format.

Parameters
pathname: Path name to convert. Path name to convert. Under windows, converts all the "/" characters in the pathname string into "\\" characters. Under Unix systems converts all the "\\" characters in the pathname string into "/" characters.
Returns
The converted path name.
See also
path(const std::string &)
Examples:
AROgre.cpp, AROgreBasic.cpp, displayD3D.cpp, displayGTK.cpp, displayOpenCV.cpp, displaySequence.cpp, displayX.cpp, displayXMulti.cpp, fernClassifier.cpp, histogram.cpp, imageDiskRW.cpp, imageSequenceReader.cpp, keyPointSurf.cpp, mbtEdgeKltTracking.cpp, mbtEdgeTracking.cpp, mbtKltTracking.cpp, photometricVisualServoing.cpp, planarObjectDetector.cpp, poseVirtualVS.cpp, servoSimu4Points.cpp, simulateCircle2DCamVelocity.cpp, simulateFourPoints2DCartesianCamVelocity.cpp, simulateFourPoints2DPolarCamVelocity.cpp, sonarPioneerReader.cpp, templateTracker.cpp, testClick.cpp, testConversion.cpp, testCreateSubImage.cpp, testIoPGM.cpp, testIoPPM.cpp, testMouseEvent.cpp, testReadImage.cpp, testSurfKeyPoint.cpp, testTrackDot.cpp, testUndistortImage.cpp, testVideoDevice.cpp, testXmlParser.cpp, trackDot.cpp, trackDot2.cpp, trackDot2WithAutoDetection.cpp, trackKltOpencv.cpp, trackMeCircle.cpp, trackMeEllipse.cpp, trackMeLine.cpp, trackMeNurbs.cpp, and videoReader.cpp.

Definition at line 715 of file vpIoTools.cpp.

Referenced by checkDirectory(), checkFilename(), copy(), loadConfigFile(), makeDirectory(), path(), and remove().

std::string vpIoTools::path ( const std::string &  pathname)
static

Converts a path name to the current system's format.

Parameters
pathname: Path name to convert. Under windows, converts all the "/" characters in the pathname string into "\\" characters. Under Unix systems converts all the "\\" characters in the pathname string into "/" characters.
Returns
The converted path name.
See also
path(const char *)

Definition at line 747 of file vpIoTools.cpp.

References path().

bool vpIoTools::readConfigVar ( const std::string &  var,
float &  value 
)
static

Tries to read the parameter named var as a float.

Parameters
var: Name of the parameter in the configuration file.
value: Value to be read.
Returns
true if the parameter could be read.

Definition at line 811 of file vpIoTools.cpp.

References configValues, and configVars.

Referenced by readConfigVar().

bool vpIoTools::readConfigVar ( const std::string &  var,
double &  value 
)
static

Tries to read the parameter named var as a double.

Parameters
var: Name of the parameter in the configuration file.
value: Value to be read.
Returns
true if the parameter could be read.

Definition at line 841 of file vpIoTools.cpp.

References configValues, and configVars.

bool vpIoTools::readConfigVar ( const std::string &  var,
int &  value 
)
static

Tries to read the parameter named var as a int.

Parameters
var: Name of the parameter in the configuration file.
value: Value to be read.
Returns
true if the parameter could be read.

Definition at line 872 of file vpIoTools.cpp.

References configValues, and configVars.

bool vpIoTools::readConfigVar ( const std::string &  var,
unsigned int &  value 
)
static

Tries to read the parameter named var as a unsigned int.

Parameters
var: Name of the parameter in the configuration file.
value: Value to be read.
Returns
true if the parameter could be read.

Definition at line 896 of file vpIoTools.cpp.

References readConfigVar().

bool vpIoTools::readConfigVar ( const std::string &  var,
bool &  value 
)
static

Tries to read the parameter named var as a bool.

Parameters
var: Name of the parameter in the configuration file.
value: Value to be read.
Returns
true if the parameter could be read.

Definition at line 912 of file vpIoTools.cpp.

References readConfigVar().

bool vpIoTools::readConfigVar ( const std::string &  var,
std::string &  value 
)
static

Tries to read the parameter named var as a std::string.

Parameters
var: Name of the parameter in the configuration file.
value: Value to be read.
Returns
true if the parameter could be read.

Definition at line 944 of file vpIoTools.cpp.

References configValues, and configVars.

bool vpIoTools::readConfigVar ( const std::string &  var,
vpColor value 
)
static

Tries to read the parameter named var as a vpColor.

Parameters
var: Name of the parameter in the configuration file.
value: Value to be read. See vpColor.cpp for the color number.
Returns
true if the parameter could be read.

Definition at line 928 of file vpIoTools.cpp.

References vpColor::getColor(), and readConfigVar().

bool vpIoTools::readConfigVar ( const std::string &  var,
vpMatrix value,
const unsigned int &  nCols = 0,
const unsigned int &  nRows = 0 
)
static

Tries to read the parameter named var as a vpMatrix. If nCols and nRows are indicated, will resize the matrix. Otherwise, will try to read as many values as indicated by the dimension of value.

Parameters
var: Name of the parameter in the configuration file.
value: Value to be read.
nCols: Column dimension if resized.
nRows: Row dimension if resized
Returns
true if the parameter could be read.

Definition at line 972 of file vpIoTools.cpp.

References configValues, configVars, vpMatrix::getCols(), vpMatrix::getRows(), and vpMatrix::resize().

bool vpIoTools::remove ( const char *  file_or_dir)
static

Remove a file or a directory.

Parameters
file_or_dir: File or directory to remove.
Returns
true if the file or the directory was removed, false otherwise.
See also
remove(const std::string &)

Definition at line 617 of file vpIoTools.cpp.

References checkDirectory(), checkFilename(), and path().

Referenced by createBaseNamePath(), and remove().

bool vpIoTools::remove ( const std::string &  file_or_dir)
static

Remove a file or a directory.

Parameters
file_or_dir: File or directory to remove.
Returns
true if the file or the directory was removed, false otherwise.
See also
remove(const char *)

Definition at line 658 of file vpIoTools.cpp.

References remove().

bool vpIoTools::rename ( const char *  oldfilename,
const char *  newfilename 
)
static

Rename an existing file oldfilename in newfilename.

Parameters
oldfilename: File to rename.
newfilename: New file name.
Returns
true if the file was renamed, false otherwise.
See also
rename(const std::string &, const std::string &)

Definition at line 675 of file vpIoTools.cpp.

Referenced by rename().

bool vpIoTools::rename ( const std::string &  oldfilename,
const std::string &  newfilename 
)
static

Rename an existing file oldfilename in newfilename.

Parameters
oldfilename: File to rename.
newfilename: New file name.
Returns
true if the file was renamed, false otherwise.
See also
rename(const char *, const char *)

Definition at line 695 of file vpIoTools.cpp.

References rename().

void vpIoTools::saveConfigFile ( const bool &  actuallySave = true)
static

Copy the initial configuration file to the experiment directory.

Parameters
actuallySave: If false, do not copy the file.

Definition at line 1071 of file vpIoTools.cpp.

References baseDir, baseName, configFile, and copy().

static void vpIoTools::setBaseDir ( const std::string &  dir)
inlinestatic

Sets the base directory of the experiment files.

Parameters
dir: Directory where the data will be saved.

Definition at line 206 of file vpIoTools.h.

static void vpIoTools::setBaseName ( const std::string &  s)
inlinestatic

Sets the base name (prefix) of the experiment files.

Parameters
s: Prefix of the experiment files.

Definition at line 200 of file vpIoTools.h.

Member Data Documentation

std::string vpIoTools::baseDir = ""
staticprotected

Definition at line 230 of file vpIoTools.h.

Referenced by createBaseNamePath(), and saveConfigFile().

std::string vpIoTools::baseName = ""
staticprotected

Definition at line 229 of file vpIoTools.h.

Referenced by addNameElement(), createBaseNamePath(), and saveConfigFile().

std::string vpIoTools::configFile = ""
staticprotected

Definition at line 231 of file vpIoTools.h.

Referenced by loadConfigFile(), and saveConfigFile().

std::vector< std::string > vpIoTools::configValues = std::vector<std::string>()
staticprotected

Definition at line 233 of file vpIoTools.h.

Referenced by loadConfigFile(), and readConfigVar().

std::vector< std::string > vpIoTools::configVars = std::vector<std::string>()
staticprotected

Definition at line 232 of file vpIoTools.h.

Referenced by loadConfigFile(), and readConfigVar().