libknx
debug.hpp
1 #pragma once
2 
3 #define KNX_OUTPUT
4 
5 #define BOOST_MPL_CFG_NO_PREPROCESSED_HEADERS
6 #define BOOST_MPL_LIMIT_VECTOR_SIZE 30
7 
8 #include <string>
9 
10 #ifdef __linux__
11 //#define MARK_UNUSED __attribute((unused))
12 #define MARK_UNUSED
13 #define TYPENAME typename
14 #else
15 #define MARK_UNUSED
16 #define TYPENAME
17 #endif
18 
19 #ifndef __linux__
20 #ifndef __APPLE__
21 #pragma warning (disable: 4251)
22 #endif
23 #endif
24 
25 namespace knx
26 {
27 
29 static const std::string COLOR_OFF="\033[0m" ; // Text Reset
30 
32 static const std::string Red="\033[0;31m" ; // Red
33 static const std::string Green="\033[0;32m" ; // Green
34 static const std::string Yellow="\033[0;33m" ; // Yellow
35 
37 static const std::string BYellow="\033[1;33m" ; // Yellow
38 static const std::string BBlue="\033[1;34m" ; // Blue
39 
41 static const std::string COLOR_RESET = COLOR_OFF;
42 static const std::string COLOR_INFO = Green;
43 static const std::string COLOR_WARNING = Yellow;
44 static const std::string COLOR_ERROR = Red;
45 static const std::string COLOR_SENDING = BBlue;
46 static const std::string COLOR_RECEIVING = BYellow;
47 
48 } // end namespace
49 
51 #define SIMPLE_FILENAME(x) x.substr(x.find_last_of('/')+1)
52 
54 #ifdef KNX_OUTPUT
55 #define ONOFF
56 #else
57 #define ONOFF if(false)
58 #endif
59 
61 #include <iostream>
62 #define KNX_SENDING ONOFF std::cerr << knx::COLOR_SENDING << SIMPLE_FILENAME(std::string(__FILE__)) << ":" << __LINE__ << " (" << __FUNCTION__ << ") >> " << knx::COLOR_RESET
63 #define KNX_RECEIVING ONOFF std::cerr << knx::COLOR_RECEIVING << SIMPLE_FILENAME(std::string(__FILE__)) << ":" << __LINE__ << " (" << __FUNCTION__ << ") >> " << knx::COLOR_RESET
64 
66 #define KNX_INFORMATION ONOFF std::cerr << knx::COLOR_INFO << SIMPLE_FILENAME(std::string(__FILE__)) << ":" << __LINE__ << " (" << __FUNCTION__ << ") >> " << knx::COLOR_RESET
67 #define KNX_WARNING ONOFF std::cerr << knx::COLOR_WARNING << SIMPLE_FILENAME(std::string(__FILE__)) << ":" << __LINE__ << " (" << __FUNCTION__ << ") WARNING >> " << knx::COLOR_RESET
68 #define KNX_ERROR std::cerr << knx::COLOR_ERROR << SIMPLE_FILENAME(std::string(__FILE__)) << ":" << __LINE__ << " (" << __FUNCTION__ << ") ERROR >> " << knx::COLOR_RESET
69 #define KNX_FINAL std::cout
70 
71 // WINDOWS
72 #ifdef __linux
73 #define KNX_IMPORT_EXPORT
74 #elif defined __APPLE__
75 #define KNX_IMPORT_EXPORT
76 #elif defined KNX_EXPORT
77 #define KNX_IMPORT_EXPORT __declspec(dllexport)
78 #else
79 #define KNX_IMPORT_EXPORT __declspec(dllimport)
80 #endif
separated namespace to embed all libknx related classes
Definition: connection.hpp:14