152 #define PRINT_INT_FLAG(DEC, OCT, HEX, VAL, FLAG) \
154 case IntFmt_decimal: \
155 fprintf(file, "%" FLAG "*" #DEC, (int) width, VAL);break; \
157 fprintf(file, "%" FLAG "*" #OCT, (int) width, VAL);break; \
158 case IntFmt_hexadecimal: \
159 fprintf(file, "%" FLAG "*" #HEX, (int) width, VAL);break; \
160 default: assert(false && "Bad int format"); \
163 #define PRINT_INT(DEC, OCT, HEX, VAL) \
167 PRINT_INT_FLAG(DEC,OCT,HEX,VAL,"-"); \
171 PRINT_INT_FLAG(DEC,OCT,HEX,VAL,"0"); \
173 PRINT_INT_FLAG(DEC,OCT,HEX,VAL,""); \
177 assert(false && "Bad alignment"); \
180 #define PRINT_FLOAT_FLAG(DEC, SCI, HEX, VAL, FLAG) \
181 switch (float_fmt) { \
182 case FloatFmt_decimal: \
183 fprintf(file, "%" FLAG "*.*" #DEC, (int) width, precision, VAL); break; \
184 case FloatFmt_scientific: \
185 fprintf(file, "%" FLAG "*.*" #SCI, (int) width, precision, VAL); break; \
186 case FloatFmt_hexadecimal: \
187 fprintf(file, "%" FLAG "*.*" #HEX, (int) width, precision, VAL); break; \
189 assert(false && "Bad float format"); \
192 #define PRINT_FLOAT(DEC, SCI, HEX, VAL) \
196 PRINT_FLOAT_FLAG(DEC,SCI,HEX,VAL,"-"); \
200 PRINT_FLOAT_FLAG(DEC,SCI,HEX,VAL,"0"); \
202 PRINT_FLOAT_FLAG(DEC,SCI,HEX,VAL,""); \
206 assert(false && "Bad alignment"); \
220 fprintf(
file,
"%*c", (
int) width, c);
229 return (*
this) << (b ?
"true" :
"false");
278 if (!p)
return (*
this) <<
"NULL";
281 OS <<
"0x" <<
hex << (
const long int)p;
287 if (!cs) cs =
"(null)";
297 fprintf(
file,
"%*s", (
int) width, cs);
409 case Black:
return (*
this) <<
"\033[30m";
410 case Red:
return (*
this) <<
"\033[31m";
411 case Green:
return (*
this) <<
"\033[32m";
412 case Yellow:
return (*
this) <<
"\033[33m";
413 case Blue:
return (*
this) <<
"\033[34m";
414 case Magenta:
return (*
this) <<
"\033[35m";
415 case Cyan:
return (*
this) <<
"\033[36m";
416 case White:
return (*
this) <<
"\033[37m";
417 case BoldBlack:
return (*
this) <<
"\033[30m\033[1m";
418 case BoldRed:
return (*
this) <<
"\033[31m\033[1m";
419 case BoldGreen:
return (*
this) <<
"\033[32m\033[1m";
420 case BoldYellow:
return (*
this) <<
"\033[33m\033[1m";
421 case BoldBlue:
return (*
this) <<
"\033[34m\033[1m";
422 case BoldMagenta:
return (*
this) <<
"\033[35m\033[1m";
423 case BoldCyan:
return (*
this) <<
"\033[36m\033[1m";
424 case BoldWhite:
return (*
this) <<
"\033[37m\033[1m";
426 assert(
false &&
"Unknown color code");
434 return (*
this) <<
"\033[0m";
438 return (*
this) <<
"\033[1m";
442 return (*
this) <<
"\033[21m";
446 return (*
this) <<
"\033[4m";
450 return (*
this) <<
"\033[24m";
size_t indent_lvl
indentation level
static SetWidth setw(size_t w)
IntegerFormat int_fmt
format used to print integer types
Set precision flag for next item to be written.
void init_flag_defaults()
initialize all format flags to their default value
FloatFormat float_fmt
format used to print floating point types
OStream & operator<<(char)
size_t width
padding for next write
void init_persistent_flags()
initialize all flags that survive a write operation
#define PRINT_FLOAT(DEC, SCI, HEX, VAL)
bool newline
true iff we are at the beginning of a new line
OStream(FILE *file)
create a new stream with default flags
#define PRINT_INT(DEC, OCT, HEX, VAL)
enum cacao::OStream::@2 align
Alignment to use when padding text.
Set indent level in stream.
intptr_t threads_get_current_tid(void)
Color prefix_color
color line prefix is printed in
static void set_force_color(int)
force color (0 = disabled, 1 = yes, 0 = no)
static int force_color
force color (0 = disabled, 1 = yes, 0 = no)
const char * prefix
line prefix
Simple stream class for formatted output.
Set width flag for next item to be written.
bool use_color() const
supports ansi escape codes
Set width flag and fill zero for next item to be written.
void init_transient_flags()
initialize all flags that only apply to one write operation
bool _use_color
supports ansi escape codes
FILE * file
file stream writes to