Point Cloud Library (PCL)  1.7.1
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 #ifndef TERMINAL_TOOLS_PRINT_H_
38 #define TERMINAL_TOOLS_PRINT_H_
39 
40 #include <stdio.h>
41 #include <stdarg.h>
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. */
112  PCL_EXPORTS VERBOSITY_LEVEL
114 
115  /** initialize verbosity level. */
116  PCL_EXPORTS bool
118 
119  /** is verbosity level enabled? */
120  PCL_EXPORTS bool
122 
123  /** \brief Change the text color (on either stdout or stderr) with an attr:fg:bg
124  * \param stream the output stream (stdout, stderr, etc)
125  * \param attribute the text attribute
126  * \param fg the foreground color
127  * \param bg the background color
128  */
129  PCL_EXPORTS void
130  change_text_color (FILE *stream, int attribute, int fg, int bg);
131 
132  /** \brief Change the text color (on either stdout or stderr) with an attr:fg
133  * \param stream the output stream (stdout, stderr, etc)
134  * \param attribute the text attribute
135  * \param fg the foreground color
136  */
137  PCL_EXPORTS void
138  change_text_color (FILE *stream, int attribute, int fg);
139 
140  /** \brief Reset the text color (on either stdout or stderr) to its original state
141  * \param stream the output stream (stdout, stderr, etc)
142  */
143  PCL_EXPORTS void
144  reset_text_color (FILE *stream);
145 
146  /** \brief Print a message on stream with colors
147  * \param stream the output stream (stdout, stderr, etc)
148  * \param attr the text attribute
149  * \param fg the foreground color
150  * \param format the message
151  */
152  PCL_EXPORTS void
153  print_color (FILE *stream, int attr, int fg, const char *format, ...);
154 
155  /** \brief Print an info message on stream with colors
156  * \param format the message
157  */
158  PCL_EXPORTS void
159  print_info (const char *format, ...);
160 
161  /** \brief Print an info message on stream with colors
162  * \param stream the output stream (stdout, stderr, etc)
163  * \param format the message
164  */
165  PCL_EXPORTS void
166  print_info (FILE *stream, const char *format, ...);
167 
168  /** \brief Print a highlighted info message on stream with colors
169  * \param format the message
170  */
171  PCL_EXPORTS void
172  print_highlight (const char *format, ...);
173 
174  /** \brief Print a highlighted info message on stream with colors
175  * \param stream the output stream (stdout, stderr, etc)
176  * \param format the message
177  */
178  PCL_EXPORTS void
179  print_highlight (FILE *stream, const char *format, ...);
180 
181  /** \brief Print an error message on stream with colors
182  * \param format the message
183  */
184  PCL_EXPORTS void
185  print_error (const char *format, ...);
186 
187  /** \brief Print an error message on stream with colors
188  * \param stream the output stream (stdout, stderr, etc)
189  * \param format the message
190  */
191  PCL_EXPORTS void
192  print_error (FILE *stream, const char *format, ...);
193 
194  /** \brief Print a warning message on stream with colors
195  * \param format the message
196  */
197  PCL_EXPORTS void
198  print_warn (const char *format, ...);
199 
200  /** \brief Print a warning message on stream with colors
201  * \param stream the output stream (stdout, stderr, etc)
202  * \param format the message
203  */
204  PCL_EXPORTS void
205  print_warn (FILE *stream, const char *format, ...);
206 
207  /** \brief Print a debug message on stream with colors
208  * \param format the message
209  */
210  PCL_EXPORTS void
211  print_debug (const char *format, ...);
212 
213  /** \brief Print a debug message on stream with colors
214  * \param stream the output stream (stdout, stderr, etc)
215  * \param format the message
216  */
217  PCL_EXPORTS void
218  print_debug (FILE *stream, const char *format, ...);
219 
220 
221  /** \brief Print a value message on stream with colors
222  * \param format the message
223  */
224  PCL_EXPORTS void
225  print_value (const char *format, ...);
226 
227  /** \brief Print a value message on stream with colors
228  * \param stream the output stream (stdout, stderr, etc)
229  * \param format the message
230  */
231  PCL_EXPORTS void
232  print_value (FILE *stream, const char *format, ...);
233 
234  /** \brief Print a message on stream
235  * \param level the verbosity level
236  * \param stream the output stream (stdout, stderr, etc)
237  * \param format the message
238  */
239  PCL_EXPORTS void
240  print (VERBOSITY_LEVEL level, FILE *stream, const char *format, ...);
241 
242  /** \brief Print a message
243  * \param level the verbosity level
244  * \param format the message
245  */
246  PCL_EXPORTS void
247  print (VERBOSITY_LEVEL level, const char *format, ...);
248  }
249 }
250 
251 #endif // TERMINAL_TOOLS_PRINT_H_
PCL_EXPORTS void print(VERBOSITY_LEVEL level, FILE *stream, const char *format,...)
Print a message on stream.
VERBOSITY_LEVEL
Definition: print.h:97
PCL_EXPORTS void print_debug(const char *format,...)
Print a debug message on stream with colors.
PCL_EXPORTS void print_warn(const char *format,...)
Print a warning message on stream with colors.
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_EXPORTS void print_info(const char *format,...)
Print an info message on stream with colors.
PCL_EXPORTS bool isVerbosityLevelEnabled(VERBOSITY_LEVEL severity)
is verbosity level enabled?
PCL_EXPORTS VERBOSITY_LEVEL getVerbosityLevel()
get the verbosity level.
PCL_EXPORTS bool initVerbosityLevel()
initialize verbosity level.
PCL_EXPORTS void print_color(FILE *stream, int attr, int fg, const char *format,...)
Print a message on stream with colors.
PCL_EXPORTS void reset_text_color(FILE *stream)
Reset the text color (on either stdout or stderr) to its original state.
PCL_EXPORTS void print_highlight(const char *format,...)
Print a highlighted info message on stream with colors.
PCL_EXPORTS void print_value(const char *format,...)
Print a value message on stream with colors.
PCL_EXPORTS void setVerbosityLevel(VERBOSITY_LEVEL level)
set the verbosity level
TT_ATTIBUTES
Definition: print.h:74
PCL_EXPORTS void print_error(const char *format,...)
Print an error message on stream with colors.