8#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
9# error "Configuration MACRO ALIB_C20_MODULES has to be given to the compiler as either 0 or 1"
23 module ALib.Camp.Base;
27# if !ALIB_SINGLE_THREADED
31 import ALib.Strings.Tokenizer;
33 import ALib.Strings.StdIOStream;
34 import ALib.Strings.Calendar;
35 import ALib.Strings.Tokenizer;
37 import ALib.EnumRecords.Bootstrap;
38 import ALib.Exceptions;
40 import ALib.Variables;
41 import ALib.Variables.IniFile;
43 import ALib.ThreadModel;
46 import ALib.BitBuffer;
49 import ALib.Format.StdImplementation;
50 import ALib.Format.FormatterPythonStyle;
51 import ALib.Format.FormatterJavaStyle;
56# if !ALIB_SINGLE_THREADED
89 #if ALIB_DEBUG && !ALIB_DEBUG_ASSERTION_PRINTABLES
91 "Instances of class Basecamp must not be created. Use singleton alib::BASECAMP" )
100#if !ALIB_CAMP_OMIT_DEFAULT_RESOURCES
105 "Alignment",
A_CHAR(
"0" "," "Left" "," "1" ","
106 "1" "," "Right" "," "1" ","
107 "2" "," "Center" "," "1" ),
109 "Bool",
A_CHAR(
"0" "," "False" "," "1" ","
110 "1" "," "True" "," "1" ","
111 "0" "," "0" "," "1" ","
112 "1" "," "1" "," "1" ","
113 "0" "," "No" "," "1" ","
114 "1" "," "Yes" "," "1" ","
115 "0" "," "Off" "," "2" ","
116 "1" "," "On" "," "2" ","
117 "0" "," "-" "," "1" ","
118 "1" "," "Ok" "," "2" ),
120 "Caching",
A_CHAR(
"0" "," "Disabled" "," "1" ","
121 "1" "," "Enabled" "," "1" ","
122 "1" "," "Auto" "," "1" ),
124 "Case",
A_CHAR(
"0" "," "Sensitive" "," "1" ","
125 "1" "," "Ignore" "," "1" ),
127 "ContainerOp",
A_CHAR(
"0" "," "Insert" "," "1" ","
128 "1" "," "Remove" "," "1" ","
129 "3" "," "GetCreate" "," "4" ","
130 "2" "," "Get" "," "1" ","
131 "4" "," "Create" "," "1" ),
136 "CurrentData",
A_CHAR(
"0" "," "Keep" "," "1" ","
137 "1" "," "Clear" "," "1" ),
139 "Inclusion",
A_CHAR(
"0" "," "Include" "," "1" ","
140 "1" "," "Exclude" "," "1" ),
142 "Initialization",
A_CHAR(
"0" "," "Suppress" "," "1" ","
143 "1" "," "Default" "," "1" ","
144 "2" "," "Nulled" "," "1" ","
145 "0" "," "None" "," "2" ","
146 "1" "," "Initialize" "," "1" ","
147 "2" "," "Zero" "," "1" ),
149 "LineFeeds",
A_CHAR(
"0" "," "None" "," "1" ","
150 "0" "," "Ignore" "," "1" ","
151 "1" "," "Unix" "," "1" ","
152 "2" "," "WindowsOS" "," "1" ","
153 "3" "," "Platform" "," "1" ),
155 "Phase",
A_CHAR(
"0" "," "Begin" "," "1" ","
156 "1" "," "End" "," "1" ),
158 "Propagation",
A_CHAR(
"0" "," "Omit" "," "1" ","
159 "1" "," "ToDescendants" "," "1" ),
161 "Reach",
A_CHAR(
"0" "," "Global" "," "1" ","
162 "1" "," "Local" "," "1" ),
166 "Responsibility",
A_CHAR(
"0" "," "KeepWithSender" "," "1" ","
167 "1" "," "Transfer" "," "1" ),
169 "Safeness",
A_CHAR(
"0" "," "Safe" "," "1" ","
170 "1" "," "Unsafe" "," "1" ),
172 "Side",
A_CHAR(
"0" "," "Left" "," "1" ","
173 "1" "," "Right" "," "1" ),
175 "SortOrder",
A_CHAR(
"0" "," "Ascending" "," "1" ","
176 "1" "," "Descending" "," "1" ),
178 "SourceData",
A_CHAR(
"0" "," "Copy" "," "1" ","
179 "1" "," "Move" "," "1" ),
181 "Switch",
A_CHAR(
"0" "," "Off" "," "2" ","
182 "1" "," "On" "," "2" ),
184 "Timezone",
A_CHAR(
"0" "," "Local" "," "1" ","
185 "1" "," "UTC" "," "1" ),
187 "Timing",
A_CHAR(
"0" "," "Async" "," "1" ","
188 "1" "," "Sync" "," "1" ","
189 "0" "," "Asynchronous" "," "1" ","
190 "1" "," "Synchronous" "," "1" ","
191 "1" "," "Synchronized" "," "1" ),
193 "ValueReference",
A_CHAR(
"0" "," "Absolute" "," "1" ","
194 "1" "," "Relative" "," "1" ),
196 "Whitespaces",
A_CHAR(
"0" "," "Trim" "," "1" ","
197 "1" "," "Keep" "," "1" ),
201 "TSts",
A_CHAR(
"0" "," "Unstarted" "," "1" ","
202 "1" "," "Started" "," "3" ","
203 "2" "," "Running" "," "1" ","
204 "3" "," "Done" "," "3" ","
205 "4" "," "Terminated" "," "1" ),
208 "TMDWP",
A_CHAR(
"0" "," "Lowest" "," "4" ","
209 "500" "," "DeferredDeletion" "," "1" ","
210 "1000" "," "Low" "," "1" ","
211 "2000" "," "Standard" "," "1" ","
212 "4000" "," "Highest" "," "5" ","
213 "3000" "," "High" "," "1" ),
220 "VARE<",
A_CHAR(
"variables::"),
221 "VARE" ,
A_CHAR(
"0" "," "OK" "," "" ","
222 "1" "," "ErrorOpeningFile" "," "VARERF" ","
223 "2" "," "ErrorWritingFile" "," "VAREWF" ),
225 "VARERF",
A_CHAR(
"Can't open {}file {!Q'} for reading.") ,
226 "VAREWF",
A_CHAR(
"Can't open {}file {!Q'} for writing.") ,
229 "VarPrio",
A_CHAR(
"0" "," "NONE" ",1,"
230 "1000" "," "AutoDetected" ",1,"
231 "2000" "," "DefaultValues" ",1,"
232 "4000" "," "Standard" ",1,"
233 "6000" "," "ConfigFile" ",2,"
234 "8000" "," "Environment" ",1,"
235 "10000" "," "SessionFile" ",8,"
236 "12000" "," "CLI" ",2,"
237 "14000" "," "Session" ",2,"
238 "max" "," "Protected" ",1" ),
241 "CFGPlgEnv" ,
A_CHAR(
"Environment Variables") ,
242 "CFGPlgCLI" ,
A_CHAR(
"Command Line Arguments") ,
244 "CFGIniWB" ,
A_CHAR(
"writeback") ,
255DOX_MARKER([DOX_VARIABLES_DECLARATION6])
256"Var0",
A_CHAR(
"1|ALIB/LOCALE|" "S" ),
257"Var1",
A_CHAR(
"2|ALIB/WAIT_FOR_KEY_PRESS|" "B" ),
258"Var2",
A_CHAR(
"3|ALIB/HAS_CONSOLE_WINDOW|" "B" ),
260"Var_C1",
A_CHAR(
"Defines the locale of the application. If empty or not set, the system's locale is used.\n"
261 "If set, a UTF8 locale should be used, for example, 'us_US.UTF-8' or 'de_DE.UTF-8'" ),
262"Var_C2",
A_CHAR(
"If true, the process waits for a key stroke on termination. If empty, under Windows" "\n"
263 "behavior is detected, under other OSes, defaults to false." ),
264"Var_C3",
A_CHAR(
"Boolean value that denotes what its name indicates. If empty, under Windows value is " "\n"
265 "detected, under other OSes, defaults to true." ),
266DOX_MARKER([DOX_VARIABLES_DECLARATION6])
270 "CFG_SECT_CMT_ALIB",
A_CHAR(
"@>'/// '@HL-General ALib library settings.\n@HL-"),
273 "EXIT_MSG" ,
A_CHAR(
"ALIB: Press 'Enter' to exit..." ),
276 "ACAlgos" ,
A_CHAR(
"0" ",NONE" "," "1" ","
277 "31" ",ALL" "," "1" ","
278 "1" ",Uncompressed" "," "1" ","
279 "2" ",MinMax" "," "1" ","
280 "4" ",Sparse" "," "1" ","
281 "8" ",VerySparse" "," "1" ","
282 "16" ",Incremental" "," "1" ","
283 "32" ",Huffman" "," "1" ),
287 "Months" ,
A_CHAR(
"January,February,March,April,May,June,July,August,September,October,November,December")
288 ,
"Days" ,
A_CHAR(
"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,") EOS
290 "DurUnts" ,
A_CHAR(
"zero time" ","
306 "FMTDT" ,
A_CHAR(
"yyyy-MM-dd HH:mm:ss"),
307 "FMTCI" ,
A_CHAR(
"[@ sf:sl from ''ya'' by ''ta'']"),
308 "FMTCINT",
A_CHAR(
"<None>"),
309 "FMTCINY",
A_CHAR(
"<None>"),
310 "FMTCINR",
A_CHAR(
"<Null>"),
313 "SF",
A_CHAR(
"0,Root" ",1,"
319 "6,VarTemp" ",1" ) EOS
323 "ExcFmtExc",
A_CHAR(
"\nAn exception occurred while formatting another (!) exception:\n" ),
326 "PHT",
A_CHAR(
"0,NotGiven" ",1,"
339 "FE<",
A_CHAR(
"format::"),
342 "FE0" ,
A_CHAR(
"11,ArgumentIndexIs0" ",FMG11" ),
343 "FE1" ,
A_CHAR(
"12,ArgumentIndexOutOfBounds" ",FMG12" ),
344 "FE2" ,
A_CHAR(
"13,IncompatibleTypeCode" ",FMG13" ),
347 "FE3" ,
A_CHAR(
"101,MissingClosingBracket" ",FPS101" ),
348 "FE4" ,
A_CHAR(
"102,MissingPrecisionValuePS" ",FPS102" ),
349 "FE5" ,
A_CHAR(
"103,DuplicateTypeCode" ",FPS103" ),
350 "FE6" ,
A_CHAR(
"104,UnknownTypeCode" ",FPS104" ),
351 "FE7" ,
A_CHAR(
"105,ExclamationMarkExpected" ",FPS105" ),
352 "FE8" ,
A_CHAR(
"106,UnknownConversionPS" ",FPS106" ),
353 "FE9" ,
A_CHAR(
"107,PrecisionSpecificationWithInteger" ",FPS107" ),
354 "FE10",
A_CHAR(
"108,MissingReplacementStrings" ",FPS108" ),
357 "FE11" ,
A_CHAR(
"201,NegativeValuesInBracketsNotSupported" ",FJS101" ),
358 "FE12" ,
A_CHAR(
"202,MissingPrecisionValueJS" ",FJS102" ),
359 "FE13" ,
A_CHAR(
"203,HexadecimalFloatFormatNotSupported" ",FJS103" ),
360 "FE14" ,
A_CHAR(
"204,NoAlternateFormOfConversion" ",FJS104" ),
361 "FE15" ,
A_CHAR(
"205,NoPrecisionWithConversion" ",FJS105" ),
362 "FE16" ,
A_CHAR(
"206,UnknownDateTimeConversionSuffix" ",FJS106" ),
363 "FE17" ,
A_CHAR(
"207,UnknownConversionJS" ",FJS107" ),
366 "FE18" ,
A_CHAR(
"501,UnknownPropertyInFormatString" ",PFM501" ),
367 "FE19" ,
A_CHAR(
"502,ErrorInResultingFormatString" ",PFM502" ),
368 "FE20" ,
A_CHAR(
"510,MissingConfigurationVariable" ",PFM510" ),
371 "FE21" ,
A_CHAR(
"601,UnknownMarker" ",ST601" ),
372 "FE22" ,
A_CHAR(
"602,EndmarkerWithoutStart" ",ST602" ),
375 "FMG11" ,
A_CHAR(
"Argument index 0 not allowed.\n"
376 "In: {!Q}\n >{!FillC-}^" ),
377 "FMG12" ,
A_CHAR(
"Argument index #{} is out of bounds. {} arguments are available.\n"
378 "In: {!Q}\n >{!FillC-}^" ),
379 "FMG13" ,
A_CHAR(
"Detected placeholder type does not match given argument.\n"
380 "Placeholder number: {}\n"
381 "Placeholder type: {} ({})\n" )
382 "Deduced argument type: {!Q}\n"
384 A_CHAR(
"Native argument type: <{}>\n" )
385 "In: {!Q}\n >{!FillC-}^" ),
388 "FPS101" ,
A_CHAR(
"Closing bracket '}}' of placeholder not found (or syntax error).\n"
389 "In: {!Q}\n >{!FillC-}^" ),
393 "FPS102" ,
A_CHAR(
"Missing precision value after '.' character."
394 "\nIn: {!Q}\n >{!FillC-}^" ),
395 "FPS103" ,
A_CHAR(
"Duplicate type code {!Q'} given (previous was {!Q'})."
397 "\nIn: {!Q}\n >{!FillC-}^" ),
398 "FPS104" ,
A_CHAR(
"Unknown type code {!Q'} given."
399 "\nIn: {!Q}\n >{!FillC-}^" )
401 "FPS105" ,
A_CHAR(
"Expected '!' in continuation of placeholder."
403 "\nIn: {!Q}\n >{!FillC-}^" ),
404 "FPS106" ,
A_CHAR(
"Unknown conversion \"!{}\"."
406 "\nIn: {!Q}\n >{!FillC-}^" ),
407 "FPS107" ,
A_CHAR(
"Precision not allowed with integer format."
409 "\nIn: {!Q}\n >{!FillC-}^" ),
410 "FPS108" ,
A_CHAR(
"Missing pair of replacement strings \"<src><repl>\" after \"!Replace\"."
412 "\nIn: {!Q}\n >{!FillC-}^" ),
416 "FJS101" ,
A_CHAR(
"Brackets for negative values not implemented/supported."
417 "\nIn: {!Q}\n >{!FillC-}^" ),
418 "FJS102" ,
A_CHAR(
"Missing precision value after '.' character."
419 "\nIn: {!Q}\n >{!FillC-}^" ),
420 "FJS103" ,
A_CHAR(
"Hexadecimal float format not implemented/supported."
421 "\nIn: {!Q}\n >{!FillC-}^" ),
422 "FJS104" ,
A_CHAR(
"Alternate form '#' not supported with conversion {!Q}."
423 "\nIn: {!Q}\n >{!FillC-}^" ),
424 "FJS105" ,
A_CHAR(
"Precision specification (\".{}\") is not supported with conversion {!Q}."
425 "\nIn: {!Q}\n >{!FillC-}^" ),
426 "FJS106" ,
A_CHAR(
"Unknown date/time conversion suffix {!Q'}."
427 "\nIn: {!Q}\n >{!FillC-}^" ),
428 "FJS107" ,
A_CHAR(
"Unknown conversion character {!Q'}."
429 "\nIn: {!Q}\n >{!FillC-}^" ),
433 "PFM501" ,
A_CHAR(
"Unknown property identifier \"{}{}\" in format string.\n"
434 "Format string: {!Q}.\n"
435 "Allowed identifiers: " ),
436 "PFM502" ,
A_CHAR(
"Error in resulting format string.\nSource format: {!Q}." ),
437 "PFM510" ,
A_CHAR(
"Missing or empty configuration variable {!Q} containing user-defined format string." ),
440 "ST601" ,
A_CHAR(
"Unknown marker at position {}.\n"
441 " Marked text: {!Q}.\n"
443 "ST602" ,
A_CHAR(
"Found an end-marker without a start marker at position {}.\n"
444 " Marked text: {!Q}.\n"
479DOX_MARKER( [DOX_ENUMS_MAKE_PARSABLE_22] )
481DOX_MARKER( [DOX_ENUMS_MAKE_PARSABLE_22] )
513DOX_MARKER([DOX_VARIABLES_DECLARATION7])
515DOX_MARKER([DOX_VARIABLES_DECLARATION7])
532 parser=
GetResource(
"Days" );
for(
int i= 0 ; i < 7 ; ++i ) { CalendarDateTime:: DAY_NAMES[i]= parser.
ConsumeToken(
','); }
535 for(
int i= 0 ; i < int(DayTimeUnits::SIZE_OF_UNITS) ; ++i )
538 ALIB_ASSERT( DT_UNITS[
size_t(
int(DayTimeUnits::SIZE_OF_UNITS)-1)].IsNotEmpty(),
"BASECAMP" )
560 if( !setlocale(LC_ALL, nLocale ) ) {
561 NString256 msg(
"ALib Error: setlocale(\""); msg << nLocale <<
"\") failed. Setting read from ";
562 msg << ( receivedFrom == 1 ?
"config variable 'ALIB_LOCALE'" :
563 receivedFrom == 2 ?
"environment variable 'LANG'" :
564 receivedFrom == 3 ?
"environment variable 'LANGUAGE'" :
"ERROR" );
568 std::cerr <<
". Trying 'setlocale(LC_ALL, \"\")': ";
569 if ( setlocale(LC_ALL,
"" ) )
570 std::cerr <<
" success.";
572 std::cerr <<
"failed. Trying 'setlocale(LC_ALL, \"C\")': ";
573 if ( setlocale(LC_ALL,
"C" ) )
574 std::cerr <<
" success.";
576 std::cerr << std::endl <<
" Panic: No standard locale setting was successful!";
578 std::cerr << std::endl;
603 (void) varHasConsoleWindow.
Define();
612 #if defined(_WIN32) && ALIB_DEBUG
618 (void) varWaitForKeyPress.
Define();
627 if (
BASECAMP.WaitForKeyPressOnTermination ) {
629 OutputDebugStringA(
"\r\nALIB: Waiting for 'Enter' key in the console window.\r\n" );
632 std::cout << std::endl <<
GetResource(
"EXIT_MSG") << std::endl;
633 while ( getchar() !=
'\n' )
648 #if (defined(__unix__) || defined(__APPLE__)) && !DOXYGEN
649namespace {
String DebuggerProcessNames=
A_CHAR(
"gdb|debugserver"); }
654#if defined(__unix__) || defined(__APPLE__)
659 if ( parentPID == 0 )
663 Tokenizer tknzr( DebuggerProcessNames,
'|' );
676 #pragma message ("Unknown Platform in file: " __FILE__ )
#define IF_ALIB_THREADS(...)
#define ALIB_SINGLE_THREADED
#define ALIB_ASSERT(cond, domain)
#define IF_ALIB_BITBUFFER(...)
#define IF_ALIB_THREADMODEL(...)
#define ALIB_ASSERT_ERROR(cond, domain,...)
#define ALIB_REL_DBG(releaseCode,...)
bool WaitForKeyPressOnTermination
virtual void Bootstrap() override
virtual void Shutdown(ShutdownPhases phase) override
BootstrapPhases GetBootstrapState()
SharedConfiguration config
Camp(const NCString &resourceCategory)
const String & GetResource(const NString &name)
NCString ResourceCategory
SPResourcePool resourcePool
Shared pointer to the resource pool.
TAString & _(const TAppendable &src)
constexpr integer Length() const
constexpr bool IsEmpty() const
constexpr bool IsNotEmpty() const
constexpr const TChar * Buffer() const
bool Equals(const TString< TChar > &rhs) const
bool StartsWith(const TString &needle) const
TString< TChar > ConsumeToken(TChar separator=',', lang::Inclusion includeSeparator=lang::Inclusion::Include)
static String MONTH_NAMES[12]
TSubstring< TChar > & Next(lang::Whitespaces trimming=lang::Whitespaces::Trim, TChar newDelim='\0')
uinteger PPID
The parent's process id as AString. (Unix like OS / Mac OS only.).
static const ProcessInfo & Current()
bool Define(Priority requestedPriority=Priority::Standard)
void(* PLUGIN)(const CallerInfo &ci, int type, std::string_view domain, std::string_view msg)
@ HAS_CONSOLE_WINDOW
See #"alibcvALIB_HAS_CONSOLE_WINDOW".
@ LOCALE
See #"alibcvALIB_LOCALE".
@ WAIT_FOR_KEY_PRESS
See #"alibcvALIB_WAIT_FOR_KEY_PRESS".
void Bootstrap(camp::Camp &camp, const NString &name, character innerDelim=',', character outerDelim=',')
TMonoAllocator< lang::HeapAllocator > GLOBAL_ALLOCATOR
strings::TNumberFormat< character > NumberFormat
Type alias in namespace alib.
@ Final
The final initialization phase. Here, camps are initializing their custom setup.
variables::Variable Variable
Type alias in namespace alib.
strings::util::TTokenizer< character > Tokenizer
Type alias in namespace alib.
ShutdownPhases
Termination levels usable with #"alib_mod_bs_camps;Bootstrapping ALib Camps".
strings::TString< character > String
Type alias in namespace alib.
system::ProcessInfo ProcessInfo
Type alias in namespace alib.
strings::TSubstring< character > Substring
Type alias in namespace alib.
camp::Basecamp BASECAMP
The singleton instance of ALib Camp class #"Basecamp".
NLocalString< 256 > NString256
Type alias name for #"TLocalString;TLocalString<nchar,256>".
LocalString< 256 > String256
Type alias name for #"TLocalString;TLocalString<character,256>".
lang::uinteger uinteger
Type alias in namespace alib.
#define ALIB_STRINGS_TO_NARROW( src, dest, bufSize)
static bool Get(const CString &varName, AString &target, lang::CurrentData targetData=lang::CurrentData::Clear)