ALib C++ Framework
by
Library Version: 2511 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
basecamp.cpp
1//##################################################################################################
2// ALib C++ Framework
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 "Configuration MACRO 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 ========================================
15#include <iostream>
21//============================================== Module ============================================
22#if ALIB_C20_MODULES
23 module ALib.Camp.Base;
24 import ALib.Lang;
25 import ALib.Time;
26 import ALib.EnumOps;
27# if !ALIB_SINGLE_THREADED
28 import ALib.Threads;
29# endif
30 import ALib.Monomem;
31 import ALib.Strings.Tokenizer;
32 import ALib.Strings;
33 import ALib.Strings.StdIOStream;
34 import ALib.Strings.Calendar;
35 import ALib.Strings.Tokenizer;
36 import ALib.Boxing;
37 import ALib.EnumRecords.Bootstrap;
38 import ALib.Exceptions;
39 import ALib.System;
40 import ALib.Variables;
41 import ALib.Variables.IniFile;
42 #if ALIB_THREADMODEL
43 import ALib.ThreadModel;
44 #endif
45 #if ALIB_BITBUFFER
46 import ALib.BitBuffer;
47 #endif
48 import ALib.Format;
49 import ALib.Format.StdImplementation;
50 import ALib.Format.FormatterPythonStyle;
51 import ALib.Format.FormatterJavaStyle;
52 import ALib.Camp;
53#else
54# include "ALib.Lang.H"
55# include "ALib.Time.H"
56# if !ALIB_SINGLE_THREADED
57# include "ALib.Threads.H"
58# endif
59# include "ALib.Monomem.H"
60# include "ALib.Strings.H"
64# include "ALib.Boxing.H"
66# include "ALib.Exceptions.H"
67# include "ALib.System.H"
69# include "ALib.ThreadModel.H"
70# include "ALib.BitBuffer.H"
71# include "ALib.Format.H"
75# include "ALib.Camp.H"
76# include "ALib.Camp.Base.H"
77#endif
78//========================================== Implementation ========================================
81
82using namespace alib::strings;
83
84namespace alib::camp {
85
87: Camp( "ALIB" )
88, LocaleFound(nullptr) {
89 #if ALIB_DEBUG && !ALIB_DEBUG_ASSERTION_PRINTABLES
90 ALIB_ASSERT_ERROR( this == &BASECAMP, "BASECAMP",
91 "Instances of class Basecamp must not be created. Use singleton alib::BASECAMP" )
92 #endif
93}
94
97//! @cond NO_DOX
98 #define EOS ,
99//! @endcond
100#if !ALIB_CAMP_OMIT_DEFAULT_RESOURCES
101 resourcePool->BootstrapBulk( ResourceCategory,
102
103
104 // CodeMarker_CommonEnums
105 "Alignment", A_CHAR("0" "," "Left" "," "1" ","
106 "1" "," "Right" "," "1" ","
107 "2" "," "Center" "," "1" ),
108
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" ),
119
120 "Caching", A_CHAR("0" "," "Disabled" "," "1" ","
121 "1" "," "Enabled" "," "1" ","
122 "1" "," "Auto" "," "1" ),
123
124 "Case", A_CHAR("0" "," "Sensitive" "," "1" ","
125 "1" "," "Ignore" "," "1" ),
126
127 "ContainerOp", A_CHAR("0" "," "Insert" "," "1" ","
128 "1" "," "Remove" "," "1" ","
129 "3" "," "GetCreate" "," "4" ","
130 "2" "," "Get" "," "1" ","
131 "4" "," "Create" "," "1" ),
132
133 // CreateDefaults: using Bool
134 // CreateIfNotExists: using Bool
135
136 "CurrentData", A_CHAR("0" "," "Keep" "," "1" ","
137 "1" "," "Clear" "," "1" ),
138
139 "Inclusion", A_CHAR("0" "," "Include" "," "1" ","
140 "1" "," "Exclude" "," "1" ),
141
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" ),
148
149 "LineFeeds", A_CHAR("0" "," "None" "," "1" ","
150 "0" "," "Ignore" "," "1" ","
151 "1" "," "Unix" "," "1" ","
152 "2" "," "WindowsOS" "," "1" ","
153 "3" "," "Platform" "," "1" ),
154
155 "Phase", A_CHAR("0" "," "Begin" "," "1" ","
156 "1" "," "End" "," "1" ),
157
158 "Propagation", A_CHAR("0" "," "Omit" "," "1" ","
159 "1" "," "ToDescendants" "," "1" ),
160
161 "Reach", A_CHAR("0" "," "Global" "," "1" ","
162 "1" "," "Local" "," "1" ),
163
164 // Recursive: using Bool
165
166 "Responsibility", A_CHAR("0" "," "KeepWithSender" "," "1" ","
167 "1" "," "Transfer" "," "1" ),
168
169 "Safeness", A_CHAR("0" "," "Safe" "," "1" ","
170 "1" "," "Unsafe" "," "1" ),
171
172 "Side", A_CHAR("0" "," "Left" "," "1" ","
173 "1" "," "Right" "," "1" ),
174
175 "SortOrder", A_CHAR("0" "," "Ascending" "," "1" ","
176 "1" "," "Descending" "," "1" ),
177
178 "SourceData", A_CHAR("0" "," "Copy" "," "1" ","
179 "1" "," "Move" "," "1" ),
180
181 "Switch", A_CHAR("0" "," "Off" "," "2" ","
182 "1" "," "On" "," "2" ),
183
184 "Timezone", A_CHAR("0" "," "Local" "," "1" ","
185 "1" "," "UTC" "," "1" ),
186
187 "Timing", A_CHAR("0" "," "Async" "," "1" ","
188 "1" "," "Sync" "," "1" ","
189 "0" "," "Asynchronous" "," "1" ","
190 "1" "," "Synchronous" "," "1" ","
191 "1" "," "Synchronized" "," "1" ),
192
193 "ValueReference", A_CHAR("0" "," "Absolute" "," "1" ","
194 "1" "," "Relative" "," "1" ),
195
196 "Whitespaces", A_CHAR("0" "," "Trim" "," "1" ","
197 "1" "," "Keep" "," "1" ),
198
199
201 "TSts", A_CHAR( "0" "," "Unstarted" "," "1" ","
202 "1" "," "Started" "," "3" ","
203 "2" "," "Running" "," "1" ","
204 "3" "," "Done" "," "3" ","
205 "4" "," "Terminated" "," "1" ),
206
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" ),
214 #endif
215 #endif
216
217
218
219 //-------------------------------------- module variables ------------------------------------
220 "VARE<", A_CHAR("variables::"),
221 "VARE" , A_CHAR("0" "," "OK" "," "" ","
222 "1" "," "ErrorOpeningFile" "," "VARERF" ","
223 "2" "," "ErrorWritingFile" "," "VAREWF" ),
224
225 "VARERF", A_CHAR("Can't open {}file {!Q'} for reading.") ,
226 "VAREWF", A_CHAR("Can't open {}file {!Q'} for writing.") ,
227
228
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" ),
239
240 // names of the configuration plug-ins added to configuration in default construction.
241 "CFGPlgEnv" , A_CHAR("Environment Variables") ,
242 "CFGPlgCLI" , A_CHAR("Command Line Arguments") ,
243
244 "CFGIniWB" , A_CHAR("writeback") ,
245
246 // boolean tokens
247 "CFGBTF", A_CHAR("False I 1," ) A_CHAR( "True I 1," )
248 A_CHAR( "0 I 1," ) A_CHAR( "1 I 1," )
249 A_CHAR( "No I 1," ) A_CHAR( "Yes I 1," )
250 A_CHAR( "Off I 3," ) A_CHAR( "On I 2," )
251 A_CHAR( "--- I 1," ) A_CHAR( "OK I 2" ),
252
253
254 // variables
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" ),
259
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])
267
268
269 // INI-File comment for section ALIB
270 "CFG_SECT_CMT_ALIB", A_CHAR("@>'/// '@HL-General ALib library settings.\n@HL-"),
271
272 // Exit message when waiting for key-press requested with variable WAIT_FOR_KEY_PRESS
273 "EXIT_MSG" , A_CHAR( "ALIB: Press 'Enter' to exit..." ),
274
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" ),
284 #endif
285
286 // Calendar
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
289
290 "DurUnts" , A_CHAR("zero time" "," // 0 TS_ZERO
291 " days" "," // 1 DayP
292 " day" "," // 2 DayS
293 " hours" "," // 3 HourP
294 " hour" "," // 4 HourS
295 " minutes" "," // 5 MinP
296 " minute" "," // 6 MinS
297 " seconds" "," // 7 SecP
298 " second" "," // 8 SecS
299 " ms" "," // 9 MlSecP
300 " ms" "," // 10 MlSecS
301 " \u00B5s" "," // 11 McSecP
302 " \u00B5s" "," // 12 McSecS
303 " ns" "," // 13 NSecP
304 " ns" ), // 14 NSecS
305
306 "FMTDT" , A_CHAR( "yyyy-MM-dd HH:mm:ss"), // default format string for DateTime values used by FFormat_DateTime()
307 "FMTCI" , A_CHAR( "[@ sf:sl from ''ya'' by ''ta'']"), // default format string for CallerInfo values used by FFormat_CallerInfo()
308 "FMTCINT", A_CHAR( "<None>"), // format output if CallerInfo has no thread set
309 "FMTCINY", A_CHAR( "<None>"), // format output if CallerInfo originates from static method or namespace function
310 "FMTCINR", A_CHAR( "<Null>"), // format output if CallerInfo originates from static method or namespace function
311
312 // Enums
313 "SF", A_CHAR("0,Root" ",1,"
314 "1,Current" ",1,"
315 "3,HomeConfig" ",5,"
316 "2,Home" ",1,"
317 "4,Module" ",1,"
318 "5,Temp" ",1,"
319 "6,VarTemp" ",1" ) EOS
320
321
322//---------------------------------------- module exceptions ---------------------------------------
323 "ExcFmtExc", A_CHAR("\nAn exception occurred while formatting another (!) exception:\n" ),
324
325//------------------------------------------ module format -----------------------------------------
326 "PHT", A_CHAR( "0,NotGiven" ",1,"
327 "1,String" ",1,"
328 "2,Character" ",1,"
329 "3,IntBase10" ",6,"
330 "4,IntBinary" ",6,"
331 "5,IntOctal" ",6,"
332 "6,IntHex" ",6,"
333 "7,Float" ",1,"
334 "8,Bool" ",1,"
335 "9,HashCode" ",1,"
336 "10,Fill" ",4" ) ,
337
338
339 "FE<", A_CHAR("format::"),
340// general formatter errors
341
342 "FE0" , A_CHAR( "11,ArgumentIndexIs0" ",FMG11" ),
343 "FE1" , A_CHAR( "12,ArgumentIndexOutOfBounds" ",FMG12" ),
344 "FE2" , A_CHAR( "13,IncompatibleTypeCode" ",FMG13" ),
345
346 // Formatter Python Style
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" ),
355
356 // Formatter Java Style
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" ),
364
365 // PropertyFormatter and PropertyFormatters
366 "FE18" , A_CHAR( "501,UnknownPropertyInFormatString" ",PFM501" ),
367 "FE19" , A_CHAR( "502,ErrorInResultingFormatString" ",PFM502" ),
368 "FE20" , A_CHAR( "510,MissingConfigurationVariable" ",PFM510" ),
369
370 // class Paragraphs
371 "FE21" , A_CHAR( "601,UnknownMarker" ",ST601" ),
372 "FE22" , A_CHAR( "602,EndmarkerWithoutStart" ",ST602" ),
373
374 // general formatter errors
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"
383 ALIB_REL_DBG( A_CHAR( "{!X}") ,
384 A_CHAR( "Native argument type: <{}>\n" )
385 "In: {!Q}\n >{!FillC-}^" ),
386
387 // Formatter Python Style
388 "FPS101" , A_CHAR( "Closing bracket '}}' of placeholder not found (or syntax error).\n"
389 "In: {!Q}\n >{!FillC-}^" ),
390 //...
391 //...
392 //...
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'})."
396 ALIB_REL_DBG( A_CHAR( "{!X}") , A_CHAR( "\nNative argument type: <{}> ") )
397 "\nIn: {!Q}\n >{!FillC-}^" ),
398 "FPS104" , A_CHAR( "Unknown type code {!Q'} given."
399 "\nIn: {!Q}\n >{!FillC-}^" )
400 ALIB_REL_DBG( A_CHAR( "{!X}") , A_CHAR( "\nNative argument type: <{}> ") ),
401 "FPS105" , A_CHAR( "Expected '!' in continuation of placeholder."
402 ALIB_REL_DBG( A_CHAR( "{!X}") , A_CHAR( "\nNative argument type: <{}> ") )
403 "\nIn: {!Q}\n >{!FillC-}^" ),
404 "FPS106" , A_CHAR( "Unknown conversion \"!{}\"."
405 ALIB_REL_DBG( A_CHAR( "{!X}") , A_CHAR( "\nNative argument type: <{}> ") )
406 "\nIn: {!Q}\n >{!FillC-}^" ),
407 "FPS107" , A_CHAR( "Precision not allowed with integer format."
408 ALIB_REL_DBG( A_CHAR( "{!X}") , A_CHAR( "\nNative argument type: <{}> ") )
409 "\nIn: {!Q}\n >{!FillC-}^" ),
410 "FPS108" , A_CHAR( "Missing pair of replacement strings \"<src><repl>\" after \"!Replace\"."
411 ALIB_REL_DBG( A_CHAR( "{!X}") , A_CHAR( "\nNative argument type: <{}> ") )
412 "\nIn: {!Q}\n >{!FillC-}^" ),
413
414
415 // Formatter Java Style
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-}^" ),
430
431
432 // PropertyFormatter and PropertyFormatters
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." ),
438
439 // class Paragraphs
440 "ST601" , A_CHAR( "Unknown marker at position {}.\n"
441 " Marked text: {!Q}.\n"
442 " >{!FillC-}^\n" ),
443 "ST602" , A_CHAR( "Found an end-marker without a start marker at position {}.\n"
444 " Marked text: {!Q}.\n"
445 " >{!FillC-}^\n" ),
446
447
448 "BS", A_CHAR( "0,B" ",3,"
449 "1,KiB" ",3,"
450 "2,MiB" ",3,"
451 "3,GiB" ",3,"
452 "4,TiB" ",3,"
453 "5,PiB" ",3,"
454 "6,EiB" ",3,"
455 "7,ZiB" ",3,"
456 "8,YiB" ",3,"
457 "9,RiB" ",3,"
458 "10,QiB" ",3,"
459 "11,B" ",1,"
460 "12,kB" ",2,"
461 "13,MB" ",2,"
462 "14,GB" ",2,"
463 "15,TB" ",2,"
464 "16,PB" ",2,"
465 "17,EB" ",2,"
466 "18,ZB" ",2,"
467 "19,YB" ",2,"
468 "20,RB" ",2,"
469 "21,QB" ",2" ) EOS
470
471 // end of BootstrapBulk()
472 nullptr );
473#endif // !ALIB_CAMP_OMIT_DEFAULT_RESOURCES
474
475 // CodeMarker_CommonEnums
476 enbs::Bootstrap<alib::lang::Alignment >( *this, "Alignment" );
477 enbs::Bootstrap<alib::lang::Bool >( *this, "Bool" );
478 enbs::Bootstrap<alib::lang::Caching >( *this, "Caching" );
479DOX_MARKER( [DOX_ENUMS_MAKE_PARSABLE_22] )
480 enbs::Bootstrap<alib::lang::Case>( *this, "Case" );
481DOX_MARKER( [DOX_ENUMS_MAKE_PARSABLE_22] )
482 enbs::Bootstrap<alib::lang::ContainerOp >( *this, "ContainerOp" );
485 enbs::Bootstrap<alib::lang::CurrentData >( *this, "CurrentData" );
486 enbs::Bootstrap<alib::lang::Inclusion >( *this, "Inclusion" );
487 enbs::Bootstrap<alib::lang::Initialization >( *this, "Initialization" );
488 enbs::Bootstrap<alib::lang::LineFeeds >( *this, "LineFeeds" );
489 enbs::Bootstrap<alib::lang::Phase >( *this, "Phase" );
490 enbs::Bootstrap<alib::lang::Propagation >( *this, "Propagation" );
491 enbs::Bootstrap<alib::lang::Reach >( *this, "Reach" );
493 enbs::Bootstrap<alib::lang::Responsibility >( *this, "Responsibility" );
494 enbs::Bootstrap<alib::lang::Safeness >( *this, "Safeness" );
495 enbs::Bootstrap<alib::lang::Side >( *this, "Side" );
496 enbs::Bootstrap<alib::lang::SortOrder >( *this, "SortOrder" );
497 enbs::Bootstrap<alib::lang::SourceData >( *this, "SourceData" );
498 enbs::Bootstrap<alib::lang::Switch >( *this, "Switch" );
499 enbs::Bootstrap<alib::lang::Timezone >( *this, "Timezone" );
500 enbs::Bootstrap<alib::lang::Timing >( *this, "Timing" );
501 enbs::Bootstrap<alib::lang::ValueReference >( *this, "ValueReference" );
502 enbs::Bootstrap<alib::lang::Whitespaces >( *this, "Whitespaces" );
503
507
508
511
512
513DOX_MARKER([DOX_VARIABLES_DECLARATION7])
515DOX_MARKER([DOX_VARIABLES_DECLARATION7])
516
517 enbs::Bootstrap<SystemFolders >( *this, "SF" );
521 }
522
524
525 // preload all variable with declarations (and without placeholders)
526 config->PreloadVariables<camp::Variables>();
527 }
528
530 Substring parser;
531 parser= GetResource( "Months" ); for( int i= 0 ; i < 12 ; ++i ) { CalendarDateTime::MONTH_NAMES[i]= parser.ConsumeToken(','); }
532 parser= GetResource( "Days" ); for( int i= 0 ; i < 7 ; ++i ) { CalendarDateTime:: DAY_NAMES[i]= parser.ConsumeToken(','); }
533
534 parser= GetResource( "DurUnts" );
535 for( int i= 0 ; i < int(DayTimeUnits::SIZE_OF_UNITS) ; ++i )
536 DT_UNITS[i]= parser.ConsumeToken(',');
537
538 ALIB_ASSERT( DT_UNITS[size_t(int(DayTimeUnits::SIZE_OF_UNITS)-1)].IsNotEmpty(), "BASECAMP" )
539 ALIB_ASSERT( parser.IsEmpty(), "BASECAMP" )
540
542 format::BYTESIZE_NUMBER_FORMAT->FractionalPartWidth= 1;
543
544 //######################################### set locale #######################################
545 int receivedFrom= 0;
546 String256 locale;
547
548 Variable varLocale(*config, Variables::LOCALE);
549 if ( varLocale.IsDefined()
550 && varLocale.GetString().IsNotEmpty() )
551 {
552 receivedFrom= 1;
553 locale._( varLocale.GetString() );
554 }
555 else if ( EnvironmentVariables::Get( A_CHAR("LANG") ,locale ) ) receivedFrom= 2;
556 else if ( EnvironmentVariables::Get( A_CHAR("LANGUAGE") ,locale ) ) receivedFrom= 3;
557
558 if( receivedFrom > 0 && !locale.Equals<NC,lang::Case::Ignore>( A_CHAR("none") ) ) {
559 ALIB_STRINGS_TO_NARROW( locale, nLocale, 1024)
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" );
565
566 std::cerr.write( msg.Buffer(), msg.Length() );
567
568 std::cerr << ". Trying 'setlocale(LC_ALL, \"\")': ";
569 if ( setlocale(LC_ALL, "" ) )
570 std::cerr << " success.";
571 else {
572 std::cerr << "failed. Trying 'setlocale(LC_ALL, \"C\")': ";
573 if ( setlocale(LC_ALL, "C" ) )
574 std::cerr << " success.";
575 else
576 std::cerr << std::endl << " Panic: No standard locale setting was successful!";
577 }
578 std::cerr << std::endl;
579 }
580 else
581 LocaleFound.Allocate( monomem::GLOBAL_ALLOCATOR, locale);
582 }
583
584 // set the system's locale as the default for our static default number format
585 #if ALIB_STRINGS
586 NumberFormat::Global.SetFromLocale();
587 NumberFormat::Global.Flags+= NumberFormatFlags::WriteGroupChars;
588 #endif
589
590
591 // --- determine if we have a console window ---
592 // read configuration
593 Variable varHasConsoleWindow(*config, Variables::HAS_CONSOLE_WINDOW );
594 if ( varHasConsoleWindow.IsDefined() )
595 HasConsoleWindow= varHasConsoleWindow;
596 else {
597 #if defined(_WIN32)
598 // determine if we have a console window
599 HasConsoleWindow= GetConsoleWindow() != NULL;
600 #else
601 HasConsoleWindow= true;
602 #endif
603 (void) varHasConsoleWindow.Define();
604 varHasConsoleWindow= HasConsoleWindow;
605 }
606
607 // --- determine if we want to wait for a keypress upon termination ---
608 Variable varWaitForKeyPress(*config, Variables::WAIT_FOR_KEY_PRESS );
609 if ( varWaitForKeyPress.IsDefined() )
610 WaitForKeyPressOnTermination= varWaitForKeyPress;
611 else {
612 #if defined(_WIN32) && ALIB_DEBUG
615 #else
617 #endif
618 (void) varWaitForKeyPress.Define();
619 varWaitForKeyPress= WaitForKeyPressOnTermination;
620} } }
621
623 if( phase == ShutdownPhases::Announce )
624 return;
625
626 // ShutdownPhases::Destruct:
627 if ( BASECAMP.WaitForKeyPressOnTermination ) {
628 #if defined(_WIN32)
629 OutputDebugStringA( "\r\nALIB: Waiting for 'Enter' key in the console window.\r\n" );
630 #endif
631
632 std::cout << std::endl << GetResource("EXIT_MSG") << std::endl;
633 while ( getchar() != '\n' )
634 ;
635 }
636
637 // alib/lang/message
638 #if ALIB_DEBUG
639 assert::PLUGIN= nullptr;
640 #endif
641}
642
643//##################################################################################################
644// Environment definition/detection
645//##################################################################################################
646
647
648 #if (defined(__unix__) || defined(__APPLE__)) && !DOXYGEN
649namespace { String DebuggerProcessNames= A_CHAR("gdb|debugserver"); }
650 #endif
651
652
654#if defined(__unix__) || defined(__APPLE__)
655
656 // Unix: search debugger process in parent processes
658 uinteger parentPID= pi.PPID;
659 if ( parentPID == 0 )
660 return false;
661
662 ProcessInfo actPI( parentPID );
663 Tokenizer tknzr( DebuggerProcessNames, '|' );
664 while(tknzr.HasNext() ) {
665 Substring& debuggerName= tknzr.Next();
666 if (actPI.Name.StartsWith( debuggerName ) )
667 return true;
668 }
669 return false;
670
671#elif defined(_WIN32)
672
673 return (bool) ( ::IsDebuggerPresent() != 0 ) ;
674
675 #else
676 #pragma message ("Unknown Platform in file: " __FILE__ )
677 return false;
678 #endif
679 }
680
681
682} // namespace [alib::camp]
#define ALIB_ENUMRECORDS
Definition alib.inl:291
#define ALIB_THREADMODEL
Definition alib.inl:297
#define IF_ALIB_THREADS(...)
Definition alib.inl:466
#define A_CHAR(STR)
Definition alib.inl:1325
#define ALIB_BITBUFFER
Definition alib.inl:281
#define ALIB_SINGLE_THREADED
Definition alib.inl:40
#define ALIB_ASSERT(cond, domain)
Definition alib.inl:1143
#define IF_ALIB_BITBUFFER(...)
Definition alib.inl:330
#define IF_ALIB_THREADMODEL(...)
Definition alib.inl:458
#define ALIB_ASSERT_ERROR(cond, domain,...)
Definition alib.inl:1144
#define ALIB_REL_DBG(releaseCode,...)
Definition alib.inl:933
bool WaitForKeyPressOnTermination
Definition basecamp.mpp:119
virtual void Bootstrap() override
Definition basecamp.cpp:95
virtual void Shutdown(ShutdownPhases phase) override
Definition basecamp.cpp:622
BootstrapPhases GetBootstrapState()
Definition camp.inl:160
SharedConfiguration config
Definition camp.inl:98
Camp(const NCString &resourceCategory)
Definition camp.inl:106
const String & GetResource(const NString &name)
SPResourcePool resourcePool
Shared pointer to the resource pool.
TAString & _(const TAppendable &src)
constexpr integer Length() const
Definition string.inl:304
constexpr bool IsEmpty() const
Definition string.inl:353
constexpr bool IsNotEmpty() const
Definition string.inl:357
constexpr const TChar * Buffer() const
Definition string.inl:299
bool Equals(const TString< TChar > &rhs) const
Definition string.inl:519
bool StartsWith(const TString &needle) const
Definition string.inl:739
TString< TChar > ConsumeToken(TChar separator=',', lang::Inclusion includeSeparator=lang::Inclusion::Include)
TSubstring< TChar > & Next(lang::Whitespaces trimming=lang::Whitespaces::Trim, TChar newDelim='\0')
Definition tokenizer.cpp:26
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)
Definition variable.cpp:260
void(* PLUGIN)(const CallerInfo &ci, int type, std::string_view domain, std::string_view msg)
Definition assert.cpp:171
@ HAS_CONSOLE_WINDOW
See #"alibcvALIB_HAS_CONSOLE_WINDOW".
Definition basecamp.mpp:96
@ LOCALE
See #"alibcvALIB_LOCALE".
Definition basecamp.mpp:94
@ WAIT_FOR_KEY_PRESS
See #"alibcvALIB_WAIT_FOR_KEY_PRESS".
Definition basecamp.mpp:95
void Bootstrap(camp::Camp &camp, const NString &name, character innerDelim=',', character outerDelim=',')
Definition camp.inl:265
NumberFormat * BYTESIZE_NUMBER_FORMAT
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.
Definition camp.inl:35
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".
Definition camp.inl:42
strings::TString< character > String
Type alias in namespace alib.
Definition string.inl:2172
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".
Definition basecamp.cpp:80
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.
Definition integers.inl:152
#define ALIB_STRINGS_TO_NARROW( src, dest, bufSize)
static bool Get(const CString &varName, AString &target, lang::CurrentData targetData=lang::CurrentData::Clear)