This is a default implementation of abstract interface ExpressionRepository which retrieves definitions of named expressions using core mechanics of ALib, namely:
Definition at line 26 of file standardrepository.hpp.
#include <standardrepository.hpp>
Public Field Index: | |
std::vector< AString > | ConfigPaths |
std::vector< std::tuple< Priority, AString, String > > | VariablesLoaded |
Public Method Index: | |
StandardRepository (Configuration *pConfig, ResourcePool *pResources, NString pResCategory) | |
virtual ALIB_API bool | Get (const String &identifier, AString &target) override |
ALIB_API int | StoreLoadedExpressions (Compiler *compiler, Priority slot=Priority::Standard) |
Public Method Index: inherited from ExpressionRepository | |
virtual | ~ExpressionRepository () |
Virtual destructor. | |
Protected Field Index: | |
Configuration * | config |
The configuration object used to retrieve definitions of nested expressions. | |
NString | resourceCategory |
The category within resources to use for searching expression strings. | |
ResourcePool * | resources |
|
protected |
The configuration object used to retrieve definitions of nested expressions.
Definition at line 30 of file standardrepository.hpp.
std::vector<AString> 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 45 of file standardrepository.hpp.
|
protected |
The category within resources to use for searching expression strings.
Definition at line 37 of file standardrepository.hpp.
|
protected |
The resource pool used to retrieve definitions of nested expressions, if not found with configuration data of field config.
Definition at line 34 of file standardrepository.hpp.
Within this vector, all variables that have been loaded from config are stored.
The tuple elements provide:
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.
Definition at line 64 of file standardrepository.hpp.
|
inline |
Constructor.
pConfig | The configuration data to use. May be set to nullptr to omit the use of configuration data. |
pResources | The resources to use. May be set to nullptr to omit the use of resource data. |
pResCategory | The category within resources to use for searching expression strings. |
Definition at line 77 of file standardrepository.hpp.
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.
identifier | The name of the required expression. | |
[out] | target | The target to write the requested expression string to. |
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 ExpressionRepository.
Definition at line 30 of file standardrepository.cpp.
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.
compiler | The compiler that this interface is attached to. |
slot | The slot of the configuration plug-in of which loaded variables are to be written back. |
Definition at line 16 of file standardrepository.cpp.