EmbAJAX
Simplistic framework for creating and handling displays and controls on a web page served by an embeddable device (Arduino or other microcontroller with Arduino support).
macro_definitions.h
Go to the documentation of this file.
1 
27 /* //////////// String formatting tokens //////////////// */
28 
29 #define JS_QUOTED_STRING_ARG "\10"
30 #define HTML_QUOTED_STRING_ARG "\11"
31 //#define JS_ESCAPED_STRING_ARG '\12'
32 #define HTML_ESCAPED_STRING_ARG "\13"
33 #define PLAIN_STRING_ARG "\14"
34 #define INTEGER_VALUE_ARG "\15"
35 
36 /* //////////// String formatting macros ////////////////
37  *
38  * The user-facing macro here is printFormatted(). This takes static strings and args in a
39  * and re-aggranges them so that static strings are merged into one, and the variable args args
40  * are appended at the end (suitable for EmbAJAXOutputDriverBase::printContentF(). */
41 
42 // See https://stackoverflow.com/questions/11761703/overloading-macro-on-number-of-arguments
43 #define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,_11,_12,_13,_14,_15,_16,_17,_18,_19,_20,_21,_22,_23,_24,_25,_26,NAME,...) NAME
44 #define printF_(...) GET_MACRO(__VA_ARGS__, printF_26, printF_25, printF_24, printF_23, printF_22, printF_21, printF_20, printF_19, printF_18, printF_17, printF_16, printF_15, printF_14, printF_13, printF_12, printF_11, printF_10, printF_9, printF_8, printF_7, printF_6, printF_5, printF_4, printF_3, printF_2, printF_1)(__VA_ARGS__)
45 
47 #define JS_QUOTED_STRING(X) JS_QUOTED_STRING_ARG, (const char*) X
49 #define HTML_QUOTED_STRING(X) HTML_QUOTED_STRING_ARG, (const char*) X
50 //#define JS_QUOTED_STRING(X) JS_ESCAPED_STRING_ARG, (const char*) X
52 #define HTML_ESCAPED_STRING(X) HTML_ESCAPED_STRING_ARG, (const char*) X
54 #define PLAIN_STRING(X) PLAIN_STRING_ARG, (const char*) X
56 #define INTEGER_VALUE(X) INTEGER_VALUE_ARG, (int) X
57 
92 #define printFormatted(...) printF_(__VA_ARGS__)
93 
94 #define printF_3(F1, A1a, A1b) printF_proxy((F1 A1a), A1b)
95 #define printF_4(F1, A1a, A1b, F2) printF_proxy((F1 A1a F2), A1b)
96 //#define printF_5(...) // Not validly possible, as we always follow fmt, arg, fmt, arg...
97 #define printF_6(F1, A1a, A1b, F2, A2a, A2b) printF_proxy((F1 A1a F2 A2a), A1b, A2b)
98 #define printF_7(F1, A1a, A1b, F2, A2a, A2b, F3) printF_proxy((F1 A1a F2 A2a F3), A1b, A2b)
99 //#define printF_8(...)
100 #define printF_9(F1, A1a, A1b, F2, A2a, A2b, F3, A3a, A3b) printF_proxy((F1 A1a F2 A2a F3 A3a), A1b, A2b, A3b)
101 #define printF_10(F1, A1a, A1b, F2, A2a, A2b, F3, A3a, A3b, F4) printF_proxy((F1 A1a F2 A2a F3 A3a F4), A1b, A2b, A3b)
102 //#define printF_11(...)
103 #define printF_12(F1, A1a, A1b, F2, A2a, A2b, F3, A3a, A3b, F4, A4a, A4b) printF_proxy((F1 A1a F2 A2a F3 A3a F4 A4a), A1b, A2b, A3b, A4b)
104 #define printF_13(F1, A1a, A1b, F2, A2a, A2b, F3, A3a, A3b, F4, A4a, A4b, F5) printF_proxy((F1 A1a F2 A2a F3 A3a F4 A4a F5), A1b, A2b, A3b, A4b)
105 //#define printF_14(...)
106 #define printF_15(F1, A1a, A1b, F2, A2a, A2b, F3, A3a, A3b, F4, A4a, A4b, F5, A5a, A5b) printF_proxy((F1 A1a F2 A2a F3 A3a F4 A4a F5 A5a), A1b, A2b, A3b, A4b, A5b)
107 #define printF_16(F1, A1a, A1b, F2, A2a, A2b, F3, A3a, A3b, F4, A4a, A4b, F5, A5a, A5b, F6) printF_proxy((F1 A1a F2 A2a F3 A3a F4 A4a F5 A5a F6), A1b, A2b, A3b, A4b, A5b)
108 //#define printF_17(...)
109 #define printF_18(F1, A1a, A1b, F2, A2a, A2b, F3, A3a, A3b, F4, A4a, A4b, F5, A5a, A5b, F6, A6a, A6b) printF_proxy((F1 A1a F2 A2a F3 A3a F4 A4a F5 A5a F6 A6a), A1b, A2b, A3b, A4b, A5b, A6b)
110 #define printF_19(F1, A1a, A1b, F2, A2a, A2b, F3, A3a, A3b, F4, A4a, A4b, F5, A5a, A5b, F6, A6a, A6b, F7) printF_proxy((F1 A1a F2 A2a F3 A3a F4 A4a F5 A5a F6 A6a F7), A1b, A2b, A3b, A4b, A5b, A6b)
111 //#define printF_20(...)
112 #define printF_21(F1, A1a, A1b, F2, A2a, A2b, F3, A3a, A3b, F4, A4a, A4b, F5, A5a, A5b, F6, A6a, A6b, F7, A7a, A7b) printF_proxy((F1 A1a F2 A2a F3 A3a F4 A4a F5 A5a F6 A6a F7 A7a), A1b, A2b, A3b, A4b, A5b, A6b, A7b)
113 #define printF_22(F1, A1a, A1b, F2, A2a, A2b, F3, A3a, A3b, F4, A4a, A4b, F5, A5a, A5b, F6, A6a, A6b, F7, A7a, A7b, F8) printF_proxy((F1 A1a F2 A2a F3 A3a F4 A4a F5 A5a F6 A6a F7 A7a F8), A1b, A2b, A3b, A4b, A5b, A6b, A7b)
114 //#define printF_23(...)
115 #define printF_24(F1, A1a, A1b, F2, A2a, A2b, F3, A3a, A3b, F4, A4a, A4b, F5, A5a, A5b, F6, A6a, A6b, F7, A7a, A7b, F8, A8a, A8b) printF_proxy((F1 A1a F2 A2a F3 A3a F4 A4a F5 A5a F6 A6a F7 A7a F8 A8a), A1b, A2b, A3b, A4b, A5b, A6b, A7b, A8b)
116 #define printF_25(F1, A1a, A1b, F2, A2a, A2b, F3, A3a, A3b, F4, A4a, A4b, F5, A5a, A5b, F6, A6a, A6b, F7, A7a, A7b, F8, A8a, A8b, F9) printF_proxy((F1 A1a F2 A2a F3 A3a F4 A4a F5 A5a F6 A6a F7 A7a F8 A8a F9), A1b, A2b, A3b, A4b, A5b, A6b, A7b, A8b)
117 
118 #if USE_PROGMEM_STRINGS
119  #define printF_proxy(X, ...) _printContentF(F(X), __VA_ARGS__);
120 #else
121  #define printF_proxy(X, ...) _printContentF(X, __VA_ARGS__);
122 #endif