My Project
Public Member Functions | Static Public Member Functions | List of all members
ParaEngine::CPathReplaceables Class Reference

replacing some known variables in string path. More...

#include <FilePath.h>

Public Member Functions

void DecodePath (std::string &output, const std::string &input)
 replace variables in input path and return the result path. More...
 
void EncodePath (std::string &output, const std::string &input)
 this does reverse of DecodePath. More...
 
void EncodePath (std::string &output, const std::string &input, const std::string &varNames)
 same as EncodePath, except that it will only replace variables who name appears in varNames. More...
 
bool AddVariable (const CPathVariable &variable, bool bCheckCanEdit=true)
 add a new variable to the replaceable pool More...
 
CPathVariableGetVariable (const char *sVarName)
 get an variable object by its name if it exist. More...
 
bool RemoveVariable (const char *sVarName, bool bCheckCanEdit)
 return a variable by its name. More...
 
bool Clear ()
 clear all variables. More...
 

Static Public Member Functions

static CPathReplaceablesGetSingleton ()
 

Detailed Description

replacing some known variables in string path.

This is usually used as a singleton. e.g. ROOT% maps to game engine root dir, and W% maps to the current world directory, USERID% maps to user id. for security reasons, most replaceables are not editable or overridable via scripting interface.

Member Function Documentation

§ AddVariable()

bool CPathReplaceables::AddVariable ( const CPathVariable variable,
bool  bCheckCanEdit = true 
)

add a new variable to the replaceable pool

Parameters
variablethe variable to add.
bCheckCanEditdefault to true. if true, the function will fail if the pool already contain a variable with the same name but it not editable
Returns
: true if succeed.

§ Clear()

bool CPathReplaceables::Clear ( void  )

clear all variables.

§ DecodePath()

void CPathReplaceables::DecodePath ( std::string &  output,
const std::string &  input 
)

replace variables in input path and return the result path.

Parameters
outputthe output string, can be same as input string.
inputa path with or without replaceable. make sure you have called ToCanonicalFilePath() to canonicalize the input before calling this function
Returns
the resulting path. Please note that the return value is the input itself if nothing is replaced. otherwise, it is a static string reference containing the result. therefore the result is NOT thread safe.

§ EncodePath() [1/2]

void ParaEngine::CPathReplaceables::EncodePath ( std::string &  output,
const std::string &  input 
)

this does reverse of DecodePath.

Parameters
outputthe output string, can be same as input string.
inputa path with or without replaceable. make sure you have called ToCanonicalFilePath() to canonicalize the input before calling this function

§ EncodePath() [2/2]

void ParaEngine::CPathReplaceables::EncodePath ( std::string &  output,
const std::string &  input,
const std::string &  varNames 
)

same as EncodePath, except that it will only replace variables who name appears in varNames.

varNames is a comma separated list of variable names.

Parameters
outputthe output string, can be same as input string.
varNamesa comma separated list of variable names. like "WORLD,USERID", etc.

§ GetVariable()

CPathVariable * CPathReplaceables::GetVariable ( const char *  sVarName)

get an variable object by its name if it exist.

it will return NULL if not exist

§ RemoveVariable()

bool CPathReplaceables::RemoveVariable ( const char *  sVarName,
bool  bCheckCanEdit 
)

return a variable by its name.

Parameters
sVarNamevariable name to remove.
bCheckCanEditdefault to true. if true, the function will fail if the pool already contain a variable with the same name but it not editable
Returns
: true if succeed.

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