le_print.h

Go to the documentation of this file.
1 /**
2  * @page c_print Print APIs
3  *
4  * @ref le_print.h "API Reference"
5  *
6  * <HR>
7  *
8  *
9  * Copyright (C) Sierra Wireless Inc.
10  *
11  */
12 
13 //--------------------------------------------------------------------------------------------------
14 /** @file le_print.h
15  * *
16  * Legato @ref c_print include file.
17  *
18  * Copyright (C) Sierra Wireless Inc.
19  *
20  */
21 
22 #ifndef LEGATO_PRINT_INCLUDE_GUARD
23 #define LEGATO_PRINT_INCLUDE_GUARD
24 
25 //--------------------------------------------------------------------------------------------------
26 /**
27  * Print a single value using specified format.
28  *
29  * @param formatSpec @ref LE_DEBUG format; must be a string literal
30  * @param value Variable name; must not be a literal
31  */
32 //--------------------------------------------------------------------------------------------------
33 #define LE_PRINT_VALUE(formatSpec, value) \
34  LE_DEBUG( STRINGIZE(value) "=" formatSpec, value)
35 
36 //--------------------------------------------------------------------------------------------------
37 /**
38  * Print a single value using specified format, if condition is met.
39  *
40  * @param condition Boolean
41  * @param formatSpec @ref LE_DEBUG format; must be a string literal
42  * @param value Variable name; must not be a literal
43  */
44 //--------------------------------------------------------------------------------------------------
45 #define LE_PRINT_VALUE_IF(condition, formatSpec, value) \
46  if (condition) \
47  { LE_PRINT_VALUE(formatSpec, value); }
48 
49 //--------------------------------------------------------------------------------------------------
50 /**
51  * Print an array of values using specified format for each value.
52  *
53  * @param formatSpec @ref LE_DEBUG format; must be a string literal
54  * @param size Array size
55  * @param array Array name
56  */
57 //--------------------------------------------------------------------------------------------------
58 #define LE_PRINT_ARRAY(formatSpec, size, array) \
59  { \
60  int i; \
61  LE_DEBUG( STRINGIZE(array) ); \
62  for (i=0; i<(size_t)size; i++) \
63  LE_DEBUG( "\t" STRINGIZE(array) "[%i]=" formatSpec, i, array[i]); \
64  }
65 
66 #endif // LEGATO_PRINT_INCLUDE_GUARD
67