HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
tinyformat.h
Go to the documentation of this file.
1 // tinyformat.h
2 // Copyright (C) 2011, Chris Foster [chris42f (at) gmail (d0t) com]
3 //
4 // Boost Software License - Version 1.0
5 //
6 // Permission is hereby granted, free of charge, to any person or organization
7 // obtaining a copy of the software and accompanying documentation covered by
8 // this license (the "Software") to use, reproduce, display, distribute,
9 // execute, and transmit the Software, and to prepare derivative works of the
10 // Software, and to permit third-parties to whom the Software is furnished to
11 // do so, all subject to the following:
12 //
13 // The copyright notices in the Software and this entire statement, including
14 // the above license grant, this restriction and the following disclaimer,
15 // must be included in all copies of the Software, in whole or in part, and
16 // all derivative works of the Software, unless such copies or derivative
17 // works are solely in the form of machine-executable object code generated by
18 // a source language processor.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
23 // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
24 // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
25 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 // DEALINGS IN THE SOFTWARE.
27 
28 //------------------------------------------------------------------------------
29 // Tinyformat: A minimal type safe printf replacement
30 //
31 // tinyformat.h is a type safe printf replacement library in a single C++
32 // header file. Design goals include:
33 //
34 // * Type safety and extensibility for user defined types.
35 // * C99 printf() compatibility, to the extent possible using std::ostream
36 // * Simplicity and minimalism. A single header file to include and distribute
37 // with your projects.
38 // * Augment rather than replace the standard stream formatting mechanism
39 // * C++98 support, with optional C++11 niceties
40 //
41 //
42 // Main interface example usage
43 // ----------------------------
44 //
45 // To print a date to std::cout:
46 //
47 // std::string weekday = "Wednesday";
48 // const char* month = "July";
49 // size_t day = 27;
50 // long hour = 14;
51 // int min = 44;
52 //
53 // tfm::printf("%s, %s %d, %.2d:%.2d\n", weekday, month, day, hour, min);
54 //
55 // The strange types here emphasize the type safety of the interface; it is
56 // possible to print a std::string using the "%s" conversion, and a
57 // size_t using the "%d" conversion. A similar result could be achieved
58 // using either of the tfm::format() functions. One prints on a user provided
59 // stream:
60 //
61 // tfm::format(std::cerr, "%s, %s %d, %.2d:%.2d\n",
62 // weekday, month, day, hour, min);
63 //
64 // The other returns a std::string:
65 //
66 // std::string date = tfm::format("%s, %s %d, %.2d:%.2d\n",
67 // weekday, month, day, hour, min);
68 // std::cout << date;
69 //
70 // These are the three primary interface functions. There is also a
71 // convenience function printfln() which appends a newline to the usual result
72 // of printf() for super simple logging.
73 //
74 //
75 // User defined format functions
76 // -----------------------------
77 //
78 // Simulating variadic templates in C++98 is pretty painful since it requires
79 // writing out the same function for each desired number of arguments. To make
80 // this bearable tinyformat comes with a set of macros which are used
81 // internally to generate the API, but which may also be used in user code.
82 //
83 // The three macros TINYFORMAT_ARGTYPES(n), TINYFORMAT_VARARGS(n) and
84 // TINYFORMAT_PASSARGS(n) will generate a list of n argument types,
85 // type/name pairs and argument names respectively when called with an integer
86 // n between 1 and 16. We can use these to define a macro which generates the
87 // desired user defined function with n arguments. To generate all 16 user
88 // defined function bodies, use the macro TINYFORMAT_FOREACH_ARGNUM. For an
89 // example, see the implementation of printf() at the end of the source file.
90 //
91 // Sometimes it's useful to be able to pass a list of format arguments through
92 // to a non-template function. The FormatList class is provided as a way to do
93 // this by storing the argument list in a type-opaque way. Continuing the
94 // example from above, we construct a FormatList using makeFormatList():
95 //
96 // FormatListRef formatList = tfm::makeFormatList(weekday, month, day, hour, min);
97 //
98 // The format list can now be passed into any non-template function and used
99 // via a call to the vformat() function:
100 //
101 // tfm::vformat(std::cout, "%s, %s %d, %.2d:%.2d\n", formatList);
102 //
103 //
104 // Additional API information
105 // --------------------------
106 //
107 // Error handling: Define TINYFORMAT_ERROR to customize the error handling for
108 // format strings which are unsupported or have the wrong number of format
109 // specifiers (calls assert() by default).
110 //
111 // User defined types: Uses operator<< for user defined types by default.
112 // Overload formatValue() for more control.
113 
114 // clang-format off
115 
116 
117 #ifndef TINYFORMAT_H_INCLUDED
118 #define TINYFORMAT_H_INCLUDED
119 
120 namespace tinyformat {}
121 //------------------------------------------------------------------------------
122 // Config section. Customize to your liking!
123 
124 // Namespace alias to encourage brevity
125 namespace tfm = tinyformat;
126 
127 // Error handling; calls assert() by default.
128 // #define TINYFORMAT_ERROR(reasonString) your_error_handler(reasonString)
129 
130 // Define for C++11 variadic templates which make the code shorter & more
131 // general. If you don't define this, C++11 support is autodetected below.
132 // #define TINYFORMAT_USE_VARIADIC_TEMPLATES
133 
134 
135 //------------------------------------------------------------------------------
136 // Implementation details.
137 #include <algorithm>
138 #include <cassert>
139 #include <iostream>
140 #include <sstream>
141 
142 #ifndef TINYFORMAT_ERROR
143 # define TINYFORMAT_ERROR(reason) assert(0 && reason)
144 #endif
145 
146 #if !defined(TINYFORMAT_USE_VARIADIC_TEMPLATES) && !defined(TINYFORMAT_NO_VARIADIC_TEMPLATES)
147 # ifdef __GXX_EXPERIMENTAL_CXX0X__
148 # define TINYFORMAT_USE_VARIADIC_TEMPLATES
149 # endif
150 #endif
151 
152 #if defined(__GLIBCXX__) && __GLIBCXX__ < 20080201
153 // std::showpos is broken on old libstdc++ as provided with OSX. See
154 // http://gcc.gnu.org/ml/libstdc++/2007-11/msg00075.html
155 # define TINYFORMAT_OLD_LIBSTDCPLUSPLUS_WORKAROUND
156 #endif
157 
158 #ifdef __APPLE__
159 // Workaround OSX linker warning: xcode uses different default symbol
160 // visibilities for static libs vs executables (see issue #25)
161 # define TINYFORMAT_HIDDEN __attribute__((visibility("hidden")))
162 #else
163 # define TINYFORMAT_HIDDEN
164 #endif
165 
166 namespace tinyformat {
167 
168 //------------------------------------------------------------------------------
169 namespace detail {
170 
171 // Test whether type T1 is convertible to type T2
172 template <typename T1, typename T2>
174 {
175  private:
176  // two types of different size
177  struct fail { char dummy[2]; };
178  struct succeed { char dummy; };
179  // Try to convert a T1 to a T2 by plugging into tryConvert
180  static fail tryConvert(...);
181  static succeed tryConvert(const T2&);
182  static const T1& makeT1();
183  public:
184 # ifdef _MSC_VER
185  // Disable spurious loss of precision warnings in tryConvert(makeT1())
186 # pragma warning(push)
187 # pragma warning(disable:4244)
188 # pragma warning(disable:4267)
189 # endif
190  // Standard trick: the (...) version of tryConvert will be chosen from
191  // the overload set only if the version taking a T2 doesn't match.
192  // Then we compare the sizes of the return types to check which
193  // function matched. Very neat, in a disgusting kind of way :)
194  static const bool value =
195  sizeof(tryConvert(makeT1())) == sizeof(succeed);
196 # ifdef _MSC_VER
197 # pragma warning(pop)
198 # endif
199 };
200 
201 
202 // Detect when a type is not a wchar_t string
203 template<typename T> struct is_wchar { typedef int tinyformat_wchar_is_not_supported; };
204 template<> struct is_wchar<wchar_t*> {};
205 template<> struct is_wchar<const wchar_t*> {};
206 template<int n> struct is_wchar<const wchar_t[n]> {};
207 template<int n> struct is_wchar<wchar_t[n]> {};
208 
209 
210 // Format the value by casting to type fmtT. This default implementation
211 // should never be called.
214 {
215  static void invoke(std::ostream& /*out*/, const T& /*value*/) { assert(0); }
216 };
217 // Specialized version for types that can actually be converted to fmtT, as
218 // indicated by the "convertible" template parameter.
219 template<typename T, typename fmtT>
220 struct formatValueAsType<T,fmtT,true>
221 {
222  static void invoke(std::ostream& out, const T& value)
223  { out << static_cast<fmtT>(value); }
224 };
225 
226 #ifdef TINYFORMAT_OLD_LIBSTDCPLUSPLUS_WORKAROUND
228 struct formatZeroIntegerWorkaround
229 {
230  static bool invoke(std::ostream& /**/, const T& /**/) { return false; }
231 };
232 template<typename T>
233 struct formatZeroIntegerWorkaround<T,true>
234 {
235  static bool invoke(std::ostream& out, const T& value)
236  {
237  if (static_cast<int>(value) == 0 && out.flags() & std::ios::showpos)
238  {
239  out << "+0";
240  return true;
241  }
242  return false;
243  }
244 };
245 #endif // TINYFORMAT_OLD_LIBSTDCPLUSPLUS_WORKAROUND
246 
247 // Convert an arbitrary type to integer. The version with convertible=false
248 // throws an error.
251 {
252  static int invoke(const T& /*value*/)
253  {
254  TINYFORMAT_ERROR("tinyformat: Cannot convert from argument type to "
255  "integer for use as variable width or precision");
256  return 0;
257  }
258 };
259 // Specialization for convertToInt when conversion is possible
260 template<typename T>
261 struct convertToInt<T,true>
262 {
263  static int invoke(const T& value) { return static_cast<int>(value); }
264 };
265 
266 // Format at most ntrunc characters to the given stream.
267 template<typename T>
268 inline void formatTruncated(std::ostream& out, const T& value, int ntrunc)
269 {
270  std::ostringstream tmp;
271  tmp.imbue (out.getloc());
272  tmp << value;
273  std::string result = tmp.str();
274  out.write(result.c_str(), (std::min)(ntrunc, static_cast<int>(result.size())));
275 }
276 #define TINYFORMAT_DEFINE_FORMAT_TRUNCATED_CSTR(type) \
277 inline void formatTruncated(std::ostream& out, type* value, int ntrunc) \
278 { \
279  std::streamsize len = 0; \
280  while(len < ntrunc && value[len] != 0) \
281  ++len; \
282  out.write(value, len); \
283 }
284 // Overload for const char* and char*. Could overload for signed & unsigned
285 // char too, but these are technically unneeded for printf compatibility.
288 #undef TINYFORMAT_DEFINE_FORMAT_TRUNCATED_CSTR
289 
290 } // namespace detail
291 
292 
293 //------------------------------------------------------------------------------
294 // Variable formatting functions. May be overridden for user-defined types if
295 // desired.
296 
297 
298 /// Format a value into a stream, delegating to operator<< by default.
299 ///
300 /// Users may override this for their own types. When this function is called,
301 /// the stream flags will have been modified according to the format string.
302 /// The format specification is provided in the range [fmtBegin, fmtEnd). For
303 /// truncating conversions, ntrunc is set to the desired maximum number of
304 /// characters, for example "%.7s" calls formatValue with ntrunc = 7.
305 ///
306 /// By default, formatValue() uses the usual stream insertion operator
307 /// operator<< to format the type T, with special cases for the %c and %p
308 /// conversions.
309 template<typename T>
310 inline void formatValue(std::ostream& out, const char* /*fmtBegin*/,
311  const char* fmtEnd, int ntrunc, const T& value)
312 {
313 #ifndef TINYFORMAT_ALLOW_WCHAR_STRINGS
314  // Since we don't support printing of wchar_t using "%ls", make it fail at
315  // compile time in preference to printing as a void* at runtime.
317  (void) DummyType(); // avoid unused type warning with gcc-4.8
318 #endif
319  // The mess here is to support the %c and %p conversions: if these
320  // conversions are active we try to convert the type to a char or const
321  // void* respectively and format that instead of the value itself. For the
322  // %p conversion it's important to avoid dereferencing the pointer, which
323  // could otherwise lead to a crash when printing a dangling (const char*).
324  const bool canConvertToChar = detail::is_convertible<T,char>::value;
325  const bool canConvertToVoidPtr = detail::is_convertible<T, const void*>::value;
326  if(canConvertToChar && *(fmtEnd-1) == 'c')
328  else if(canConvertToVoidPtr && *(fmtEnd-1) == 'p')
330 #ifdef TINYFORMAT_OLD_LIBSTDCPLUSPLUS_WORKAROUND
331  else if(detail::formatZeroIntegerWorkaround<T>::invoke(out, value)) /**/;
332 #endif
333  else if(ntrunc >= 0)
334  {
335  // Take care not to overread C strings in truncating conversions like
336  // "%.4s" where at most 4 characters may be read.
337  detail::formatTruncated(out, value, ntrunc);
338  }
339  else
340  out << value;
341 }
342 
343 
344 // Overloaded version for char types to support printing as an integer
345 #define TINYFORMAT_DEFINE_FORMATVALUE_CHAR(charType) \
346 inline void formatValue(std::ostream& out, const char* /*fmtBegin*/, \
347  const char* fmtEnd, int /**/, charType value) \
348 { \
349  switch(*(fmtEnd-1)) \
350  { \
351  case 'u': case 'd': case 'i': case 'o': case 'X': case 'x': \
352  out << static_cast<int>(value); break; \
353  default: \
354  out << value; break; \
355  } \
356 }
357 // per 3.9.1: char, signed char and unsigned char are all distinct types
361 #undef TINYFORMAT_DEFINE_FORMATVALUE_CHAR
362 
363 
364 //------------------------------------------------------------------------------
365 // Tools for emulating variadic templates in C++98. The basic idea here is
366 // stolen from the hboost preprocessor metaprogramming library and cut down to
367 // be just general enough for what we need.
368 
369 #define TINYFORMAT_ARGTYPES(n) TINYFORMAT_ARGTYPES_ ## n
370 #define TINYFORMAT_VARARGS(n) TINYFORMAT_VARARGS_ ## n
371 #define TINYFORMAT_PASSARGS(n) TINYFORMAT_PASSARGS_ ## n
372 #define TINYFORMAT_PASSARGS_TAIL(n) TINYFORMAT_PASSARGS_TAIL_ ## n
373 
374 // To keep it as transparent as possible, the macros below have been generated
375 // using python via the excellent cog.py code generation script. This avoids
376 // the need for a bunch of complex (but more general) preprocessor tricks as
377 // used in hboost.preprocessor.
378 //
379 // To rerun the code generation in place, use `cog.py -r tinyformat.h`
380 // (see http://nedbatchelder.com/code/cog). Alternatively you can just create
381 // extra versions by hand.
382 
383 /*[[[cog
384 maxParams = 16
385 
386 def makeCommaSepLists(lineTemplate, elemTemplate, startInd=1):
387  for j in range(startInd,maxParams+1):
388  list = ', '.join([elemTemplate % {'i':i} for i in range(startInd,j+1)])
389  cog.outl(lineTemplate % {'j':j, 'list':list})
390 
391 makeCommaSepLists('#define TINYFORMAT_ARGTYPES_%(j)d %(list)s',
392  'class T%(i)d')
393 
394 cog.outl()
395 makeCommaSepLists('#define TINYFORMAT_VARARGS_%(j)d %(list)s',
396  'const T%(i)d& v%(i)d')
397 
398 cog.outl()
399 makeCommaSepLists('#define TINYFORMAT_PASSARGS_%(j)d %(list)s', 'v%(i)d')
400 
401 cog.outl()
402 cog.outl('#define TINYFORMAT_PASSARGS_TAIL_1')
403 makeCommaSepLists('#define TINYFORMAT_PASSARGS_TAIL_%(j)d , %(list)s',
404  'v%(i)d', startInd = 2)
405 
406 cog.outl()
407 cog.outl('#define TINYFORMAT_FOREACH_ARGNUM(m) \\\n ' +
408  ' '.join(['m(%d)' % (j,) for j in range(1,maxParams+1)]))
409 ]]]*/
410 #define TINYFORMAT_ARGTYPES_1 class T1
411 #define TINYFORMAT_ARGTYPES_2 class T1, class T2
412 #define TINYFORMAT_ARGTYPES_3 class T1, class T2, class T3
413 #define TINYFORMAT_ARGTYPES_4 class T1, class T2, class T3, class T4
414 #define TINYFORMAT_ARGTYPES_5 class T1, class T2, class T3, class T4, class T5
415 #define TINYFORMAT_ARGTYPES_6 class T1, class T2, class T3, class T4, class T5, class T6
416 #define TINYFORMAT_ARGTYPES_7 class T1, class T2, class T3, class T4, class T5, class T6, class T7
417 #define TINYFORMAT_ARGTYPES_8 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8
418 #define TINYFORMAT_ARGTYPES_9 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9
419 #define TINYFORMAT_ARGTYPES_10 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10
420 #define TINYFORMAT_ARGTYPES_11 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11
421 #define TINYFORMAT_ARGTYPES_12 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12
422 #define TINYFORMAT_ARGTYPES_13 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12, class T13
423 #define TINYFORMAT_ARGTYPES_14 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12, class T13, class T14
424 #define TINYFORMAT_ARGTYPES_15 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12, class T13, class T14, class T15
425 #define TINYFORMAT_ARGTYPES_16 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12, class T13, class T14, class T15, class T16
426 
427 #define TINYFORMAT_VARARGS_1 const T1& v1
428 #define TINYFORMAT_VARARGS_2 const T1& v1, const T2& v2
429 #define TINYFORMAT_VARARGS_3 const T1& v1, const T2& v2, const T3& v3
430 #define TINYFORMAT_VARARGS_4 const T1& v1, const T2& v2, const T3& v3, const T4& v4
431 #define TINYFORMAT_VARARGS_5 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5
432 #define TINYFORMAT_VARARGS_6 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6
433 #define TINYFORMAT_VARARGS_7 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7
434 #define TINYFORMAT_VARARGS_8 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8
435 #define TINYFORMAT_VARARGS_9 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9
436 #define TINYFORMAT_VARARGS_10 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10
437 #define TINYFORMAT_VARARGS_11 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10, const T11& v11
438 #define TINYFORMAT_VARARGS_12 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10, const T11& v11, const T12& v12
439 #define TINYFORMAT_VARARGS_13 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10, const T11& v11, const T12& v12, const T13& v13
440 #define TINYFORMAT_VARARGS_14 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10, const T11& v11, const T12& v12, const T13& v13, const T14& v14
441 #define TINYFORMAT_VARARGS_15 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10, const T11& v11, const T12& v12, const T13& v13, const T14& v14, const T15& v15
442 #define TINYFORMAT_VARARGS_16 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10, const T11& v11, const T12& v12, const T13& v13, const T14& v14, const T15& v15, const T16& v16
443 
444 #define TINYFORMAT_PASSARGS_1 v1
445 #define TINYFORMAT_PASSARGS_2 v1, v2
446 #define TINYFORMAT_PASSARGS_3 v1, v2, v3
447 #define TINYFORMAT_PASSARGS_4 v1, v2, v3, v4
448 #define TINYFORMAT_PASSARGS_5 v1, v2, v3, v4, v5
449 #define TINYFORMAT_PASSARGS_6 v1, v2, v3, v4, v5, v6
450 #define TINYFORMAT_PASSARGS_7 v1, v2, v3, v4, v5, v6, v7
451 #define TINYFORMAT_PASSARGS_8 v1, v2, v3, v4, v5, v6, v7, v8
452 #define TINYFORMAT_PASSARGS_9 v1, v2, v3, v4, v5, v6, v7, v8, v9
453 #define TINYFORMAT_PASSARGS_10 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10
454 #define TINYFORMAT_PASSARGS_11 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11
455 #define TINYFORMAT_PASSARGS_12 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12
456 #define TINYFORMAT_PASSARGS_13 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13
457 #define TINYFORMAT_PASSARGS_14 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14
458 #define TINYFORMAT_PASSARGS_15 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15
459 #define TINYFORMAT_PASSARGS_16 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16
460 
461 #define TINYFORMAT_PASSARGS_TAIL_1
462 #define TINYFORMAT_PASSARGS_TAIL_2 , v2
463 #define TINYFORMAT_PASSARGS_TAIL_3 , v2, v3
464 #define TINYFORMAT_PASSARGS_TAIL_4 , v2, v3, v4
465 #define TINYFORMAT_PASSARGS_TAIL_5 , v2, v3, v4, v5
466 #define TINYFORMAT_PASSARGS_TAIL_6 , v2, v3, v4, v5, v6
467 #define TINYFORMAT_PASSARGS_TAIL_7 , v2, v3, v4, v5, v6, v7
468 #define TINYFORMAT_PASSARGS_TAIL_8 , v2, v3, v4, v5, v6, v7, v8
469 #define TINYFORMAT_PASSARGS_TAIL_9 , v2, v3, v4, v5, v6, v7, v8, v9
470 #define TINYFORMAT_PASSARGS_TAIL_10 , v2, v3, v4, v5, v6, v7, v8, v9, v10
471 #define TINYFORMAT_PASSARGS_TAIL_11 , v2, v3, v4, v5, v6, v7, v8, v9, v10, v11
472 #define TINYFORMAT_PASSARGS_TAIL_12 , v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12
473 #define TINYFORMAT_PASSARGS_TAIL_13 , v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13
474 #define TINYFORMAT_PASSARGS_TAIL_14 , v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14
475 #define TINYFORMAT_PASSARGS_TAIL_15 , v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15
476 #define TINYFORMAT_PASSARGS_TAIL_16 , v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16
477 
478 #define TINYFORMAT_FOREACH_ARGNUM(m) \
479  m(1) m(2) m(3) m(4) m(5) m(6) m(7) m(8) m(9) m(10) m(11) m(12) m(13) m(14) m(15) m(16)
480 //[[[end]]]
481 
482 
483 
484 namespace detail {
485 
486 // Type-opaque holder for an argument to format(), with associated actions on
487 // the type held as explicit function pointers. This allows FormatArg's for
488 // each argument to be allocated as a homogenous array inside FormatList
489 // whereas a naive implementation based on inheritance does not.
491 {
492  public:
494 
495  template<typename T>
496  FormatArg(const T& value)
497  : m_value(static_cast<const void*>(&value)),
498  m_formatImpl(&formatImpl<T>),
499  m_toIntImpl(&toIntImpl<T>)
500  { }
501 
502  void format(std::ostream& out, const char* fmtBegin,
503  const char* fmtEnd, int ntrunc) const
504  {
505  m_formatImpl(out, fmtBegin, fmtEnd, ntrunc, m_value);
506  }
507 
508  int toInt() const
509  {
510  return m_toIntImpl(m_value);
511  }
512 
513  private:
514  template<typename T>
515  TINYFORMAT_HIDDEN static void formatImpl(std::ostream& out, const char* fmtBegin,
516  const char* fmtEnd, int ntrunc, const void* value)
517  {
518  formatValue(out, fmtBegin, fmtEnd, ntrunc, *static_cast<const T*>(value));
519  }
520 
521  template<typename T>
522  TINYFORMAT_HIDDEN static int toIntImpl(const void* value)
523  {
524  return convertToInt<T>::invoke(*static_cast<const T*>(value));
525  }
526 
527  const void* m_value;
528  void (*m_formatImpl)(std::ostream& out, const char* fmtBegin,
529  const char* fmtEnd, int ntrunc, const void* value);
530  int (*m_toIntImpl)(const void* value);
531 };
532 
533 
534 // Parse and return an integer from the string c, as atoi()
535 // On return, c is set to one past the end of the integer.
536 inline int parseIntAndAdvance(const char*& c)
537 {
538  int i = 0;
539  for(;*c >= '0' && *c <= '9'; ++c)
540  i = 10*i + (*c - '0');
541  return i;
542 }
543 
544 // Print literal part of format string and return next format spec
545 // position.
546 //
547 // Skips over any occurrences of '%%', printing a literal '%' to the
548 // output. The position of the first % character of the next
549 // nontrivial format spec is returned, or the end of string.
550 inline const char* printFormatStringLiteral(std::ostream& out, const char* fmt)
551 {
552  const char* c = fmt;
553  for(;; ++c)
554  {
555  switch(*c)
556  {
557  case '\0':
558  out.write(fmt, c - fmt);
559  return c;
560  case '%':
561  out.write(fmt, c - fmt);
562  if(*(c+1) != '%')
563  return c;
564  // for "%%", tack trailing % onto next literal section.
565  fmt = ++c;
566  break;
567  default:
568  break;
569  }
570  }
571 }
572 
573 
574 // Parse a format string and set the stream state accordingly.
575 //
576 // The format mini-language recognized here is meant to be the one from C99,
577 // with the form "%[flags][width][.precision][length]type".
578 //
579 // Formatting options which can't be natively represented using the ostream
580 // state are returned in spacePadPositive (for space padded positive numbers)
581 // and ntrunc (for truncating conversions). argIndex is incremented if
582 // necessary to pull out variable width and precision . The function returns a
583 // pointer to the character after the end of the current format spec.
584 inline const char* streamStateFromFormat(std::ostream& out, bool& spacePadPositive,
585  int& ntrunc, const char* fmtStart,
586  const detail::FormatArg* formatters,
587  int& argIndex, int numFormatters)
588 {
589  if(*fmtStart != '%')
590  {
591  TINYFORMAT_ERROR("tinyformat: Not enough conversion specifiers in format string");
592  return fmtStart;
593  }
594  // Reset stream state to defaults.
595  out.width(0);
596  out.precision(6);
597  out.fill(' ');
598  // Reset most flags; ignore irrelevant unitbuf & skipws.
599  out.unsetf(std::ios::adjustfield | std::ios::basefield |
600  std::ios::floatfield | std::ios::showbase | std::ios::boolalpha |
601  std::ios::showpoint | std::ios::showpos | std::ios::uppercase);
602  bool precisionSet = false;
603  bool widthSet = false;
604  int widthExtra = 0;
605  const char* c = fmtStart + 1;
606  // 1) Parse flags
607  for(;; ++c)
608  {
609  switch(*c)
610  {
611  case '#':
612  out.setf(std::ios::showpoint | std::ios::showbase);
613  continue;
614  case '0':
615  // overridden by left alignment ('-' flag)
616  if(!(out.flags() & std::ios::left))
617  {
618  // Use internal padding so that numeric values are
619  // formatted correctly, eg -00010 rather than 000-10
620  out.fill('0');
621  out.setf(std::ios::internal, std::ios::adjustfield);
622  }
623  continue;
624  case '-':
625  out.fill(' ');
626  out.setf(std::ios::left, std::ios::adjustfield);
627  continue;
628  case ' ':
629  // overridden by show positive sign, '+' flag.
630  if(!(out.flags() & std::ios::showpos))
631  spacePadPositive = true;
632  continue;
633  case '+':
634  out.setf(std::ios::showpos);
635  spacePadPositive = false;
636  widthExtra = 1;
637  continue;
638  default:
639  break;
640  }
641  break;
642  }
643  // 2) Parse width
644  if(*c >= '0' && *c <= '9')
645  {
646  widthSet = true;
647  out.width(parseIntAndAdvance(c));
648  }
649  if(*c == '*')
650  {
651  widthSet = true;
652  int width = 0;
653  if(argIndex < numFormatters)
654  width = formatters[argIndex++].toInt();
655  else
656  TINYFORMAT_ERROR("tinyformat: Not enough arguments to read variable width");
657  if(width < 0)
658  {
659  // negative widths correspond to '-' flag set
660  out.fill(' ');
661  out.setf(std::ios::left, std::ios::adjustfield);
662  width = -width;
663  }
664  out.width(width);
665  ++c;
666  }
667  // 3) Parse precision
668  if(*c == '.')
669  {
670  ++c;
671  int precision = 0;
672  if(*c == '*')
673  {
674  ++c;
675  if(argIndex < numFormatters)
676  precision = formatters[argIndex++].toInt();
677  else
678  TINYFORMAT_ERROR("tinyformat: Not enough arguments to read variable precision");
679  }
680  else
681  {
682  if(*c >= '0' && *c <= '9')
683  precision = parseIntAndAdvance(c);
684  else if(*c == '-') // negative precisions ignored, treated as zero.
685  parseIntAndAdvance(++c);
686  }
687  out.precision(precision);
688  precisionSet = true;
689  }
690  // 4) Ignore any C99 length modifier
691  while(*c == 'l' || *c == 'h' || *c == 'L' ||
692  *c == 'j' || *c == 'z' || *c == 't')
693  ++c;
694  // 5) We're up to the conversion specifier character.
695  // Set stream flags based on conversion specifier (thanks to the
696  // hboost::format class for forging the way here).
697  bool intConversion = false;
698  switch(*c)
699  {
700  case 'u': case 'd': case 'i':
701  out.setf(std::ios::dec, std::ios::basefield);
702  intConversion = true;
703  break;
704  case 'o':
705  out.setf(std::ios::oct, std::ios::basefield);
706  intConversion = true;
707  break;
708  case 'X':
709  out.setf(std::ios::uppercase);
710  case 'x': case 'p':
711  out.setf(std::ios::hex, std::ios::basefield);
712  intConversion = true;
713  break;
714  case 'E':
715  out.setf(std::ios::uppercase);
716  case 'e':
717  out.setf(std::ios::scientific, std::ios::floatfield);
718  out.setf(std::ios::dec, std::ios::basefield);
719  break;
720  case 'F':
721  out.setf(std::ios::uppercase);
722  case 'f':
723  out.setf(std::ios::fixed, std::ios::floatfield);
724  break;
725  case 'G':
726  out.setf(std::ios::uppercase);
727  case 'g':
728  out.setf(std::ios::dec, std::ios::basefield);
729  // As in hboost::format, let stream decide float format.
730  out.flags(out.flags() & ~std::ios::floatfield);
731  break;
732  case 'a': case 'A':
733  TINYFORMAT_ERROR("tinyformat: the %a and %A conversion specs "
734  "are not supported");
735  break;
736  case 'c':
737  // Handled as special case inside formatValue()
738  break;
739  case 's':
740  if(precisionSet)
741  ntrunc = static_cast<int>(out.precision());
742  // Make %s print booleans as "true" and "false"
743  out.setf(std::ios::boolalpha);
744  break;
745  case 'n':
746  // Not supported - will cause problems!
747  TINYFORMAT_ERROR("tinyformat: %n conversion spec not supported");
748  break;
749  case '\0':
750  TINYFORMAT_ERROR("tinyformat: Conversion spec incorrectly "
751  "terminated by end of string");
752  return c;
753  default:
754  break;
755  }
756  if(intConversion && precisionSet && !widthSet)
757  {
758  // "precision" for integers gives the minimum number of digits (to be
759  // padded with zeros on the left). This isn't really supported by the
760  // iostreams, but we can approximately simulate it with the width if
761  // the width isn't otherwise used.
762  out.width(out.precision() + widthExtra);
763  out.setf(std::ios::internal, std::ios::adjustfield);
764  out.fill('0');
765  }
766  return c+1;
767 }
768 
769 
770 //------------------------------------------------------------------------------
771 inline void formatImpl(std::ostream& out, const char* fmt,
772  const detail::FormatArg* formatters,
773  int numFormatters)
774 {
775  // Saved stream state
776  std::streamsize origWidth = out.width();
777  std::streamsize origPrecision = out.precision();
778  std::ios::fmtflags origFlags = out.flags();
779  char origFill = out.fill();
780 
781  for (int argIndex = 0; argIndex < numFormatters; ++argIndex)
782  {
783  // Parse the format string
784  fmt = printFormatStringLiteral(out, fmt);
785  bool spacePadPositive = false;
786  int ntrunc = -1;
787  const char* fmtEnd = streamStateFromFormat(out, spacePadPositive, ntrunc, fmt,
788  formatters, argIndex, numFormatters);
789  if (argIndex >= numFormatters)
790  {
791  // Check args remain after reading any variable width/precision
792  TINYFORMAT_ERROR("tinyformat: Not enough format arguments");
793  return;
794  }
795  const FormatArg& arg = formatters[argIndex];
796  // Format the arg into the stream.
797  if(!spacePadPositive)
798  arg.format(out, fmt, fmtEnd, ntrunc);
799  else
800  {
801  // The following is a special case with no direct correspondence
802  // between stream formatting and the printf() behaviour. Simulate
803  // it crudely by formatting into a temporary string stream and
804  // munging the resulting string.
805  std::ostringstream tmpStream;
806  tmpStream.imbue (out.getloc());
807  tmpStream.copyfmt(out);
808  tmpStream.setf(std::ios::showpos);
809  arg.format(tmpStream, fmt, fmtEnd, ntrunc);
810  std::string result = tmpStream.str(); // allocates... yuck.
811  for(size_t i = 0, iend = result.size(); i < iend; ++i)
812  if(result[i] == '+') result[i] = ' ';
813  out << result;
814  }
815  fmt = fmtEnd;
816  }
817 
818  // Print remaining part of format string.
819  fmt = printFormatStringLiteral(out, fmt);
820  if(*fmt != '\0')
821  TINYFORMAT_ERROR("tinyformat: Too many conversion specifiers in format string");
822 
823  // Restore stream state
824  out.width(origWidth);
825  out.precision(origPrecision);
826  out.flags(origFlags);
827  out.fill(origFill);
828 }
829 
830 } // namespace detail
831 
832 
833 /// List of template arguments format(), held in a type-opaque way.
834 ///
835 /// A const reference to FormatList (typedef'd as FormatListRef) may be
836 /// conveniently used to pass arguments to non-template functions: All type
837 /// information has been stripped from the arguments, leaving just enough of a
838 /// common interface to perform formatting as required.
840 {
841  public:
842  FormatList(detail::FormatArg* formatters, int N)
843  : m_formatters(formatters), m_N(N) { }
844 
845  friend void vformat(std::ostream& out, const char* fmt,
846  const FormatList& list);
847 
848  private:
849  const detail::FormatArg* m_formatters;
850  int m_N;
851 };
852 
853 /// Reference to type-opaque format list for passing to vformat()
854 typedef const FormatList& FormatListRef;
855 
856 
857 namespace detail {
858 
859 // Format list subclass with fixed storage to avoid dynamic allocation
860 template<int N>
861 class FormatListN : public FormatList
862 {
863  public:
864 #ifdef TINYFORMAT_USE_VARIADIC_TEMPLATES
865  template<typename... Args>
866  FormatListN(const Args&... args)
867  : FormatList(&m_formatterStore[0], N),
868  m_formatterStore { FormatArg(args)... }
869  { static_assert(sizeof...(args) == N, "Number of args must be N"); }
870 #else // C++98 version
871  void init(int) {}
872 # define TINYFORMAT_MAKE_FORMATLIST_CONSTRUCTOR(n) \
873  \
874  template<TINYFORMAT_ARGTYPES(n)> \
875  FormatListN(TINYFORMAT_VARARGS(n)) \
876  : FormatList(&m_formatterStore[0], n) \
877  { assert(n == N); init(0, TINYFORMAT_PASSARGS(n)); } \
878  \
879  template<TINYFORMAT_ARGTYPES(n)> \
880  void init(int i, TINYFORMAT_VARARGS(n)) \
881  { \
882  m_formatterStore[i] = FormatArg(v1); \
883  init(i+1 TINYFORMAT_PASSARGS_TAIL(n)); \
884  }
885 
887 # undef TINYFORMAT_MAKE_FORMATLIST_CONSTRUCTOR
888 #endif
889 
890  private:
891  FormatArg m_formatterStore[N];
892 };
893 
894 // Special 0-arg version - MSVC says zero-sized C array in struct is nonstandard
895 template<> class FormatListN<0> : public FormatList
896 {
897  public: FormatListN() : FormatList(0, 0) {}
898 };
899 
900 } // namespace detail
901 
902 
903 //------------------------------------------------------------------------------
904 // Primary API functions
905 
906 #ifdef TINYFORMAT_USE_VARIADIC_TEMPLATES
907 
908 /// Make type-agnostic format list from list of template arguments.
909 ///
910 /// The exact return type of this function is an implementation detail and
911 /// shouldn't be relied upon. Instead it should be stored as a FormatListRef:
912 ///
913 /// FormatListRef formatList = makeFormatList( /*...*/ );
914 template<typename... Args>
915 detail::FormatListN<sizeof...(Args)> makeFormatList(const Args&... args)
916 {
917  return detail::FormatListN<sizeof...(args)>(args...);
918 }
919 
920 #else // C++98 version
921 
923 {
924  return detail::FormatListN<0>();
925 }
926 #define TINYFORMAT_MAKE_MAKEFORMATLIST(n) \
927 template<TINYFORMAT_ARGTYPES(n)> \
928 detail::FormatListN<n> makeFormatList(TINYFORMAT_VARARGS(n)) \
929 { \
930  return detail::FormatListN<n>(TINYFORMAT_PASSARGS(n)); \
931 }
933 #undef TINYFORMAT_MAKE_MAKEFORMATLIST
934 
935 #endif
936 
937 /// Format list of arguments to the stream according to the given format string.
938 /// This honors the stream's existing locale conventions.
939 ///
940 /// The name vformat() is chosen for the semantic similarity to vprintf(): the
941 /// list of format arguments is held in a single function argument.
942 inline void vformat(std::ostream& out, const char* fmt, FormatListRef list)
943 {
944  detail::formatImpl(out, fmt, list.m_formatters, list.m_N);
945 }
946 
947 
948 #ifdef TINYFORMAT_USE_VARIADIC_TEMPLATES
949 
950 /// Format list of arguments to the stream according to given format string.
951 /// This honors the stream's existing locale conventions.
952 template<typename... Args>
953 void format(std::ostream& out, const char* fmt, const Args&... args)
954 {
955  vformat(out, fmt, makeFormatList(args...));
956 }
957 
958 /// Format list of arguments according to the given format string and return
959 /// the result as a string, using classic "C" locale conventions (e.g.,
960 /// using '.' as decimal mark).
961 template<typename... Args>
962 std::string format(const char* fmt, const Args&... args)
963 {
964  std::ostringstream oss;
965  oss.imbue (std::locale::classic()); // force "C" locale with '.' decimal
966  format(oss, fmt, args...);
967  return oss.str();
968 }
969 
970 /// Format list of arguments according to the given format string and return
971 /// the result as a string, using an explicit locale. Passing loc as a
972 /// default-constructed std::locale will result in adhering to the current
973 /// "native" locale set by the OS.
974 template<typename... Args>
975 std::string format(const std::locale& loc, const char* fmt, const Args&... args)
976 {
977  std::ostringstream oss;
978  oss.imbue (loc);
979  format(oss, fmt, args...);
980  return oss.str();
981 }
982 
983 /// Format list of arguments to std::cout, according to the given format string
984 /// This honors std::out's existing locale conventions.
985 template<typename... Args>
986 void printf(const char* fmt, const Args&... args)
987 {
988  format(std::cout, fmt, args...);
989 }
990 
991 template<typename... Args>
992 void printfln(const char* fmt, const Args&... args)
993 {
994  format(std::cout, fmt, args...);
995  std::cout << '\n';
996 }
997 
998 
999 #else // C++98 version
1000 
1001 inline void format(std::ostream& out, const char* fmt)
1002 {
1003  vformat(out, fmt, makeFormatList());
1004 }
1005 
1006 inline std::string format(const char* fmt)
1007 {
1008  std::ostringstream oss;
1009  format(oss, fmt);
1010  return oss.str();
1011 }
1012 
1013 inline void printf(const char* fmt)
1014 {
1015  format(std::cout, fmt);
1016 }
1017 
1018 inline void printfln(const char* fmt)
1019 {
1020  format(std::cout, fmt);
1021  std::cout << '\n';
1022 }
1023 
1024 #define TINYFORMAT_MAKE_FORMAT_FUNCS(n) \
1025  \
1026 template<TINYFORMAT_ARGTYPES(n)> \
1027 void format(std::ostream& out, const char* fmt, TINYFORMAT_VARARGS(n)) \
1028 { \
1029  vformat(out, fmt, makeFormatList(TINYFORMAT_PASSARGS(n))); \
1030 } \
1031  \
1032 template<TINYFORMAT_ARGTYPES(n)> \
1033 std::string format(const char* fmt, TINYFORMAT_VARARGS(n)) \
1034 { \
1035  std::ostringstream oss; \
1036  oss.imbue (std::locale::classic()); \
1037  format(oss, fmt, TINYFORMAT_PASSARGS(n)); \
1038  return oss.str(); \
1039 } \
1040  \
1041 template<TINYFORMAT_ARGTYPES(n)> \
1042 std::string format(const std::locale& loc, const char* fmt, TINYFORMAT_VARARGS(n)) \
1043 { \
1044  std::ostringstream oss; \
1045  oss.imbue (loc); \
1046  format(oss, fmt, TINYFORMAT_PASSARGS(n)); \
1047  return oss.str(); \
1048 } \
1049  \
1050 template<TINYFORMAT_ARGTYPES(n)> \
1051 void printf(const char* fmt, TINYFORMAT_VARARGS(n)) \
1052 { \
1053  format(std::cout, fmt, TINYFORMAT_PASSARGS(n)); \
1054 } \
1055  \
1056 template<TINYFORMAT_ARGTYPES(n)> \
1057 void printfln(const char* fmt, TINYFORMAT_VARARGS(n)) \
1058 { \
1059  format(std::cout, fmt, TINYFORMAT_PASSARGS(n)); \
1060  std::cout << '\n'; \
1061 }
1062 
1064 #undef TINYFORMAT_MAKE_FORMAT_FUNCS
1065 
1066 #endif
1067 
1068 
1069 } // namespace tinyformat
1070 
1071 #endif // TINYFORMAT_H_INCLUDED
detail::FormatListN< 0 > makeFormatList()
Definition: tinyformat.h:922
static int invoke(const T &)
Definition: tinyformat.h:252
const FormatList & FormatListRef
Reference to type-opaque format list for passing to vformat()
Definition: tinyformat.h:854
GLint GLint GLint GLint GLint GLint GLsizei width
Definition: glew.h:1252
const Args & args
Definition: printf.h:628
GLint left
Definition: glew.h:8008
#define TINYFORMAT_HIDDEN
Definition: tinyformat.h:163
void formatTruncated(std::ostream &out, const T &value, int ntrunc)
Definition: tinyformat.h:268
internal::named_arg< T, char > arg(string_view name, const T &arg)
Definition: core.h:1393
void printfln(const char *fmt)
Definition: tinyformat.h:1018
#define TINYFORMAT_DEFINE_FORMAT_TRUNCATED_CSTR(type)
Definition: tinyformat.h:276
int parseIntAndAdvance(const char *&c)
Definition: tinyformat.h:536
#define TINYFORMAT_DEFINE_FORMATVALUE_CHAR(charType)
Definition: tinyformat.h:345
friend void vformat(std::ostream &out, const char *fmt, const FormatList &list)
FormatList(detail::FormatArg *formatters, int N)
Definition: tinyformat.h:842
void formatImpl(std::ostream &out, const char *fmt, const detail::FormatArg *formatters, int numFormatters)
Definition: tinyformat.h:771
void format(std::ostream &out, const char *fmt)
Definition: tinyformat.h:1001
const char * printFormatStringLiteral(std::ostream &out, const char *fmt)
Definition: tinyformat.h:550
void printf(const char *fmt)
Definition: tinyformat.h:1013
void
Definition: png.h:1083
GLsizei n
Definition: glew.h:4040
const GLfloat * c
Definition: glew.h:16296
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
static void invoke(std::ostream &out, const T &value)
Definition: tinyformat.h:222
void format(std::ostream &out, const char *fmtBegin, const char *fmtEnd, int ntrunc) const
Definition: tinyformat.h:502
GLsizei const GLchar *const * string
Definition: glew.h:1844
const char * streamStateFromFormat(std::ostream &out, bool &spacePadPositive, int &ntrunc, const char *fmtStart, const detail::FormatArg *formatters, int &argIndex, int numFormatters)
Definition: tinyformat.h:584
#define TINYFORMAT_MAKE_FORMATLIST_CONSTRUCTOR(n)
Definition: tinyformat.h:872
static void invoke(std::ostream &, const T &)
Definition: tinyformat.h:215
void vformat(std::ostream &out, const char *fmt, FormatListRef list)
Definition: tinyformat.h:942
GA_API const UT_StringHolder N
static int invoke(const T &value)
Definition: tinyformat.h:263
#define TINYFORMAT_MAKE_MAKEFORMATLIST(n)
Definition: tinyformat.h:926
GLuint64EXT * result
Definition: glew.h:14007
#define const
Definition: zconf.h:214
void formatValue(std::ostream &out, const char *, const char *fmtEnd, int ntrunc, const T &value)
Definition: tinyformat.h:310
vint4 min(const vint4 &a, const vint4 &b)
Definition: simd.h:4694
#define TINYFORMAT_FOREACH_ARGNUM(m)
Definition: tinyformat.h:478
#define TINYFORMAT_MAKE_FORMAT_FUNCS(n)
Definition: tinyformat.h:1024
GLenum GLint GLint * precision
Definition: glew.h:3500
GLsizei const GLfloat * value
Definition: glew.h:1849
#define TINYFORMAT_ERROR(reason)
Definition: tinyformat.h:143