ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
aloxinit.cpp
1// #################################################################################################
2// alib::lox::detail - ALox Logging 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 ======================================
19
20// =========================================== Module ==========================================
21#if ALIB_C20_MODULES
22 module ALib.ALox.init;
23 import ALib.Lang;
25 import ALib.Strings;
26 import ALib.Boxing;
27 import ALib.EnumRecords;
29 import ALib.Variables;
30 import ALib.Camp;
31 import ALib.Camp.Base;
32#else
33# include "ALib.Lang.H"
34# include "ALib.Containers.List.H"
35# include "ALib.Strings.H"
36# include "ALib.Boxing.H"
37# include "ALib.ALox.H"
38#endif
39// ====================================== Implementation =======================================
40
41#if !DOXYGEN
44#endif // !DOXYGEN
45
46namespace alib::lox {
47
48void ESC::ReplaceToReadable( AString& target, integer startIdx )
49{
50 while( (startIdx= target.IndexOf( '\033', startIdx ) ) >= 0 )
51 {
52 String32 val("{ESC::");
53 character c= target.CharAt( startIdx + 1 );
54 character c2= target.CharAt( startIdx + 2 );
55
56 const character* code= A_CHAR("ERROR");
57
58 // colors
59 if( c == 'c' || c == 'C' )
60 {
61 if ( c == 'C' )
62 val._<NC>( A_CHAR("BG_") );
63 switch( c2 - '0' )
64 {
65 case 0: code= A_CHAR("RED") ; break;
66 case 1: code= A_CHAR("GREEN") ; break;
67 case 2: code= A_CHAR("YELLOW") ; break;
68 case 3: code= A_CHAR("BLUE") ; break;
69 case 4: code= A_CHAR("MAGENTA") ; break;
70 case 5: code= A_CHAR("CYAN") ; break;
71 case 6: code= A_CHAR("BLACK") ; break;
72 case 7: code= A_CHAR("WHITE") ; break;
73 case 8: code= A_CHAR("GRAY") ; break;
74 case 9: code= A_CHAR("RESET") ; break;
75 default: code= A_CHAR("COL_ERR"); break;
76 }
77
78 }
79
80 // styles
81 else if( c == 's' )
82 {
83 switch( c2 )
84 {
85 case 'B': code= A_CHAR("BOLD") ; break;
86 case 'I': code= A_CHAR("ITALICS") ; break;
87 case 'r': code= A_CHAR("STYLE_RESET") ; break;
88 case 'a': code= A_CHAR("RESET") ; break;
89 default: code= A_CHAR("STYLE_ERR") ; break;
90 }
91 }
92
93 // styles
94 else if( c == 'l' )
95 {
96 switch( c2 )
97 {
98 case 'S': code= A_CHAR("URL_START") ; break;
99 case 'E': code= A_CHAR("URL_END") ; break;
100 default: code= A_CHAR("URL_ERR") ; break;
101 }
102 }
103
104 // others
105 else if( c == 't' && c2 == '0' ) code= A_CHAR("TAB");
106 else if( c == 'A' && c2 == '0' ) code= A_CHAR("EOMETA");
107
108 // Replace
109 val._<NC>(code)._('}');
110 target.ReplaceSubstring<NC>( val, startIdx, 3 );
111 startIdx+= 3;
112 }
113}
114
115} // namespace [alib::lox]
static ALIB_DLL void ReplaceToReadable(AString &target, integer startIdx)
Definition aloxinit.cpp:48
TAString & ReplaceSubstring(const TString< TChar > &src, integer regionStart, integer regionLength)
TAString & _(const TAppendable &src)
integer IndexOf(TChar needle, integer startIdx=0) const
Definition string.inl:844
TChar CharAt(integer idx) const
Definition string.inl:421
#define ALIB_BOXING_VTABLE_DEFINE(TMapped, Identifier)
#define A_CHAR(STR)
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
Definition integers.inl:149
LocalString< 32 > String32
Type alias name for TLocalString<character,32>.
characters::character character
Type alias in namespace alib.