UCILoader 1.1.2
Small C++ library that allows user to connect to a chess engines via UCI protocol.
Loading...
Searching...
No Matches
UCILoader::EngineOptionProxy Class Reference

Proxy object for interacting with a UCI engine option. More...

#include <EngineConnection.h>

Classes

class  NotSupportedValueException
 Exception thrown when setting an option to an unsupported value. More...
 
class  ParsingError
 Exception thrown when parsing fails for a miscellaneus reason. More...
 
class  WrongTypeError
 Exception thrown when an operation is incompatible with the option type. More...
 

Public Member Functions

 EngineOptionProxy (const Option &option, std::shared_ptr< AbstractPipeWriter > pipeWriter)
 
 EngineOptionProxy (const EngineOptionProxy &other)
 
OptionType type () const
 Get the option type.
 
const std::string & id () const
 Get the option name.
 
const Option & getAsOption () const
 Get the full Option object with all metadata.
 
void click ()
 Activate a button option.
 
const std::string & operator= (const std::string &value)
 Set option value from a string.
 
const char * operator= (const char *value)
 Set option value from a C-string.
 
const int32_t & operator= (const int32_t &number)
 Set a spin option to an integer value.
 
const bool & operator= (const bool &value)
 Set a check option to a boolean value.
 
 operator bool ()
 Get check option value as boolean.
 
 operator int ()
 Get spin option value as integer.
 
 operator std::string ()
 Get option value as string.
 

Detailed Description

Proxy object for interacting with a UCI engine option.

EngineOptionProxy provides a convenient interface for reading and modifying engine options. Instances are typically obtained through bracket notation on EngineInstance::options:

auto& hashOption = instance->options["Hash"];

Assigning values to this proxy automatically sends the appropriate setoption UCI command to the engine. The initial value is the engine's declared default.

See also
EngineInstance::options

Member Function Documentation

◆ click()

void UCILoader::EngineOptionProxy::click ( )

Activate a button option.

Exceptions
WrongTypeErrorif the option type is not Button

◆ getAsOption()

const Option & UCILoader::EngineOptionProxy::getAsOption ( ) const
inline

Get the full Option object with all metadata.

Returns
Const reference to the underlying Option

Useful for exporting or inspecting the full option configuration including type-specific details.

◆ id()

const std::string & UCILoader::EngineOptionProxy::id ( ) const
inline

Get the option name.

Returns
The option identifier (e.g., "Hash", "UCI_ShowWDL", "Clear Hash")

◆ operator bool()

UCILoader::EngineOptionProxy::operator bool ( )

Get check option value as boolean.

Exceptions
WrongTypeErrorif option type is not Check
Returns
The boolean option value

◆ operator int()

UCILoader::EngineOptionProxy::operator int ( )

Get spin option value as integer.

Exceptions
WrongTypeErrorif option type is not Spin
Returns
The integer option value

◆ operator std::string()

UCILoader::EngineOptionProxy::operator std::string ( )

Get option value as string.

Exceptions
WrongTypeErrorif option type is Button
Returns
The string representation of the option value

◆ operator=() [1/4]

const bool & UCILoader::EngineOptionProxy::operator= ( const bool &  value)

Set a check option to a boolean value.

Parameters
valueThe boolean state (true or false)
Returns
Reference to the assigned value
Exceptions
WrongTypeErrorif option type is not Check

◆ operator=() [2/4]

const char * UCILoader::EngineOptionProxy::operator= ( const char *  value)

Set option value from a C-string.

Parameters
valueThe C-string value to assign
Returns
Pointer to the assigned value
Exceptions
ParsingErrorif value cannot be parsed as integer for a spin option
NotSupportedValueExceptionif value violates option constraints
WrongTypeErrorif trying to set a Button option
See also
NotSupportedValueException for validation rules by option type

◆ operator=() [3/4]

const int32_t & UCILoader::EngineOptionProxy::operator= ( const int32_t &  number)

Set a spin option to an integer value.

Parameters
numberThe integer value to assign
Returns
Reference to the assigned value
Exceptions
NotSupportedValueExceptionif number is outside the valid range [min, max]
WrongTypeErrorif option type is not Spin
See also
getAsOption().spin_content() to check min/max range

◆ operator=() [4/4]

const std::string & UCILoader::EngineOptionProxy::operator= ( const std::string &  value)

Set option value from a string.

Parameters
valueThe string value to assign
Returns
Reference to the assigned value
Exceptions
ParsingErrorif value cannot be parsed as integer for a spin option
NotSupportedValueExceptionif value violates option constraints
WrongTypeErrorif trying to set a Button option
See also
NotSupportedValueException for validation rules by option type

◆ type()

OptionType UCILoader::EngineOptionProxy::type ( ) const
inline

Get the option type.

Returns
The OptionType (Button, Check, Spin, Combo, or String)

The documentation for this class was generated from the following files: