ALib C++ Library
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
standardrepository.cpp
1//##################################################################################################
2// ALib C++ Library
3//
4// Copyright 2013-2025 A-Worx GmbH, Germany
5// Published under 'Boost Software License' (a free software license, see LICENSE.txt)
6//##################################################################################################
7#include "alib_precompile.hpp"
8#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
9# error "Symbol ALIB_C20_MODULES has to be given to the compiler as either 0 or 1"
10#endif
11#if ALIB_C20_MODULES
12 module;
13#endif
14//========================================= Global Fragment ========================================
16
17//============================================== Module ============================================
18#if ALIB_C20_MODULES
19 module ALib.Expressions;
20#else
21# include "ALib.Expressions.H"
22#endif
23//========================================== Implementation ========================================
24namespace alib { namespace expressions {
25
27 int count= 0;
28 for( auto& entry : VariablesLoaded )
29 if( std::get<0>( entry ) == slot ) {
30 ++count;
31 Variable var(*config, std::get<1>( entry ), A_CHAR("S") );
32 var= compiler->GetNamed( std::get<2>( entry ))->GetNormalizedString();
33 }
34
35 return count;
36}
37
38bool StandardRepository::Get( const String& identifier, AString& target ) {
39 if( config != nullptr ) {
40 if( ConfigPaths.empty() )
41 ConfigPaths.emplace_back( "" );
42
43 // search in given default categories first.
44 Variable var(*config);
45 for( auto& path : ConfigPaths )
47 String256 name(path); name << '/' << identifier;
48 if( var.Try(name, A_CHAR("S") ) && var.IsDefined() ) {
49 target << var.GetString();
50 VariablesLoaded.emplace_back( var.GetPriority(), name, identifier );
51 return true;
52 } } }
53
54 if( resources != nullptr ) {
55 auto& result= resources->Get( resourceCategory, identifier ALIB_DBG(, false) );
56 if( result.IsNotNull() ) {
57 target << result;
58 return true;
59 } }
60
61 // failed
62 return false;
63
64}
65
66}} // namespace [alib::expressions]
virtual ALIB_DLL Expression GetNamed(const String &name)
Definition compiler.cpp:375
ALIB_DLL int StoreLoadedExpressions(Compiler *compiler, Priority slot=Priority::Standard)
std::vector< std::tuple< Priority, AString, String > > VariablesLoaded
SharedConfiguration config
The configuration object used to retrieve definitions of nested expressions.
NString resourceCategory
The category within resources to use for searching expression strings.
virtual ALIB_DLL bool Get(const String &identifier, AString &target) override
bool Try(const String &name)
#define A_CHAR(STR)
#define ALIB_DBG(...)
Definition alib.inl:853
#define ALIB_LOCK_WITH(lock)
Definition alib.inl:1339
LocalString< 256 > String256
Type alias name for TLocalString<character,256>.
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
variables::Variable Variable
Type alias in namespace alib.
alib::variables::Priority Priority
Type alias in namespace alib.
strings::TString< character > String
Type alias in namespace alib.
Definition string.inl:2189