ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::expressions::StandardRepository Class Reference

Description:

This is a default implementation of abstract interface ExpressionRepository which retrieves definitions of named expressions using core mechanics of ALib, namely:

  1. Static resource data, and
  2. Configuration data.

Definition at line 16 of file standardrepository.inl.

Inheritance diagram for alib::expressions::StandardRepository:
[legend]
Collaboration diagram for alib::expressions::StandardRepository:
[legend]

Public Field Index:

std::vector< AStringConfigPaths
 
std::vector< std::tuple< Priority, AString, String > > VariablesLoaded
 

Public Method Index:

 StandardRepository (const SharedConfiguration &pConfig, ResourcePool *pResources, NString pResCategory)
 
virtual ALIB_DLL bool Get (const String &identifier, AString &target) override
 
ALIB_DLL int StoreLoadedExpressions (Compiler *compiler, Priority slot=Priority::Standard)
 
- Public Method Index: inherited from alib::expressions::ExpressionRepository
virtual ~ExpressionRepository ()
 Virtual destructor.
 

Protected Field Index:

SharedConfiguration config
 The configuration object used to retrieve definitions of nested expressions.
 
NString resourceCategory
 The category within resources to use for searching expression strings.
 
ResourcePoolresources
 

Field Details:

◆ config

SharedConfiguration alib::expressions::StandardRepository::config
protected

The configuration object used to retrieve definitions of nested expressions.

Definition at line 20 of file standardrepository.inl.

◆ ConfigPaths

std::vector<AString> alib::expressions::StandardRepository::ConfigPaths

May be filled with paths in field config. A named expression's identifier will be first tried to be loaded using each path name added here.

If this is left empty, with the first invocation of method Get, an empty string is added to enable to search an expression in the root of the StringTree of config.

Definition at line 35 of file standardrepository.inl.

◆ resourceCategory

NString alib::expressions::StandardRepository::resourceCategory
protected

The category within resources to use for searching expression strings.

Definition at line 27 of file standardrepository.inl.

◆ resources

ResourcePool* alib::expressions::StandardRepository::resources
protected

The resource pool used to retrieve definitions of nested expressions, if not found with configuration data of field config.

Definition at line 24 of file standardrepository.inl.

◆ VariablesLoaded

std::vector<std::tuple<Priority,AString,String> > alib::expressions::StandardRepository::VariablesLoaded

Within this vector, all variables that have been loaded from config are stored.

The tuple elements provide:

  • the priority (configuration slot),
  • the variable name and
  • the name of the nested expression.

The latter is needed, as it might differ from the combination of the "category" and variable name due to definitions in ConfigPaths.

This vector might be used for various things, e.g., logging out status information. It is also used by method StoreLoadedExpressions.

Note
This list is never cleared by this class. It might be cleared from outside (e.g., to release memory) without causing any side effects, other than those occurring to mechanics an application itself volunteers to implement using this information.

Definition at line 54 of file standardrepository.inl.

Constructor(s) / Destructor Details:

◆ StandardRepository()

alib::expressions::StandardRepository::StandardRepository ( const SharedConfiguration & pConfig,
ResourcePool * pResources,
NString pResCategory )
inline

Constructor.

Parameters
pConfigThe configuration data to use. May be set to nullptr to omit the use of configuration data.
pResourcesThe resources to use. May be set to nullptr to omit the use of resource data.
pResCategoryThe category within resources to use for searching expression strings.

Definition at line 67 of file standardrepository.inl.

Method Details:

◆ Get()

bool alib::expressions::StandardRepository::Get ( const String & identifier,
AString & target )
overridevirtual

Implementation of the central interface method. If invoked, the definition string is first searched in config and if not found, secondly searched in field resources.

Parameters
identifierThe name of the required expression.
[out]targetThe target to write the requested expression string to.
Returns
This true, if the expression string could be retrieved, false otherwise. If true is returned and target is still empty, then the string is defined to be empty, which throws an exception on compilation.

Implements alib::expressions::ExpressionRepository.

Definition at line 40 of file standardrepository.cpp.

Here is the call graph for this function:

◆ StoreLoadedExpressions()

int alib::expressions::StandardRepository::StoreLoadedExpressions ( Compiler * compiler,
Priority slot = Priority::Standard )

Stores back all expression strings which had been automatically loaded from the plug-in of field config, specified by parameter slot. For storing, the normalized expression string is used. Thus, this method may be used to write a "clean" expression string, that does not use abbreviations for identifiers, has no unnecessary whitespaces, etc.

Note the importance of parameter slot: Usually, only such expression variables should be stored that had been loaded from a configuration source that is manually edited by end-users, like INI-files.

Parameters
compilerThe compiler that this interface is attached to.
slotThe slot of the configuration plug-in of which loaded variables are to be written back.
Returns
The number of variables written.

Definition at line 26 of file standardrepository.cpp.

Here is the call graph for this function:

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