ALib C++ Library
Library Version: 2510 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{
28 int count= 0;
29 for( auto& entry : VariablesLoaded )
30 if( std::get<0>( entry ) == slot )
31 {
32 ++count;
33 Variable var(*config, std::get<1>( entry ), A_CHAR("S") );
34 var= compiler->GetNamed( std::get<2>( entry ))->GetNormalizedString();
35 }
36
37 return count;
38}
39
40bool StandardRepository::Get( const String& identifier, AString& target )
41{
42 if( config != nullptr )
43 {
44 if( ConfigPaths.empty() )
45 ConfigPaths.emplace_back( "" );
46
47 // search in given default categories first.
48 Variable var(*config);
49 for( auto& path : ConfigPaths )
51 String256 name(path); name << '/' << identifier;
52 if( var.Try(name, A_CHAR("S") ) && var.IsDefined() )
53 {
54 target << var.GetString();
55 VariablesLoaded.emplace_back( var.GetPriority(), name, identifier );
56 return true;
57 }
58 }
59 }
60
61 if( resources != nullptr )
62 {
63 auto& result= resources->Get( resourceCategory, identifier ALIB_DBG(, false) );
64 if( result.IsNotNull() )
65 {
66 target << result;
67 return true;
68 }
69 }
70
71 // failed
72 return false;
73
74}
75
76}} // namespace [alib::expressions]
virtual ALIB_DLL Expression GetNamed(const String &name)
Definition compiler.cpp:394
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:836
#define ALIB_LOCK_WITH(lock)
Definition alib.inl:1322
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:2381