TORCS  1.3.9
The Open Racing Car Simulator
Parameter Helper Functions

Internal (not exported) helper functions, not part of the API. More...

Collaboration diagram for Parameter Helper Functions:

Functions

static char * getFullName (const char *sectionName, const char *paramName)
 Helper function to get the full name of a parameter (full name: "sectionName/paramName"). More...
 
static struct paramgetParamByName (struct parmHeader *conf, const char *sectionName, const char *paramName, int flag)
 Helper function to get (or create) a parameter by name. More...
 
static void removeParamByName (struct parmHeader *conf, const char *sectionName, const char *paramName)
 Helper function to remove a parameter with given name paramName. More...
 
static void cleanUnusedSection (struct parmHeader *conf, struct section *section)
 Helper function to clean up unused (empty) sections starting with given section. More...
 
static void removeParam (struct parmHeader *conf, struct section *section, struct param *param)
 Helper function to remove given parameter. More...
 
static struct paramaddParam (struct parmHeader *conf, struct section *section, const char *paramName, const char *value)
 Helper function to add parameter, does not check for duplicated name. More...
 
static void removeSection (struct parmHeader *conf, struct section *section)
 Helper function to remove a section and its contents (subsections, elements). More...
 
static struct sectiongetParent (struct parmHeader *conf, const char *sectionName)
 Helper function to get (or create if not found) parent section of section given in sectionName. More...
 
static struct sectionaddSection (struct parmHeader *conf, const char *sectionName)
 Helper function to add a section to a parameter set. More...
 
static struct parmHeadergetSharedHeader (const char *file, int mode)
 Helper function for looking up parameter sets in the cache. More...
 
static struct parmHeadercreateParmHeader (const char *file)
 Helper function to create header for parameter set handle. More...
 
static void addWithin (struct param *curParam, char *s1)
 Helper function to add "within" options to parameter curParam. More...
 
static tdble getValNumFromStr (const char *str)
 Helper function to parse number. More...
 
static void xmlStartElement (void *userData, const char *name, const char **atts)
 Helper function to process opening XML elements. More...
 
static void xmlEndElement (void *userData, const XML_Char *name)
 Helper function to process closing XML elements. More...
 
static int xmlExternalEntityRefHandler (XML_Parser mainparser, const XML_Char *openEntityNames, const XML_Char *base, const XML_Char *systemId, const XML_Char *publicId)
 Helper function to handle external XML entities (XML referencing over multiple files/URI's). More...
 
static int parseXml (struct parmHandle *parmHandle, char *buf, int len, int done)
 Helper function to parse one line of XML. More...
 
static int parserXmlInit (struct parmHandle *parmHandle)
 Helper function to set up XML parser in parmHandle. More...
 
static char * handleEntities (char *buf, const int BUFSIZE, const char *val)
 Helper function to convert the input line given in val into proper XML notation, the output goes into buf. More...
 
static void createIndent (char *buf, const int BUFSIZE, const int blanks)
 Helper function for indentation in the XML. More...
 
static void createIn (char *buf, const int BUFSIZE, withinHead *head)
 Helper function to support the serialization into the XML of the "within" attribute. More...
 
static int xmlGetOuputLine (struct parmHandle *parmHandle, char *buffer, int size)
 Helper function to output one line of XML generated from the given parameter set. More...
 
static void parmClean (struct parmHeader *conf)
 Helper function to release the parameter set content. More...
 
static void parmReleaseHeader (struct parmHeader *conf)
 Helper function to release the parameter set if the reference counter is 0. More...
 
static void parmReleaseHandle (struct parmHandle *parmHandle)
 Helper function to release the handle and eventually the referenced parameter set (if the reference counter falls to 0). More...
 
static void evalUnit (char *unit, tdble *dest, int flg)
 Support function to multiply or divide dest with unit conversion factor. More...
 
static void insertParamMerge (struct parmHandle *parmHandle, char *path, struct param *paramRef, struct param *param)
 Helper function to merge a parameter into a parameter set. More...
 
static void insertParam (struct parmHandle *parmHandle, char *path, struct param *param)
 Helper function to insert a parameter into a parameter set. More...
 

Detailed Description

Internal (not exported) helper functions, not part of the API.

Function Documentation

◆ addParam()

static struct param * addParam ( struct parmHeader conf,
struct section section,
const char *  paramName,
const char *  value 
)
static

Helper function to add parameter, does not check for duplicated name.

Parameters
[in,out]confparameter set header
[in,out]sectionsection to add parameter to
[in]paramNameparameter name
[in]valuevalue of parameter
Returns
param
NULL on error

Definition at line 346 of file params.cpp.

Here is the call graph for this function:

◆ addSection()

static struct section * addSection ( struct parmHeader conf,
const char *  sectionName 
)
static

Helper function to add a section to a parameter set.

Parameters
[in,out]confparameter set header
[in]sectionNamesection name
Returns
section on success
NULL on error

Definition at line 481 of file params.cpp.

Here is the call graph for this function:

◆ addWithin()

static void addWithin ( struct param curParam,
char *  s1 
)
static

Helper function to add "within" options to parameter curParam.

Parameters
[in]curParamparameter to add "within" option
[in]s1option string

Definition at line 648 of file params.cpp.

◆ cleanUnusedSection()

static void cleanUnusedSection ( struct parmHeader conf,
struct section section 
)
static

Helper function to clean up unused (empty) sections starting with given section.

Parameters
[in,out]confparameter set header
[in]sectionsection to start up cleaning
Note
A section is unused if it does not contain subsections or elements, or if the fullName property is empty. If the given section is in use nothing is changed. If the section is unused it gets cleaned up and the process continues with the parent section (could now be empty as well).

Definition at line 291 of file params.cpp.

Here is the call graph for this function:

◆ createIn()

static void createIn ( char *  buf,
const int  BUFSIZE,
withinHead *  head 
)
static

Helper function to support the serialization into the XML of the "within" attribute.

Parameters
[in,out]bufbuffer for the result
[in]BUFSIZEbuffer size
[in]headhead of the list with the within options

Definition at line 1325 of file params.cpp.

◆ createIndent()

static void createIndent ( char *  buf,
const int  BUFSIZE,
const int  blanks 
)
static

Helper function for indentation in the XML.

Parameters
[in,out]bufbuffer for the result
[in]BUFSIZEbuffer size
[in]blanksnumber of blanks to write

Definition at line 1307 of file params.cpp.

◆ createParmHeader()

static struct parmHeader* createParmHeader ( const char *  file)
static

Helper function to create header for parameter set handle.

Parameters
[in]filefilename
Returns
parmHeader in case of success
NULL on error

Definition at line 582 of file params.cpp.

Here is the call graph for this function:

◆ evalUnit()

static void evalUnit ( char *  unit,
tdble dest,
int  flg 
)
static

Support function to multiply or divide dest with unit conversion factor.

This function is used by GfParmUnit2SI and GfParmSI2Unit. The given unit string gets split up and processed unit by unit with evalUnit.

Parameters
[in]unitunit name from dest
[in,out]destpointer to value to convert
flgmultiply (0) or divide (otherwise)
See also
GfParmUnit2SI
GfParmSI2Unit

Definition at line 1859 of file params.cpp.

◆ getFullName()

static char * getFullName ( const char *  sectionName,
const char *  paramName 
)
static

Helper function to get the full name of a parameter (full name: "sectionName/paramName").

Parameters
[in]sectionNamename of the section containing the parameter
[in]paramNamename of the parameter
Returns
string
NULL on error
Note
Heap memory is allocated for the return value, so the caller is responsible for releasing the memory of the returned string.

Definition at line 187 of file params.cpp.

◆ getParamByName()

static struct param * getParamByName ( struct parmHeader conf,
const char *  sectionName,
const char *  paramName,
int  flag 
)
static

Helper function to get (or create) a parameter by name.

Parameters
[in,out]confparameter set header
[in]sectionNamename of the section containing the parameter
[in]paramNamename of the parameter
[in]flagif in flag the PARAM_CREATE bit is set the parameter gets created if it is not found
Returns
param
NULL on error or not found

Definition at line 213 of file params.cpp.

Here is the call graph for this function:

◆ getParent()

static struct section * getParent ( struct parmHeader conf,
const char *  sectionName 
)
static

Helper function to get (or create if not found) parent section of section given in sectionName.

Parameters
[in]confparameter set header
[in]sectionNamename of the section
Returns
section
NULL on error

Definition at line 441 of file params.cpp.

Here is the call graph for this function:

◆ getSharedHeader()

static struct parmHeader* getSharedHeader ( const char *  file,
int  mode 
)
static

Helper function for looking up parameter sets in the cache.

Parameters
filename of the file to look up
modeopening mode is a mask of:
GFPARM_RMODE_STD if the parameter set is already loaded and not private return a handle pointing to the existing parameter set (default)
GFPARM_RMODE_REREAD re-read the parameters file
GFPARM_RMODE_CREAT if the parameters file does not exist return a handle pointing to an empty parameter set (does not create a file on disk, this is done using GfParmWriteFile).
GFPARM_RMODE_PRIVATE mark handle as private
Returns
handle to parameter set
0 if not in cache
See also
GfParmReadFile

Definition at line 546 of file params.cpp.

Here is the call graph for this function:

◆ getValNumFromStr()

static tdble getValNumFromStr ( const char *  str)
static

Helper function to parse number.

Parameters
[in]strnumber as string
Returns
number

Definition at line 674 of file params.cpp.

◆ handleEntities()

static char* handleEntities ( char *  buf,
const int  BUFSIZE,
const char *  val 
)
static

Helper function to convert the input line given in val into proper XML notation, the output goes into buf.

Parameters
[in,out]bufbuffer for the processed line
[in]BUFSIZEbuffer size
[in]valinput line
Returns
pointer to given buffer buf

Definition at line 1254 of file params.cpp.

◆ insertParam()

static void insertParam ( struct parmHandle parmHandle,
char *  path,
struct param param 
)
static

Helper function to insert a parameter into a parameter set.

If the parameter param already exists in paramHandle, the values are overwritten with the values from param. If the parameter param does not yet exist in paramHandle, it gets created.

Parameters
[in,out]parmHandleparameter set handle
[in]pathpath to the parameter
[in]paramparameter
See also
GfParmMergeHandles

Definition at line 2906 of file params.cpp.

Here is the call graph for this function:

◆ insertParamMerge()

static void insertParamMerge ( struct parmHandle parmHandle,
char *  path,
struct param paramRef,
struct param param 
)
static

Helper function to merge a parameter into a parameter set.

If the parameter param already exists in paramHandle, the values are overwritten with the values from param. If the parameter param does not yet exist in paramHandle, it gets created. The value and restrictions (min, max, within) in param are checked against the restrictions given by parmRef and adjusted if required.

Parameters
[in,out]parmHandleparameter set handle
[in]pathpath to the parameter
[in]paramRefreference parameter for min/max boundaries or string set restrictions
[in]paramparameter
See also
GfParmMergeHandles

Definition at line 2814 of file params.cpp.

Here is the call graph for this function:

◆ parmClean()

static void parmClean ( struct parmHeader conf)
static

Helper function to release the parameter set content.

Parameters
[in]confparameter set header

Definition at line 1719 of file params.cpp.

Here is the call graph for this function:

◆ parmReleaseHandle()

static void parmReleaseHandle ( struct parmHandle parmHandle)
static

Helper function to release the handle and eventually the referenced parameter set (if the reference counter falls to 0).

Parameters
[in]parmHandleparameter set handle
See also
GfParmReleaseHandle
GfParmWriteFile
GfParmReadFile

Definition at line 1802 of file params.cpp.

Here is the call graph for this function:

◆ parmReleaseHeader()

static void parmReleaseHeader ( struct parmHeader conf)
static

Helper function to release the parameter set if the reference counter is 0.

Parameters
[in]confparameter set header
See also
GfParmReleaseHandle
GfParmWriteFile
GfParmReadFile

Definition at line 1765 of file params.cpp.

Here is the call graph for this function:

◆ parserXmlInit()

static int parserXmlInit ( struct parmHandle parmHandle)
static

Helper function to set up XML parser in parmHandle.

Parameters
[in]parmHandleparameter set handle

Definition at line 1072 of file params.cpp.

Here is the call graph for this function:

◆ parseXml()

static int parseXml ( struct parmHandle parmHandle,
char *  buf,
int  len,
int  done 
)
static

Helper function to parse one line of XML.

Parameters
[in,out]parmHandleparameter set handle
[in]bufline to parse
[in]lenbuffer size
[in]donethis was the last slice, no more input available
Returns
0 ok
1 error

Definition at line 1049 of file params.cpp.

Here is the call graph for this function:

◆ removeParam()

static void removeParam ( struct parmHeader conf,
struct section section,
struct param param 
)
static

Helper function to remove given parameter.

Parameters
[in,out]confparameter set header
[in,out]sectionsection to remove parameter from
[in]paramparameter to remove

Definition at line 316 of file params.cpp.

Here is the call graph for this function:

◆ removeParamByName()

static void removeParamByName ( struct parmHeader conf,
const char *  sectionName,
const char *  paramName 
)
static

Helper function to remove a parameter with given name paramName.

Parameters
[in,out]confparameter set header
[in]sectionNamename of the section containing the parameter
[in]paramNamename of the parameter
Note
cleanUnusedSection is called after removing the parameter.

Definition at line 254 of file params.cpp.

Here is the call graph for this function:

◆ removeSection()

static void removeSection ( struct parmHeader conf,
struct section section 
)
static

Helper function to remove a section and its contents (subsections, elements).

Parameters
[in,out]confparameter set header
[in]sectionsection to remove

Definition at line 411 of file params.cpp.

Here is the call graph for this function:

◆ xmlEndElement()

static void xmlEndElement ( void *  userData,
const XML_Char name 
)
static

Helper function to process closing XML elements.

Parameters
[in,out]userDatahandle to parameter set to read data into
[in]namename of the current XML element

Definition at line 943 of file params.cpp.

◆ xmlExternalEntityRefHandler()

static int xmlExternalEntityRefHandler ( XML_Parser  mainparser,
const XML_Char openEntityNames,
const XML_Char base,
const XML_Char systemId,
const XML_Char publicId 
)
static

Helper function to handle external XML entities (XML referencing over multiple files/URI's).

Parameters
[in]mainparserparent XML parser
[in]openEntityNamesspace separated list of names of entities that are open for the parse of this entity
[in]baseunused (base path for resolving system id)
[in]systemIdpath to external entity (SYSTEM in XML)
[in]publicIdunused (public identifier of external entity, PUBLIC in XML)
Returns
1 ok
0 error

Definition at line 973 of file params.cpp.

Here is the call graph for this function:

◆ xmlGetOuputLine()

static int xmlGetOuputLine ( struct parmHandle parmHandle,
char *  buffer,
int  size 
)
static

Helper function to output one line of XML generated from the given parameter set.

The parameter set handle parmHandle keeps track of the progress internally.

Parameters
[in,out]parmHandleparameter set handle
[in,out]bufferbuffer for the line
[in]sizebuffer size
Returns
1 more lines available
0 done

Definition at line 1373 of file params.cpp.

Here is the call graph for this function:

◆ xmlStartElement()

static void xmlStartElement ( void *  userData,
const char *  name,
const char **  atts 
)
static

Helper function to process opening XML elements.

Parameters
[in,out]userDatahandle to parameter set to read data into
[in]namename of the current XML element
[in]attsattributes of the XML element

Definition at line 698 of file params.cpp.

Here is the call graph for this function: