TORCS  1.3.9
The Open Racing Car Simulator
Parameter File Handling API

Create, read and write parameter files. More...

Collaboration diagram for Parameter File Handling API:

Functions

void * GfParmReadBuf (char *buffer)
 Read parameter set from memory buffer and return handle to parameter set. More...
 
void * GfParmReadFile (const char *file, int mode)
 Read parameter set from file and return handle to parameter set. More...
 
int GfParmWriteBuf (void *handle, char *buf, int size)
 Write a parameter set into a memory buffer. More...
 
void GfParmSetDTD (void *parmHandle, char *dtd, char *header)
 Set the dtd path and header. More...
 
int GfParmWriteFile (const char *file, void *parmHandle, const char *name)
 Write parameter set into file. More...
 
int GfParmCreateDirectory (const char *file, void *parmHandle)
 Create directory for parameter set handle if it does not yet exist. More...
 
void GfParmClean (void *parmHandle)
 Clean all the parameters of a parameter set. More...
 
void GfParmReleaseHandle (void *parmHandle)
 Release given parameter set handle parmHandle. More...
 
char * GfParmGetFileName (void *handle)
 Get the filename property of the parameter set handle. More...
 
int GfParmCheckHandle (void *ref, void *tgt)
 Check the values in the parameter set tgt against the min/max/within definitions in the ref parameter set. More...
 
void * GfParmMergeHandles (void *ref, void *tgt, int mode)
 Merge two parameter sets into a new one, either containing parameters from ref, tgt or from both sets, the ref and tgt sets are not changed. More...
 

Detailed Description

Create, read and write parameter files.

Function Documentation

◆ GfParmCheckHandle()

int GfParmCheckHandle ( void *  ref,
void *  tgt 
)

Check the values in the parameter set tgt against the min/max/within definitions in the ref parameter set.

Parameters
[in]refreference parameter set handle for check (min/max/within)
[in]tgttarget parameter set handle for check (values)
Returns
0 All checked values are ok
-1 Some values are out of bounds
Note
Only the parameters present in both sets, tgt and ref, are tested. Min/max/within values eventually present in tgt are not checked.
See also
GfParmMergeHandles

Definition at line 2728 of file params.cpp.

Here is the call graph for this function:

◆ GfParmClean()

void GfParmClean ( void *  parmHandle)

Clean all the parameters of a parameter set.

Removes all contained parameters in the parameter set, the parmHande remains valid.

Parameters
[in,out]parmHandleparameter set handle
Returns
0 if OK
-1 if Error

Definition at line 1741 of file params.cpp.

Here is the call graph for this function:

◆ GfParmCreateDirectory()

int GfParmCreateDirectory ( const char *  file,
void *  parmHandle 
)

Create directory for parameter set handle if it does not yet exist.

Parameters
[in]fileif NULL the internally stored path is used, if not NULL the given path is used (it is not stored in the handle)
[in,out]parmHandleparameter set handle
Returns
0 if ok
1 if Error

Definition at line 1665 of file params.cpp.

Here is the call graph for this function:

◆ GfParmGetFileName()

char* GfParmGetFileName ( void *  handle)

Get the filename property of the parameter set handle.

Parameters
[in]handleparameter set handle
Returns
File name
NULL if failed or not set
Note
The pointer returned is for immediate use, if you plan to keep the value for a long time, it is necessary to copy the string, because manipulating the handle will produce an incoherent pointer.

Definition at line 2082 of file params.cpp.

Here is the call graph for this function:

◆ GfParmMergeHandles()

void* GfParmMergeHandles ( void *  ref,
void *  tgt,
int  mode 
)

Merge two parameter sets into a new one, either containing parameters from ref, tgt or from both sets, the ref and tgt sets are not changed.

Used to create a new parameter set from two exising ones, e.g. like the car category and car. If GFPARM_MMODE_SRC mode is used, all parameterers from ref will exist in the new parameter set. If GFPARM_MMODE_DST mode is used, all parameterers from tgt will exist in the new parameter set. You can combine GFPARM_MMODE_SRC and GFPARM_MMODE_DST to get all parameters from both sets into the new set.

The parameter value is taken from the tgt set if the parameter exists in the tgt set. If a parameter exists in both sets (ref and tgt) and has different min/max values, then the greater min value and the smaller max value is selected, so with combining parameters it is only possible to shrink the possible range. If the parameter value does not fit the new min/max range it is adjusted.

Parameters
[in]refreference parameter set handle for merge
[in]tgttarget parameter set handle for merge
[in]modemerge mode, can be any combination (binary or opearator, "|") of:
GFPARM_MMODE_SRC Use parameters from ref and modify parameters existing in tgt with tgt
GFPARM_MMODE_DST Use parameters from tgt and verify parameters existing in ref against ref
GFPARM_MMODE_RELSRC Release ref handle after the merge
GFPARM_MMODE_RELDST Release tgt handle after the merge
Returns
The new handle containing the merge
See also
GfParmCheckHandle

Definition at line 2962 of file params.cpp.

Here is the call graph for this function:

◆ GfParmReadBuf()

void* GfParmReadBuf ( char *  buffer)

Read parameter set from memory buffer and return handle to parameter set.

Parameters
[in]bufferbuffer to read the configuration from
Returns
handle to the parameter set
0 if Error
See also
GfParmWriteBuf

Definition at line 1091 of file params.cpp.

Here is the call graph for this function:

◆ GfParmReadFile()

void* GfParmReadFile ( const char *  file,
int  mode 
)

Read parameter set from file and return handle to parameter set.

Parameters
[in]filename of the file to read
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 error
See also
GfParmWriteFile

Definition at line 1157 of file params.cpp.

Here is the call graph for this function:

◆ GfParmReleaseHandle()

void GfParmReleaseHandle ( void *  parmHandle)

Release given parameter set handle parmHandle.

Releases the parameter set handle and eventally the parameter set which it refers to.

The parameter sets are internally reused and reference counted, so if the parameter set has still a reference counter greater than 0, just the reference counter is decremented, if it reaches 0, the whole parameter set is deleted from memory.

The parameter file is not written on release, write operations are done explicitely with GfParmWriteFile.

Parameters
[in]parmHandleparameter set handle
See also
GfParmWriteFile
GfParmReadFile

Definition at line 1834 of file params.cpp.

Here is the call graph for this function:

◆ GfParmSetDTD()

void GfParmSetDTD ( void *  parmHandle,
char *  dtd,
char *  header 
)

Set the dtd path and header.

Parameters
parmHandleparameter set handle
dtdoptional dtd path
headeroptional header

Definition at line 1584 of file params.cpp.

◆ GfParmWriteBuf()

int GfParmWriteBuf ( void *  handle,
char *  buf,
int  size 
)

Write a parameter set into a memory buffer.

Parameters
[in]handleparameter set handle
[in,out]bufbuffer to write the configuration to (must be big enough)
[in]sizebuffer size
Returns
0 if ok
1 if error

Definition at line 1543 of file params.cpp.

Here is the call graph for this function:

◆ GfParmWriteFile()

int GfParmWriteFile ( const char *  file,
void *  parmHandle,
const char *  name 
)

Write parameter set into file.

Parameters
[in]fileif NULL the internally stored filename is used, if not NULL the given filename is used (it is not stored in the handle)
[in,out]parmHandleparameter set handle
[in]nameif NULL the internally stored name is used, if not NULL the given name is used and stored in the handle
Returns
0 if ok
1 if Error

Definition at line 1610 of file params.cpp.

Here is the call graph for this function: