ALib C++ Library
Library Version: 2402 R1
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 34 of file standardrepository.hpp.

#include <standardrepository.hpp>

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

Public Field Index:

std::vector< AStringDefaultCategories
 
std::vector< std::tuple< Priorities, AString, 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, Priorities slot=Priorities::Standard)
 
- Public Method Index: inherited from ExpressionRepository
virtual ~ExpressionRepository ()
 

Field Details:

◆ config

Configuration* config
protected

The configuration object used to retrieve definitions of nested expressions.

Definition at line 43 of file standardrepository.hpp.

◆ DefaultCategories

std::vector<AString> DefaultCategories

May be filled with category names of field config. A named expression's identifier will be first tried to be loaded using each category name added here. If this fails, it is checked if an underscore '_'character is found in the name, if yes, it is then tried to extract the category from the variable name.

Note
To allow to search in the unnamed-category as well, an empty string may be added.

Definition at line 65 of file standardrepository.hpp.

◆ resourceCategory

NString resourceCategory
protected

The category within resources to use for searching expression strings.

Definition at line 54 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 49 of file standardrepository.hpp.

◆ var

Variable var
protected

A variable object, reused (performance vs memory)

Definition at line 38 of file standardrepository.hpp.

◆ VariablesLoaded

std::vector<std::tuple<Priorities,AString,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 category name,
  • 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 DefaultCategories.

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 87 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 101 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 39 of file standardrepository.cpp.

Here is the call graph for this function:

◆ StoreLoadedExpressions()

int StoreLoadedExpressions ( Compiler * compiler,
Priorities slot = Priorities::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 23 of file standardrepository.cpp.

Here is the call graph for this function:

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