ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
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 26 of file standardrepository.hpp.

#include <standardrepository.hpp>

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

Public Field Index:

std::vector< AStringConfigPaths
 
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:

Configurationconfig
 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

Configuration* config
protected

The configuration object used to retrieve definitions of nested expressions.

Definition at line 30 of file standardrepository.hpp.

◆ ConfigPaths

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.

◆ resourceCategory

NString resourceCategory
protected

The category within resources to use for searching expression strings.

Definition at line 37 of file standardrepository.hpp.

◆ resources

ResourcePool* resources
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.

◆ VariablesLoaded

std::vector<std::tuple<Priority,AString,String> > 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 64 of file standardrepository.hpp.

Constructor(s) / Destructor Details:

◆ StandardRepository()

StandardRepository ( Configuration * 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 77 of file standardrepository.hpp.

Method Details:

◆ Get()

bool 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 ExpressionRepository.

Definition at line 30 of file standardrepository.cpp.

Here is the call graph for this function:

◆ StoreLoadedExpressions()

int 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 16 of file standardrepository.cpp.

Here is the call graph for this function:

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