TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
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").
static struct param * getParamByName (struct parmHeader *conf, const char *sectionName, const char *paramName, int flag)
 Helper function to get (or create) a parameter by name.
static void removeParamByName (struct parmHeader *conf, const char *sectionName, const char *paramName)
 Helper function to remove a parameter with given name paramName.
static void cleanUnusedSection (struct parmHeader *conf, struct section *section)
 Helper function to clean up unused (empty) sections starting with given section.
static void removeParam (struct parmHeader *conf, struct section *section, struct param *param)
 Helper function to remove given parameter.
static struct param * addParam (struct parmHeader *conf, struct section *section, const char *paramName, const char *value)
 Helper function to add parameter, does not check for duplicated name.
static void removeSection (struct parmHeader *conf, struct section *section)
 Helper function to remove a section and its contents (subsections, elements).
static struct section * getParent (struct parmHeader *conf, const char *sectionName)
 Helper function to get (or create if not found) parent section of section given in sectionName.
static struct section * addSection (struct parmHeader *conf, const char *sectionName)
 Helper function to add a section to a parameter set.
static struct parmHeader * getSharedHeader (const char *file, int mode)
 Helper function for looking up parameter sets in the cache.
static struct parmHeader * createParmHeader (const char *file)
 Helper function to create header for parameter set handle.
static void addWithin (struct param *curParam, char *s1)
 Helper function to add "within" options to parameter curParam.
static tdble getValNumFromStr (const char *str)
 Helper function to parse number.
static void xmlStartElement (void *userData, const char *name, const char **atts)
 Helper function to process opening XML elements.
static void xmlEndElement (void *userData, const XML_Char *name)
 Helper function to process closing XML elements.
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).
static int parseXml (struct parmHandle *parmHandle, char *buf, int len, int done)
 Helper function to parse one line of XML.
static int parserXmlInit (struct parmHandle *parmHandle)
 Helper function to set up XML parser in parmHandle.
static int formatXmlBuffer (char *buf, const int size, const char *format,...)
 Helper function to format text without truncating the output.
static int 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.
static int createIndent (char *buf, const int BUFSIZE, const int blanks)
 Helper function for indentation in the XML.
static int createIn (char *buf, const int BUFSIZE, withinHead *head)
 Helper function to support the serialization into the XML of the "within" attribute.
static int xmlGetOuputLine (struct parmHandle *parmHandle, char *buffer, int size)
 Helper function to output one line of XML generated from the given parameter set.
static void parmClean (struct parmHeader *conf)
 Helper function to release the parameter set content.
static void parmReleaseHeader (struct parmHeader *conf)
 Helper function to release the parameter set if the reference counter is 0.
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).
static void evalUnit (char *unit, tdble *dest, int flg)
 Support function to multiply or divide dest with unit conversion factor.
static void insertParamMerge (struct parmHandle *parmHandle, char *path, struct param *paramRef, struct param *param)
 Helper function to merge a parameter into a parameter set.
static void insertParam (struct parmHandle *parmHandle, char *path, struct param *param)
 Helper function to insert a parameter into a parameter set.

Detailed Description

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

Function Documentation

◆ addParam()

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 351 of file params.cpp.

Here is the call graph for this function:

◆ addSection()

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 486 of file params.cpp.

Here is the call graph for this function:

◆ addWithin()

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 653 of file params.cpp.

◆ cleanUnusedSection()

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 296 of file params.cpp.

Here is the call graph for this function:

◆ createIn()

int 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
Returns
0 if ok
-1 if error

Definition at line 1398 of file params.cpp.

◆ createIndent()

int 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
Returns
0 if ok
-1 if error

Definition at line 1368 of file params.cpp.

◆ createParmHeader()

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 587 of file params.cpp.

Here is the call graph for this function:

◆ evalUnit()

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 1988 of file params.cpp.

◆ formatXmlBuffer()

int formatXmlBuffer ( char * buf,
const int size,
const char * format,
... )
static

Helper function to format text without truncating the output.

Parameters
[in,out]bufbuffer for the formatted output
[in]sizebuffer size
[in]formatprintf-style format string
Returns
0 if ok
-1 if error

Definition at line 1274 of file params.cpp.

◆ getFullName()

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 192 of file params.cpp.

◆ getParamByName()

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 218 of file params.cpp.

Here is the call graph for this function:

◆ getParent()

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 446 of file params.cpp.

Here is the call graph for this function:

◆ getSharedHeader()

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 551 of file params.cpp.

Here is the call graph for this function:

◆ getValNumFromStr()

tdble getValNumFromStr ( const char * str)
static

Helper function to parse number.

Parameters
[in]strnumber as string
Returns
number

Definition at line 679 of file params.cpp.

◆ handleEntities()

int 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
0 if ok
-1 if error

Definition at line 1307 of file params.cpp.

◆ insertParam()

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 3063 of file params.cpp.

Here is the call graph for this function:

◆ insertParamMerge()

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 2971 of file params.cpp.

Here is the call graph for this function:

◆ parmClean()

void parmClean ( struct parmHeader * conf)
static

Helper function to release the parameter set content.

Parameters
[in]confparameter set header

Definition at line 1850 of file params.cpp.

Here is the call graph for this function:

◆ parmReleaseHandle()

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 1931 of file params.cpp.

Here is the call graph for this function:

◆ parmReleaseHeader()

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 1894 of file params.cpp.

Here is the call graph for this function:

◆ parserXmlInit()

int parserXmlInit ( struct parmHandle * parmHandle)
static

Helper function to set up XML parser in parmHandle.

Parameters
[in]parmHandleparameter set handle

Definition at line 1077 of file params.cpp.

Here is the call graph for this function:

◆ parseXml()

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 1054 of file params.cpp.

Here is the call graph for this function:

◆ removeParam()

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 321 of file params.cpp.

Here is the call graph for this function:

◆ removeParamByName()

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 259 of file params.cpp.

Here is the call graph for this function:

◆ removeSection()

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 416 of file params.cpp.

Here is the call graph for this function:

◆ xmlEndElement()

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 948 of file params.cpp.

◆ xmlExternalEntityRefHandler()

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 978 of file params.cpp.

Here is the call graph for this function:

◆ xmlGetOuputLine()

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
-1 error

Definition at line 1456 of file params.cpp.

Here is the call graph for this function:

◆ xmlStartElement()

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 703 of file params.cpp.

Here is the call graph for this function: