Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/log/detail/snprintf.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children | c530137014c0 |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 /* | |
2 * Copyright Andrey Semashev 2007 - 2013. | |
3 * Distributed under the Boost Software License, Version 1.0. | |
4 * (See accompanying file LICENSE_1_0.txt or copy at | |
5 * http://www.boost.org/LICENSE_1_0.txt) | |
6 */ | |
7 /*! | |
8 * \file snprintf.hpp | |
9 * \author Andrey Semashev | |
10 * \date 20.02.2009 | |
11 * | |
12 * \brief This header is the Boost.Log library implementation, see the library documentation | |
13 * at http://www.boost.org/doc/libs/release/libs/log/doc/html/index.html. | |
14 */ | |
15 | |
16 #ifndef BOOST_LOG_DETAIL_SNPRINTF_HPP_INCLUDED_ | |
17 #define BOOST_LOG_DETAIL_SNPRINTF_HPP_INCLUDED_ | |
18 | |
19 #include <stdio.h> | |
20 #include <cstddef> | |
21 #include <cstdarg> | |
22 #include <boost/log/detail/config.hpp> | |
23 #ifdef BOOST_LOG_USE_WCHAR_T | |
24 #include <wchar.h> | |
25 #endif // BOOST_LOG_USE_WCHAR_T | |
26 #include <boost/log/detail/header.hpp> | |
27 | |
28 #ifdef BOOST_HAS_PRAGMA_ONCE | |
29 #pragma once | |
30 #endif | |
31 | |
32 namespace boost { | |
33 | |
34 BOOST_LOG_OPEN_NAMESPACE | |
35 | |
36 namespace aux { | |
37 | |
38 #if !defined(_MSC_VER) | |
39 | |
40 // Standard-conforming compilers already have the correct snprintfs | |
41 using ::snprintf; | |
42 using ::vsnprintf; | |
43 | |
44 # ifdef BOOST_LOG_USE_WCHAR_T | |
45 using ::swprintf; | |
46 using ::vswprintf; | |
47 # endif // BOOST_LOG_USE_WCHAR_T | |
48 | |
49 #else // !defined(_MSC_VER) | |
50 | |
51 # if _MSC_VER >= 1400 | |
52 | |
53 // MSVC 2005 and later provide the safe-CRT implementation of the conforming snprintf | |
54 inline int vsnprintf(char* buf, std::size_t size, const char* format, std::va_list args) | |
55 { | |
56 return ::vsprintf_s(buf, size, format, args); | |
57 } | |
58 | |
59 # ifdef BOOST_LOG_USE_WCHAR_T | |
60 inline int vswprintf(wchar_t* buf, std::size_t size, const wchar_t* format, std::va_list args) | |
61 { | |
62 return ::vswprintf_s(buf, size, format, args); | |
63 } | |
64 # endif // BOOST_LOG_USE_WCHAR_T | |
65 | |
66 # else // _MSC_VER >= 1400 | |
67 | |
68 // MSVC prior to 2005 had a non-conforming extension _vsnprintf, that sometimes did not put a terminating '\0' | |
69 inline int vsnprintf(char* buf, std::size_t size, const char* format, std::va_list args) | |
70 { | |
71 register int n = _vsnprintf(buf, size - 1, format, args); | |
72 buf[size - 1] = '\0'; | |
73 return n; | |
74 } | |
75 | |
76 # ifdef BOOST_LOG_USE_WCHAR_T | |
77 inline int vswprintf(wchar_t* buf, std::size_t size, const wchar_t* format, std::va_list args) | |
78 { | |
79 register int n = _vsnwprintf(buf, size - 1, format, args); | |
80 buf[size - 1] = L'\0'; | |
81 return n; | |
82 } | |
83 # endif // BOOST_LOG_USE_WCHAR_T | |
84 | |
85 # endif // _MSC_VER >= 1400 | |
86 | |
87 inline int snprintf(char* buf, std::size_t size, const char* format, ...) | |
88 { | |
89 std::va_list args; | |
90 va_start(args, format); | |
91 register int n = vsnprintf(buf, size, format, args); | |
92 va_end(args); | |
93 return n; | |
94 } | |
95 | |
96 # ifdef BOOST_LOG_USE_WCHAR_T | |
97 inline int swprintf(wchar_t* buf, std::size_t size, const wchar_t* format, ...) | |
98 { | |
99 std::va_list args; | |
100 va_start(args, format); | |
101 register int n = vswprintf(buf, size, format, args); | |
102 va_end(args); | |
103 return n; | |
104 } | |
105 # endif // BOOST_LOG_USE_WCHAR_T | |
106 | |
107 #endif // !defined(_MSC_VER) | |
108 | |
109 } // namespace aux | |
110 | |
111 BOOST_LOG_CLOSE_NAMESPACE // namespace log | |
112 | |
113 } // namespace boost | |
114 | |
115 #include <boost/log/detail/footer.hpp> | |
116 | |
117 #endif // BOOST_LOG_DETAIL_SNPRINTF_HPP_INCLUDED_ |