Skip to main content
Version: 🚧 Nightly

Class f3d::options

Definition: options.h (line 30)

Class used to control the different options.

A class to control the different options of f3d.

Inner classes

Members

Constructors

Function options

f3d::options::options()

Default/Copy/move constructors/operators.

Return type:

Function ~options

f3d::options::~options()

Default/Copy/move constructors/operators.

Return type:

Function options

f3d::options::options(const options &opt)

Default/Copy/move constructors/operators.

Parameters:

Return type:

Function operator=

options & f3d::options::operator=(const options &opt)

Default/Copy/move constructors/operators.

Parameters:

Return type: options &

Function options

f3d::options::options(options &&other) noexcept

Default/Copy/move constructors/operators.

Parameters:

Return type:

Function operator=

options & f3d::options::operator=(options &&other) noexcept

Default/Copy/move constructors/operators.

Parameters:

Return type: options &

Public attributes

Variable interactor

Definition: options.h (line 212)

struct f3d::options::interactor f3d::options::interactor

Type: struct f3d::options::interactor

Variable model

Definition: options.h (line 264)

struct f3d::options::model f3d::options::model

Type: struct f3d::options::model

Variable render

Definition: options.h (line 325)

struct f3d::options::render f3d::options::render

Type: struct f3d::options::render

Variable scene

Definition: options.h (line 342)

struct f3d::options::scene f3d::options::scene

Type: struct f3d::options::scene

Variable ui

Definition: options.h (line 371)

struct f3d::options::ui f3d::options::ui

Type: struct f3d::options::ui

Public functions

Function set

options & f3d::options::set(std::string_view name, const option_variant_t &value)

Set an option as a variant based on its name Please note that, on Windows, using an explicit std::string may be required: https://stackoverflow.com/questions/60681710/prefer-stdstring-in-stdvariantbool-stdstring-for-const-char

Throws an options::inexistent_exception if option does not exist. Throws an options::incompatible_exception if value is not compatible with option.

Parameters:

  • std::string_view name
  • const option_variant_t & value

Return type: options &

Function get

option_variant_t f3d::options::get(std::string_view name) const

Get an option as a variant based on its name

Throws an options::inexistent_exception if option does not exist. Throws an options::no_value_exception if option has not been set.

Parameters:

  • std::string_view name

Return type: option_variant_t

Function setAsString

options & f3d::options::setAsString(std::string_view name, const std::string &str)

Set an option as a string based on its name Use dedicated parsing code, see the related doc in PARSING.md.

Throws an options::inexistent_exception if option does not exist. Throws an options::parsing_exception if parsing failed.

Parameters:

  • std::string_view name
  • const std::string & str

Return type: options &

Function getAsString

std::string f3d::options::getAsString(std::string_view name) const

Get an option as a string based on its name

Throws an options::inexistent_exception if option does not exist. Throws an options::no_value_exception if option has not been set.

Parameters:

  • std::string_view name

Return type: std::string

Function toggle

options & f3d::options::toggle(std::string_view name)

A boolean option specific method to toggle it. If the option has not been set yet, set it to true.

Throws an options::inexistent_exception if option does not exist. Throws an options::incompatible_exception if option is not boolean.

Parameters:

  • std::string_view name

Return type: options &

Function isSame

bool f3d::options::isSame(const options &other, std::string_view name) const

Compare an option between this and a provided other. Return true if they are the same value, false otherwise.

Throws an options::inexistent_exception if option does not exist.

Parameters:

  • const options & other
  • std::string_view name

Return type: bool

Function hasValue

bool f3d::options::hasValue(std::string_view name) const

Return true if an option has a value, false otherwise Always returns true for non-optional options.

Throws an options::inexistent_exception if option does not exist.

Parameters:

  • std::string_view name

Return type: bool

Function copy

options & f3d::options::copy(const options &other, std::string_view name)

Copy the value of an option from this to the provided other.

Throws an options::inexistent_exception if option does not exist.

Parameters:

  • const options & other
  • std::string_view name

Return type: options &

Function getNames

std::vector< std::string > f3d::options::getNames() const

Get all option names that currently have values.

Return type: std::vector< std::string >

Function getClosestOption

std::pair< std::string, unsigned int > f3d::options::getClosestOption(std::string_view option) const

Get the closest option name and its Levenshtein distance.

Parameters:

  • std::string_view option

Return type: std::pair< std::string, unsigned int >

Function isOptional

bool f3d::options::isOptional(std::string_view option) const

Returns true if the option is optional else returns false.

Throws an options::inexistent_exception if option does not exist.

Parameters:

  • std::string_view option

Return type: bool

Function reset

options & f3d::options::reset(std::string_view name)

Resets the option to default value.

Throws an options::inexistent_exception if option does not exist.

Parameters:

  • std::string_view name

Return type: options &

Function removeValue

options & f3d::options::removeValue(std::string_view name)

Unset the option if it is optional else throws options::incompatible_exception.

Throws an options::inexistent_exception if option does not exist.

Parameters:

  • std::string_view name

Return type: options &

Public static functions

Function getAllNames

static std::vector< std::string > f3d::options::getAllNames()

Get all available option names.

Return type: std::vector< std::string >

Function parse

static T f3d::options::parse(const std::string &str)

Templated parsing method used internally to parse strings. Implemented for the different supported types, see PARSING.md for more info.

Throws an options::parsing_exception if parsing failed.

Parameters:

  • const std::string & str

Return type: T

Function format

static std::string f3d::options::format(const T &var)

Templated parsing method used internally to format var into strings. Implemented for the different supported types,

see PARSING.md for more info.

Parameters:

  • const T & var

Return type: std::string