-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCOut.hxx
489 lines (451 loc) · 12.2 KB
/
COut.hxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
// Copyright Kabuki Starship� <kabukistarship.com>.
#include "COut.h"
#if SEAM >= SCRIPT2_COUT && USING_CONSOLE == YES_0
//
#include "Uniprinter.hpp"
//#include <cstdio>
#include <iostream>
#if SEAM == SCRIPT2_COUT
#include "_Debug.hxx"
#else
#include "_Release.hxx"
#endif
#define STD_COUT std::wcerr
namespace _ {
BOL CIsPrintable(CHA item) {
if (item < ' ') {
if (item == 9) return true; // TAB
return false;
}
if (item == 127) return false;
return true;
}
BOL CIsPrintable(CHB item) {
if (item < ' ') {
if (item == 9) return true; // TAB
return false;
}
if (item == 127) return false;
return true;
}
BOL CIsPrintable(CHC item) {
if (item < ' ') {
if (item == 9) return true; // TAB
return false;
}
if (item == 127) return false;
return true;
}
COut::COut() {}
COut::COut(CHA item) { Print(item); }
COut::COut(const CHA* item) { Print(item); }
#if USING_UTF16 == YES_0
COut::COut(CHB item) { Print(item); }
COut::COut(const CHB* item) { Print(item); }
#endif
#if USING_UTF32 == YES_0
COut::COut(CHC item) { Print(item); }
COut::COut(const CHC* item) { Print(item); }
#endif
COut::COut(ISA item) { Print(item); }
COut::COut(IUA item) { Print(item); }
COut::COut(ISB item) { Print(item); }
COut::COut(IUB item) { Print(item); }
COut::COut(ISC item) { Print(item); }
COut::COut(IUC item) { Print(item); }
COut::COut(ISD item) { Print(item); }
COut::COut(IUD item) { Print(item); }
#if USING_FPC == YES_0
COut::COut(FPC item) { Print(item); }
#endif
#if USING_FPD == YES_0
COut::COut(FPD item) { Print(item); }
#endif
COut::COut(Hexf item) { Print(item); }
COut::COut(Binaryf item) { Print(item); }
COut::COut(Centerf item) { Print(item); }
COut::COut(Rightf item) { Print(item); }
COut::COut(Linef item) { Print(item); }
COut::COut(Headingf item) { Print(item); }
COut::COut(Indentf item) { Print(item); }
COut::COut(Charsf item) { Print(item); }
COut::COut(const CHA* item, CHA second_item) {
Print(item);
Print(second_item);
}
COut::COut(const CHA* item, const CHA* second_item) {
Print(item);
Print(second_item);
}
COut::COut(CHA item, CHA second_item) {
Print(item);
Print(second_item);
}
COut::COut(CHA item, const CHA* second_item) {
Print(item);
Print(second_item);
}
COut::COut(CHA item, CHA second_item, CHA third_item) {
Print(item);
Print(second_item);
Print(third_item);
}
COut::COut(CHA item, CHA second_item, const CHA* third_item) {
Print(item);
Print(second_item);
Print(third_item);
}
COut::COut(const CHA* item, const CHA* second_item, CHA third_item) {
Print(item);
Print(second_item);
Print(third_item);
}
COut::COut(const CHA* item, const CHA* second_item, const CHA* third_item) {
Print(item);
Print(second_item);
Print(third_item);
}
COut& COut::Star() { return *this; }
COut& COut::Print(CHA item) {
STD_COUT << item;
return *this;
}
COut& COut::Print(const CHA* item) {
return TSPrintString<COut, CHA>(*this, item);
}
#if USING_UTF16 == YES_0
COut& COut::Print(CHB item) {
STD_COUT << (CHN)item;
return *this;
}
COut& COut::Print(const CHB* item) {
return TSPrintString<COut, CHB>(*this, item);
}
#endif
#if USING_UTF32 == YES_0
COut& COut::Print(CHC item) {
if (item >= (CHC(1) << 9)) {
STD_COUT << (CHN)(item & 0x3f) + 0xD800;
STD_COUT << (CHN)((item >> 10) & 0x3f) + 0xDC00;
} else {
STD_COUT << (CHN)item;
}
return *this;
}
COut& COut::Print(const CHC* item) {
return TSPrintString<COut, CHC>(*this, item);
}
#endif
COut& COut::Print(ISC item) {
#if SEAM <= SCRIPT2_ITOS
STD_COUT << item;
#else
#if CPU_SIZE == CPU_8_BYTE
Print((ISD)item);
#else
enum { Size = 24 };
CHA socket[Size];
TSPrintSigned<ISD, IUD, CHA>(socket, Size, (ISD)value);
Print(socket);
#endif
#endif
return *this;
}
COut& COut::Print(IUC item) {
#if SEAM <= SCRIPT2_ITOS
STD_COUT << item;
#else
#if CPU_SIZE == CPU_8_BYTE
Print((IUD)item);
#else
enum { Size = 24 };
CHA boofer[Size];
TSPrintUnsigned<IUC, CHA>(boofer, Size, item);
Print(boofer);
#endif
#endif
return *this;
}
COut& COut::Print(ISD item) {
#if SEAM <= SCRIPT2_ITOS
STD_COUT << item;
#else
enum { Size = 24 };
CHA boofer[Size];
auto result = TSPrint<CHA>(boofer, Size, item);
Print(boofer);
#endif
return *this;
}
COut& COut::Print(IUD item) {
#if SEAM <= SCRIPT2_ITOS
STD_COUT << item;
#else
enum { Size = 24 };
CHA boofer[Size];
TSPrint<CHA>(boofer, Size, item);
Print(boofer);
#endif
return *this;
}
#if USING_FPC == YES_0
COut& COut::Print(FPC item) {
#if SEAM <= SCRIPT2_BOOK
STD_COUT << item;
#else
enum { Size = 16 };
CHA boofer[Size];
TSPrint<CHA>(boofer, Size, item);
Print(boofer);
#endif
return *this;
}
#endif
#if USING_FPD == YES_0
COut& COut::Print(FPD item) {
#if SEAM <= SCRIPT2_BOOK
STD_COUT << item;
#else
enum { Size = 24 };
CHA boofer[Size];
TSPrint<CHA>(boofer, Size, item);
Print(boofer);
#endif
return *this;
}
#endif
COut& COut::Print(Hexf& item) {
return TPrintHex<COut>(*this, item.element.Value(), item.element.count);
}
COut& COut::Print(Binaryf& item) {
return TPrintBinary<COut>(*this, item.element.Value(), item.element.count);
}
COut& COut::Print(Centerf& item) {
return TPrintCenter<COut>(*this, item.element);
}
COut& COut::Print(Rightf& item) {
return TPrintRight<COut>(*this, item.element);
}
COut& COut::Print(Linef& item) { return TPrint<COut>(*this, item); }
COut& COut::Print(Headingf& item) { return TPrint<COut>(*this, item); }
COut& COut::Print(Indentf& item) {
return _::TPrintIndent<_::COut>(*this, item.indent_count);
}
COut& COut::Print(Charsf& item) {
return _::TPrint<COut>(*this, item);
}
//COut& COut::Print(TypeWordValue item) {
// return _::TPrintAType<COut>(*this, item);
//}
COut& COut::NL() { return Print('\n'); }
COut& COut::NL(CHA item) {
NL();
return Print(item);
}
COut& COut::NL(const CHA* item) {
NL();
return Print(item);
}
#if USING_UTF16 == YES_0
COut& COut::NL(CHB item) {
NL();
return Print(item);
}
COut& COut::NL(const CHB* item) {
NL();
return Print(item);
}
#endif
#if USING_UTF32 == YES_0
COut& COut::NL(CHC item) {
NL();
return Print(item);
}
COut& COut::NL(const CHC* item) {
NL();
return Print(item);
}
#endif
COut& COut::NL(ISC item) {
NL();
return Print(item);
}
COut& COut::NL(IUC item) {
NL();
return Print(item);
}
COut& COut::NL(ISD item) {
NL();
return Print(item);
}
COut& COut::NL(IUD item) {
NL();
return Print(item);
}
#if USING_FPC == YES_0
COut& COut::NL(FPC item) {
NL();
return Print(item);
}
#endif
#if USING_FPD == YES_0
COut& COut::NL(FPD item) {
NL();
return Print(item);
}
#endif
COut& COut::Hex(const void* item) { return TPrintHex<COut>(*this, item); }
COut& COut::Hex(const void* item, ISW size) {
return TPrintHex<COut>(*this, item, size);
}
COut& COut::Hex(const void* item, const void* item_stop) {
return TPrintHex<COut>(*this, item, item_stop);
}
COut& COut::Hex(ISA item) { return TPrintHex<COut, ISA, IUA>(*this, item); }
COut& COut::Hex(IUA item) { return TPrintHex<COut, IUA>(*this, item); }
COut& COut::Hex(ISB item) { return TPrintHex<COut, ISB, IUB>(*this, item); }
COut& COut::Hex(IUB item) { return TPrintHex<COut, IUB>(*this, item); }
COut& COut::Hex(ISC item) { return TPrintHex<COut, ISC, IUC>(*this, item); }
COut& COut::Hex(IUC item) { return TPrintHex<COut, IUC>(*this, item); }
COut& COut::Hex(ISD item) { return TPrintHex<COut, ISD, IUD>(*this, item); }
COut& COut::Hex(IUD item) { return TPrintHex<COut, IUD>(*this, item); }
#if USING_FPC == YES_0
COut& COut::Hex(FPC item) { return TPrintHex<COut>(*this, item); }
#endif
#if USING_FPD == YES_0
COut& COut::Hex(FPD item) { return TPrintHex<COut>(*this, item); }
#endif
/* Stores the given item to the boofer and store the size. */
COut& COut::Binary(const void* item) { return TPrintBinary<COut>(*this, item); }
COut& COut::Binary(const void* item, ISW size) {
return TPrintBinary<COut>(*this, item, size);
}
COut& COut::Binary(const void* start, const void* stop) {
return TPrintBinary<COut>(
*this, start,
TPtr<const CHA>(stop) - TPtr<const CHA>(start));
}
COut& COut::Binary(ISA item) {
return TPrintBinary<COut, ISA, IUA>(*this, item);
}
COut& COut::Binary(IUA item) { return TPrintBinary<COut, IUA>(*this, item); }
COut& COut::Binary(ISB item) {
return TPrintBinary<COut, ISB, IUB>(*this, item);
}
COut& COut::Binary(IUB item) { return TPrintBinary<COut, IUB>(*this, item); }
COut& COut::Binary(ISC item) {
return TPrintBinary<COut, ISC, IUC>(*this, item);
}
COut& COut::Binary(IUC item) { return TPrintBinary<COut, IUC>(*this, item); }
COut& COut::Binary(ISD item) {
return TPrintBinary<COut, ISD, IUD>(*this, item);
}
COut& COut::Binary(IUD item) { return TPrintBinary<COut, IUD>(*this, item); }
#if USING_FPC == YES_0
COut& COut::Binary(FPC item) { return TPrintBinary<COut>(*this, item); }
#endif
#if USING_FPD == YES_0
COut& COut::Binary(FPD item) { return TPrintBinary<COut>(*this, item); }
#endif
ISN COut::PrintAndCount(const CHA* string) {
return TPrintAndCount<COut, CHA>(*this, string);
}
#if USING_UTF16 == YES_0
ISN COut::PrintAndCount(const CHB* string) {
return TPrintAndCount<COut, CHB>(*this, string);
}
#endif
#if USING_UTF32 == YES_0
ISN COut::PrintAndCount(const CHC* string) {
return TPrintAndCount<COut, CHC>(*this, string);
}
#endif
COut& StdOut() { return COut().Star(); }
COut CPrint(CHA item) { return COut(item); }
COut CPrint(const CHA* item) { return COut(item); }
#if USING_UTF16 == YES_0
COut CPrint(CHB item) { return COut(item); }
COut CPrint(const CHB* item) { return COut(item); }
#endif
#if USING_UTF32 == YES_0
COut CPrint(CHC item) { return COut(item); }
COut CPrint(const CHC* item) { return COut(item); }
#endif
COut CPrint(ISC item) { return COut(item); }
COut CPrint(IUC item) { return COut(item); }
COut CPrint(ISD item) { return COut(item); }
COut CPrint(IUD item) { return COut(item); }
#if USING_FPC == YES_0
COut CPrint(FPC item) { return COut(item); }
#endif
#if USING_FPD == YES_0
COut CPrint(FPD item) { return COut(item); }
#endif
COut CPrint(Hexf& item) { return COut(item); }
COut CPrint(Binaryf& item) { return COut(item); }
COut CPrint(Centerf& item) { return COut(item); }
COut CPrint(Rightf& item) { return COut(item); }
COut CPrint(Linef& item) { return COut(item); }
COut CPrint(Headingf& item) { return COut(item); }
COut CPrint(Indentf& item) { return COut(item); }
} //< namespace _
_::COut& operator<<(_::COut& o, CHA item) { return o.Print(item); }
_::COut& operator<<(_::COut& o, const CHA* item) { return o.Print(item); }
#if USING_UTF16 == YES_0
_::COut& operator<<(_::COut& o, CHB item) { return o.Print(item); }
_::COut& operator<<(_::COut& o, const CHB* item) { return o.Print(item); }
#endif
#if USING_UTF32 == YES_0
_::COut& operator<<(_::COut& o, CHC item) { return o.Print(item); }
_::COut& operator<<(_::COut& o, const CHC* item) { return o.Print(item); }
#endif
_::COut& operator<<(_::COut& o, ISC item) { return o.Print(item); }
_::COut& operator<<(_::COut& o, IUC item) { return o.Print(item); }
_::COut& operator<<(_::COut& o, ISD item) { return o.Print(item); }
_::COut& operator<<(_::COut& o, IUD item) { return o.Print(item); }
#if USING_FPC == YES_0
_::COut& operator<<(_::COut& o, FPC item) { return o.Print(item); }
#endif
#if USING_FPD == YES_0
_::COut& operator<<(_::COut& o, FPD item) { return o.Print(item); }
#endif
_::COut& operator<<(_::COut& o, _::Hexf item) {
return _::TPrint<_::COut>(o, item);
}
_::COut& operator<<(_::COut& o, _::Binaryf item) {
return _::TPrint<_::COut>(o, item);
}
_::COut& operator<<(_::COut& o, _::Headingf item) {
return _::TPrint<_::COut>(o, item);
}
#if SEAM >= SCRIPT2_UNIPRINTER
_::COut& operator<<(_::COut& o, _::Centerf item) {
return _::TPrint<_::COut>(o, item);
}
_::COut& operator<<(_::COut& o, _::Rightf item) {
return _::TPrint<_::COut>(o, item);
}
_::COut& operator<<(_::COut& o, _::Linef item) {
return _::TPrint<_::COut>(o, item);
}
_::COut& operator<<(_::COut& o, _::Indentf item) {
return _::TPrint<_::COut>(o, item);
}
_::COut& operator<<(_::COut& o, _::Charsf item) {
return _::TPrint<_::COut>(o, item);
}
_::COut& operator<<(_::COut& o, _::Sizef item) {
return _::TPrint<_::COut>(o, item);
}
_::COut& operator<<(_::COut& printer, _::ATypef item) {
return _::TPrint<_::COut>(printer, item);
}
/*
inline _::COut& operator<<(_::COut& printer, _::TypeWordValue item) {
return _::TPrint<_::COut>(printer, item);
}*/
_::COut& operator<<(_::COut& o, _::COut& item) {
return o;
}
#endif
#endif