ALib C++ Framework
by
Library Version: 2605 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
numberformat.cpp
1namespace alib { namespace strings {
2
3#if !DOXYGEN
4//##################################################################################################
5// Set methods
6//##################################################################################################
7
8template<typename TChar>
10 struct lconv * lc=localeconv();
11
12 DecimalPointChar= static_cast<TChar>( *(lc->decimal_point) );
13 ThousandsGroupChar= static_cast<TChar>( *(lc->thousands_sep) );
14}
15
16template<typename TChar>
18 if ( other == nullptr )
19 other= &Global;
20
21 // let C++ do the job
22 *this= *other;
23}
24
25namespace {
26 template<typename TChar>
27void setComputational( TNumberFormat<TChar>& nf ) {
28 nf.Flags = NumberFormatFlags::ForceDecimalPoint;
29 nf.DecimalPointChar = '.';
30 nf.Whitespaces = CStringConstantsTraits<TChar>::DefaultWhitespaces();
31 nf.PlusSign = '\0';
32
33 // automatic field width (->minimum size of maximum accuracy)
34 nf.DecMinimumFieldWidth=
35 nf.BinFieldWidth=
36 nf.HexFieldWidth=
37 nf.OctFieldWidth=
38 nf.IntegralPartMinimumWidth=
39 nf.FractionalPartWidth= -1;
40
41 // group characters
42 nf.LeadingGroupCharReplacement= ' ';
43
44 nf.ThousandsGroupChar= ',';
45
46 nf.BinNibbleGroupChar=
47 nf.HexWordGroupChar=
48 nf.HexWord32GroupChar=
49 nf.OctGroupChar= '\'';
50
51 nf.HexByteGroupChar= '\0';
52 nf.BinByteGroupChar= '-';
53 nf.BinWordGroupChar= '=';
54 nf.BinWord32GroupChar= '#';
55
56}
57}
58
59template<>
61 setComputational( *this );
62
63 ExponentSeparator = "E" ;
64 INFLiteral = "INF" ;
65 NANLiteral = "NAN" ;
66 BinLiteralPrefix = "0b" ;
67 HexLiteralPrefix = "0x" ;
68 OctLiteralPrefix = "0o" ;
69}
70
71template<>
73 setComputational( *this );
74
75 ExponentSeparator = A_WCHAR( "E" ) ;
76 INFLiteral = A_WCHAR( "INF" ) ;
77 NANLiteral = A_WCHAR( "NAN" ) ;
78 BinLiteralPrefix = A_WCHAR( "0b" ) ;
79 HexLiteralPrefix = A_WCHAR( "0x" ) ;
80 OctLiteralPrefix = A_WCHAR( "0o" ) ;
81}
82
83template<>
85 setComputational( *this );
86
87 ExponentSeparator = A_XCHAR( "E" ) ;
88 INFLiteral = A_XCHAR( "INF" ) ;
89 NANLiteral = A_XCHAR( "NAN" ) ;
90 BinLiteralPrefix = A_XCHAR( "0b" ) ;
91 HexLiteralPrefix = A_XCHAR( "0x" ) ;
92 OctLiteralPrefix = A_XCHAR( "0o" ) ;
93}
94
95
102
103#endif // !DOXYGEN
104
105}} // namespace [alib::strings]
#define A_XCHAR(STR)
#define A_WCHAR(STR)
@ Global
Denotes the global (singleton) scope.
Definition alox.cpp:14
void Set(TNumberFormat *other=nullptr)