Bayeux  3.4.1
Core Foundation library for SuperNEMO
Public Types | Public Member Functions | List of all members
datatools::configuration::variant_preprocessor Class Reference

Configuration variant string preprocessor. More...

#include <bayeux/datatools/configuration/io.h>

Public Types

enum  flag_type { FLAG_TRACE = datatools::bit_mask::bit00, FLAG_REMOVE_QUOTES = datatools::bit_mask::bit01 }
 Construction flags. More...
 

Public Member Functions

bool is_remove_quotes () const
 Check the remove quotes flag. More...
 
void set_remove_quotes (bool)
 Set the remove quotes flag. More...
 
 variant_preprocessor (unsigned int flags_=0)
 Default constructor. More...
 
bool has_repository () const
 Check if a variant configuration repository is used. More...
 
void set_repository (const variant_repository &repository_)
 Set the variant configuration repository. More...
 
void reset_repository ()
 Reset the variant configuration repository. More...
 
bool repository_is_active () const
 Check if the variant configuration repository is active. More...
 
const variant_repositoryget_repository () const
 Get the variant configuration repository. More...
 
command::returned_info preprocess (const std::string &source_, std::string &target_) const
 Process a source string into a target string. More...
 
std::string preprocess_string (const std::string &source_) const
 Process a source string into a target string. More...
 
bool preprocess_boolean (const std::string &source_) const
 Process a source string into a target boolean. More...
 
int preprocess_integer (const std::string &source_) const
 Process a source string into a target integer. More...
 
double preprocess_real (const std::string &source_) const
 Process a source string into a target double. More...
 
void preprocess_args_options (int argc_, char **argv_, std::vector< std::string > &preprocessed_args_)
 Process a list of arguments and options. More...
 
void preprocess_args_options (const std::vector< std::string > &args_, std::vector< std::string > &preprocessed_args_)
 Process a list of arguments and options. More...
 
command::returned_info preprocess_parameter (const std::string &parameter_token_, std::string &parameter_effective_token_) const
 Process a source string into a target string as a variant parameter. More...
 
command::returned_info resolve_variant (const std::string &variant_desc_, bool &variant_active_, bool &variant_reverse_) const
 
logger::priority get_logging () const
 Return the logging priority. More...
 
void set_logging (logger::priority)
 Set the logging priority. More...
 

Detailed Description

Configuration variant string preprocessor.

Member Enumeration Documentation

◆ flag_type

Construction flags.

Enumerator
FLAG_TRACE 

Flag to print trace messages.

FLAG_REMOVE_QUOTES 

Flag to remove quotes around string parameters.

Constructor & Destructor Documentation

◆ variant_preprocessor()

datatools::configuration::variant_preprocessor::variant_preprocessor ( unsigned int  flags_ = 0)

Default constructor.

Member Function Documentation

◆ get_logging()

logger::priority datatools::configuration::variant_preprocessor::get_logging ( ) const

Return the logging priority.

◆ get_repository()

const variant_repository& datatools::configuration::variant_preprocessor::get_repository ( ) const

Get the variant configuration repository.

◆ has_repository()

bool datatools::configuration::variant_preprocessor::has_repository ( ) const

Check if a variant configuration repository is used.

◆ is_remove_quotes()

bool datatools::configuration::variant_preprocessor::is_remove_quotes ( ) const

Check the remove quotes flag.

◆ preprocess()

command::returned_info datatools::configuration::variant_preprocessor::preprocess ( const std::string &  source_,
std::string &  target_ 
) const

Process a source string into a target string.

◆ preprocess_args_options() [1/2]

void datatools::configuration::variant_preprocessor::preprocess_args_options ( int  argc_,
char **  argv_,
std::vector< std::string > &  preprocessed_args_ 
)

Process a list of arguments and options.

The 'argc_' and 'argv_' parameters should be the same as passed to 'main'.

◆ preprocess_args_options() [2/2]

void datatools::configuration::variant_preprocessor::preprocess_args_options ( const std::vector< std::string > &  args_,
std::vector< std::string > &  preprocessed_args_ 
)

Process a list of arguments and options.

The 'args_' parameter should not include program name.

◆ preprocess_boolean()

bool datatools::configuration::variant_preprocessor::preprocess_boolean ( const std::string &  source_) const

Process a source string into a target boolean.

◆ preprocess_integer()

int datatools::configuration::variant_preprocessor::preprocess_integer ( const std::string &  source_) const

Process a source string into a target integer.

◆ preprocess_parameter()

command::returned_info datatools::configuration::variant_preprocessor::preprocess_parameter ( const std::string &  parameter_token_,
std::string &  parameter_effective_token_ 
) const

Process a source string into a target string as a variant parameter.

◆ preprocess_real()

double datatools::configuration::variant_preprocessor::preprocess_real ( const std::string &  source_) const

Process a source string into a target double.

◆ preprocess_string()

std::string datatools::configuration::variant_preprocessor::preprocess_string ( const std::string &  source_) const

Process a source string into a target string.

◆ repository_is_active()

bool datatools::configuration::variant_preprocessor::repository_is_active ( ) const

Check if the variant configuration repository is active.

◆ reset_repository()

void datatools::configuration::variant_preprocessor::reset_repository ( )

Reset the variant configuration repository.

◆ resolve_variant()

command::returned_info datatools::configuration::variant_preprocessor::resolve_variant ( const std::string &  variant_desc_,
bool &  variant_active_,
bool &  variant_reverse_ 
) const

Parse a string and check if a given configuration variant is activate

Parameters
variant_desc_The string to be parsed
variant_active_The flag that checks if the variant is activated
variant_reverse_The flag that checks if the test must be reversed
Returns
The command error record with supported error codes:
      command::CEC_SUCCESS : variant has been succesfully resolved or default value is used
      command::CEC_PARSING_FAILURE : syntax error in variant description
      command::CEC_CONTEXT_INVALID : variant repository is not activated
      command::CEC_SCOPE_INVALID : variant registry is unknown
      command::CEC_PARAMETER_INVALID_KEY : variant record is unknown

Supported syntax is:

Case 1:

geometry:has_detector_0/if_detector

The 'variant_active_' value is set to true if the 'geometry:has_detector_0/if_detector' variant is found activated from the variant repository. The 'variant_reverse_' flag is set to false.

Case 2:

geometry:has_detector_0/if_detector|true

The 'variant_active_' value is set to true if the 'geometry:has_detector_0/if_detector' variant is found activated from the variant repository. The 'variant_reverse_' flag is set to false. if the 'geometry:has_detector_0/if_detector' variant is not found from the variant repository, the 'variant_active_' is set to 'true' by default.

Case 3:

!geometry:has_detector_0/if_detector

The 'variant_active_' value is set to true if the 'geometry:has_detector_0/if_detector' variant is found activated from the variant repository, false elsewhere. The 'variant_reverse_' flag is set to true to indicate that the test uses reversed logic.

◆ set_logging()

void datatools::configuration::variant_preprocessor::set_logging ( logger::priority  )

Set the logging priority.

◆ set_remove_quotes()

void datatools::configuration::variant_preprocessor::set_remove_quotes ( bool  )

Set the remove quotes flag.

◆ set_repository()

void datatools::configuration::variant_preprocessor::set_repository ( const variant_repository repository_)

Set the variant configuration repository.


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