1 #ifndef TEXT_WRITER_TYPES 2 #define TEXT_WRITER_TYPES 12 #define DEFAULT_STREAM std::cerr 26 virtual ~aTextWriter() {}
27 virtual void write(
const char* text)
const = 0;
30 class TextPrinter :
public aTextWriter
33 TextPrinter(
const char* s = 0)
38 if (strcmp(s,
"stdout") == 0 || strcmp(s,
"cout") == 0)
40 else if (strcmp(s,
"stderr") == 0 || strcmp(s,
"cerr") == 0)
44 void write(
const char* text)
const override 55 DEFAULT_STREAM << text;
63 class TextWriter :
public aTextWriter
67 TextWriter(std::ostream* os = 0)
70 void write(
const char* text)
const override 80 class TextWriterHandle
83 TextWriterHandle() { init_(); }
84 void set_information_channel(aTextWriter*
info) { information_channel_ =
info; }
85 void* information_channel_ptr() {
return (
void*)information_channel_; }
86 void set_warning_channel(aTextWriter* warn) { warning_channel_ = warn; }
87 void* warning_channel_ptr() {
return (
void*)warning_channel_; }
88 void set_error_channel(aTextWriter* errr) { error_channel_ = errr; }
89 void* error_channel_ptr() {
return (
void*)error_channel_; }
90 void print_information(
const char* text)
92 if (information_channel_)
93 information_channel_->write(text);
97 void print_warning(
const char* text)
100 warning_channel_->write(text);
104 void print_error(
const char* text)
107 error_channel_->write(text);
113 static aTextWriter* information_channel_;
114 static aTextWriter* warning_channel_;
115 static aTextWriter* error_channel_;
118 static bool initialized =
false;
121 information_channel_ = 0;
122 warning_channel_ = 0;
129 void writeText(
const char* text, OUTPUT_CHANNEL channel = INFORMATION_CHANNEL);
void info(const STRING &string, const int verbosity_level=1)
Use this function for writing informational messages.
Definition: info.h:51
basic configuration include file