v_sim.ConfigFileEntry

Fields

None

Methods

getKey ()

getLabel ()

popAllTokens ()

popToken ()

popTokenAsBoolean (values)

popTokenAsColor ()

popTokenAsEnum (toEnum)

popTokenAsFloat (values, clamp)

popTokenAsInt (values, clamp)

setReplace (oldEntry)

setTag (tag)

setVersion (version)

Details

class v_sim.ConfigFileEntry

This is the common name of the structure.

getKey()
Returns:

the key of self.

Return type:

str

An entry is defined by its key.

New in version 3.8.

getLabel()
Returns:

the label as parsed.

Return type:

str or None

An entry can be defined as some values preceeded by a label. After parsing an entry, this label, if it exists can be retrieve with this function. See for instance v_sim.ConfigFile.addBooleanArrayEntry() to define an entry with a label.

New in version 3.8.

popAllTokens()
Returns:

a newly created string.

Return type:

str

Join the remaining tokens of self into a string.

New in version 3.8.

popToken()
Returns:

True if self still has tokens to be retrieved and value has be set.

value:

a location to store a string.

Return type:

(bool, value: str)

Pop a string from a tokenified data line corresponding to self in a configuration file.

New in version 3.8.

popTokenAsBoolean(values)
Parameters:

values ([bool]) – an array of boolean.

Returns:

True if self has nValues boolean tokens to be read.

Return type:

bool

Read nValues as boolean from self and stores them in values. These tokens are poped from the current list of tokens of self.

New in version 3.8.

popTokenAsColor()
Returns:

True if self has a color tokens to be read.

color:

a location to store a v_sim.Color.

Return type:

(bool, color: v_sim.Color)

Like v_sim.ConfigFileEntry.popToken() but convert the token as a v_sim.Color.

New in version 3.8.

popTokenAsEnum(toEnum)
Parameters:

toEnum (v_sim.ConfigFileEnumFunc) – a method to convert a string to an enum value.

Returns:

True if a token can be found and the conversion succeed.

value:

a location to store an enum value.

Return type:

(bool, value: int)

Parse the next non null token in self and parse it with toEnum function. The result, if valid, is stored in value.

New in version 3.8.

popTokenAsFloat(values, clamp)
Parameters:
  • values ([float]) – an array of floats.

  • clamp (float) – a range.

Returns:

True if self has nValues float tokens to be read.

Return type:

bool

Like v_sim.ConfigFileEntry.popTokenAsInt() but for floats.

New in version 3.8.

popTokenAsInt(values, clamp)
Parameters:
  • values ([int]) – an array of integers.

  • clamp (int) – a range.

Returns:

True if self has nValues integer tokens to be read.

Return type:

bool

Like v_sim.ConfigFileEntry.popTokenAsBoolean() but for integers. Additionally conduct a range check using clamp.

New in version 3.8.

setReplace(oldEntry)
Parameters:

oldEntry (v_sim.ConfigFileEntry) – idem.

Use this method to declare that oldEntry has become obsolete and has been replaced by self.

setTag(tag)
Parameters:

tag (str) – a string.

This method is used to set a tag to the given entry. This tag is used to ignore or not the entry when the file is read. The tag argument is copied.

setVersion(version)
Parameters:

version (float) – the version the entry appear in.

Set the version number the entry appear in.