Point Cloud Library (PCL)  1.10.0
print.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2010, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the copyright holder(s) nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  * $Id$
35  *
36  */
37 
38 #pragma once
39 
40 #include <cstdio>
41 #include <cstdarg>
42 
43 #include <pcl/pcl_exports.h>
44 #include <pcl/pcl_config.h>
45 
46 #define PCL_ALWAYS(...) pcl::console::print (pcl::console::L_ALWAYS, __VA_ARGS__)
47 #define PCL_ERROR(...) pcl::console::print (pcl::console::L_ERROR, __VA_ARGS__)
48 #define PCL_WARN(...) pcl::console::print (pcl::console::L_WARN, __VA_ARGS__)
49 #define PCL_INFO(...) pcl::console::print (pcl::console::L_INFO, __VA_ARGS__)
50 #define PCL_DEBUG(...) pcl::console::print (pcl::console::L_DEBUG, __VA_ARGS__)
51 #define PCL_VERBOSE(...) pcl::console::print (pcl::console::L_VERBOSE, __VA_ARGS__)
52 
53 #define PCL_ASSERT_ERROR_PRINT_CHECK(pred, msg) \
54  do \
55  { \
56  if (!(pred)) \
57  { \
58  PCL_ERROR(msg); \
59  PCL_ERROR("In File %s, in line %d\n" __FILE__, __LINE__); \
60  } \
61  } while (0)
62 
63 #define PCL_ASSERT_ERROR_PRINT_RETURN(pred, msg, err) \
64  do \
65  { \
66  PCL_ASSERT_ERROR_PRINT_CHECK(pred, msg); \
67  if (!(pred)) return err; \
68  } while (0)
69 
70 namespace pcl
71 {
72  namespace console
73  {
75  {
76  TT_RESET = 0,
77  TT_BRIGHT = 1,
78  TT_DIM = 2,
80  TT_BLINK = 4,
83  };
84 
85  enum TT_COLORS
86  {
95  };
96 
98  {
105  };
106 
107  /** set the verbosity level */
108  PCL_EXPORTS void
110 
111  /** get the verbosity level. */
114 
115  /** initialize verbosity level. */
116  PCL_EXPORTS bool
118 
119  /** is verbosity level enabled? */
120  PCL_EXPORTS bool
122 
123  /** \brief Enable or disable colored text output, overriding the default behavior.
124  *
125  * By default, colored output is enabled for interactive terminals or when the environment
126  * variable PCL_CLICOLOR_FORCE is set.
127  *
128  * \param stream the output stream (stdout, stderr, etc)
129  * \param enable whether to emit color codes when calling any of the color related methods
130  */
131  PCL_EXPORTS void
132  enableColoredOutput (FILE *stream, bool enable);
133 
134  /** \brief Change the text color (on either stdout or stderr) with an attr:fg:bg
135  * \param stream the output stream (stdout, stderr, etc)
136  * \param attribute the text attribute
137  * \param fg the foreground color
138  * \param bg the background color
139  */
140  PCL_EXPORTS void
141  change_text_color (FILE *stream, int attribute, int fg, int bg);
142 
143  /** \brief Change the text color (on either stdout or stderr) with an attr:fg
144  * \param stream the output stream (stdout, stderr, etc)
145  * \param attribute the text attribute
146  * \param fg the foreground color
147  */
148  PCL_EXPORTS void
149  change_text_color (FILE *stream, int attribute, int fg);
150 
151  /** \brief Reset the text color (on either stdout or stderr) to its original state
152  * \param stream the output stream (stdout, stderr, etc)
153  */
154  PCL_EXPORTS void
155  reset_text_color (FILE *stream);
156 
157  /** \brief Print a message on stream with colors
158  * \param stream the output stream (stdout, stderr, etc)
159  * \param attr the text attribute
160  * \param fg the foreground color
161  * \param format the message
162  */
163  PCL_EXPORTS void
164  print_color (FILE *stream, int attr, int fg, const char *format, ...);
165 
166  /** \brief Print an info message on stream with colors
167  * \param format the message
168  */
169  PCL_EXPORTS void
170  print_info (const char *format, ...);
171 
172  /** \brief Print an info message on stream with colors
173  * \param stream the output stream (stdout, stderr, etc)
174  * \param format the message
175  */
176  PCL_EXPORTS void
177  print_info (FILE *stream, const char *format, ...);
178 
179  /** \brief Print a highlighted info message on stream with colors
180  * \param format the message
181  */
182  PCL_EXPORTS void
183  print_highlight (const char *format, ...);
184 
185  /** \brief Print a highlighted info message on stream with colors
186  * \param stream the output stream (stdout, stderr, etc)
187  * \param format the message
188  */
189  PCL_EXPORTS void
190  print_highlight (FILE *stream, const char *format, ...);
191 
192  /** \brief Print an error message on stream with colors
193  * \param format the message
194  */
195  PCL_EXPORTS void
196  print_error (const char *format, ...);
197 
198  /** \brief Print an error message on stream with colors
199  * \param stream the output stream (stdout, stderr, etc)
200  * \param format the message
201  */
202  PCL_EXPORTS void
203  print_error (FILE *stream, const char *format, ...);
204 
205  /** \brief Print a warning message on stream with colors
206  * \param format the message
207  */
208  PCL_EXPORTS void
209  print_warn (const char *format, ...);
210 
211  /** \brief Print a warning message on stream with colors
212  * \param stream the output stream (stdout, stderr, etc)
213  * \param format the message
214  */
215  PCL_EXPORTS void
216  print_warn (FILE *stream, const char *format, ...);
217 
218  /** \brief Print a debug message on stream with colors
219  * \param format the message
220  */
221  PCL_EXPORTS void
222  print_debug (const char *format, ...);
223 
224  /** \brief Print a debug message on stream with colors
225  * \param stream the output stream (stdout, stderr, etc)
226  * \param format the message
227  */
228  PCL_EXPORTS void
229  print_debug (FILE *stream, const char *format, ...);
230 
231 
232  /** \brief Print a value message on stream with colors
233  * \param format the message
234  */
235  PCL_EXPORTS void
236  print_value (const char *format, ...);
237 
238  /** \brief Print a value message on stream with colors
239  * \param stream the output stream (stdout, stderr, etc)
240  * \param format the message
241  */
242  PCL_EXPORTS void
243  print_value (FILE *stream, const char *format, ...);
244 
245  /** \brief Print a message on stream
246  * \param level the verbosity level
247  * \param stream the output stream (stdout, stderr, etc)
248  * \param format the message
249  */
250  PCL_EXPORTS void
251  print (VERBOSITY_LEVEL level, FILE *stream, const char *format, ...);
252 
253  /** \brief Print a message
254  * \param level the verbosity level
255  * \param format the message
256  */
257  PCL_EXPORTS void
258  print (VERBOSITY_LEVEL level, const char *format, ...);
259  }
260 }
pcl
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
pcl::console::L_VERBOSE
@ L_VERBOSE
Definition: print.h:104
pcl::console::print
PCL_EXPORTS void print(VERBOSITY_LEVEL level, FILE *stream, const char *format,...)
Print a message on stream.
pcl::console::TT_BLUE
@ TT_BLUE
Definition: print.h:91
pcl::console::TT_HIDDEN
@ TT_HIDDEN
Definition: print.h:82
pcl::console::TT_ATTIBUTES
TT_ATTIBUTES
Definition: print.h:74
pcl::console::print_highlight
PCL_EXPORTS void print_highlight(const char *format,...)
Print a highlighted info message on stream with colors.
pcl::io::ply::format
format
Definition: ply.h:98
pcl::console::L_INFO
@ L_INFO
Definition: print.h:102
pcl::console::TT_GREEN
@ TT_GREEN
Definition: print.h:89
pcl::console::enableColoredOutput
PCL_EXPORTS void enableColoredOutput(FILE *stream, bool enable)
Enable or disable colored text output, overriding the default behavior.
pcl::console::TT_REVERSE
@ TT_REVERSE
Definition: print.h:81
pcl::console::L_ALWAYS
@ L_ALWAYS
Definition: print.h:99
pcl::console::reset_text_color
PCL_EXPORTS void reset_text_color(FILE *stream)
Reset the text color (on either stdout or stderr) to its original state.
pcl::console::L_DEBUG
@ L_DEBUG
Definition: print.h:103
pcl::console::TT_CYAN
@ TT_CYAN
Definition: print.h:93
pcl::console::TT_BLINK
@ TT_BLINK
Definition: print.h:80
pcl::console::initVerbosityLevel
PCL_EXPORTS bool initVerbosityLevel()
initialize verbosity level.
pcl::console::TT_WHITE
@ TT_WHITE
Definition: print.h:94
pcl::console::TT_BRIGHT
@ TT_BRIGHT
Definition: print.h:77
pcl::console::print_error
PCL_EXPORTS void print_error(const char *format,...)
Print an error message on stream with colors.
pcl::console::print_value
PCL_EXPORTS void print_value(const char *format,...)
Print a value message on stream with colors.
pcl::console::print_info
PCL_EXPORTS void print_info(const char *format,...)
Print an info message on stream with colors.
pcl::console::L_ERROR
@ L_ERROR
Definition: print.h:100
pcl::console::TT_DIM
@ TT_DIM
Definition: print.h:78
pcl::console::TT_COLORS
TT_COLORS
Definition: print.h:85
pcl::console::print_debug
PCL_EXPORTS void print_debug(const char *format,...)
Print a debug message on stream with colors.
pcl::console::TT_RED
@ TT_RED
Definition: print.h:88
pcl::console::TT_YELLOW
@ TT_YELLOW
Definition: print.h:90
pcl::console::isVerbosityLevelEnabled
PCL_EXPORTS bool isVerbosityLevelEnabled(VERBOSITY_LEVEL severity)
is verbosity level enabled?
pcl::console::setVerbosityLevel
PCL_EXPORTS void setVerbosityLevel(VERBOSITY_LEVEL level)
set the verbosity level
pcl::console::print_color
PCL_EXPORTS void print_color(FILE *stream, int attr, int fg, const char *format,...)
Print a message on stream with colors.
pcl::console::getVerbosityLevel
PCL_EXPORTS VERBOSITY_LEVEL getVerbosityLevel()
get the verbosity level.
pcl::console::change_text_color
PCL_EXPORTS void change_text_color(FILE *stream, int attribute, int fg, int bg)
Change the text color (on either stdout or stderr) with an attr:fg:bg.
pcl::console::VERBOSITY_LEVEL
VERBOSITY_LEVEL
Definition: print.h:97
pcl::console::TT_RESET
@ TT_RESET
Definition: print.h:76
pcl::console::TT_BLACK
@ TT_BLACK
Definition: print.h:87
pcl::console::TT_MAGENTA
@ TT_MAGENTA
Definition: print.h:92
pcl::console::TT_UNDERLINE
@ TT_UNDERLINE
Definition: print.h:79
PCL_EXPORTS
#define PCL_EXPORTS
Definition: pcl_macros.h:253
pcl::console::print_warn
PCL_EXPORTS void print_warn(const char *format,...)
Print a warning message on stream with colors.
pcl::console::L_WARN
@ L_WARN
Definition: print.h:101