ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
standardrepository.cpp
1// #################################################################################################
2// ALib C++ Library
3//
4// Copyright 2013-2024 A-Worx GmbH, Germany
5// Published under 'Boost Software License' (a free software license, see LICENSE.txt)
6// #################################################################################################
8
9#if !DOXYGEN
12#endif // !DOXYGEN
13
14namespace alib { namespace expressions {
15
17{
18 int count= 0;
19 for( auto& entry : VariablesLoaded )
20 if( std::get<0>( entry ) == slot )
21 {
22 ++count;
23 Variable var(*config, std::get<1>( entry ), A_CHAR("S") );
24 var= compiler->GetNamed( std::get<2>( entry ))->GetNormalizedString();
25 }
26
27 return count;
28}
29
30bool StandardRepository::Get( const String& identifier, AString& target )
31{
32 if( config != nullptr )
33 {
34 if( ConfigPaths.empty() )
35 ConfigPaths.emplace_back( "" );
36
37 // search in given default categories first.
38 Variable var(*config);
39 for( auto& path : ConfigPaths )
40 {
41 String256 name(path); name << '/' << identifier;
42 if( var.Try(name, A_CHAR("S") ) && var.IsDefined() )
43 {
44 target << var.GetString();
45 VariablesLoaded.emplace_back( var.GetPriority(), name, identifier );
46 return true;
47 }
48 }
49 }
50
51 if( resources != nullptr )
52 {
53 auto& result= resources->Get( resourceCategory, identifier ALIB_DBG(, false) );
54 if( result.IsNotNull() )
55 {
56 target << result;
57 return true;
58 }
59 }
60
61 // failed
62 return false;
63
64}
65
66}} // namespace [alib::expressions]
bool Try(const String &name)
Priority GetPriority() const
virtual ALIB_API Expression GetNamed(const String &name)
Definition compiler.cpp:392
Configuration * config
The configuration object used to retrieve definitions of nested expressions.
std::vector< std::tuple< Priority, AString, String > > VariablesLoaded
NString resourceCategory
The category within resources to use for searching expression strings.
virtual ALIB_API bool Get(const String &identifier, AString &target) override
ALIB_API int StoreLoadedExpressions(Compiler *compiler, Priority slot=Priority::Standard)
virtual const String & Get(const NString &category, const NString &name, bool dbgAssert)=0
#define A_CHAR(STR)
#define ALIB_DBG(...)
Definition alib.hpp:390
Definition alib.cpp:69