Fixed include directory name.
[libsex.git] / libsex / utility.ixx
blob9f810d88d9c3dfb32ae8b08d5862f7d385782cd7
1 /**
2  * @file
3  *
4  * Templates of formatting-related internal functions.
5  */
7 #include <libsex/Exception.hxx> // Exception::LENGTH
9 template <typename T>
10 T libsex::formatted(
11         const char* const file,
12         unsigned short line,
13         ...) throw()
15         // Temporary string should be initialized
16         // with 0 to not forget a trailing 0.
17         char buf[Exception::LENGTH + 1] = { 0 };
19         va_list ap;
20         va_start(ap, line);
22         // Fill buf with formatted T::TEMPLATE message.
23         vformat(buf, Exception::LENGTH + 1,
24                 file, line,
25                 T::TEMPLATE, ap);\
26         va_end(ap);
28         return T(buf);
31 template <typename T>
32 T libsex::formatted(
33         const Exception& previous,
34         const char* const file,
35         unsigned short line,
36         ...) throw()
38         char buf[Exception::LENGTH + 1] = { 0 };
40         va_list ap;
41         va_start(ap, line);
42         vformat(buf, Exception::LENGTH + 1,
43                 file, line,
44                 T::TEMPLATE, ap);\
45         va_end(ap);
47         return T(buf, previous);