| 1 | /* |
| 2 | Formatting library for C++ |
| 3 | |
| 4 | Copyright (c) 2012 - 2016, Victor Zverovich |
| 5 | All rights reserved. |
| 6 | |
| 7 | Redistribution and use in source and binary forms, with or without |
| 8 | modification, are permitted provided that the following conditions are met: |
| 9 | |
| 10 | 1. Redistributions of source code must retain the above copyright notice, this |
| 11 | list of conditions and the following disclaimer. |
| 12 | 2. Redistributions in binary form must reproduce the above copyright notice, |
| 13 | this list of conditions and the following disclaimer in the documentation |
| 14 | and/or other materials provided with the distribution. |
| 15 | |
| 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR |
| 20 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | #ifndef FMT_FORMAT_H_ |
| 29 | #define FMT_FORMAT_H_cxx . . $ `src/common/format.h:29:9`! |
| 30 | |
| 31 | #include <cassert> |
| 32 | #include <clocale> |
| 33 | #include <cmath> |
| 34 | #include <cstdio> |
| 35 | #include <cstring> |
| 36 | #include <limits> |
| 37 | #include <memory> |
| 38 | #include <stdexcept> |
| 39 | #include <string> |
| 40 | #include <vector> |
| 41 | #include <utility> |
| 42 | |
| 43 | #ifdef _SECURE_SCL |
| 44 | # define FMT_SECURE_SCL _SECURE_SCL |
| 45 | #else |
| 46 | # define FMT_SECURE_SCLcxx . . $ `src/common/format.h:46:10`! 0 |
| 47 | #endif |
| 48 | |
| 49 | #if FMT_SECURE_SCLcxx . . $ `src/common/format.h:46:10`! |
| 50 | # include <iterator> |
| 51 | #endif |
| 52 | |
| 53 | #ifdef _MSC_VER |
| 54 | # define FMT_MSC_VER _MSC_VER |
| 55 | #else |
| 56 | # define FMT_MSC_VERcxx . . $ `src/common/format.h:56:10`! 0 |
| 57 | #endif |
| 58 | |
| 59 | #if FMT_MSC_VERcxx . . $ `src/common/format.h:56:10`! && FMT_MSC_VERcxx . . $ `src/common/format.h:56:10`! <= 1500 |
| 60 | typedef unsigned __int32 uint32_t; |
| 61 | typedef unsigned __int64 uint64_t; |
| 62 | typedef __int64 intmax_t; |
| 63 | #else |
| 64 | #include <stdint.h> |
| 65 | #endif |
| 66 | |
| 67 | #if !defined(FMT_HEADER_ONLY) && defined(_WIN32) |
| 68 | # ifdef FMT_EXPORT |
| 69 | # define FMT_API __declspec(dllexport) |
| 70 | # elif defined(FMT_SHARED) |
| 71 | # define FMT_API __declspec(dllimport) |
| 72 | # endif |
| 73 | #endif |
| 74 | #ifndef FMT_API |
| 75 | # define FMT_APIcxx . . $ `src/common/format.h:75:10`! |
| 76 | #endif |
| 77 | |
| 78 | #ifdef __GNUC__cxx . . $ `<built-in>:8:9`! |
| 79 | # define FMT_GCC_VERSIONcxx . . $ `src/common/format.h:79:10`! (__GNUC__cxx . . $ `<built-in>:8:9`! * 100 + __GNUC_MINOR__cxx . . $ `<built-in>:9:9`!) |
| 80 | # define FMT_GCC_EXTENSIONcxx . . $ `src/common/format.h:80:10`! __extension__ |
| 81 | # if FMT_GCC_VERSIONcxx . . $ `src/common/format.h:79:10`! >= 406 |
| 82 | # pragma GCC diagnostic push |
| 83 | // Disable the warning about "long long" which is sometimes reported even |
| 84 | // when using __extension__. |
| 85 | # pragma GCC diagnostic ignored "-Wlong-long" |
| 86 | // Disable the warning about declaration shadowing because it affects too |
| 87 | // many valid cases. |
| 88 | # pragma GCC diagnostic ignored "-Wshadow" |
| 89 | // Disable the warning about implicit conversions that may change the sign of |
| 90 | // an integer; silencing it otherwise would require many explicit casts. |
| 91 | # pragma GCC diagnostic ignored "-Wsign-conversion" |
| 92 | # endif |
| 93 | # if __cpluspluscxx . . $ `<built-in>:472:9`! >= 201103L || defined __GXX_EXPERIMENTAL_CXX0X__cxx . . $ `<built-in>:42:9`! |
| 94 | # define FMT_HAS_GXX_CXX11cxx . . $ `src/common/format.h:94:11`! 1 |
| 95 | # endif |
| 96 | #else |
| 97 | # define FMT_GCC_EXTENSION |
| 98 | #endif |
| 99 | |
| 100 | #if defined(__INTEL_COMPILER) |
| 101 | # define FMT_ICC_VERSION __INTEL_COMPILER |
| 102 | #elif defined(__ICL) |
| 103 | # define FMT_ICC_VERSION __ICL |
| 104 | #endif |
| 105 | |
| 106 | #if defined(__clang__cxx . . $ `<built-in>:3:9`!) && !defined(FMT_ICC_VERSION) |
| 107 | # pragma clang diagnostic push |
| 108 | # pragma clang diagnostic ignored "-Wdocumentation-unknown-command" |
| 109 | # pragma clang diagnostic ignored "-Wpadded" |
| 110 | #endif |
| 111 | |
| 112 | #ifdef __GNUC_LIBSTD__ |
| 113 | # define FMT_GNUC_LIBSTD_VERSION (__GNUC_LIBSTD__ * 100 + __GNUC_LIBSTD_MINOR__) |
| 114 | #endif |
| 115 | |
| 116 | #ifdef __has_feature |
| 117 | # define FMT_HAS_FEATUREcxx . . $ `src/common/format.h:117:10`!(x) __has_feature(x) |
| 118 | #else |
| 119 | # define FMT_HAS_FEATURE(x) 0 |
| 120 | #endif |
| 121 | |
| 122 | #ifdef __has_builtin |
| 123 | # define FMT_HAS_BUILTINcxx . . $ `src/common/format.h:123:10`!(x) __has_builtin(x) |
| 124 | #else |
| 125 | # define FMT_HAS_BUILTIN(x) 0 |
| 126 | #endif |
| 127 | |
| 128 | #ifdef __has_cpp_attribute |
| 129 | # define FMT_HAS_CPP_ATTRIBUTEcxx . . $ `src/common/format.h:129:10`!(x) __has_cpp_attribute(x) |
| 130 | #else |
| 131 | # define FMT_HAS_CPP_ATTRIBUTE(x) 0 |
| 132 | #endif |
| 133 | |
| 134 | #ifndef FMT_USE_VARIADIC_TEMPLATES |
| 135 | // Variadic templates are available in GCC since version 4.4 |
| 136 | // (http://gcc.gnu.org/projects/cxx0x.html) and in Visual C++ |
| 137 | // since version 2013. |
| 138 | # define FMT_USE_VARIADIC_TEMPLATEScxx . . $ `src/common/format.h:138:10`! \ |
| 139 | (FMT_HAS_FEATUREcxx . . $ `src/common/format.h:117:10`!(cxx_variadic_templates) || \ |
| 140 | (FMT_GCC_VERSIONcxx . . $ `src/common/format.h:79:10`! >= 404 && FMT_HAS_GXX_CXX11cxx . . $ `src/common/format.h:94:11`!) || FMT_MSC_VERcxx . . $ `src/common/format.h:56:10`! >= 1800) |
| 141 | #endif |
| 142 | |
| 143 | #ifndef FMT_USE_RVALUE_REFERENCES |
| 144 | // Don't use rvalue references when compiling with clang and an old libstdc++ |
| 145 | // as the latter doesn't provide std::move. |
| 146 | # if defined(FMT_GNUC_LIBSTD_VERSION) && FMT_GNUC_LIBSTD_VERSION <= 402 |
| 147 | # define FMT_USE_RVALUE_REFERENCES 0 |
| 148 | # else |
| 149 | # define FMT_USE_RVALUE_REFERENCEScxx . . $ `src/common/format.h:149:11`! \ |
| 150 | (FMT_HAS_FEATUREcxx . . $ `src/common/format.h:117:10`!(cxx_rvalue_references) || \ |
| 151 | (FMT_GCC_VERSIONcxx . . $ `src/common/format.h:79:10`! >= 403 && FMT_HAS_GXX_CXX11cxx . . $ `src/common/format.h:94:11`!) || FMT_MSC_VERcxx . . $ `src/common/format.h:56:10`! >= 1600) |
| 152 | # endif |
| 153 | #endif |
| 154 | |
| 155 | #if FMT_USE_RVALUE_REFERENCEScxx . . $ `src/common/format.h:149:11`! |
| 156 | # include <utility> // for std::move |
| 157 | #endif |
| 158 | |
| 159 | // Check if exceptions are disabled. |
| 160 | #if defined(__GNUC__cxx . . $ `<built-in>:8:9`!) && !defined(__EXCEPTIONScxx . . $ `<built-in>:102:9`!) |
| 161 | # define FMT_EXCEPTIONS 0 |
| 162 | #endif |
| 163 | #if FMT_MSC_VERcxx . . $ `src/common/format.h:56:10`! && !_HAS_EXCEPTIONS |
| 164 | # define FMT_EXCEPTIONS 0 |
| 165 | #endif |
| 166 | #ifndef FMT_EXCEPTIONS |
| 167 | # define FMT_EXCEPTIONScxx . . $ `src/common/format.h:167:10`! 1 |
| 168 | #endif |
| 169 | |
| 170 | #ifndef FMT_THROW |
| 171 | # if FMT_EXCEPTIONScxx . . $ `src/common/format.h:167:10`! |
| 172 | # define FMT_THROWcxx . . $ `src/common/format.h:172:11`!(x) throw x |
| 173 | # else |
| 174 | # define FMT_THROW(x) assert(false) |
| 175 | # endif |
| 176 | #endif |
| 177 | |
| 178 | // Define FMT_USE_NOEXCEPT to make fmt use noexcept (C++11 feature). |
| 179 | #ifndef FMT_USE_NOEXCEPT |
| 180 | # define FMT_USE_NOEXCEPTcxx . . $ `src/common/format.h:180:10`! 0 |
| 181 | #endif |
| 182 | |
| 183 | #ifndef FMT_NOEXCEPT |
| 184 | # if FMT_EXCEPTIONScxx . . $ `src/common/format.h:167:10`! |
| 185 | # if FMT_USE_NOEXCEPTcxx . . $ `src/common/format.h:180:10`! || FMT_HAS_FEATUREcxx . . $ `src/common/format.h:117:10`!(cxx_noexcept) || \ |
| 186 | (FMT_GCC_VERSIONcxx . . $ `src/common/format.h:79:10`! >= 408 && FMT_HAS_GXX_CXX11cxx . . $ `src/common/format.h:94:11`!) || \ |
| 187 | FMT_MSC_VERcxx . . $ `src/common/format.h:56:10`! >= 1900 |
| 188 | # define FMT_NOEXCEPTcxx . . $ `src/common/format.h:188:12`! noexcept |
| 189 | # else |
| 190 | # define FMT_NOEXCEPT throw() |
| 191 | # endif |
| 192 | # else |
| 193 | # define FMT_NOEXCEPT |
| 194 | # endif |
| 195 | #endif |
| 196 | |
| 197 | #ifndef FMT_OVERRIDE |
| 198 | # if FMT_USE_OVERRIDE || FMT_HAS_FEATUREcxx . . $ `src/common/format.h:117:10`!(cxx_override) || \ |
| 199 | (FMT_GCC_VERSIONcxx . . $ `src/common/format.h:79:10`! >= 408 && FMT_HAS_GXX_CXX11cxx . . $ `src/common/format.h:94:11`!) || \ |
| 200 | FMT_MSC_VERcxx . . $ `src/common/format.h:56:10`! >= 1900 |
| 201 | # define FMT_OVERRIDE override |
| 202 | # else |
| 203 | # define FMT_OVERRIDEcxx . . $ `src/common/format.h:203:11`! |
| 204 | # endif |
| 205 | #endif |
| 206 | |
| 207 | |
| 208 | // A macro to disallow the copy constructor and operator= functions |
| 209 | // This should be used in the private: declarations for a class |
| 210 | #ifndef FMT_USE_DELETED_FUNCTIONS |
| 211 | # define FMT_USE_DELETED_FUNCTIONScxx . . $ `src/common/format.h:211:10`! 0 |
| 212 | #endif |
| 213 | |
| 214 | #if FMT_USE_DELETED_FUNCTIONScxx . . $ `src/common/format.h:211:10`! || FMT_HAS_FEATUREcxx . . $ `src/common/format.h:117:10`!(cxx_deleted_functions) || \ |
| 215 | (FMT_GCC_VERSIONcxx . . $ `src/common/format.h:79:10`! >= 404 && FMT_HAS_GXX_CXX11cxx . . $ `src/common/format.h:94:11`!) || FMT_MSC_VERcxx . . $ `src/common/format.h:56:10`! >= 1800 |
| 216 | # define FMT_DELETED_OR_UNDEFINEDcxx . . $ `src/common/format.h:216:10`! = delete |
| 217 | # define FMT_DISALLOW_COPY_AND_ASSIGNcxx . . $ `src/common/format.h:217:10`!(TypeName) \ |
| 218 | TypeName(const TypeName&) = delete; \ |
| 219 | TypeName& operator=(const TypeName&) = delete |
| 220 | #else |
| 221 | # define FMT_DELETED_OR_UNDEFINED |
| 222 | # define FMT_DISALLOW_COPY_AND_ASSIGN(TypeName) \ |
| 223 | TypeName(const TypeName&); \ |
| 224 | TypeName& operator=(const TypeName&) |
| 225 | #endif |
| 226 | |
| 227 | #ifndef FMT_USE_USER_DEFINED_LITERALS |
| 228 | // All compilers which support UDLs also support variadic templates. This |
| 229 | // makes the fmt::literals implementation easier. However, an explicit check |
| 230 | // for variadic templates is added here just in case. |
| 231 | // For Intel's compiler both it and the system gcc/msc must support UDLs. |
| 232 | # define FMT_USE_USER_DEFINED_LITERALScxx . . $ `src/common/format.h:232:10`! \ |
| 233 | FMT_USE_VARIADIC_TEMPLATEScxx . . $ `src/common/format.h:138:10`! && FMT_USE_RVALUE_REFERENCEScxx . . $ `src/common/format.h:149:11`! && \ |
| 234 | (FMT_HAS_FEATUREcxx . . $ `src/common/format.h:117:10`!(cxx_user_literals) || \ |
| 235 | (FMT_GCC_VERSIONcxx . . $ `src/common/format.h:79:10`! >= 407 && FMT_HAS_GXX_CXX11cxx . . $ `src/common/format.h:94:11`!) || FMT_MSC_VERcxx . . $ `src/common/format.h:56:10`! >= 1900) && \ |
| 236 | (!defined(FMT_ICC_VERSION) || FMT_ICC_VERSION >= 1500) |
| 237 | #endif |
| 238 | |
| 239 | #ifndef FMT_ASSERT |
| 240 | # define FMT_ASSERTcxx . . $ `src/common/format.h:240:10`!(condition, message) assertcxx . . $ `/usr/include/assert.h:102:11`!((condition) && message) |
| 241 | #endif |
| 242 | |
| 243 | #if FMT_GCC_VERSIONcxx . . $ `src/common/format.h:79:10`! >= 400 || FMT_HAS_BUILTINcxx . . $ `src/common/format.h:123:10`!(__builtin_clz) |
| 244 | # define FMT_BUILTIN_CLZcxx . . $ `src/common/format.h:244:10`!(n) __builtin_clz(n) |
| 245 | #endif |
| 246 | |
| 247 | #if FMT_GCC_VERSIONcxx . . $ `src/common/format.h:79:10`! >= 400 || FMT_HAS_BUILTINcxx . . $ `src/common/format.h:123:10`!(__builtin_clzll) |
| 248 | # define FMT_BUILTIN_CLZLLcxx . . $ `src/common/format.h:248:10`!(n) __builtin_clzll(n) |
| 249 | #endif |
| 250 | |
| 251 | // Some compilers masquerade as both MSVC and GCC-likes or |
| 252 | // otherwise support __builtin_clz and __builtin_clzll, so |
| 253 | // only define FMT_BUILTIN_CLZ using the MSVC intrinsics |
| 254 | // if the clz and clzll builtins are not available. |
| 255 | #if FMT_MSC_VERcxx . . $ `src/common/format.h:56:10`! && !defined(FMT_BUILTIN_CLZLLcxx . . $ `src/common/format.h:248:10`!) |
| 256 | # include <intrin.h> // _BitScanReverse, _BitScanReverse64 |
| 257 | |
| 258 | namespace fmt { |
| 259 | namespace internal { |
| 260 | # pragma intrinsic(_BitScanReverse) |
| 261 | inline uint32_t clz(uint32_t x) { |
| 262 | unsigned long r = 0; |
| 263 | _BitScanReverse(&r, x); |
| 264 | |
| 265 | assert(x != 0); |
| 266 | // Static analysis complains about using uninitialized data |
| 267 | // "r", but the only way that can happen is if "x" is 0, |
| 268 | // which the callers guarantee to not happen. |
| 269 | # pragma warning(suppress: 6102) |
| 270 | return 31 - r; |
| 271 | } |
| 272 | # define FMT_BUILTIN_CLZ(n) fmt::internal::clz(n) |
| 273 | |
| 274 | # ifdef _WIN64 |
| 275 | # pragma intrinsic(_BitScanReverse64) |
| 276 | # endif |
| 277 | |
| 278 | inline uint32_t clzll(uint64_t x) { |
| 279 | unsigned long r = 0; |
| 280 | # ifdef _WIN64 |
| 281 | _BitScanReverse64(&r, x); |
| 282 | # else |
| 283 | // Scan the high 32 bits. |
| 284 | if (_BitScanReverse(&r, static_cast<uint32_t>(x >> 32))) |
| 285 | return 63 - (r + 32); |
| 286 | |
| 287 | // Scan the low 32 bits. |
| 288 | _BitScanReverse(&r, static_cast<uint32_t>(x)); |
| 289 | # endif |
| 290 | |
| 291 | assert(x != 0); |
| 292 | // Static analysis complains about using uninitialized data |
| 293 | // "r", but the only way that can happen is if "x" is 0, |
| 294 | // which the callers guarantee to not happen. |
| 295 | # pragma warning(suppress: 6102) |
| 296 | return 63 - r; |
| 297 | } |
| 298 | # define FMT_BUILTIN_CLZLL(n) fmt::internal::clzll(n) |
| 299 | } |
| 300 | } |
| 301 | #endif |
| 302 | |
| 303 | namespace fmtcxx . . $ fmt/ { |
| 304 | namespace internalcxx . . $ fmt/internal/ { |
| 305 | struct DummyIntcxx . . $ fmt/internal/DummyInt# { |
| 306 | int datacxx . . $ fmt/internal/DummyInt#data.[2]; |
| 307 | operatorcxx . . $ fmt/internal/DummyInt#`operator int`(455f465bc33b4cdf). int() const { return 0; } |
| 308 | }; |
| 309 | typedef stdcxx . . $ std/::numeric_limitscxx . . $ std/numeric_limits#<fmtcxx . . $ fmt/::internalcxx . . $ fmt/internal/::DummyIntcxx . . $ fmt/internal/DummyInt#> FPUtilcxx . . $ fmt/internal/FPUtil#; |
| 310 | |
| 311 | // Dummy implementations of system functions such as signbit and ecvt called |
| 312 | // if the latter are not available. |
| 313 | inline DummyIntcxx . . $ fmt/internal/DummyInt# signbitcxx . . $ fmt/internal/signbit(56620ad6bdecb187).(...) { return DummyIntcxx . . $ fmt/internal/DummyInt#(); } |
| 314 | inline DummyIntcxx . . $ fmt/internal/DummyInt# _ecvt_scxx . . $ fmt/internal/_ecvt_s(56620ad6bdecb187).(...) { return DummyIntcxx . . $ fmt/internal/DummyInt#(); } |
| 315 | inline DummyIntcxx . . $ fmt/internal/DummyInt# isinfcxx . . $ fmt/internal/isinf(56620ad6bdecb187).(...) { return DummyIntcxx . . $ fmt/internal/DummyInt#(); } |
| 316 | inline DummyIntcxx . . $ fmt/internal/DummyInt# _finitecxx . . $ fmt/internal/_finite(56620ad6bdecb187).(...) { return DummyIntcxx . . $ fmt/internal/DummyInt#(); } |
| 317 | inline DummyIntcxx . . $ fmt/internal/DummyInt# isnancxx . . $ fmt/internal/isnan(56620ad6bdecb187).(...) { return DummyIntcxx . . $ fmt/internal/DummyInt#(); } |
| 318 | inline DummyIntcxx . . $ fmt/internal/DummyInt# _isnancxx . . $ fmt/internal/_isnan(56620ad6bdecb187).(...) { return DummyIntcxx . . $ fmt/internal/DummyInt#(); } |
| 319 | |
| 320 | // A helper function to suppress bogus "conditional expression is constant" |
| 321 | // warnings. |
| 322 | template <typename T> |
| 323 | inline T const_checkcxx . . $ fmt/internal/const_check(ada6a8422704cf8a).(T value) { return value; } |
| 324 | } |
| 325 | } // namespace fmt |
| 326 | |
| 327 | namespace stdcxx . . $ std/ { |
| 328 | // Standard permits specialization of std::numeric_limits. This specialization |
| 329 | // is used to resolve ambiguity between isinf and std::isinf in glibc: |
| 330 | // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48891 |
| 331 | // and the same for isnan and signbit. |
| 332 | template <> |
| 333 | class numeric_limitscxx . . $ std/numeric_limits#<fmtcxx . . $ fmt/::internalcxx . . $ fmt/internal/::DummyIntcxx . . $ fmt/internal/DummyInt#> : |
| 334 | public stdcxx . . $ std/::numeric_limitscxx . . $ std/numeric_limits#<int> { |
| 335 | public: |
| 336 | // Portable version of isinf. |
| 337 | template <typename T> |
| 338 | static bool isinfinitycxx . . $ std/numeric_limits#isinfinity(ee44d93984fb03e9).(T x) { |
| 339 | using namespace fmtcxx . . $ fmt/::internal; |
| 340 | // The resolution "priority" is: |
| 341 | // isinf macro > std::isinf > ::isinf > fmt::internal::isinf |
| 342 | if (const_checkcxx . . $ fmt/internal/const_check(ada6a8422704cf8a).(sizeof(isinf(x)) == sizeof(bool) || |
| 343 | sizeof(isinf(x)) == sizeof(int))) { |
| 344 | return isinf(x) !=cxx . . $ std/`operator!=`(48af00471b8240b). 0; |
| 345 | } |
| 346 | return !_finitecxx . . $ fmt/internal/_finite(56620ad6bdecb187).(static_cast<double>(x)); |
| 347 | } |
| 348 | |
| 349 | // Portable version of isnan. |
| 350 | template <typename T> |
| 351 | static bool isnotanumbercxx . . $ std/numeric_limits#isnotanumber(ee44d93984fb03e9).(T x) { |
| 352 | using namespace fmtcxx . . $ fmt/::internal; |
| 353 | if (const_checkcxx . . $ fmt/internal/const_check(ada6a8422704cf8a).(sizeof(isnan(x)) == sizeof(bool) || |
| 354 | sizeof(isnan(x)) == sizeof(int))) { |
| 355 | return isnan(x) !=cxx . . $ std/`operator!=`(422bc6f94ca19d90). 0; |
| 356 | } |
| 357 | return _isnancxx . . $ fmt/internal/_isnan(56620ad6bdecb187).(static_cast<double>(x)) != 0; |
| 358 | } |
| 359 | |
| 360 | // Portable version of signbit. |
| 361 | static bool isnegativecxx . . $ std/numeric_limits#isnegative(f8197d536af80c96).(double x) { |
| 362 | using namespace fmtcxx . . $ fmt/::internal; |
| 363 | if (const_checkcxx . . $ fmt/internal/const_check(ada6a8422704cf8a).(sizeof(signbit(x)) == sizeof(int))) |
| 364 | return signbit(x) != 0; |
| 365 | if (x < 0) return true; |
| 366 | if (!isnotanumbercxx . . $ std/numeric_limits#isnotanumber(ee44d93984fb03e9).(x)) return false; |
| 367 | int dec = 0, sign = 0; |
| 368 | char buffer[2]; // The buffer size must be >= 2 or _ecvt_s will fail. |
| 369 | _ecvt_scxx . . $ fmt/internal/_ecvt_s(56620ad6bdecb187).(buffer, sizeof(buffer), x, 0, &dec, &sign); |
| 370 | return sign != 0; |
| 371 | } |
| 372 | }; |
| 373 | } // namespace std |
| 374 | |
| 375 | namespace fmtcxx . . $ fmt/ { |
| 376 | |
| 377 | // Fix the warning about long long on older versions of GCC |
| 378 | // that don't support the diagnostic pragma. |
| 379 | FMT_GCC_EXTENSIONcxx . . $ `src/common/format.h:80:10`! typedef long long LongLongcxx . . $ fmt/LongLong#; |
| 380 | FMT_GCC_EXTENSIONcxx . . $ `src/common/format.h:80:10`! typedef unsigned long long ULongLongcxx . . $ fmt/ULongLong#; |
| 381 | |
| 382 | #if FMT_USE_RVALUE_REFERENCEScxx . . $ `src/common/format.h:149:11`! |
| 383 | using stdcxx . . $ std/::movecxx . . $ std/move(88304b602929f6f4).; |
| 384 | #endif |
| 385 | |
| 386 | template <typename Char> |
| 387 | class BasicWritercxx . . $ fmt/BasicWriter#; |
| 388 | |
| 389 | typedef BasicWritercxx . . $ fmt/BasicWriter#<char> Writercxx . . $ fmt/Writer#; |
| 390 | typedef BasicWritercxx . . $ fmt/BasicWriter#<wchar_t> WWritercxx . . $ fmt/WWriter#; |
| 391 | |
| 392 | template <typename Char> |
| 393 | class ArgFormattercxx . . $ fmt/ArgFormatter#; |
| 394 | |
| 395 | template <typename CharType, |
| 396 | typename ArgFormatter = fmtcxx . . $ fmt/::ArgFormattercxx . . $ fmt/ArgFormatter#<CharType> > |
| 397 | class BasicFormattercxx . . $ fmt/BasicFormatter#; |
| 398 | |
| 399 | /** |
| 400 | \rst |
| 401 | A string reference. It can be constructed from a C string or ``std::string``. |
| 402 | |
| 403 | You can use one of the following typedefs for common character types: |
| 404 | |
| 405 | +------------+-------------------------+ |
| 406 | | Type | Definition | |
| 407 | +============+=========================+ |
| 408 | | StringRef | BasicStringRef<char> | |
| 409 | +------------+-------------------------+ |
| 410 | | WStringRef | BasicStringRef<wchar_t> | |
| 411 | +------------+-------------------------+ |
| 412 | |
| 413 | This class is most useful as a parameter type to allow passing |
| 414 | different types of strings to a function, for example:: |
| 415 | |
| 416 | template <typename... Args> |
| 417 | std::string format(StringRef format_str, const Args & ... args); |
| 418 | |
| 419 | format("{}", 42); |
| 420 | format(std::string("{}"), 42); |
| 421 | \endrst |
| 422 | */ |
| 423 | template <typename Char> |
| 424 | class BasicStringRefcxx . . $ fmt/BasicStringRef# { |
| 425 | private: |
| 426 | const Char *data_cxx . . $ fmt/BasicStringRef#data_.; |
| 427 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# size_cxx . . $ fmt/BasicStringRef#size_.; |
| 428 | |
| 429 | public: |
| 430 | /** Constructs a string reference object from a C string and a size. */ |
| 431 | BasicStringRefcxx . . $ fmt/BasicStringRef#`BasicStringRef<Char>`(dd0cd2e3e0bccc9c).(const Char *s, stdcxx . . $ std/::size_tcxx . . $ std/size_t# size) : data_cxx . . $ fmt/BasicStringRef#data_.(s), size_cxx . . $ fmt/BasicStringRef#size_.(size) {} |
| 432 | |
| 433 | /** |
| 434 | \rst |
| 435 | Constructs a string reference object from a C string computing |
| 436 | the size with ``std::char_traits<Char>::length``. |
| 437 | \endrst |
| 438 | */ |
| 439 | BasicStringRefcxx . . $ fmt/BasicStringRef#`BasicStringRef<Char>`(88376428bb603c08).(const Char *s) |
| 440 | : data_cxx . . $ fmt/BasicStringRef#data_.(s), size_cxx . . $ fmt/BasicStringRef#size_.(stdcxx . . $ std/::char_traitscxx . . $ std/char_traits#<Char>::length(s)) {} |
| 441 | |
| 442 | /** |
| 443 | \rst |
| 444 | Constructs a string reference from an ``std::string`` object. |
| 445 | \endrst |
| 446 | */ |
| 447 | BasicStringRefcxx . . $ fmt/BasicStringRef#`BasicStringRef<Char>`(a6cf34ce58443556).(const stdcxx . . $ std/::basic_stringcxx . . $ std/__cxx11/basic_string#<Char> &s) |
| 448 | : data_cxx . . $ fmt/BasicStringRef#data_.(s.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()), size_cxx . . $ fmt/BasicStringRef#size_.(s.sizecxx . . $ std/__cxx11/basic_string#size(6f8bd5c0ea8fb29a).()) {} |
| 449 | |
| 450 | /** |
| 451 | \rst |
| 452 | Converts a string reference to an ``std::string`` object. |
| 453 | \endrst |
| 454 | */ |
| 455 | stdcxx . . $ std/::basic_stringcxx . . $ std/__cxx11/basic_string#<Char> to_stringcxx . . $ fmt/BasicStringRef#to_string(25a55eb745a1b6bc).() const { |
| 456 | return stdcxx . . $ std/::basic_stringcxx . . $ std/__cxx11/basic_string#<Char>(data_cxx . . $ fmt/BasicStringRef#data_., size_cxx . . $ fmt/BasicStringRef#size_.); |
| 457 | } |
| 458 | |
| 459 | /** Returns a pointer to the string data. */ |
| 460 | const Char *datacxx . . $ fmt/BasicStringRef#data(1016ee5406d91ab9).() const { return data_cxx . . $ fmt/BasicStringRef#data_.; } |
| 461 | |
| 462 | /** Returns the string size. */ |
| 463 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# sizecxx . . $ fmt/BasicStringRef#size(fe4d2d262d4164a8).() const { return size_cxx . . $ fmt/BasicStringRef#size_.; } |
| 464 | |
| 465 | // Lexicographically compare this string reference to other. |
| 466 | int comparecxx . . $ fmt/BasicStringRef#compare(105192c6ddaef015).(BasicStringRef other) const { |
| 467 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# size = size_cxx . . $ fmt/BasicStringRef#size_. < other.size_cxx . . $ fmt/BasicStringRef#size_. ? size_cxx . . $ fmt/BasicStringRef#size_. : other.size_cxx . . $ fmt/BasicStringRef#size_.; |
| 468 | int result = stdcxx . . $ std/::char_traitscxx . . $ std/char_traits#<Char>::compare(data_cxx . . $ fmt/BasicStringRef#data_., other.data_cxx . . $ fmt/BasicStringRef#data_., size); |
| 469 | if (result == 0) |
| 470 | result = size_cxx . . $ fmt/BasicStringRef#size_. == other.size_cxx . . $ fmt/BasicStringRef#size_. ? 0 : (size_cxx . . $ fmt/BasicStringRef#size_. < other.size_cxx . . $ fmt/BasicStringRef#size_. ? -1 : 1); |
| 471 | return result; |
| 472 | } |
| 473 | |
| 474 | friend bool operatorcxx . . $ fmt/`operator==`(b9fd666dd7db3c99).==(BasicStringRef lhs, BasicStringRef rhs) { |
| 475 | return lhs.comparecxx . . $ fmt/BasicStringRef#compare(105192c6ddaef015).(rhs) == 0; |
| 476 | } |
| 477 | friend bool operatorcxx . . $ fmt/`operator!=`(b9fd666dd7db3c99).!=(BasicStringRef lhs, BasicStringRef rhs) { |
| 478 | return lhs.comparecxx . . $ fmt/BasicStringRef#compare(105192c6ddaef015).(rhs) != 0; |
| 479 | } |
| 480 | friend bool operatorcxx . . $ fmt/`operator<`(b9fd666dd7db3c99).<(BasicStringRef lhs, BasicStringRef rhs) { |
| 481 | return lhs.comparecxx . . $ fmt/BasicStringRef#compare(105192c6ddaef015).(rhs) < 0; |
| 482 | } |
| 483 | friend bool operatorcxx . . $ fmt/`operator<=`(b9fd666dd7db3c99).<=(BasicStringRef lhs, BasicStringRef rhs) { |
| 484 | return lhs.comparecxx . . $ fmt/BasicStringRef#compare(105192c6ddaef015).(rhs) <= 0; |
| 485 | } |
| 486 | friend bool operatorcxx . . $ fmt/`operator>`(b9fd666dd7db3c99).>(BasicStringRef lhs, BasicStringRef rhs) { |
| 487 | return lhs.comparecxx . . $ fmt/BasicStringRef#compare(105192c6ddaef015).(rhs) > 0; |
| 488 | } |
| 489 | friend bool operatorcxx . . $ fmt/`operator>=`(b9fd666dd7db3c99).>=(BasicStringRef lhs, BasicStringRef rhs) { |
| 490 | return lhs.comparecxx . . $ fmt/BasicStringRef#compare(105192c6ddaef015).(rhs) >= 0; |
| 491 | } |
| 492 | }; |
| 493 | |
| 494 | typedef BasicStringRefcxx . . $ fmt/BasicStringRef#<char> StringRefcxx . . $ fmt/StringRef#; |
| 495 | typedef BasicStringRefcxx . . $ fmt/BasicStringRef#<wchar_t> WStringRefcxx . . $ fmt/WStringRef#; |
| 496 | |
| 497 | /** |
| 498 | \rst |
| 499 | A reference to a null terminated string. It can be constructed from a C |
| 500 | string or ``std::string``. |
| 501 | |
| 502 | You can use one of the following typedefs for common character types: |
| 503 | |
| 504 | +-------------+--------------------------+ |
| 505 | | Type | Definition | |
| 506 | +=============+==========================+ |
| 507 | | CStringRef | BasicCStringRef<char> | |
| 508 | +-------------+--------------------------+ |
| 509 | | WCStringRef | BasicCStringRef<wchar_t> | |
| 510 | +-------------+--------------------------+ |
| 511 | |
| 512 | This class is most useful as a parameter type to allow passing |
| 513 | different types of strings to a function, for example:: |
| 514 | |
| 515 | template <typename... Args> |
| 516 | std::string format(CStringRef format_str, const Args & ... args); |
| 517 | |
| 518 | format("{}", 42); |
| 519 | format(std::string("{}"), 42); |
| 520 | \endrst |
| 521 | */ |
| 522 | template <typename Char> |
| 523 | class BasicCStringRefcxx . . $ fmt/BasicCStringRef# { |
| 524 | private: |
| 525 | const Char *data_cxx . . $ fmt/BasicCStringRef#data_.; |
| 526 | |
| 527 | public: |
| 528 | /** Constructs a string reference object from a C string. */ |
| 529 | BasicCStringRefcxx . . $ fmt/BasicCStringRef#`BasicCStringRef<Char>`(88376428bb603c08).(const Char *s) : data_cxx . . $ fmt/BasicCStringRef#data_.(s) {} |
| 530 | |
| 531 | /** |
| 532 | \rst |
| 533 | Constructs a string reference from an ``std::string`` object. |
| 534 | \endrst |
| 535 | */ |
| 536 | BasicCStringRefcxx . . $ fmt/BasicCStringRef#`BasicCStringRef<Char>`(a6cf34ce58443556).(const stdcxx . . $ std/::basic_stringcxx . . $ std/__cxx11/basic_string#<Char> &s) : data_cxx . . $ fmt/BasicCStringRef#data_.(s.c_strcxx . . $ std/__cxx11/basic_string#c_str(8e614c7de0b1573e).()) {} |
| 537 | |
| 538 | /** Returns the pointer to a C string. */ |
| 539 | const Char *c_strcxx . . $ fmt/BasicCStringRef#c_str(1016ee5406d91ab9).() const { return data_cxx . . $ fmt/BasicCStringRef#data_.; } |
| 540 | }; |
| 541 | |
| 542 | typedef BasicCStringRefcxx . . $ fmt/BasicCStringRef#<char> CStringRefcxx . . $ fmt/CStringRef#; |
| 543 | typedef BasicCStringRefcxx . . $ fmt/BasicCStringRef#<wchar_t> WCStringRefcxx . . $ fmt/WCStringRef#; |
| 544 | |
| 545 | /** A formatting error such as invalid format string. */ |
| 546 | class FormatErrorcxx . . $ fmt/FormatError# : public stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error# { |
| 547 | public: |
| 548 | explicit FormatErrorcxx . . $ fmt/FormatError#FormatError(330b15046e8ecb2a).(CStringRefcxx . . $ fmt/CStringRef# message) |
| 549 | : stdcxx . . $ std/runtime_error#runtime_error(85c52e162fed56f9).::runtime_errorcxx . . $ std/runtime_error#(message.c_strcxx . . $ fmt/BasicCStringRef#c_str(1016ee5406d91ab9).()) {} |
| 550 | ~cxx . . $ fmt/FormatError#`~FormatError`(ced63f7c635d850d).FormatErrorcxx . . $ fmt/FormatError#() throw(); |
| 551 | }; |
| 552 | |
| 553 | namespace internalcxx . . $ fmt/internal/ { |
| 554 | |
| 555 | // MakeUnsigned<T>::Type gives an unsigned type corresponding to integer type T. |
| 556 | template <typename T> |
| 557 | struct MakeUnsignedcxx . . $ fmt/internal/MakeUnsigned# { typedef T Typecxx . . $ fmt/internal/MakeUnsigned#Type#; }; |
| 558 | |
| 559 | #define FMT_SPECIALIZE_MAKE_UNSIGNEDcxx . . $ `src/common/format.h:559:9`!(T, U) \ |
| 560 | template <> \ |
| 561 | struct MakeUnsigned<T> { typedef U Type; } |
| 562 | |
| 563 | FMT_SPECIALIZE_MAKE_UNSIGNEDcxx . . $ fmt/internal/MakeUnsigned#(char, unsigned char); |
| 564 | FMT_SPECIALIZE_MAKE_UNSIGNEDcxx . . $ fmt/internal/MakeUnsigned#Type#(signed char, unsigned char); |
| 565 | FMT_SPECIALIZE_MAKE_UNSIGNEDcxx . . $ fmt/internal/MakeUnsigned#(short, unsigned short); |
| 566 | FMT_SPECIALIZE_MAKE_UNSIGNEDcxx . . $ fmt/internal/MakeUnsigned#Type#(int, unsigned); |
| 567 | FMT_SPECIALIZE_MAKE_UNSIGNEDcxx . . $ `src/common/format.h:559:9`!(long, unsigned long); |
| 568 | FMT_SPECIALIZE_MAKE_UNSIGNEDcxx . . $ fmt/internal/MakeUnsigned#Type#(LongLong, ULongLong); |
| 569 | |
| 570 | // Casts nonnegative integer to unsigned. |
| 571 | template <typename Int> |
| 572 | inline typename MakeUnsignedcxx . . $ fmt/internal/MakeUnsigned#<Int>::Type to_unsignedcxx . . $ fmt/internal/to_unsigned(4de866539cf5f5fc).(Int value) { |
| 573 | FMT_ASSERTcxx . . $ `src/common/format.h:240:10`!(value >= 0, "negative value"); |
| 574 | return static_cast<typename MakeUnsignedcxx . . $ fmt/internal/MakeUnsigned#<Int>::Type>(value); |
| 575 | } |
| 576 | |
| 577 | // The number of characters to store in the MemoryBuffer object itself |
| 578 | // to avoid dynamic memory allocation. |
| 579 | enumcxx . . $ fmt/internal/$anonymous_type_27c265af509cfe5e_0# { INLINE_BUFFER_SIZEcxx . . $ fmt/internal/INLINE_BUFFER_SIZE. = 500 }; |
| 580 | |
| 581 | #if FMT_SECURE_SCLcxx . . $ `src/common/format.h:46:10`! |
| 582 | // Use checked iterator to avoid warnings on MSVC. |
| 583 | template <typename T> |
| 584 | inline stdext::checked_array_iterator<T*> make_ptr(T *ptr, std::size_t size) { |
| 585 | return stdext::checked_array_iterator<T*>(ptr, size); |
| 586 | } |
| 587 | #else |
| 588 | template <typename T> |
| 589 | inline T *make_ptrcxx . . $ fmt/internal/make_ptr(1149d387c81d78d0).(T *ptr, stdcxx . . $ std/::size_tcxx . . $ std/size_t#) { return ptr; } |
| 590 | #endif |
| 591 | } // namespace internal |
| 592 | |
| 593 | /** |
| 594 | \rst |
| 595 | A buffer supporting a subset of ``std::vector``'s operations. |
| 596 | \endrst |
| 597 | */ |
| 598 | template <typename T> |
| 599 | class Buffercxx . . $ fmt/Buffer# { |
| 600 | private: |
| 601 | FMT_DISALLOW_COPY_AND_ASSIGNcxx . . $ fmt/Buffer#`operator=`(9e63f858b10ae1db).(Buffer); |
| 602 | |
| 603 | protected: |
| 604 | T *ptr_cxx . . $ fmt/Buffer#ptr_.; |
| 605 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# size_cxx . . $ fmt/Buffer#size_.; |
| 606 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# capacity_cxx . . $ fmt/Buffer#capacity_.; |
| 607 | |
| 608 | Buffercxx . . $ fmt/Buffer#`Buffer<T>`(afd8256c216b84b2).(T *ptr = 0, stdcxx . . $ std/::size_tcxx . . $ std/size_t# capacity = 0) |
| 609 | : ptr_cxx . . $ fmt/Buffer#ptr_.(ptr), size_cxx . . $ fmt/Buffer#size_.(0), capacity_cxx . . $ fmt/Buffer#capacity_.(capacity) {} |
| 610 | |
| 611 | /** |
| 612 | \rst |
| 613 | Increases the buffer capacity to hold at least *size* elements updating |
| 614 | ``ptr_`` and ``capacity_``. |
| 615 | \endrst |
| 616 | */ |
| 617 | virtual void growcxx . . $ fmt/Buffer#grow(2c44cd906ae4e829).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# size) = 0; |
| 618 | |
| 619 | public: |
| 620 | virtual ~cxx . . $ fmt/Buffer#`~Buffer<T>`(49f6e7a06ebc5aa8).Buffer() {} |
| 621 | |
| 622 | /** Returns the size of this buffer. */ |
| 623 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# sizecxx . . $ fmt/Buffer#size(fe4d2d262d4164a8).() const { return size_cxx . . $ fmt/Buffer#size_.; } |
| 624 | |
| 625 | /** Returns the capacity of this buffer. */ |
| 626 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# capacitycxx . . $ fmt/Buffer#capacity(fe4d2d262d4164a8).() const { return capacity_cxx . . $ fmt/Buffer#capacity_.; } |
| 627 | |
| 628 | /** |
| 629 | Resizes the buffer. If T is a POD type new elements may not be initialized. |
| 630 | */ |
| 631 | void resizecxx . . $ fmt/Buffer#resize(2c44cd906ae4e829).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# new_size) { |
| 632 | if (new_size > capacity_cxx . . $ fmt/Buffer#capacity_.) |
| 633 | growcxx . . $ fmt/Buffer#grow(2c44cd906ae4e829).(new_size); |
| 634 | size_cxx . . $ fmt/Buffer#size_. = new_size; |
| 635 | } |
| 636 | |
| 637 | /** |
| 638 | \rst |
| 639 | Reserves space to store at least *capacity* elements. |
| 640 | \endrst |
| 641 | */ |
| 642 | void reservecxx . . $ fmt/Buffer#reserve(2c44cd906ae4e829).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# capacity) { |
| 643 | if (capacity > capacity_cxx . . $ fmt/Buffer#capacity_.) |
| 644 | growcxx . . $ fmt/Buffer#grow(2c44cd906ae4e829).(capacity); |
| 645 | } |
| 646 | |
| 647 | void clearcxx . . $ fmt/Buffer#clear(ced63f7c635d850d).() FMT_NOEXCEPTcxx . . $ `src/common/format.h:188:12`! { size_cxx . . $ fmt/Buffer#size_. = 0; } |
| 648 | |
| 649 | void push_backcxx . . $ fmt/Buffer#push_back(77d9f17553126ecb).(const T &value) { |
| 650 | if (size_cxx . . $ fmt/Buffer#size_. == capacity_cxx . . $ fmt/Buffer#capacity_.) |
| 651 | growcxx . . $ fmt/Buffer#grow(2c44cd906ae4e829).(size_cxx . . $ fmt/Buffer#size_. + 1); |
| 652 | ptr_cxx . . $ fmt/Buffer#ptr_.[size_cxx . . $ fmt/Buffer#size_.++] = value; |
| 653 | } |
| 654 | |
| 655 | /** Appends data to the end of the buffer. */ |
| 656 | template <typename U> |
| 657 | void appendcxx . . $ fmt/Buffer#append(780bc11a522ca03e).(const U *begin, const U *end); |
| 658 | |
| 659 | T &operatorcxx . . $ fmt/Buffer#`operator[]`(ec43b8547ac5c60).[](stdcxx . . $ std/::size_tcxx . . $ std/size_t# index) { return ptr_cxx . . $ fmt/Buffer#ptr_.[index]; } |
| 660 | const T &operatorcxx . . $ fmt/Buffer#`operator[]`(b741b238679282eb).[](stdcxx . . $ std/::size_tcxx . . $ std/size_t# index) const { return ptr_cxx . . $ fmt/Buffer#ptr_.[index]; } |
| 661 | }; |
| 662 | |
| 663 | template <typename T> |
| 664 | template <typename U> |
| 665 | void Buffercxx . . $ fmt/Buffer#<T>::appendcxx . . $ fmt/Buffer#append(780bc11a522ca03e).(const U *begin, const U *end) { |
| 666 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# new_size = size_cxx . . $ fmt/Buffer#size_. + internalcxx . . $ fmt/internal/::to_unsignedcxx . . $ fmt/internal/to_unsigned(4de866539cf5f5fc).(end - begin); |
| 667 | if (new_size > capacity_cxx . . $ fmt/Buffer#capacity_.) |
| 668 | growcxx . . $ fmt/Buffer#grow(2c44cd906ae4e829).(new_size); |
| 669 | stdcxx . . $ std/::uninitialized_copycxx . . $ std/uninitialized_copy(7316eb2979bdd03c).(begin, end, |
| 670 | internalcxx . . $ fmt/internal/::make_ptrcxx . . $ fmt/internal/make_ptr(1149d387c81d78d0).(ptr_cxx . . $ fmt/Buffer#ptr_., capacity_cxx . . $ fmt/Buffer#capacity_.) + size_cxx . . $ fmt/Buffer#size_.); |
| 671 | size_cxx . . $ fmt/Buffer#size_. = new_size; |
| 672 | } |
| 673 | |
| 674 | namespace internalcxx . . $ fmt/internal/ { |
| 675 | |
| 676 | // A memory buffer for trivially copyable/constructible types with the first |
| 677 | // SIZE elements stored in the object itself. |
| 678 | template <typename T, stdcxx . . $ std/::size_tcxx . . $ std/size_t# SIZE, typename Allocator = stdcxx . . $ std/::allocatorcxx . . $ std/allocator#<T> > |
| 679 | class MemoryBuffercxx . . $ fmt/internal/MemoryBuffer# : private Allocator, public Buffercxx . . $ fmt/Buffer#<T> { |
| 680 | private: |
| 681 | T data_cxx . . $ fmt/internal/MemoryBuffer#data_.[SIZE]; |
| 682 | |
| 683 | // Deallocate memory allocated by the buffer. |
| 684 | void deallocatecxx . . $ fmt/internal/MemoryBuffer#deallocate(49f6e7a06ebc5aa8).() { |
| 685 | if (this->ptr_cxx . . $ fmt/Buffer#ptr_. != data_cxx . . $ fmt/internal/MemoryBuffer#data_.) Allocator::deallocate(this->ptr_cxx . . $ fmt/Buffer#ptr_., this->capacity_cxx . . $ fmt/Buffer#capacity_.); |
| 686 | } |
| 687 | |
| 688 | protected: |
| 689 | void growcxx . . $ fmt/internal/MemoryBuffer#grow(2c44cd906ae4e829).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# size) FMT_OVERRIDEcxx . . $ `src/common/format.h:203:11`!; |
| 690 | |
| 691 | public: |
| 692 | explicit MemoryBuffercxx . . $ fmt/internal/MemoryBuffer#`MemoryBuffer<T, SIZE, Allocator>`(dac9925308f1454a).(const Allocator &alloc = Allocator()) |
| 693 | : Allocator(alloc), Buffercxx . . $ fmt/Buffer#<T>(data_cxx . . $ fmt/internal/MemoryBuffer#data_., SIZE) {} |
| 694 | ~cxx . . $ fmt/internal/MemoryBuffer#`~MemoryBuffer<T, SIZE, Allocator>`(49f6e7a06ebc5aa8).MemoryBuffer() { deallocatecxx . . $ fmt/internal/MemoryBuffer#deallocate(49f6e7a06ebc5aa8).(); } |
| 695 | |
| 696 | #if FMT_USE_RVALUE_REFERENCEScxx . . $ `src/common/format.h:149:11`! |
| 697 | private: |
| 698 | // Move data from other to this buffer. |
| 699 | void movecxx . . $ fmt/internal/MemoryBuffer#move(f103fc97a03f9514).(MemoryBuffer &other) { |
| 700 | Allocator &this_alloc = *this, &other_alloc = other; |
| 701 | this_alloc = stdcxx . . $ std/::movecxx . . $ std/move(7316eb2979bdd03c).(other_alloc); |
| 702 | this->size_cxx . . $ fmt/Buffer#size_. = other.size_cxx . . $ fmt/Buffer#size_.; |
| 703 | this->capacity_cxx . . $ fmt/Buffer#capacity_. = other.capacity_cxx . . $ fmt/Buffer#capacity_.; |
| 704 | if (other.ptr_cxx . . $ fmt/Buffer#ptr_. == other.data_cxx . . $ fmt/internal/MemoryBuffer#data_.) { |
| 705 | this->ptr_cxx . . $ fmt/Buffer#ptr_. = data_cxx . . $ fmt/internal/MemoryBuffer#data_.; |
| 706 | stdcxx . . $ std/::uninitialized_copycxx . . $ std/uninitialized_copy(7316eb2979bdd03c).(other.data_cxx . . $ fmt/internal/MemoryBuffer#data_., other.data_cxx . . $ fmt/internal/MemoryBuffer#data_. + this->size_cxx . . $ fmt/Buffer#size_., |
| 707 | make_ptrcxx . . $ fmt/internal/make_ptr(1149d387c81d78d0).(data_cxx . . $ fmt/internal/MemoryBuffer#data_., this->capacity_cxx . . $ fmt/Buffer#capacity_.)); |
| 708 | } |
| 709 | else { |
| 710 | this->ptr_cxx . . $ fmt/Buffer#ptr_. = other.ptr_cxx . . $ fmt/Buffer#ptr_.; |
| 711 | // Set pointer to the inline array so that delete is not called |
| 712 | // when deallocating. |
| 713 | other.ptr_cxx . . $ fmt/Buffer#ptr_. = other.data_cxx . . $ fmt/internal/MemoryBuffer#data_.; |
| 714 | } |
| 715 | } |
| 716 | |
| 717 | public: |
| 718 | MemoryBuffercxx . . $ fmt/internal/MemoryBuffer#`MemoryBuffer<T, SIZE, Allocator>`(c09f6a568aeb42cb).(MemoryBuffer &&other) { |
| 719 | movecxx . . $ fmt/internal/MemoryBuffer#move(f103fc97a03f9514).(other); |
| 720 | } |
| 721 | |
| 722 | MemoryBuffer &operatorcxx . . $ fmt/internal/MemoryBuffer#`operator=`(6b5c384b5aac7ee0).=(MemoryBuffer &&other) { |
| 723 | assertcxx . . $ `/usr/include/assert.h:102:11`!(this != &other); |
| 724 | deallocatecxx . . $ fmt/internal/MemoryBuffer#deallocate(49f6e7a06ebc5aa8).(); |
| 725 | movecxx . . $ fmt/internal/MemoryBuffer#move(f103fc97a03f9514).(other); |
| 726 | return *this; |
| 727 | } |
| 728 | #endif |
| 729 | |
| 730 | // Returns a copy of the allocator associated with this buffer. |
| 731 | Allocator get_allocatorcxx . . $ fmt/internal/MemoryBuffer#get_allocator(4e1d64b011eb729).() const { return *this; } |
| 732 | }; |
| 733 | |
| 734 | template <typename T, stdcxx . . $ std/::size_tcxx . . $ std/size_t# SIZE, typename Allocator> |
| 735 | void MemoryBuffercxx . . $ fmt/internal/MemoryBuffer#<T, SIZE, Allocator>::growcxx . . $ fmt/internal/MemoryBuffer#grow(2c44cd906ae4e829).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# size) { |
| 736 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# new_capacity = this->capacity_cxx . . $ fmt/Buffer#capacity_. + this->capacity_cxx . . $ fmt/Buffer#capacity_. / 2; |
| 737 | if (size > new_capacity) |
| 738 | new_capacity = size; |
| 739 | T *new_ptr = this->allocate(new_capacity); |
| 740 | // The following code doesn't throw, so the raw pointer above doesn't leak. |
| 741 | stdcxx . . $ std/::uninitialized_copycxx . . $ std/uninitialized_copy(7316eb2979bdd03c).(this->ptr_cxx . . $ fmt/Buffer#ptr_., this->ptr_cxx . . $ fmt/Buffer#ptr_. + this->size_cxx . . $ fmt/Buffer#size_., |
| 742 | make_ptrcxx . . $ fmt/internal/make_ptr(1149d387c81d78d0).(new_ptr, new_capacity)); |
| 743 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# old_capacity = this->capacity_cxx . . $ fmt/Buffer#capacity_.; |
| 744 | T *old_ptr = this->ptr_cxx . . $ fmt/Buffer#ptr_.; |
| 745 | this->capacity_cxx . . $ fmt/Buffer#capacity_. = new_capacity; |
| 746 | this->ptr_cxx . . $ fmt/Buffer#ptr_. = new_ptr; |
| 747 | // deallocate may throw (at least in principle), but it doesn't matter since |
| 748 | // the buffer already uses the new storage and will deallocate it in case |
| 749 | // of exception. |
| 750 | if (old_ptr != data_cxx . . $ fmt/internal/MemoryBuffer#data_.) |
| 751 | Allocator::deallocate(old_ptr, old_capacity); |
| 752 | } |
| 753 | |
| 754 | // A fixed-size buffer. |
| 755 | template <typename Char> |
| 756 | class FixedBuffercxx . . $ fmt/internal/FixedBuffer# : public fmtcxx . . $ fmt/::Buffercxx . . $ fmt/Buffer#<Char> { |
| 757 | public: |
| 758 | FixedBuffercxx . . $ fmt/internal/FixedBuffer#`FixedBuffer<Char>`(afd8256c216b84b2).(Char *array, stdcxx . . $ std/::size_tcxx . . $ std/size_t# size) : fmtcxx . . $ fmt/::Buffercxx . . $ fmt/Buffer#<Char>(array, size) {} |
| 759 | |
| 760 | protected: |
| 761 | FMT_APIcxx . . $ `src/common/format.h:75:10`! void growcxx . . $ fmt/internal/FixedBuffer#grow(2c44cd906ae4e829).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# size); |
| 762 | }; |
| 763 | |
| 764 | template <typename Char> |
| 765 | class BasicCharTraitscxx . . $ fmt/internal/BasicCharTraits# { |
| 766 | public: |
| 767 | #if FMT_SECURE_SCLcxx . . $ `src/common/format.h:46:10`! |
| 768 | typedef stdext::checked_array_iterator<Char*> CharPtr; |
| 769 | #else |
| 770 | typedef Char *CharPtrcxx . . $ fmt/internal/BasicCharTraits#CharPtr#; |
| 771 | #endif |
| 772 | static Char castcxx . . $ fmt/internal/BasicCharTraits#cast(767fea59dce4185d).(int value) { return static_cast<Char>(value); } |
| 773 | }; |
| 774 | |
| 775 | template <typename Char> |
| 776 | class CharTraitscxx . . $ fmt/internal/CharTraits#; |
| 777 | |
| 778 | template <> |
| 779 | class CharTraitscxx . . $ fmt/internal/CharTraits#<char> : public BasicCharTraitscxx . . $ fmt/internal/BasicCharTraits#<char> { |
| 780 | private: |
| 781 | // Conversion from wchar_t to char is not allowed. |
| 782 | static char convertcxx . . $ fmt/internal/CharTraits#convert(c325038e2602ebb7).(wchar_t); |
| 783 | |
| 784 | public: |
| 785 | static char convertcxx . . $ fmt/internal/CharTraits#convert(e6e5e845b55315fc).(char value) { return value; } |
| 786 | |
| 787 | // Formats a floating-point number. |
| 788 | template <typename T> |
| 789 | FMT_APIcxx . . $ `src/common/format.h:75:10`! static int format_floatcxx . . $ fmt/internal/CharTraits#format_float(9e602bfe50fad09d).(char *buffer, stdcxx . . $ std/::size_tcxx . . $ std/size_t# size, |
| 790 | const char *format, unsigned width, int precision, T value); |
| 791 | }; |
| 792 | |
| 793 | template <> |
| 794 | class CharTraitscxx . . $ fmt/internal/CharTraits#<wchar_t> : public BasicCharTraitscxx . . $ fmt/internal/BasicCharTraits#<wchar_t> { |
| 795 | public: |
| 796 | static wchar_t convertcxx . . $ fmt/internal/CharTraits#convert(1f8b8328d879f63a).(char value) { return value; } |
| 797 | static wchar_t convertcxx . . $ fmt/internal/CharTraits#convert(81a7c28504ec2a5f).(wchar_t value) { return value; } |
| 798 | |
| 799 | template <typename T> |
| 800 | FMT_APIcxx . . $ `src/common/format.h:75:10`! static int format_floatcxx . . $ fmt/internal/CharTraits#format_float(ab2f2ee480ef4af2).(wchar_t *buffer, stdcxx . . $ std/::size_tcxx . . $ std/size_t# size, |
| 801 | const wchar_t *format, unsigned width, int precision, T value); |
| 802 | }; |
| 803 | |
| 804 | // Checks if a number is negative - used to avoid warnings. |
| 805 | template <bool IsSigned> |
| 806 | struct SignCheckercxx . . $ fmt/internal/SignChecker# { |
| 807 | template <typename T> |
| 808 | static bool is_negativecxx . . $ fmt/internal/SignChecker#is_negative(809eade93cab327b).(T value) { return value < 0; } |
| 809 | }; |
| 810 | |
| 811 | template <> |
| 812 | struct SignCheckercxx . . $ fmt/internal/SignChecker#<false> { |
| 813 | template <typename T> |
| 814 | static bool is_negativecxx . . $ fmt/internal/SignChecker#is_negative(ee44d93984fb03e9).(T) { return false; } |
| 815 | }; |
| 816 | |
| 817 | // Returns true if value is negative, false otherwise. |
| 818 | // Same as (value < 0) but doesn't produce warnings if T is an unsigned type. |
| 819 | template <typename T> |
| 820 | inline bool is_negativecxx . . $ fmt/internal/is_negative(ee44d93984fb03e9).(T value) { |
| 821 | return SignCheckercxx . . $ fmt/internal/SignChecker#<std::numeric_limits<T>::is_signed>::is_negative(value); |
| 822 | } |
| 823 | |
| 824 | // Selects uint32_t if FitsIn32Bits is true, uint64_t otherwise. |
| 825 | template <bool FitsIn32Bits> |
| 826 | struct TypeSelectorcxx . . $ fmt/internal/TypeSelector# { typedef uint32_tcxx . . $ uint32_t# Typecxx . . $ fmt/internal/TypeSelector#Type#; }; |
| 827 | |
| 828 | template <> |
| 829 | struct TypeSelectorcxx . . $ fmt/internal/TypeSelector#<false> { typedef uint64_tcxx . . $ uint64_t# Typecxx . . $ fmt/internal/TypeSelector#Type#; }; |
| 830 | |
| 831 | template <typename T> |
| 832 | struct IntTraitscxx . . $ fmt/internal/IntTraits# { |
| 833 | // Smallest of uint32_t and uint64_t that is large enough to represent |
| 834 | // all values of T. |
| 835 | typedef typename |
| 836 | TypeSelectorcxx . . $ fmt/internal/TypeSelector#<std::numeric_limits<T>::digits <= 32>::Type MainTypecxx . . $ fmt/internal/IntTraits#MainType#; |
| 837 | }; |
| 838 | |
| 839 | FMT_APIcxx . . $ `src/common/format.h:75:10`! void report_unknown_typecxx . . $ fmt/internal/report_unknown_type(6d02e1a5f7bf8914).(char code, const char *type); |
| 840 | |
| 841 | // Static data is placed in this class template to allow header-only |
| 842 | // configuration. |
| 843 | template <typename T = void> |
| 844 | struct FMT_APIcxx . . $ `src/common/format.h:75:10`! BasicDatacxx . . $ fmt/internal/BasicData# { |
| 845 | static const uint32_tcxx . . $ uint32_t# POWERS_OF_10_32cxx . . $ fmt/internal/BasicData#POWERS_OF_10_32.[]; |
| 846 | static const uint64_tcxx . . $ uint64_t# POWERS_OF_10_64cxx . . $ fmt/internal/BasicData#POWERS_OF_10_64.[]; |
| 847 | static const char DIGITScxx . . $ fmt/internal/BasicData#DIGITS.[]; |
| 848 | }; |
| 849 | |
| 850 | #ifndef FMT_USE_EXTERN_TEMPLATES |
| 851 | // Clang doesn't have a feature check for extern templates so we check |
| 852 | // for variadic templates which were introduced in the same version. |
| 853 | # define FMT_USE_EXTERN_TEMPLATEScxx . . $ `src/common/format.h:853:10`! (__clang__cxx . . $ `<built-in>:3:9`! && FMT_USE_VARIADIC_TEMPLATEScxx . . $ `src/common/format.h:138:10`!) |
| 854 | #endif |
| 855 | |
| 856 | #if FMT_USE_EXTERN_TEMPLATEScxx . . $ `src/common/format.h:853:10`! && !defined(FMT_HEADER_ONLY) |
| 857 | extern template struct BasicDatacxx . . $ fmt/internal/BasicData#<void>; |
| 858 | #endif |
| 859 | |
| 860 | typedef BasicDatacxx . . $ fmt/internal/BasicData#<> Datacxx . . $ fmt/internal/Data#; |
| 861 | |
| 862 | #ifdef FMT_BUILTIN_CLZLLcxx . . $ `src/common/format.h:248:10`! |
| 863 | // Returns the number of decimal digits in n. Leading zeros are not counted |
| 864 | // except for n == 0 in which case count_digits returns 1. |
| 865 | inline unsigned count_digitscxx . . $ fmt/internal/count_digits(ea88b852781e8a38).(uint64_tcxx . . $ uint64_t# n) { |
| 866 | // Based on http://graphics.stanford.edu/~seander/bithacks.html#IntegerLog10 |
| 867 | // and the benchmark https://github.com/localvoid/cxx-benchmark-count-digits. |
| 868 | int t = (64 - FMT_BUILTIN_CLZLLcxx . . $ `src/common/format.h:248:10`!(n | 1)) * 1233 >> 12; |
| 869 | return to_unsignedcxx . . $ fmt/internal/to_unsigned(4de866539cf5f5fc).(t) - (n < Datacxx . . $ fmt/internal/Data#::POWERS_OF_10_64cxx . . $ fmt/internal/BasicData#POWERS_OF_10_64.[t]) + 1; |
| 870 | } |
| 871 | #else |
| 872 | // Fallback version of count_digits used when __builtin_clz is not available. |
| 873 | inline unsigned count_digits(uint64_t n) { |
| 874 | unsigned count = 1; |
| 875 | for (;;) { |
| 876 | // Integer division is slow so do it for a group of four digits instead |
| 877 | // of for every digit. The idea comes from the talk by Alexandrescu |
| 878 | // "Three Optimization Tips for C++". See speed-test for a comparison. |
| 879 | if (n < 10) return count; |
| 880 | if (n < 100) return count + 1; |
| 881 | if (n < 1000) return count + 2; |
| 882 | if (n < 10000) return count + 3; |
| 883 | n /= 10000u; |
| 884 | count += 4; |
| 885 | } |
| 886 | } |
| 887 | #endif |
| 888 | |
| 889 | #ifdef FMT_BUILTIN_CLZcxx . . $ `src/common/format.h:244:10`! |
| 890 | // Optional version of count_digits for better performance on 32-bit platforms. |
| 891 | inline unsigned count_digitscxx . . $ fmt/internal/count_digits(2141b656ce2cc063).(uint32_tcxx . . $ uint32_t# n) { |
| 892 | int t = (32 - FMT_BUILTIN_CLZcxx . . $ `src/common/format.h:244:10`!(n | 1)) * 1233 >> 12; |
| 893 | return to_unsignedcxx . . $ fmt/internal/to_unsigned(4de866539cf5f5fc).(t) - (n < Datacxx . . $ fmt/internal/Data#::POWERS_OF_10_32cxx . . $ fmt/internal/BasicData#POWERS_OF_10_32.[t]) + 1; |
| 894 | } |
| 895 | #endif |
| 896 | |
| 897 | // A functor that doesn't add a thousands separator. |
| 898 | struct NoThousandsSepcxx . . $ fmt/internal/NoThousandsSep# { |
| 899 | template <typename Char> |
| 900 | void operatorcxx . . $ fmt/internal/NoThousandsSep#`operator()`(ebd0a1552f8ce24f).()(Char *) {} |
| 901 | }; |
| 902 | |
| 903 | // A functor that adds a thousands separator. |
| 904 | class ThousandsSepcxx . . $ fmt/internal/ThousandsSep# { |
| 905 | private: |
| 906 | fmtcxx . . $ fmt/::StringRefcxx . . $ fmt/StringRef# sep_cxx . . $ fmt/internal/ThousandsSep#sep_.; |
| 907 | |
| 908 | // Index of a decimal digit with the least significant digit having index 0. |
| 909 | unsigned digit_index_cxx . . $ fmt/internal/ThousandsSep#digit_index_.; |
| 910 | |
| 911 | public: |
| 912 | explicit ThousandsSepcxx . . $ fmt/internal/ThousandsSep#ThousandsSep(1fa171f18af400a9).(fmtcxx . . $ fmt/::StringRefcxx . . $ fmt/StringRef# sep) : sep_cxx . . $ fmt/internal/ThousandsSep#sep_.(sep), digit_index_cxx . . $ fmt/internal/ThousandsSep#digit_index_.(0) {} |
| 913 | |
| 914 | template <typename Char> |
| 915 | void operatorcxx . . $ fmt/internal/ThousandsSep#`operator()`(cf61340cf45ae89c).()(Char *&buffer) { |
| 916 | if (++digit_index_cxx . . $ fmt/internal/ThousandsSep#digit_index_. % 3 != 0) |
| 917 | return; |
| 918 | buffer -= sep_cxx . . $ fmt/internal/ThousandsSep#sep_..sizecxx . . $ fmt/BasicStringRef#size(fe4d2d262d4164a8).(); |
| 919 | stdcxx . . $ std/::uninitialized_copycxx . . $ std/uninitialized_copy(7316eb2979bdd03c).(sep_cxx . . $ fmt/internal/ThousandsSep#sep_..datacxx . . $ fmt/BasicStringRef#data(1016ee5406d91ab9).(), sep_cxx . . $ fmt/internal/ThousandsSep#sep_..datacxx . . $ fmt/BasicStringRef#data(1016ee5406d91ab9).() + sep_cxx . . $ fmt/internal/ThousandsSep#sep_..sizecxx . . $ fmt/BasicStringRef#size(fe4d2d262d4164a8).(), |
| 920 | internalcxx . . $ fmt/internal/::make_ptrcxx . . $ fmt/internal/make_ptr(1149d387c81d78d0).(buffer, sep_cxx . . $ fmt/internal/ThousandsSep#sep_..sizecxx . . $ fmt/BasicStringRef#size(fe4d2d262d4164a8).())); |
| 921 | } |
| 922 | }; |
| 923 | |
| 924 | // Formats a decimal unsigned integer value writing into buffer. |
| 925 | // thousands_sep is a functor that is called after writing each char to |
| 926 | // add a thousands separator if necessary. |
| 927 | template <typename UInt, typename Char, typename ThousandsSep> |
| 928 | inline void format_decimalcxx . . $ fmt/internal/format_decimal(2ee2ed860afba233).(Char *buffer, UInt value, unsigned num_digits, |
| 929 | ThousandsSep thousands_sep) { |
| 930 | buffer += num_digits; |
| 931 | while (value >= 100) { |
| 932 | // Integer division is slow so do it for a group of two digits instead |
| 933 | // of for every digit. The idea comes from the talk by Alexandrescu |
| 934 | // "Three Optimization Tips for C++". See speed-test for a comparison. |
| 935 | unsigned index = static_cast<unsigned>((value % 100) * 2); |
| 936 | value /= 100; |
| 937 | *--buffer = Datacxx . . $ fmt/internal/Data#::DIGITScxx . . $ fmt/internal/BasicData#DIGITS.[index + 1]; |
| 938 | thousands_sep(buffer); |
| 939 | *--buffer = Datacxx . . $ fmt/internal/Data#::DIGITScxx . . $ fmt/internal/BasicData#DIGITS.[index]; |
| 940 | thousands_sep(buffer); |
| 941 | } |
| 942 | if (value < 10) { |
| 943 | *--buffer = static_cast<char>('0' + value); |
| 944 | return; |
| 945 | } |
| 946 | unsigned index = static_cast<unsigned>(value * 2); |
| 947 | *--buffer = Datacxx . . $ fmt/internal/Data#::DIGITScxx . . $ fmt/internal/BasicData#DIGITS.[index + 1]; |
| 948 | thousands_sep(buffer); |
| 949 | *--buffer = Datacxx . . $ fmt/internal/Data#::DIGITScxx . . $ fmt/internal/BasicData#DIGITS.[index]; |
| 950 | } |
| 951 | |
| 952 | template <typename UInt, typename Char> |
| 953 | inline void format_decimalcxx . . $ fmt/internal/format_decimal(e36525a719ed0f39).(Char *buffer, UInt value, unsigned num_digits) { |
| 954 | return format_decimalcxx . . $ fmt/internal/format_decimal(e36525a719ed0f39).(buffer, value, num_digits, NoThousandsSepcxx . . $ fmt/internal/NoThousandsSep#()); |
| 955 | } |
| 956 | |
| 957 | #ifndef _WIN32 |
| 958 | # define FMT_USE_WINDOWS_Hcxx . . $ `src/common/format.h:958:10`! 0 |
| 959 | #elif !defined(FMT_USE_WINDOWS_H) |
| 960 | # define FMT_USE_WINDOWS_H 1 |
| 961 | #endif |
| 962 | |
| 963 | // Define FMT_USE_WINDOWS_H to 0 to disable use of windows.h. |
| 964 | // All the functionality that relies on it will be disabled too. |
| 965 | #if FMT_USE_WINDOWS_Hcxx . . $ `src/common/format.h:958:10`! |
| 966 | // A converter from UTF-8 to UTF-16. |
| 967 | // It is only provided for Windows since other systems support UTF-8 natively. |
| 968 | class UTF8ToUTF16 { |
| 969 | private: |
| 970 | MemoryBuffer<wchar_t, INLINE_BUFFER_SIZE> buffer_; |
| 971 | |
| 972 | public: |
| 973 | FMT_API explicit UTF8ToUTF16(StringRef s); |
| 974 | operator WStringRef() const { return WStringRef(&buffer_[0], size()); } |
| 975 | size_t size() const { return buffer_.size() - 1; } |
| 976 | const wchar_t *c_str() const { return &buffer_[0]; } |
| 977 | std::wstring str() const { return std::wstring(&buffer_[0], size()); } |
| 978 | }; |
| 979 | |
| 980 | // A converter from UTF-16 to UTF-8. |
| 981 | // It is only provided for Windows since other systems support UTF-8 natively. |
| 982 | class UTF16ToUTF8 { |
| 983 | private: |
| 984 | MemoryBuffer<char, INLINE_BUFFER_SIZE> buffer_; |
| 985 | |
| 986 | public: |
| 987 | UTF16ToUTF8() {} |
| 988 | FMT_API explicit UTF16ToUTF8(WStringRef s); |
| 989 | operator StringRef() const { return StringRef(&buffer_[0], size()); } |
| 990 | size_t size() const { return buffer_.size() - 1; } |
| 991 | const char *c_str() const { return &buffer_[0]; } |
| 992 | std::string str() const { return std::string(&buffer_[0], size()); } |
| 993 | |
| 994 | // Performs conversion returning a system error code instead of |
| 995 | // throwing exception on conversion error. This method may still throw |
| 996 | // in case of memory allocation error. |
| 997 | FMT_API int convert(WStringRef s); |
| 998 | }; |
| 999 | |
| 1000 | FMT_API void format_windows_error(fmt::Writer &out, int error_code, |
| 1001 | fmt::StringRef message) FMT_NOEXCEPT; |
| 1002 | #endif |
| 1003 | |
| 1004 | FMT_APIcxx . . $ `src/common/format.h:75:10`! void format_system_errorcxx . . $ fmt/internal/format_system_error(a97816e40fb22830).(fmtcxx . . $ fmt/::Writercxx . . $ fmt/Writer# &out, int error_code, |
| 1005 | fmtcxx . . $ fmt/::StringRefcxx . . $ fmt/StringRef# message) FMT_NOEXCEPTcxx . . $ `src/common/format.h:188:12`!; |
| 1006 | |
| 1007 | // A formatting argument value. |
| 1008 | struct Valuecxx . . $ fmt/internal/Value# { |
| 1009 | template <typename Char> |
| 1010 | struct StringValuecxx . . $ fmt/internal/Value#StringValue# { |
| 1011 | const Char *valuecxx . . $ fmt/internal/Value#StringValue#value.; |
| 1012 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# sizecxx . . $ fmt/internal/Value#StringValue#size.; |
| 1013 | }; |
| 1014 | |
| 1015 | typedef void(*FormatFunccxx . . $ fmt/internal/Value#FormatFunc#)( |
| 1016 | void *formatter, const void *arg, void *format_str_ptr); |
| 1017 | |
| 1018 | struct CustomValuecxx . . $ fmt/internal/Value#CustomValue# { |
| 1019 | const void *valuecxx . . $ fmt/internal/Value#CustomValue#value.; |
| 1020 | FormatFunccxx . . $ fmt/internal/Value#FormatFunc# formatcxx . . $ fmt/internal/Value#CustomValue#format.; |
| 1021 | }; |
| 1022 | |
| 1023 | unioncxx . . $ fmt/internal/Value#$anonymous_type_1# { |
| 1024 | int int_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#int_value.; |
| 1025 | unsigned uint_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#uint_value.; |
| 1026 | LongLongcxx . . $ fmt/LongLong# long_long_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#long_long_value.; |
| 1027 | ULongLongcxx . . $ fmt/ULongLong# ulong_long_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#ulong_long_value.; |
| 1028 | double double_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#double_value.; |
| 1029 | long double long_double_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#long_double_value.; |
| 1030 | const void *pointercxx . . $ fmt/internal/Value#$anonymous_type_1#pointer.; |
| 1031 | StringValuecxx . . $ fmt/internal/Value#StringValue#<char> stringcxx . . $ fmt/internal/Value#$anonymous_type_1#string.; |
| 1032 | StringValuecxx . . $ fmt/internal/Value#StringValue#<signed char> sstringcxx . . $ fmt/internal/Value#$anonymous_type_1#sstring.; |
| 1033 | StringValuecxx . . $ fmt/internal/Value#StringValue#<unsigned char> ustringcxx . . $ fmt/internal/Value#$anonymous_type_1#ustring.; |
| 1034 | StringValuecxx . . $ fmt/internal/Value#StringValue#<wchar_t> wstringcxx . . $ fmt/internal/Value#$anonymous_type_1#wstring.; |
| 1035 | CustomValuecxx . . $ fmt/internal/Value#CustomValue# customcxx . . $ fmt/internal/Value#$anonymous_type_1#custom.; |
| 1036 | }; |
| 1037 | |
| 1038 | enum Typecxx . . $ fmt/internal/Value#Type# { |
| 1039 | NONEcxx . . $ fmt/internal/Value#NONE., NAMED_ARGcxx . . $ fmt/internal/Value#NAMED_ARG., |
| 1040 | // Integer types should go first, |
| 1041 | INTcxx . . $ fmt/internal/Value#INT., UINTcxx . . $ fmt/internal/Value#UINT., LONG_LONGcxx . . $ fmt/internal/Value#LONG_LONG., ULONG_LONGcxx . . $ fmt/internal/Value#ULONG_LONG., BOOLcxx . . $ fmt/internal/Value#BOOL., CHARcxx . . $ fmt/internal/Value#CHAR., LAST_INTEGER_TYPEcxx . . $ fmt/internal/Value#LAST_INTEGER_TYPE. = CHARcxx . . $ fmt/internal/Value#CHAR., |
| 1042 | // followed by floating-point types. |
| 1043 | DOUBLEcxx . . $ fmt/internal/Value#DOUBLE., LONG_DOUBLEcxx . . $ fmt/internal/Value#LONG_DOUBLE., LAST_NUMERIC_TYPEcxx . . $ fmt/internal/Value#LAST_NUMERIC_TYPE. = LONG_DOUBLEcxx . . $ fmt/internal/Value#LONG_DOUBLE., |
| 1044 | CSTRINGcxx . . $ fmt/internal/Value#CSTRING., STRINGcxx . . $ fmt/internal/Value#STRING., WSTRINGcxx . . $ fmt/internal/Value#WSTRING., POINTERcxx . . $ fmt/internal/Value#POINTER., CUSTOMcxx . . $ fmt/internal/Value#CUSTOM. |
| 1045 | }; |
| 1046 | }; |
| 1047 | |
| 1048 | // A formatting argument. It is a trivially copyable/constructible type to |
| 1049 | // allow storage in internal::MemoryBuffer. |
| 1050 | struct Argcxx . . $ fmt/internal/Arg# : Valuecxx . . $ fmt/internal/Value# { |
| 1051 | Typecxx . . $ fmt/internal/Value#Type# typecxx . . $ fmt/internal/Arg#type.; |
| 1052 | }; |
| 1053 | |
| 1054 | template <typename Char> |
| 1055 | struct NamedArgcxx . . $ fmt/internal/NamedArg#; |
| 1056 | |
| 1057 | template <typename T = void> |
| 1058 | struct Nullcxx . . $ fmt/internal/Null# {}; |
| 1059 | |
| 1060 | // A helper class template to enable or disable overloads taking wide |
| 1061 | // characters and strings in MakeValue. |
| 1062 | template <typename T, typename Char> |
| 1063 | struct WCharHelpercxx . . $ fmt/internal/WCharHelper# { |
| 1064 | typedef Nullcxx . . $ fmt/internal/Null#<T> Supportedcxx . . $ fmt/internal/WCharHelper#Supported#; |
| 1065 | typedef T Unsupportedcxx . . $ fmt/internal/WCharHelper#Unsupported#; |
| 1066 | }; |
| 1067 | |
| 1068 | template <typename T> |
| 1069 | struct WCharHelpercxx . . $ fmt/internal/WCharHelper#<T, wchar_t> { |
| 1070 | typedef T Supportedcxx . . $ fmt/internal/WCharHelper#Supported#; |
| 1071 | typedef Nullcxx . . $ fmt/internal/Null#<T> Unsupportedcxx . . $ fmt/internal/WCharHelper#Unsupported#; |
| 1072 | }; |
| 1073 | |
| 1074 | typedef char Yescxx . . $ fmt/internal/Yes#[1]; |
| 1075 | typedef char Nocxx . . $ fmt/internal/No#[2]; |
| 1076 | |
| 1077 | template <typename T> |
| 1078 | T &getcxx . . $ fmt/internal/get(19b2b6f17af048b).(); |
| 1079 | |
| 1080 | // These are non-members to workaround an overload resolution bug in bcc32. |
| 1081 | Yescxx . . $ fmt/internal/Yes# &convertcxx . . $ fmt/internal/convert(94faa010f651ee20).(fmtcxx . . $ fmt/::ULongLongcxx . . $ fmt/ULongLong#); |
| 1082 | Nocxx . . $ fmt/internal/No# &convertcxx . . $ fmt/internal/convert(5a9e71ec4561c69d).(...); |
| 1083 | |
| 1084 | template<typename T, bool ENABLE_CONVERSION> |
| 1085 | struct ConvertToIntImplcxx . . $ fmt/internal/ConvertToIntImpl# { |
| 1086 | enumcxx . . $ fmt/internal/ConvertToIntImpl#$anonymous_type_2# { valuecxx . . $ fmt/internal/ConvertToIntImpl#value. = ENABLE_CONVERSION }; |
| 1087 | }; |
| 1088 | |
| 1089 | template<typename T, bool ENABLE_CONVERSION> |
| 1090 | struct ConvertToIntImpl2cxx . . $ fmt/internal/ConvertToIntImpl2# { |
| 1091 | enumcxx . . $ fmt/internal/ConvertToIntImpl2#$anonymous_type_3# { valuecxx . . $ fmt/internal/ConvertToIntImpl2#value. = false }; |
| 1092 | }; |
| 1093 | |
| 1094 | template<typename T> |
| 1095 | struct ConvertToIntImpl2cxx . . $ fmt/internal/ConvertToIntImpl2#<T, true> { |
| 1096 | enumcxx . . $ fmt/internal/ConvertToIntImpl2#$anonymous_type_4# { |
| 1097 | // Don't convert numeric types. |
| 1098 | valuecxx . . $ fmt/internal/ConvertToIntImpl2#value. = ConvertToIntImplcxx . . $ fmt/internal/ConvertToIntImpl#<T, !std::numeric_limits<T>::is_specialized>::value |
| 1099 | }; |
| 1100 | }; |
| 1101 | |
| 1102 | template<typename T> |
| 1103 | struct ConvertToIntcxx . . $ fmt/internal/ConvertToInt# { |
| 1104 | enumcxx . . $ fmt/internal/ConvertToInt#$anonymous_type_5# { enable_conversioncxx . . $ fmt/internal/ConvertToInt#enable_conversion. = sizeof(convertcxx . . $ fmt/internal/convert(94faa010f651ee20).(getcxx . . $ fmt/internal/get(19b2b6f17af048b).<T>())) == sizeof(Yescxx . . $ fmt/internal/Yes#) }; |
| 1105 | enumcxx . . $ fmt/internal/ConvertToInt#$anonymous_type_6# { valuecxx . . $ fmt/internal/ConvertToInt#value. = ConvertToIntImpl2cxx . . $ fmt/internal/ConvertToIntImpl2#<T, enable_conversion>::value }; |
| 1106 | }; |
| 1107 | |
| 1108 | #define FMT_DISABLE_CONVERSION_TO_INTcxx . . $ `src/common/format.h:1108:9`!(Type) \ |
| 1109 | template <> \ |
| 1110 | struct ConvertToInt<Type> { enum { value = 0 }; } |
| 1111 | |
| 1112 | // Silence warnings about convering float to int. |
| 1113 | FMT_DISABLE_CONVERSION_TO_INTcxx . . $ fmt/internal/ConvertToInt#$anonymous_type_7#(float); |
| 1114 | FMT_DISABLE_CONVERSION_TO_INTcxx . . $ fmt/internal/ConvertToInt#value.(double); |
| 1115 | FMT_DISABLE_CONVERSION_TO_INTcxx . . $ fmt/internal/ConvertToInt#$anonymous_type_9#(long double); |
| 1116 | |
| 1117 | template<bool B, class T = void> |
| 1118 | struct EnableIfcxx . . $ fmt/internal/EnableIf# {}; |
| 1119 | |
| 1120 | template<class T> |
| 1121 | struct EnableIfcxx . . $ fmt/internal/EnableIf#<true, T> { typedef T typecxx . . $ fmt/internal/EnableIf#type#; }; |
| 1122 | |
| 1123 | template<bool B, class T, class F> |
| 1124 | struct Conditionalcxx . . $ fmt/internal/Conditional# { typedef T typecxx . . $ fmt/internal/Conditional#type#; }; |
| 1125 | |
| 1126 | template<class T, class F> |
| 1127 | struct Conditionalcxx . . $ fmt/internal/Conditional#<false, T, F> { typedef F typecxx . . $ fmt/internal/Conditional#type#; }; |
| 1128 | |
| 1129 | // For bcc32 which doesn't understand ! in template arguments. |
| 1130 | template<bool> |
| 1131 | struct Notcxx . . $ fmt/internal/Not# { enumcxx . . $ fmt/internal/Not#$anonymous_type_10# { valuecxx . . $ fmt/internal/Not#value. = 0 }; }; |
| 1132 | |
| 1133 | template<> |
| 1134 | struct Notcxx . . $ fmt/internal/Not#<false> { enumcxx . . $ fmt/internal/Not#$anonymous_type_11# { valuecxx . . $ fmt/internal/Not#value. = 1 }; }; |
| 1135 | |
| 1136 | template<typename T, T> struct LConvCheckcxx . . $ fmt/internal/LConvCheck# { |
| 1137 | LConvCheckcxx . . $ fmt/internal/LConvCheck#`LConvCheck<T, value-parameter-0-1>`(d4f767463ce0a6b3).(int) {} |
| 1138 | }; |
| 1139 | |
| 1140 | // Returns the thousands separator for the current locale. |
| 1141 | // We check if ``lconv`` contains ``thousands_sep`` because on Android |
| 1142 | // ``lconv`` is stubbed as an empty struct. |
| 1143 | template <typename LConv> |
| 1144 | inline StringRefcxx . . $ fmt/StringRef# thousands_sepcxx . . $ fmt/internal/thousands_sep(fdb6883f460ea402).( |
| 1145 | LConv *lc, LConvCheckcxx . . $ fmt/internal/LConvCheck#<char *LConv::*, &LConv::thousands_sep> = 0) { |
| 1146 | return lc->thousands_sep; |
| 1147 | } |
| 1148 | |
| 1149 | inline fmtcxx . . $ fmt/::StringRefcxx . . $ fmt/StringRef# thousands_sepcxx . . $ fmt/internal/thousands_sep(270b38d350a91d6c).(...) { return ""cxx . . $ fmt/BasicStringRef#BasicStringRef(88376428bb603c08).; } |
| 1150 | |
| 1151 | // Makes an Arg object from any type. |
| 1152 | template <typename Formatter> |
| 1153 | class MakeValuecxx . . $ fmt/internal/MakeValue# : public Argcxx . . $ fmt/internal/Arg# { |
| 1154 | public: |
| 1155 | typedef typename Formatter::Char Charcxx . . $ fmt/internal/MakeValue#Char#; |
| 1156 | |
| 1157 | private: |
| 1158 | // The following two methods are private to disallow formatting of |
| 1159 | // arbitrary pointers. If you want to output a pointer cast it to |
| 1160 | // "void *" or "const void *". In particular, this forbids formatting |
| 1161 | // of "[const] volatile char *" which is printed as bool by iostreams. |
| 1162 | // Do not implement! |
| 1163 | template <typename T> |
| 1164 | MakeValuecxx . . $ fmt/internal/MakeValue#`MakeValue<Formatter>`(3f9eee46045fc938).(const T *value); |
| 1165 | template <typename T> |
| 1166 | MakeValuecxx . . $ fmt/internal/MakeValue#`MakeValue<Formatter>`(7e6e718d4f0ca9be).(T *value); |
| 1167 | |
| 1168 | // The following methods are private to disallow formatting of wide |
| 1169 | // characters and strings into narrow strings as in |
| 1170 | // fmt::format("{}", L"test"); |
| 1171 | // To fix this, use a wide format string: fmt::format(L"{}", L"test"). |
| 1172 | #if !FMT_MSC_VERcxx . . $ `src/common/format.h:56:10`! || defined(_NATIVE_WCHAR_T_DEFINED) |
| 1173 | MakeValuecxx . . $ fmt/internal/MakeValue#`MakeValue<Formatter>`(cb786ef44337d558).(typename WCharHelpercxx . . $ fmt/internal/WCharHelper#<wchar_t, Char>::Unsupported); |
| 1174 | #endif |
| 1175 | MakeValuecxx . . $ fmt/internal/MakeValue#`MakeValue<Formatter>`(74d25fda78fc9581).(typename WCharHelpercxx . . $ fmt/internal/WCharHelper#<wchar_t *, Char>::Unsupported); |
| 1176 | MakeValuecxx . . $ fmt/internal/MakeValue#`MakeValue<Formatter>`(84221e280176c248).(typename WCharHelpercxx . . $ fmt/internal/WCharHelper#<const wchar_t *, Char>::Unsupported); |
| 1177 | MakeValuecxx . . $ fmt/internal/MakeValue#`MakeValue<Formatter>`(50e268bf4b0c66da).(typename WCharHelpercxx . . $ fmt/internal/WCharHelper#<const std::wstring &, Char>::Unsupported); |
| 1178 | MakeValuecxx . . $ fmt/internal/MakeValue#`MakeValue<Formatter>`(ca5593204a80b106).(typename WCharHelpercxx . . $ fmt/internal/WCharHelper#<WStringRef, Char>::Unsupported); |
| 1179 | |
| 1180 | void set_stringcxx . . $ fmt/internal/MakeValue#set_string(1fa171f18af400a9).(StringRefcxx . . $ fmt/StringRef# str) { |
| 1181 | stringcxx . . $ fmt/internal/Value#$anonymous_type_1#string..valuecxx . . $ fmt/internal/Value#StringValue#value. = str.datacxx . . $ fmt/BasicStringRef#data(1016ee5406d91ab9).(); |
| 1182 | stringcxx . . $ fmt/internal/Value#$anonymous_type_1#string..sizecxx . . $ fmt/internal/Value#StringValue#size. = str.sizecxx . . $ fmt/BasicStringRef#size(fe4d2d262d4164a8).(); |
| 1183 | } |
| 1184 | |
| 1185 | void set_stringcxx . . $ fmt/internal/MakeValue#set_string(8a1d73b94810b61).(WStringRefcxx . . $ fmt/WStringRef# str) { |
| 1186 | wstringcxx . . $ fmt/internal/Value#$anonymous_type_1#wstring..valuecxx . . $ fmt/internal/Value#StringValue#value. = str.datacxx . . $ fmt/BasicStringRef#data(1016ee5406d91ab9).(); |
| 1187 | wstringcxx . . $ fmt/internal/Value#$anonymous_type_1#wstring..sizecxx . . $ fmt/internal/Value#StringValue#size. = str.sizecxx . . $ fmt/BasicStringRef#size(fe4d2d262d4164a8).(); |
| 1188 | } |
| 1189 | |
| 1190 | // Formats an argument of a custom type, such as a user-defined class. |
| 1191 | template <typename T> |
| 1192 | static void format_custom_argcxx . . $ fmt/internal/MakeValue#format_custom_arg(67ec5b66cac54e78).( |
| 1193 | void *formatter, const void *arg, void *format_str_ptr) { |
| 1194 | format(*static_cast<Formatter*>(formatter), |
| 1195 | *static_cast<const Charcxx . . $ fmt/internal/MakeValue#Char#**>(format_str_ptr), |
| 1196 | *static_cast<const T*>(arg)); |
| 1197 | } |
| 1198 | |
| 1199 | public: |
| 1200 | MakeValuecxx . . $ fmt/internal/MakeValue#`MakeValue<Formatter>`(49f6e7a06ebc5aa8).() {} |
| 1201 | |
| 1202 | #define FMT_MAKE_VALUE_cxx . . $ `src/common/format.h:1202:9`!(Type, field, TYPE, rhs) \ |
| 1203 | MakeValue(Type value) { field = rhs; } \ |
| 1204 | static uint64_t type(Type) { return Arg::TYPE; } |
| 1205 | |
| 1206 | #define FMT_MAKE_VALUEcxx . . $ `src/common/format.h:1206:9`!(Type, field, TYPE) \ |
| 1207 | FMT_MAKE_VALUE_cxx . . $ `src/common/format.h:1202:9`!(Type, field, TYPE, value) |
| 1208 | |
| 1209 | FMT_MAKE_VALUEcxx . . $ `src/common/format.h:1206:9`!(bool, int_value, BOOL) |
| 1210 | FMT_MAKE_VALUEcxx . . $ fmt/internal/Value#INT.(short, int_value, INT) |
| 1211 | FMT_MAKE_VALUEcxx . . $ fmt/internal/Value#UINT.(unsigned short, uint_value, UINT) |
| 1212 | FMT_MAKE_VALUEcxx . . $ fmt/internal/MakeValue#`MakeValue<Formatter>`(d4f767463ce0a6b3).(int, int_value, INT) |
| 1213 | FMT_MAKE_VALUEcxx . . $ fmt/internal/MakeValue#type(1892545c1754497d).(unsigned, uint_value, UINT) |
| 1214 | |
| 1215 | MakeValuecxx . . $ fmt/internal/MakeValue#`MakeValue<Formatter>`(1624ee8275b10bda).(long value) { |
| 1216 | // To minimize the number of types we need to deal with, long is |
| 1217 | // translated either to int or to long long depending on its size. |
| 1218 | if (const_checkcxx . . $ fmt/internal/const_check(ada6a8422704cf8a).(sizeof(long) == sizeof(int))) |
| 1219 | int_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#int_value. = static_cast<int>(value); |
| 1220 | else |
| 1221 | long_long_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#long_long_value. = value; |
| 1222 | } |
| 1223 | static uint64_tcxx . . $ uint64_t# typecxx . . $ fmt/internal/MakeValue#type(2b379ed948b94b7b).(long) { |
| 1224 | return sizeof(long) == sizeof(int) ? Argcxx . . $ fmt/internal/Arg#::INTcxx . . $ fmt/internal/Value#INT. : Argcxx . . $ fmt/internal/Arg#::LONG_LONGcxx . . $ fmt/internal/Value#LONG_LONG.; |
| 1225 | } |
| 1226 | |
| 1227 | MakeValuecxx . . $ fmt/internal/MakeValue#`MakeValue<Formatter>`(2c44cd906ae4e829).(unsigned long value) { |
| 1228 | if (const_checkcxx . . $ fmt/internal/const_check(ada6a8422704cf8a).(sizeof(unsigned long) == sizeof(unsigned))) |
| 1229 | uint_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#uint_value. = static_cast<unsigned>(value); |
| 1230 | else |
| 1231 | ulong_long_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#ulong_long_value. = value; |
| 1232 | } |
| 1233 | static uint64_tcxx . . $ uint64_t# typecxx . . $ fmt/internal/MakeValue#type(ecdaa1632f49f591).(unsigned long) { |
| 1234 | return sizeof(unsigned long) == sizeof(unsigned) ? |
| 1235 | Argcxx . . $ fmt/internal/Arg#::UINTcxx . . $ fmt/internal/Value#UINT. : Argcxx . . $ fmt/internal/Arg#::ULONG_LONGcxx . . $ fmt/internal/Value#ULONG_LONG.; |
| 1236 | } |
| 1237 | |
| 1238 | FMT_MAKE_VALUEcxx . . $ fmt/internal/MakeValue#`MakeValue<Formatter>`(35cb52607f6af42f).(LongLong, long_long_value, LONG_LONG) |
| 1239 | FMT_MAKE_VALUEcxx . . $ fmt/internal/MakeValue#`MakeValue<Formatter>`(891dc3055356b409).(ULongLong, ulong_long_value, ULONG_LONG) |
| 1240 | FMT_MAKE_VALUEcxx . . $ fmt/internal/MakeValue#`MakeValue<Formatter>`(9364e6e7bff7660).(float, double_value, DOUBLE) |
| 1241 | FMT_MAKE_VALUEcxx . . $ fmt/internal/Arg#(double, double_value, DOUBLE) |
| 1242 | FMT_MAKE_VALUEcxx . . $ fmt/internal/MakeValue#`MakeValue<Formatter>`(8e6692e4d5b2613a).(long double, long_double_value, LONG_DOUBLE) |
| 1243 | FMT_MAKE_VALUEcxx . . $ fmt/internal/MakeValue#type(8a5a92dae0f8e078).(signed char, int_value, INT) |
| 1244 | FMT_MAKE_VALUEcxx . . $ fmt/internal/Arg#(unsigned char, uint_value, UINT) |
| 1245 | FMT_MAKE_VALUEcxx . . $ fmt/internal/Arg#(char, int_value, CHAR) |
| 1246 | |
| 1247 | #if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED) |
| 1248 | MakeValuecxx . . $ fmt/internal/MakeValue#`MakeValue<Formatter>`(65adfe921cedd40e).(typename WCharHelpercxx . . $ fmt/internal/WCharHelper#<wchar_t, Char>::Supported value) { |
| 1249 | int_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#int_value. = value; |
| 1250 | } |
| 1251 | static uint64_tcxx . . $ uint64_t# typecxx . . $ fmt/internal/MakeValue#type(76f26c1a17bb1cc).(wchar_t) { return Argcxx . . $ fmt/internal/Arg#::CHARcxx . . $ fmt/internal/Value#CHAR.; } |
| 1252 | #endif |
| 1253 | |
| 1254 | #define FMT_MAKE_STR_VALUEcxx . . $ `src/common/format.h:1254:9`!(Type, TYPE) \ |
| 1255 | MakeValue(Type value) { set_string(value); } \ |
| 1256 | static uint64_t type(Type) { return Arg::TYPE; } |
| 1257 | |
| 1258 | FMT_MAKE_VALUEcxx . . $ fmt/internal/Value#$anonymous_type_1#string.(char *, string.value, CSTRING) |
| 1259 | FMT_MAKE_VALUEcxx . . $ fmt/internal/MakeValue#type(751346f8406fd082).(const char *, string.value, CSTRING) |
| 1260 | FMT_MAKE_VALUEcxx . . $ fmt/internal/MakeValue#type(91808d10590ebb6a).(signed char *, sstring.value, CSTRING) |
| 1261 | FMT_MAKE_VALUEcxx . . $ fmt/internal/MakeValue#`MakeValue<Formatter>`(d18ab712bd9240a7).(const signed char *, sstring.value, CSTRING) |
| 1262 | FMT_MAKE_VALUEcxx . . $ fmt/internal/Value#StringValue#value.(unsigned char *, ustring.value, CSTRING) |
| 1263 | FMT_MAKE_VALUEcxx . . $ fmt/internal/Value#StringValue#value.(const unsigned char *, ustring.value, CSTRING) |
| 1264 | FMT_MAKE_STR_VALUEcxx . . $ fmt/internal/Arg#(const std::string &, STRING) |
| 1265 | FMT_MAKE_STR_VALUEcxx . . $ fmt/internal/Value#STRING.(StringRef, STRING) |
| 1266 | FMT_MAKE_VALUE_cxx . . $ uint64_t#(CStringRef, string.value, CSTRING, value.c_str()) |
| 1267 | |
| 1268 | #define FMT_MAKE_WSTR_VALUEcxx . . $ `src/common/format.h:1268:9`!(Type, TYPE) \ |
| 1269 | MakeValue(typename WCharHelper<Type, Char>::Supported value) { \ |
| 1270 | set_string(value); \ |
| 1271 | } \ |
| 1272 | static uint64_t type(Type) { return Arg::TYPE; } |
| 1273 | |
| 1274 | FMT_MAKE_WSTR_VALUEcxx . . $ fmt/internal/MakeValue#set_string(8a1d73b94810b61).(wchar_t *, WSTRING) |
| 1275 | FMT_MAKE_WSTR_VALUEcxx . . $ `src/common/format.h:1268:9`!(const wchar_t *, WSTRING) |
| 1276 | FMT_MAKE_WSTR_VALUEcxx . . $ std/wstring#(const std::wstring &, WSTRING) |
| 1277 | FMT_MAKE_WSTR_VALUEcxx . . $ fmt/internal/Value#WSTRING.(WStringRef, WSTRING) |
| 1278 | |
| 1279 | FMT_MAKE_VALUEcxx . . $ fmt/internal/Value#POINTER.(void *, pointer, POINTER) |
| 1280 | FMT_MAKE_VALUEcxx . . $ fmt/internal/Arg#(const void *, pointer, POINTER) |
| 1281 | |
| 1282 | template <typename T> |
| 1283 | MakeValuecxx . . $ fmt/internal/MakeValue#`MakeValue<Formatter>`(e290145d91bb9f95).(const T &value, |
| 1284 | typename EnableIfcxx . . $ fmt/internal/EnableIf#<Not< |
| 1285 | ConvertToInt<T>::value>::value, int>::type = 0) { |
| 1286 | customcxx . . $ fmt/internal/Value#$anonymous_type_1#custom..valuecxx . . $ fmt/internal/Value#CustomValue#value. = &value; |
| 1287 | customcxx . . $ fmt/internal/Value#$anonymous_type_1#custom..formatcxx . . $ fmt/internal/Value#CustomValue#format. = &format_custom_argcxx . . $ fmt/internal/MakeValue#format_custom_arg(67ec5b66cac54e78).<T>; |
| 1288 | } |
| 1289 | |
| 1290 | template <typename T> |
| 1291 | MakeValuecxx . . $ fmt/internal/MakeValue#`MakeValue<Formatter>`(70ff20d506f4b8bf).(const T &value, |
| 1292 | typename EnableIfcxx . . $ fmt/internal/EnableIf#<ConvertToInt<T>::value, int>::type = 0) { |
| 1293 | int_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#int_value. = value; |
| 1294 | } |
| 1295 | |
| 1296 | template <typename T> |
| 1297 | static uint64_tcxx . . $ uint64_t# typecxx . . $ fmt/internal/MakeValue#type(5532d4cedfe8c914).(const T &) { |
| 1298 | return ConvertToIntcxx . . $ fmt/internal/ConvertToInt#<T>::value ? Argcxx . . $ fmt/internal/Arg#::INTcxx . . $ fmt/internal/Value#INT. : Argcxx . . $ fmt/internal/Arg#::CUSTOMcxx . . $ fmt/internal/Value#CUSTOM.; |
| 1299 | } |
| 1300 | |
| 1301 | // Additional template param `Char_` is needed here because make_type always |
| 1302 | // uses char. |
| 1303 | template <typename Char_> |
| 1304 | MakeValuecxx . . $ fmt/internal/MakeValue#`MakeValue<Formatter>`(74470ae2ffcb37c7).(const NamedArgcxx . . $ fmt/internal/NamedArg#<Char_> &value) { pointercxx . . $ fmt/internal/Value#$anonymous_type_1#pointer. = &value; } |
| 1305 | |
| 1306 | template <typename Char_> |
| 1307 | static uint64_tcxx . . $ uint64_t# typecxx . . $ fmt/internal/MakeValue#type(2099950419756894).(const NamedArgcxx . . $ fmt/internal/NamedArg#<Char_> &) { return Argcxx . . $ fmt/internal/Arg#::NAMED_ARGcxx . . $ fmt/internal/Value#NAMED_ARG.; } |
| 1308 | }; |
| 1309 | |
| 1310 | template <typename Formatter> |
| 1311 | class MakeArgcxx . . $ fmt/internal/MakeArg# : public Argcxx . . $ fmt/internal/Arg# { |
| 1312 | public: |
| 1313 | MakeArgcxx . . $ fmt/internal/MakeArg#`MakeArg<Formatter>`(49f6e7a06ebc5aa8).() { |
| 1314 | typecxx . . $ fmt/internal/Arg#type. = Argcxx . . $ fmt/internal/Arg#::NONEcxx . . $ fmt/internal/Value#NONE.; |
| 1315 | } |
| 1316 | |
| 1317 | template <typename T> |
| 1318 | MakeArgcxx . . $ fmt/internal/MakeArg#`MakeArg<Formatter>`(edcd8b2679e9bd1a).(const T &value) |
| 1319 | : Argcxx . . $ fmt/internal/Arg#(MakeValuecxx . . $ fmt/internal/MakeValue#<Formatter>(value)) { |
| 1320 | typecxx . . $ fmt/internal/Arg#type. = static_cast<Argcxx . . $ fmt/internal/Arg#::Typecxx . . $ fmt/internal/Value#Type#>(MakeValuecxx . . $ fmt/internal/MakeValue#<Formatter>::type(value)); |
| 1321 | } |
| 1322 | }; |
| 1323 | |
| 1324 | template <typename Char> |
| 1325 | struct NamedArgcxx . . $ fmt/internal/NamedArg# : Argcxx . . $ fmt/internal/Arg# { |
| 1326 | BasicStringRefcxx . . $ fmt/BasicStringRef#<Char> namecxx . . $ fmt/internal/NamedArg#name.; |
| 1327 | |
| 1328 | template <typename T> |
| 1329 | NamedArgcxx . . $ fmt/internal/NamedArg#`NamedArg<Char>`(88e3a25ddfad7087).(BasicStringRefcxx . . $ fmt/BasicStringRef#<Char> argname, const T &value) |
| 1330 | : Argcxx . . $ fmt/internal/Arg#(MakeArgcxx . . $ fmt/internal/MakeArg#< BasicFormattercxx . . $ fmt/BasicFormatter#<Char> >(value)), namecxx . . $ fmt/internal/NamedArg#name.(argname) {} |
| 1331 | }; |
| 1332 | |
| 1333 | class RuntimeErrorcxx . . $ fmt/internal/RuntimeError# : public stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error# { |
| 1334 | protected: |
| 1335 | RuntimeErrorcxx . . $ fmt/internal/RuntimeError#RuntimeError(49f6e7a06ebc5aa8).() : stdcxx . . $ std/::runtime_errorcxx . . $ std/runtime_error#("") {} |
| 1336 | ~cxx . . $ fmt/internal/RuntimeError#`~RuntimeError`(ced63f7c635d850d).RuntimeErrorcxx . . $ fmt/internal/RuntimeError#() throw(); |
| 1337 | }; |
| 1338 | |
| 1339 | template <typename Char> |
| 1340 | class PrintfArgFormattercxx . . $ fmt/internal/PrintfArgFormatter#; |
| 1341 | |
| 1342 | template <typename Char> |
| 1343 | class ArgMapcxx . . $ fmt/internal/ArgMap#; |
| 1344 | } // namespace internal |
| 1345 | |
| 1346 | /** An argument list. */ |
| 1347 | class ArgListcxx . . $ fmt/ArgList# { |
| 1348 | private: |
| 1349 | // To reduce compiled code size per formatting function call, types of first |
| 1350 | // MAX_PACKED_ARGS arguments are passed in the types_ field. |
| 1351 | uint64_tcxx . . $ uint64_t# types_cxx . . $ fmt/ArgList#types_.; |
| 1352 | unioncxx . . $ fmt/ArgList#$anonymous_type_12# { |
| 1353 | // If the number of arguments is less than MAX_PACKED_ARGS, the argument |
| 1354 | // values are stored in values_, otherwise they are stored in args_. |
| 1355 | // This is done to reduce compiled code size as storing larger objects |
| 1356 | // may require more code (at least on x86-64) even if the same amount of |
| 1357 | // data is actually copied to stack. It saves ~10% on the bloat test. |
| 1358 | const internalcxx . . $ fmt/internal/::Valuecxx . . $ fmt/internal/Value# *values_cxx . . $ fmt/ArgList#$anonymous_type_12#values_.; |
| 1359 | const internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg# *args_cxx . . $ fmt/ArgList#$anonymous_type_12#args_.; |
| 1360 | }; |
| 1361 | |
| 1362 | internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg#::Typecxx . . $ fmt/internal/Value#Type# typecxx . . $ fmt/ArgList#type(9e7eabfe59388a4d).(unsigned index) const { |
| 1363 | unsigned shift = index * 4; |
| 1364 | uint64_tcxx . . $ uint64_t# mask = 0xf; |
| 1365 | return static_cast<internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg#::Typecxx . . $ fmt/internal/Value#Type#>( |
| 1366 | (types_cxx . . $ fmt/ArgList#types_. & (mask << shift)) >> shift); |
| 1367 | } |
| 1368 | |
| 1369 | template <typename Char> |
| 1370 | friend class internalcxx . . $ fmt/internal/::ArgMapcxx . . $ fmt/internal/ArgMap#; |
| 1371 | |
| 1372 | public: |
| 1373 | // Maximum number of arguments with packed types. |
| 1374 | enumcxx . . $ fmt/ArgList#$anonymous_type_13# { MAX_PACKED_ARGScxx . . $ fmt/ArgList#MAX_PACKED_ARGS. = 16 }; |
| 1375 | |
| 1376 | ArgListcxx . . $ fmt/ArgList#ArgList(49f6e7a06ebc5aa8).() : types_cxx . . $ fmt/ArgList#types_.(0) {} |
| 1377 | |
| 1378 | ArgListcxx . . $ fmt/ArgList#ArgList(10d9b423be1c17f8).(ULongLongcxx . . $ fmt/ULongLong# types, const internalcxx . . $ fmt/internal/::Valuecxx . . $ fmt/internal/Value# *values) |
| 1379 | : types_cxx . . $ fmt/ArgList#types_.(types), values_cxx . . $ fmt/ArgList#$anonymous_type_12#values_.(values) {} |
| 1380 | ArgListcxx . . $ fmt/ArgList#ArgList(866dc52d73a1a3eb).(ULongLongcxx . . $ fmt/ULongLong# types, const internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg# *args) |
| 1381 | : types_cxx . . $ fmt/ArgList#types_.(types), args_cxx . . $ fmt/ArgList#$anonymous_type_12#args_.(args) {} |
| 1382 | |
| 1383 | /** Returns the argument at specified index. */ |
| 1384 | internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg# operatorcxx . . $ fmt/ArgList#`operator[]`(608608331423e214).[](unsigned index) const { |
| 1385 | using internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/ArgList#`operator[]`(608608331423e214).Arg#; |
| 1386 | Argcxx . . $ fmt/ArgList#`operator[]`(608608331423e214).Arg# arg; |
| 1387 | bool use_values = typecxx . . $ fmt/ArgList#type(9e7eabfe59388a4d).(MAX_PACKED_ARGScxx . . $ fmt/ArgList#MAX_PACKED_ARGS. - 1) == Argcxx . . $ fmt/internal/Arg#::NONEcxx . . $ fmt/internal/Value#NONE.; |
| 1388 | if (index < MAX_PACKED_ARGScxx . . $ fmt/ArgList#MAX_PACKED_ARGS.) { |
| 1389 | Argcxx . . $ fmt/internal/Arg#::Typecxx . . $ fmt/internal/Value#Type# arg_type = typecxx . . $ fmt/ArgList#type(9e7eabfe59388a4d).(index); |
| 1390 | internalcxx . . $ fmt/internal/::Valuecxx . . $ fmt/internal/Value# &val = arg; |
| 1391 | if (arg_type != Argcxx . . $ fmt/internal/Arg#::NONEcxx . . $ fmt/internal/Value#NONE.) |
| 1392 | val =cxx . . $ fmt/internal/Value#`operator=`(8849fe31169bf9ce). use_values ? values_cxx . . $ fmt/ArgList#$anonymous_type_12#values_.[index] : args_cxx . . $ fmt/ArgList#$anonymous_type_12#args_.[index]; |
| 1393 | arg.typecxx . . $ fmt/internal/Arg#type. = arg_type; |
| 1394 | return arg; |
| 1395 | } |
| 1396 | if (use_values) { |
| 1397 | // The index is greater than the number of arguments that can be stored |
| 1398 | // in values, so return a "none" argument. |
| 1399 | arg.typecxx . . $ fmt/internal/Arg#type. = Argcxx . . $ fmt/internal/Arg#::NONEcxx . . $ fmt/internal/Value#NONE.; |
| 1400 | return arg; |
| 1401 | } |
| 1402 | for (unsigned i = MAX_PACKED_ARGScxx . . $ fmt/ArgList#MAX_PACKED_ARGS.; i <= index; ++i) { |
| 1403 | if (args_cxx . . $ fmt/ArgList#$anonymous_type_12#args_.[i].typecxx . . $ fmt/internal/Arg#type. == Argcxx . . $ fmt/internal/Arg#::NONEcxx . . $ fmt/internal/Value#NONE.) |
| 1404 | return args_cxx . . $ fmt/ArgList#$anonymous_type_12#args_.[i]; |
| 1405 | } |
| 1406 | return args_cxx . . $ fmt/ArgList#$anonymous_type_12#args_.[index]; |
| 1407 | } |
| 1408 | }; |
| 1409 | |
| 1410 | #define FMT_DISPATCHcxx . . $ `src/common/format.h:1410:9`!(call) static_cast<Impl*>(this)->call |
| 1411 | |
| 1412 | /** |
| 1413 | \rst |
| 1414 | An argument visitor based on the `curiously recurring template pattern |
| 1415 | <http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern>`_. |
| 1416 | |
| 1417 | To use `~fmt::ArgVisitor` define a subclass that implements some or all of the |
| 1418 | visit methods with the same signatures as the methods in `~fmt::ArgVisitor`, |
| 1419 | for example, `~fmt::ArgVisitor::visit_int()`. |
| 1420 | Pass the subclass as the *Impl* template parameter. Then calling |
| 1421 | `~fmt::ArgVisitor::visit` for some argument will dispatch to a visit method |
| 1422 | specific to the argument type. For example, if the argument type is |
| 1423 | ``double`` then the `~fmt::ArgVisitor::visit_double()` method of a subclass |
| 1424 | will be called. If the subclass doesn't contain a method with this signature, |
| 1425 | then a corresponding method of `~fmt::ArgVisitor` will be called. |
| 1426 | |
| 1427 | **Example**:: |
| 1428 | |
| 1429 | class MyArgVisitor : public fmt::ArgVisitor<MyArgVisitor, void> { |
| 1430 | public: |
| 1431 | void visit_int(int value) { fmt::print("{}", value); } |
| 1432 | void visit_double(double value) { fmt::print("{}", value ); } |
| 1433 | }; |
| 1434 | \endrst |
| 1435 | */ |
| 1436 | template <typename Impl, typename Result> |
| 1437 | class ArgVisitorcxx . . $ fmt/ArgVisitor# { |
| 1438 | private: |
| 1439 | typedef internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg# Argcxx . . $ fmt/ArgVisitor#Arg#; |
| 1440 | |
| 1441 | public: |
| 1442 | void report_unhandled_argcxx . . $ fmt/ArgVisitor#report_unhandled_arg(49f6e7a06ebc5aa8).() {} |
| 1443 | |
| 1444 | Result visit_unhandled_argcxx . . $ fmt/ArgVisitor#visit_unhandled_arg(ec908ef952b256c2).() { |
| 1445 | FMT_DISPATCHcxx . . $ `src/common/format.h:1410:9`!(report_unhandled_arg()); |
| 1446 | return Result(); |
| 1447 | } |
| 1448 | |
| 1449 | /** Visits an ``int`` argument. **/ |
| 1450 | Result visit_intcxx . . $ fmt/ArgVisitor#visit_int(d4de6b430c28aecf).(int value) { |
| 1451 | return FMT_DISPATCHcxx . . $ `src/common/format.h:1410:9`!(visit_any_int(value)); |
| 1452 | } |
| 1453 | |
| 1454 | /** Visits a ``long long`` argument. **/ |
| 1455 | Result visit_long_longcxx . . $ fmt/ArgVisitor#visit_long_long(1fc674a91dc50306).(LongLongcxx . . $ fmt/LongLong# value) { |
| 1456 | return FMT_DISPATCHcxx . . $ `src/common/format.h:1410:9`!(visit_any_int(value)); |
| 1457 | } |
| 1458 | |
| 1459 | /** Visits an ``unsigned`` argument. **/ |
| 1460 | Result visit_uintcxx . . $ fmt/ArgVisitor#visit_uint(ce6bd6bbe47dc6e6).(unsigned value) { |
| 1461 | return FMT_DISPATCHcxx . . $ `src/common/format.h:1410:9`!(visit_any_int(value)); |
| 1462 | } |
| 1463 | |
| 1464 | /** Visits an ``unsigned long long`` argument. **/ |
| 1465 | Result visit_ulong_longcxx . . $ fmt/ArgVisitor#visit_ulong_long(9ad2da125af35102).(ULongLongcxx . . $ fmt/ULongLong# value) { |
| 1466 | return FMT_DISPATCHcxx . . $ `src/common/format.h:1410:9`!(visit_any_int(value)); |
| 1467 | } |
| 1468 | |
| 1469 | /** Visits a ``bool`` argument. **/ |
| 1470 | Result visit_boolcxx . . $ fmt/ArgVisitor#visit_bool(83abaec966c61a8b).(bool value) { |
| 1471 | return FMT_DISPATCHcxx . . $ `src/common/format.h:1410:9`!(visit_any_int(value)); |
| 1472 | } |
| 1473 | |
| 1474 | /** Visits a ``char`` or ``wchar_t`` argument. **/ |
| 1475 | Result visit_charcxx . . $ fmt/ArgVisitor#visit_char(d4de6b430c28aecf).(int value) { |
| 1476 | return FMT_DISPATCHcxx . . $ `src/common/format.h:1410:9`!(visit_any_int(value)); |
| 1477 | } |
| 1478 | |
| 1479 | /** Visits an argument of any integral type. **/ |
| 1480 | template <typename T> |
| 1481 | Result visit_any_intcxx . . $ fmt/ArgVisitor#visit_any_int(9617d6309f305ca8).(T) { |
| 1482 | return FMT_DISPATCHcxx . . $ `src/common/format.h:1410:9`!(visit_unhandled_arg()); |
| 1483 | } |
| 1484 | |
| 1485 | /** Visits a ``double`` argument. **/ |
| 1486 | Result visit_doublecxx . . $ fmt/ArgVisitor#visit_double(52b8bcce7ce4838a).(double value) { |
| 1487 | return FMT_DISPATCHcxx . . $ `src/common/format.h:1410:9`!(visit_any_double(value)); |
| 1488 | } |
| 1489 | |
| 1490 | /** Visits a ``long double`` argument. **/ |
| 1491 | Result visit_long_doublecxx . . $ fmt/ArgVisitor#visit_long_double(657208f7c72fc460).(long double value) { |
| 1492 | return FMT_DISPATCHcxx . . $ `src/common/format.h:1410:9`!(visit_any_double(value)); |
| 1493 | } |
| 1494 | |
| 1495 | /** Visits a ``double`` or ``long double`` argument. **/ |
| 1496 | template <typename T> |
| 1497 | Result visit_any_doublecxx . . $ fmt/ArgVisitor#visit_any_double(9617d6309f305ca8).(T) { |
| 1498 | return FMT_DISPATCHcxx . . $ `src/common/format.h:1410:9`!(visit_unhandled_arg()); |
| 1499 | } |
| 1500 | |
| 1501 | /** Visits a null-terminated C string (``const char *``) argument. **/ |
| 1502 | Result visit_cstringcxx . . $ fmt/ArgVisitor#visit_cstring(7c8e45e5d129f6ee).(const char *) { |
| 1503 | return FMT_DISPATCHcxx . . $ `src/common/format.h:1410:9`!(visit_unhandled_arg()); |
| 1504 | } |
| 1505 | |
| 1506 | /** Visits a string argument. **/ |
| 1507 | Result visit_stringcxx . . $ fmt/ArgVisitor#visit_string(f5c82ecf3ba8e560).(Argcxx . . $ fmt/ArgVisitor#Arg#::StringValuecxx . . $ fmt/internal/Value#StringValue#<char>) { |
| 1508 | return FMT_DISPATCHcxx . . $ `src/common/format.h:1410:9`!(visit_unhandled_arg()); |
| 1509 | } |
| 1510 | |
| 1511 | /** Visits a wide string argument. **/ |
| 1512 | Result visit_wstringcxx . . $ fmt/ArgVisitor#visit_wstring(41bd78dd0233ece6).(Argcxx . . $ fmt/ArgVisitor#Arg#::StringValuecxx . . $ fmt/internal/Value#StringValue#<wchar_t>) { |
| 1513 | return FMT_DISPATCHcxx . . $ `src/common/format.h:1410:9`!(visit_unhandled_arg()); |
| 1514 | } |
| 1515 | |
| 1516 | /** Visits a pointer argument. **/ |
| 1517 | Result visit_pointercxx . . $ fmt/ArgVisitor#visit_pointer(708ee3f40b211f53).(const void *) { |
| 1518 | return FMT_DISPATCHcxx . . $ `src/common/format.h:1410:9`!(visit_unhandled_arg()); |
| 1519 | } |
| 1520 | |
| 1521 | /** Visits an argument of a custom (user-defined) type. **/ |
| 1522 | Result visit_customcxx . . $ fmt/ArgVisitor#visit_custom(e8239fdc5f6315bb).(Argcxx . . $ fmt/ArgVisitor#Arg#::CustomValuecxx . . $ fmt/internal/Value#CustomValue#) { |
| 1523 | return FMT_DISPATCHcxx . . $ `src/common/format.h:1410:9`!(visit_unhandled_arg()); |
| 1524 | } |
| 1525 | |
| 1526 | /** |
| 1527 | \rst |
| 1528 | Visits an argument dispatching to the appropriate visit method based on |
| 1529 | the argument type. For example, if the argument type is ``double`` then |
| 1530 | the `~fmt::ArgVisitor::visit_double()` method of the *Impl* class will be |
| 1531 | called. |
| 1532 | \endrst |
| 1533 | */ |
| 1534 | Result visitcxx . . $ fmt/ArgVisitor#visit(7949385e61793c69).(const Argcxx . . $ fmt/ArgVisitor#Arg# &arg) { |
| 1535 | switch (arg.typecxx . . $ fmt/internal/Arg#type.) { |
| 1536 | case Argcxx . . $ fmt/ArgVisitor#Arg#::NONEcxx . . $ fmt/internal/Value#NONE.: |
| 1537 | case Argcxx . . $ fmt/ArgVisitor#Arg#::NAMED_ARGcxx . . $ fmt/internal/Value#NAMED_ARG.: |
| 1538 | FMT_ASSERTcxx . . $ `src/common/format.h:240:10`!(false, "invalid argument type"); |
| 1539 | break; |
| 1540 | case Argcxx . . $ fmt/ArgVisitor#Arg#::INTcxx . . $ fmt/internal/Value#INT.: |
| 1541 | return FMT_DISPATCHcxx . . $ `src/common/format.h:1410:9`!(visit_int(arg.int_value)); |
| 1542 | case Argcxx . . $ fmt/ArgVisitor#Arg#::UINTcxx . . $ fmt/internal/Value#UINT.: |
| 1543 | return FMT_DISPATCHcxx . . $ `src/common/format.h:1410:9`!(visit_uint(arg.uint_value)); |
| 1544 | case Argcxx . . $ fmt/ArgVisitor#Arg#::LONG_LONGcxx . . $ fmt/internal/Value#LONG_LONG.: |
| 1545 | return FMT_DISPATCHcxx . . $ `src/common/format.h:1410:9`!(visit_long_long(arg.long_long_value)); |
| 1546 | case Argcxx . . $ fmt/ArgVisitor#Arg#::ULONG_LONGcxx . . $ fmt/internal/Value#ULONG_LONG.: |
| 1547 | return FMT_DISPATCHcxx . . $ `src/common/format.h:1410:9`!(visit_ulong_long(arg.ulong_long_value)); |
| 1548 | case Argcxx . . $ fmt/ArgVisitor#Arg#::BOOLcxx . . $ fmt/internal/Value#BOOL.: |
| 1549 | return FMT_DISPATCHcxx . . $ fmt/internal/Value#$anonymous_type_1#int_value.(visit_bool(arg.int_value != 0)); |
| 1550 | case Argcxx . . $ fmt/ArgVisitor#Arg#::CHARcxx . . $ fmt/internal/Value#CHAR.: |
| 1551 | return FMT_DISPATCHcxx . . $ fmt/internal/Value#$anonymous_type_1#int_value.(visit_char(arg.int_value)); |
| 1552 | case Argcxx . . $ fmt/ArgVisitor#Arg#::DOUBLEcxx . . $ fmt/internal/Value#DOUBLE.: |
| 1553 | return FMT_DISPATCHcxx . . $ fmt/internal/Value#$anonymous_type_1#double_value.(visit_double(arg.double_value)); |
| 1554 | case Argcxx . . $ fmt/ArgVisitor#Arg#::LONG_DOUBLEcxx . . $ fmt/internal/Value#LONG_DOUBLE.: |
| 1555 | return FMT_DISPATCHcxx . . $ fmt/internal/Value#$anonymous_type_1#long_double_value.(visit_long_double(arg.long_double_value)); |
| 1556 | case Argcxx . . $ fmt/ArgVisitor#Arg#::CSTRINGcxx . . $ fmt/internal/Value#CSTRING.: |
| 1557 | return FMT_DISPATCHcxx . . $ fmt/internal/Value#StringValue#value.(visit_cstring(arg.string.value)); |
| 1558 | case Argcxx . . $ fmt/ArgVisitor#Arg#::STRINGcxx . . $ fmt/internal/Value#STRING.: |
| 1559 | return FMT_DISPATCHcxx . . $ `src/common/format.h:1410:9`!(visit_string(arg.string)); |
| 1560 | case Argcxx . . $ fmt/ArgVisitor#Arg#::WSTRINGcxx . . $ fmt/internal/Value#WSTRING.: |
| 1561 | return FMT_DISPATCHcxx . . $ fmt/internal/Value#$anonymous_type_1#wstring.(visit_wstring(arg.wstring)); |
| 1562 | case Argcxx . . $ fmt/ArgVisitor#Arg#::POINTERcxx . . $ fmt/internal/Value#POINTER.: |
| 1563 | return FMT_DISPATCHcxx . . $ `src/common/format.h:1410:9`!(visit_pointer(arg.pointer)); |
| 1564 | case Argcxx . . $ fmt/ArgVisitor#Arg#::CUSTOMcxx . . $ fmt/internal/Value#CUSTOM.: |
| 1565 | return FMT_DISPATCHcxx . . $ fmt/internal/Value#$anonymous_type_1#custom.(visit_custom(arg.custom)); |
| 1566 | } |
| 1567 | return Result(); |
| 1568 | } |
| 1569 | }; |
| 1570 | |
| 1571 | enum Alignmentcxx . . $ fmt/Alignment# { |
| 1572 | ALIGN_DEFAULTcxx . . $ fmt/ALIGN_DEFAULT., ALIGN_LEFTcxx . . $ fmt/ALIGN_LEFT., ALIGN_RIGHTcxx . . $ fmt/ALIGN_RIGHT., ALIGN_CENTERcxx . . $ fmt/ALIGN_CENTER., ALIGN_NUMERICcxx . . $ fmt/ALIGN_NUMERIC. |
| 1573 | }; |
| 1574 | |
| 1575 | // Flags. |
| 1576 | enumcxx . . $ fmt/$anonymous_type_27c265af509cfe5e_14# { |
| 1577 | SIGN_FLAGcxx . . $ fmt/SIGN_FLAG. = 1, PLUS_FLAGcxx . . $ fmt/PLUS_FLAG. = 2, MINUS_FLAGcxx . . $ fmt/MINUS_FLAG. = 4, HASH_FLAGcxx . . $ fmt/HASH_FLAG. = 8, |
| 1578 | CHAR_FLAGcxx . . $ fmt/CHAR_FLAG. = 0x10 // Argument has char type - used in error reporting. |
| 1579 | }; |
| 1580 | |
| 1581 | // An empty format specifier. |
| 1582 | struct EmptySpeccxx . . $ fmt/EmptySpec# {}; |
| 1583 | |
| 1584 | // A type specifier. |
| 1585 | template <char TYPE> |
| 1586 | struct TypeSpeccxx . . $ fmt/TypeSpec# : EmptySpeccxx . . $ fmt/EmptySpec# { |
| 1587 | Alignmentcxx . . $ fmt/Alignment# aligncxx . . $ fmt/TypeSpec#align(8ad7b378d7859fc1).() const { return ALIGN_DEFAULTcxx . . $ fmt/ALIGN_DEFAULT.; } |
| 1588 | unsigned widthcxx . . $ fmt/TypeSpec#width(ddd8539a2fcdd4ce).() const { return 0; } |
| 1589 | int precisioncxx . . $ fmt/TypeSpec#precision(455f465bc33b4cdf).() const { return -1; } |
| 1590 | bool flagcxx . . $ fmt/TypeSpec#flag(8de63fdb265b07c1).(unsigned) const { return false; } |
| 1591 | char typecxx . . $ fmt/TypeSpec#type(1b8b762cbef9c2c9).() const { return TYPE; } |
| 1592 | char fillcxx . . $ fmt/TypeSpec#fill(1b8b762cbef9c2c9).() const { return ' '; } |
| 1593 | }; |
| 1594 | |
| 1595 | // A width specifier. |
| 1596 | struct WidthSpeccxx . . $ fmt/WidthSpec# { |
| 1597 | unsigned width_cxx . . $ fmt/WidthSpec#width_.; |
| 1598 | // Fill is always wchar_t and cast to char if necessary to avoid having |
| 1599 | // two specialization of WidthSpec and its subclasses. |
| 1600 | wchar_t fill_cxx . . $ fmt/WidthSpec#fill_.; |
| 1601 | |
| 1602 | WidthSpeccxx . . $ fmt/WidthSpec#WidthSpec(d113cb360529b4f8).(unsigned width, wchar_t fill) : width_cxx . . $ fmt/WidthSpec#width_.(width), fill_cxx . . $ fmt/WidthSpec#fill_.(fill) {} |
| 1603 | |
| 1604 | unsigned widthcxx . . $ fmt/WidthSpec#width(ddd8539a2fcdd4ce).() const { return width_cxx . . $ fmt/WidthSpec#width_.; } |
| 1605 | wchar_t fillcxx . . $ fmt/WidthSpec#fill(301fc089a05c7cd9).() const { return fill_cxx . . $ fmt/WidthSpec#fill_.; } |
| 1606 | }; |
| 1607 | |
| 1608 | // An alignment specifier. |
| 1609 | struct AlignSpeccxx . . $ fmt/AlignSpec# : WidthSpeccxx . . $ fmt/WidthSpec# { |
| 1610 | Alignmentcxx . . $ fmt/Alignment# align_cxx . . $ fmt/AlignSpec#align_.; |
| 1611 | |
| 1612 | AlignSpeccxx . . $ fmt/AlignSpec#AlignSpec(f27b7951b0778fcc).(unsigned width, wchar_t fill, Alignmentcxx . . $ fmt/Alignment# align = ALIGN_DEFAULTcxx . . $ fmt/ALIGN_DEFAULT.) |
| 1613 | : WidthSpeccxx . . $ fmt/WidthSpec#(width, fill), align_cxx . . $ fmt/AlignSpec#align_.(align) {} |
| 1614 | |
| 1615 | Alignmentcxx . . $ fmt/Alignment# aligncxx . . $ fmt/AlignSpec#align(8ad7b378d7859fc1).() const { return align_cxx . . $ fmt/AlignSpec#align_.; } |
| 1616 | |
| 1617 | int precisioncxx . . $ fmt/AlignSpec#precision(455f465bc33b4cdf).() const { return -1; } |
| 1618 | }; |
| 1619 | |
| 1620 | // An alignment and type specifier. |
| 1621 | template <char TYPE> |
| 1622 | struct AlignTypeSpeccxx . . $ fmt/AlignTypeSpec# : AlignSpeccxx . . $ fmt/AlignSpec# { |
| 1623 | AlignTypeSpeccxx . . $ fmt/AlignTypeSpec#`AlignTypeSpec<TYPE>`(d113cb360529b4f8).(unsigned width, wchar_t fill) : AlignSpeccxx . . $ fmt/AlignSpec#(width, fill) {} |
| 1624 | |
| 1625 | bool flagcxx . . $ fmt/AlignTypeSpec#flag(8de63fdb265b07c1).(unsigned) const { return false; } |
| 1626 | char typecxx . . $ fmt/AlignTypeSpec#type(1b8b762cbef9c2c9).() const { return TYPE; } |
| 1627 | }; |
| 1628 | |
| 1629 | // A full format specifier. |
| 1630 | struct FormatSpeccxx . . $ fmt/FormatSpec# : AlignSpeccxx . . $ fmt/AlignSpec# { |
| 1631 | unsigned flags_cxx . . $ fmt/FormatSpec#flags_.; |
| 1632 | int precision_cxx . . $ fmt/FormatSpec#precision_.; |
| 1633 | char type_cxx . . $ fmt/FormatSpec#type_.; |
| 1634 | |
| 1635 | FormatSpeccxx . . $ fmt/FormatSpec#FormatSpec(38cf5fc7ed65b972).( |
| 1636 | unsigned width = 0, char type = 0, wchar_t fill = ' ') |
| 1637 | : AlignSpeccxx . . $ fmt/AlignSpec#(width, fill), flags_cxx . . $ fmt/FormatSpec#flags_.(0), precision_cxx . . $ fmt/FormatSpec#precision_.(-1), type_cxx . . $ fmt/FormatSpec#type_.(type) {} |
| 1638 | |
| 1639 | bool flagcxx . . $ fmt/FormatSpec#flag(8de63fdb265b07c1).(unsigned f) const { return (flags_cxx . . $ fmt/FormatSpec#flags_. & f) != 0; } |
| 1640 | int precisioncxx . . $ fmt/FormatSpec#precision(455f465bc33b4cdf).() const { return precision_cxx . . $ fmt/FormatSpec#precision_.; } |
| 1641 | char typecxx . . $ fmt/FormatSpec#type(1b8b762cbef9c2c9).() const { return type_cxx . . $ fmt/FormatSpec#type_.; } |
| 1642 | }; |
| 1643 | |
| 1644 | // An integer format specifier. |
| 1645 | template <typename T, typename SpecT = TypeSpeccxx . . $ fmt/TypeSpec#<0>, typename Char = char> |
| 1646 | class IntFormatSpeccxx . . $ fmt/IntFormatSpec# : public SpecT { |
| 1647 | private: |
| 1648 | T value_cxx . . $ fmt/IntFormatSpec#value_.; |
| 1649 | |
| 1650 | public: |
| 1651 | IntFormatSpeccxx . . $ fmt/IntFormatSpec#`IntFormatSpec<T, SpecT, Char>`(90f57c4de08f710d).(T val, const SpecT &spec = SpecT()) |
| 1652 | : SpecT(spec), value_cxx . . $ fmt/IntFormatSpec#value_.(val) {} |
| 1653 | |
| 1654 | T valuecxx . . $ fmt/IntFormatSpec#value(8f5363d873dd4781).() const { return value_cxx . . $ fmt/IntFormatSpec#value_.; } |
| 1655 | }; |
| 1656 | |
| 1657 | // A string format specifier. |
| 1658 | template <typename Char> |
| 1659 | class StrFormatSpeccxx . . $ fmt/StrFormatSpec# : public AlignSpeccxx . . $ fmt/AlignSpec# { |
| 1660 | private: |
| 1661 | const Char *str_cxx . . $ fmt/StrFormatSpec#str_.; |
| 1662 | |
| 1663 | public: |
| 1664 | template <typename FillChar> |
| 1665 | StrFormatSpeccxx . . $ fmt/StrFormatSpec#`StrFormatSpec<Char>`(2497481f4182986d).(const Char *str, unsigned width, FillChar fill) |
| 1666 | : AlignSpeccxx . . $ fmt/AlignSpec#(width, fill), str_cxx . . $ fmt/StrFormatSpec#str_.(str) { |
| 1667 | internalcxx . . $ fmt/internal/::CharTraitscxx . . $ fmt/internal/CharTraits#<Char>::convert(FillChar()); |
| 1668 | } |
| 1669 | |
| 1670 | const Char *strcxx . . $ fmt/StrFormatSpec#str(1016ee5406d91ab9).() const { return str_cxx . . $ fmt/StrFormatSpec#str_.; } |
| 1671 | }; |
| 1672 | |
| 1673 | /** |
| 1674 | Returns an integer format specifier to format the value in base 2. |
| 1675 | */ |
| 1676 | IntFormatSpeccxx . . $ fmt/IntFormatSpec#<int, TypeSpeccxx . . $ fmt/TypeSpec#<'b'> > bincxx . . $ fmt/bin(9ba8933c05e374d9).(int value); |
| 1677 | |
| 1678 | /** |
| 1679 | Returns an integer format specifier to format the value in base 8. |
| 1680 | */ |
| 1681 | IntFormatSpeccxx . . $ fmt/IntFormatSpec#<int, TypeSpeccxx . . $ fmt/TypeSpec#<'o'> > octcxx . . $ fmt/oct(d36b0e8b0d61e2e0).(int value); |
| 1682 | |
| 1683 | /** |
| 1684 | Returns an integer format specifier to format the value in base 16 using |
| 1685 | lower-case letters for the digits above 9. |
| 1686 | */ |
| 1687 | IntFormatSpeccxx . . $ fmt/IntFormatSpec#<int, TypeSpeccxx . . $ fmt/TypeSpec#<'x'> > hexcxx . . $ fmt/hex(24ab54b95f5db178).(int value); |
| 1688 | |
| 1689 | /** |
| 1690 | Returns an integer formatter format specifier to format in base 16 using |
| 1691 | upper-case letters for the digits above 9. |
| 1692 | */ |
| 1693 | IntFormatSpeccxx . . $ fmt/IntFormatSpec#<int, TypeSpeccxx . . $ fmt/TypeSpec#<'X'> > hexucxx . . $ fmt/hexu(ca80bbe595657aef).(int value); |
| 1694 | |
| 1695 | /** |
| 1696 | \rst |
| 1697 | Returns an integer format specifier to pad the formatted argument with the |
| 1698 | fill character to the specified width using the default (right) numeric |
| 1699 | alignment. |
| 1700 | |
| 1701 | **Example**:: |
| 1702 | |
| 1703 | MemoryWriter out; |
| 1704 | out << pad(hex(0xcafe), 8, '0'); |
| 1705 | // out.str() == "0000cafe" |
| 1706 | |
| 1707 | \endrst |
| 1708 | */ |
| 1709 | template <char TYPE_CODE, typename Char> |
| 1710 | IntFormatSpeccxx . . $ fmt/IntFormatSpec#<int, AlignTypeSpeccxx . . $ fmt/AlignTypeSpec#<TYPE_CODE>, Char> padcxx . . $ fmt/pad(646cd1a3ad35bb90).( |
| 1711 | int value, unsigned width, Char fill = ' '); |
| 1712 | |
| 1713 | #define FMT_DEFINE_INT_FORMATTERScxx . . $ `src/common/format.h:1713:9`!(TYPE) \ |
| 1714 | inline IntFormatSpec<TYPE, TypeSpec<'b'> > bin(TYPE value) { \ |
| 1715 | return IntFormatSpec<TYPE, TypeSpec<'b'> >(value, TypeSpec<'b'>()); \ |
| 1716 | } \ |
| 1717 | \ |
| 1718 | inline IntFormatSpec<TYPE, TypeSpec<'o'> > oct(TYPE value) { \ |
| 1719 | return IntFormatSpec<TYPE, TypeSpec<'o'> >(value, TypeSpec<'o'>()); \ |
| 1720 | } \ |
| 1721 | \ |
| 1722 | inline IntFormatSpec<TYPE, TypeSpec<'x'> > hex(TYPE value) { \ |
| 1723 | return IntFormatSpec<TYPE, TypeSpec<'x'> >(value, TypeSpec<'x'>()); \ |
| 1724 | } \ |
| 1725 | \ |
| 1726 | inline IntFormatSpec<TYPE, TypeSpec<'X'> > hexu(TYPE value) { \ |
| 1727 | return IntFormatSpec<TYPE, TypeSpec<'X'> >(value, TypeSpec<'X'>()); \ |
| 1728 | } \ |
| 1729 | \ |
| 1730 | template <char TYPE_CODE> \ |
| 1731 | inline IntFormatSpec<TYPE, AlignTypeSpec<TYPE_CODE> > pad( \ |
| 1732 | IntFormatSpec<TYPE, TypeSpec<TYPE_CODE> > f, unsigned width) { \ |
| 1733 | return IntFormatSpec<TYPE, AlignTypeSpec<TYPE_CODE> >( \ |
| 1734 | f.value(), AlignTypeSpec<TYPE_CODE>(width, ' ')); \ |
| 1735 | } \ |
| 1736 | \ |
| 1737 | /* For compatibility with older compilers we provide two overloads for pad, */ \ |
| 1738 | /* one that takes a fill character and one that doesn't. In the future this */ \ |
| 1739 | /* can be replaced with one overload making the template argument Char */ \ |
| 1740 | /* default to char (C++11). */ \ |
| 1741 | template <char TYPE_CODE, typename Char> \ |
| 1742 | inline IntFormatSpec<TYPE, AlignTypeSpec<TYPE_CODE>, Char> pad( \ |
| 1743 | IntFormatSpec<TYPE, TypeSpec<TYPE_CODE>, Char> f, \ |
| 1744 | unsigned width, Char fill) { \ |
| 1745 | return IntFormatSpec<TYPE, AlignTypeSpec<TYPE_CODE>, Char>( \ |
| 1746 | f.value(), AlignTypeSpec<TYPE_CODE>(width, fill)); \ |
| 1747 | } \ |
| 1748 | \ |
| 1749 | inline IntFormatSpec<TYPE, AlignTypeSpec<0> > pad( \ |
| 1750 | TYPE value, unsigned width) { \ |
| 1751 | return IntFormatSpec<TYPE, AlignTypeSpec<0> >( \ |
| 1752 | value, AlignTypeSpec<0>(width, ' ')); \ |
| 1753 | } \ |
| 1754 | \ |
| 1755 | template <typename Char> \ |
| 1756 | inline IntFormatSpec<TYPE, AlignTypeSpec<0>, Char> pad( \ |
| 1757 | TYPE value, unsigned width, Char fill) { \ |
| 1758 | return IntFormatSpec<TYPE, AlignTypeSpec<0>, Char>( \ |
| 1759 | value, AlignTypeSpec<0>(width, fill)); \ |
| 1760 | } |
| 1761 | |
| 1762 | FMT_DEFINE_INT_FORMATTERScxx . . $ `src/common/format.h:1713:9`!(int) |
| 1763 | FMT_DEFINE_INT_FORMATTERScxx . . $ fmt/AlignTypeSpec#(long) |
| 1764 | FMT_DEFINE_INT_FORMATTERScxx . . $ `src/common/format.h:1713:9`!(unsigned) |
| 1765 | FMT_DEFINE_INT_FORMATTERScxx . . $ fmt/IntFormatSpec#IntFormatSpec(90f57c4de08f710d).(unsigned long) |
| 1766 | FMT_DEFINE_INT_FORMATTERScxx . . $ `src/common/format.h:1713:9`!(LongLong) |
| 1767 | FMT_DEFINE_INT_FORMATTERScxx . . $ `src/common/format.h:1713:9`!(ULongLong) |
| 1768 | |
| 1769 | /** |
| 1770 | \rst |
| 1771 | Returns a string formatter that pads the formatted argument with the fill |
| 1772 | character to the specified width using the default (left) string alignment. |
| 1773 | |
| 1774 | **Example**:: |
| 1775 | |
| 1776 | std::string s = str(MemoryWriter() << pad("abc", 8)); |
| 1777 | // s == "abc " |
| 1778 | |
| 1779 | \endrst |
| 1780 | */ |
| 1781 | template <typename Char> |
| 1782 | inline StrFormatSpeccxx . . $ fmt/StrFormatSpec#<Char> padcxx . . $ fmt/pad(7617af368e214156).( |
| 1783 | const Char *str, unsigned width, Char fill = ' ') { |
| 1784 | return StrFormatSpeccxx . . $ fmt/StrFormatSpec#<Char>(str, width, fill); |
| 1785 | } |
| 1786 | |
| 1787 | inline StrFormatSpeccxx . . $ fmt/StrFormatSpec#<wchar_t> padcxx . . $ fmt/pad(a348cc11c1f97844).( |
| 1788 | const wchar_t *str, unsigned width, char fill = ' ') { |
| 1789 | return StrFormatSpeccxx . . $ fmt/StrFormatSpec#<wchar_t>(str, width, fill); |
| 1790 | } |
| 1791 | |
| 1792 | namespace internalcxx . . $ fmt/internal/ { |
| 1793 | |
| 1794 | template <typename Char> |
| 1795 | class ArgMapcxx . . $ fmt/internal/ArgMap# { |
| 1796 | private: |
| 1797 | typedef stdcxx . . $ std/::vectorcxx . . $ std/vector#< |
| 1798 | stdcxx . . $ std/::paircxx . . $ std/pair#<fmtcxx . . $ fmt/::BasicStringRefcxx . . $ fmt/BasicStringRef#<Char>, internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg#> > MapTypecxx . . $ fmt/internal/ArgMap#MapType#; |
| 1799 | typedef typename MapTypecxx . . $ fmt/internal/ArgMap#MapType#::value_type Paircxx . . $ fmt/internal/ArgMap#Pair#; |
| 1800 | |
| 1801 | MapTypecxx . . $ fmt/internal/ArgMap#MapType# map_cxx . . $ fmt/internal/ArgMap#map_.; |
| 1802 | |
| 1803 | public: |
| 1804 | FMT_APIcxx . . $ `src/common/format.h:75:10`! void initcxx . . $ fmt/internal/ArgMap#init(10fb0965a9c0bb8c).(const ArgListcxx . . $ fmt/ArgList# &args); |
| 1805 | |
| 1806 | const internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg#* findcxx . . $ fmt/internal/ArgMap#find(51ff5ba4c57f142f).(const fmtcxx . . $ fmt/::BasicStringRefcxx . . $ fmt/BasicStringRef#<Char> &name) const { |
| 1807 | // The list is unsorted, so just return the first matching name. |
| 1808 | for (typename MapTypecxx . . $ fmt/internal/ArgMap#MapType#::const_iterator it = map_cxx . . $ fmt/internal/ArgMap#map_..begincxx . . $ std/vector#begin(d1e1699016b9d7e6).(), end = map_cxx . . $ fmt/internal/ArgMap#map_..endcxx . . $ std/vector#end(d1e1699016b9d7e6).(); |
| 1809 | it != end; ++it) { |
| 1810 | if (it->first == name) |
| 1811 | return &it->second; |
| 1812 | } |
| 1813 | return 0; |
| 1814 | } |
| 1815 | }; |
| 1816 | |
| 1817 | template <typename Impl, typename Char> |
| 1818 | class ArgFormatterBasecxx . . $ fmt/internal/ArgFormatterBase# : public ArgVisitorcxx . . $ fmt/ArgVisitor#<Impl, void> { |
| 1819 | private: |
| 1820 | BasicWritercxx . . $ fmt/BasicWriter#<Char> &writer_cxx . . $ fmt/internal/ArgFormatterBase#writer_.; |
| 1821 | FormatSpeccxx . . $ fmt/FormatSpec# &spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_.; |
| 1822 | |
| 1823 | FMT_DISALLOW_COPY_AND_ASSIGNcxx . . $ fmt/internal/ArgFormatterBase#`ArgFormatterBase<Impl, Char>`(1462bef656fd40d2).(ArgFormatterBase); |
| 1824 | |
| 1825 | void write_pointercxx . . $ fmt/internal/ArgFormatterBase#write_pointer(e4289f82fef2c2f9).(const void *p) { |
| 1826 | spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_..flags_cxx . . $ fmt/FormatSpec#flags_. = HASH_FLAGcxx . . $ fmt/HASH_FLAG.; |
| 1827 | spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_..type_cxx . . $ fmt/FormatSpec#type_. = 'x'; |
| 1828 | writer_cxx . . $ fmt/internal/ArgFormatterBase#writer_..write_intcxx . . $ fmt/BasicWriter#write_int(ff2be549ebcde8b0).(reinterpret_cast<uintptr_tcxx . . $ uintptr_t#>(p), spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_.); |
| 1829 | } |
| 1830 | |
| 1831 | protected: |
| 1832 | BasicWritercxx . . $ fmt/BasicWriter#<Char> &writercxx . . $ fmt/internal/ArgFormatterBase#writer(3a564b1b84870d38).() { return writer_cxx . . $ fmt/internal/ArgFormatterBase#writer_.; } |
| 1833 | FormatSpeccxx . . $ fmt/FormatSpec# &speccxx . . $ fmt/internal/ArgFormatterBase#spec(2dfd5853dabd6fc1).() { return spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_.; } |
| 1834 | |
| 1835 | void writecxx . . $ fmt/internal/ArgFormatterBase#write(b45ddcbc8423892c).(bool value) { |
| 1836 | const char *str_value = value ? "true" : "false"; |
| 1837 | Argcxx . . $ fmt/internal/Arg#::StringValuecxx . . $ fmt/internal/Value#StringValue#<char> str = { str_value, stdcxx . . $ std/::strlen(str_value) }; |
| 1838 | writer_cxx . . $ fmt/internal/ArgFormatterBase#writer_..write_strcxx . . $ fmt/BasicWriter#write_str(eec3d3228bf04f22).(str, spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_.); |
| 1839 | } |
| 1840 | |
| 1841 | void writecxx . . $ fmt/internal/ArgFormatterBase#write(85c52e162fed56f9).(const char *value) { |
| 1842 | Argcxx . . $ fmt/internal/Arg#::StringValuecxx . . $ fmt/internal/Value#StringValue#<char> str = { value, value != 0 ? stdcxx . . $ std/::strlen(value) : 0 }; |
| 1843 | writer_cxx . . $ fmt/internal/ArgFormatterBase#writer_..write_strcxx . . $ fmt/BasicWriter#write_str(eec3d3228bf04f22).(str, spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_.); |
| 1844 | } |
| 1845 | |
| 1846 | public: |
| 1847 | ArgFormatterBasecxx . . $ fmt/internal/ArgFormatterBase#`ArgFormatterBase<Impl, Char>`(8004bd1eff0ac4af).(BasicWritercxx . . $ fmt/BasicWriter#<Char> &w, FormatSpeccxx . . $ fmt/FormatSpec# &s) |
| 1848 | : writer_cxx . . $ fmt/internal/ArgFormatterBase#writer_.(w), spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_.(s) {} |
| 1849 | |
| 1850 | template <typename T> |
| 1851 | void visit_any_intcxx . . $ fmt/internal/ArgFormatterBase#visit_any_int(b07662a27bd562f9).(T value) { writer_cxx . . $ fmt/internal/ArgFormatterBase#writer_..write_intcxx . . $ fmt/BasicWriter#write_int(ff2be549ebcde8b0).(value, spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_.); } |
| 1852 | |
| 1853 | template <typename T> |
| 1854 | void visit_any_doublecxx . . $ fmt/internal/ArgFormatterBase#visit_any_double(b07662a27bd562f9).(T value) { writer_cxx . . $ fmt/internal/ArgFormatterBase#writer_..write_doublecxx . . $ fmt/BasicWriter#write_double(7f39721b6698cf0).(value, spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_.); } |
| 1855 | |
| 1856 | void visit_boolcxx . . $ fmt/internal/ArgFormatterBase#visit_bool(b45ddcbc8423892c).(bool value) { |
| 1857 | if (spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_..type_cxx . . $ fmt/FormatSpec#type_.) |
| 1858 | return visit_any_intcxx . . $ fmt/internal/ArgFormatterBase#visit_any_int(b07662a27bd562f9).(value); |
| 1859 | writecxx . . $ fmt/internal/ArgFormatterBase#write(85c52e162fed56f9).(value); |
| 1860 | } |
| 1861 | |
| 1862 | void visit_charcxx . . $ fmt/internal/ArgFormatterBase#visit_char(d4f767463ce0a6b3).(int value) { |
| 1863 | if (spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_..type_cxx . . $ fmt/FormatSpec#type_. && spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_..type_cxx . . $ fmt/FormatSpec#type_. != 'c') { |
| 1864 | spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_..flags_cxx . . $ fmt/FormatSpec#flags_. |= CHAR_FLAGcxx . . $ fmt/CHAR_FLAG.; |
| 1865 | writer_cxx . . $ fmt/internal/ArgFormatterBase#writer_..write_intcxx . . $ fmt/BasicWriter#write_int(ff2be549ebcde8b0).(value, spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_.); |
| 1866 | return; |
| 1867 | } |
| 1868 | if (spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_..align_cxx . . $ fmt/AlignSpec#align_. == ALIGN_NUMERICcxx . . $ fmt/ALIGN_NUMERIC. || spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_..flags_cxx . . $ fmt/FormatSpec#flags_. != 0) |
| 1869 | FMT_THROWcxx . . $ fmt/BasicCStringRef#BasicCStringRef(88376428bb603c08).(FormatError("invalid format specifier for char")); |
| 1870 | typedef typename BasicWritercxx . . $ fmt/BasicWriter#<Char>::CharPtr CharPtrcxx . . $ fmt/internal/ArgFormatterBase#visit_char(d4f767463ce0a6b3).CharPtr#; |
| 1871 | Char fill = internalcxx . . $ fmt/internal/::CharTraitscxx . . $ fmt/internal/CharTraits#<Char>::cast(spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_..fillcxx . . $ fmt/WidthSpec#fill(301fc089a05c7cd9).()); |
| 1872 | CharPtrcxx . . $ fmt/internal/ArgFormatterBase#visit_char(d4f767463ce0a6b3).CharPtr# out = CharPtrcxx . . $ fmt/internal/ArgFormatterBase#visit_char(d4f767463ce0a6b3).CharPtr#(); |
| 1873 | const unsigned CHAR_SIZE = 1; |
| 1874 | if (spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_..width_cxx . . $ fmt/WidthSpec#width_. > CHAR_SIZE) { |
| 1875 | out = writer_cxx . . $ fmt/internal/ArgFormatterBase#writer_..grow_buffercxx . . $ fmt/BasicWriter#grow_buffer(6801df611ac9c5f5).(spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_..width_cxx . . $ fmt/WidthSpec#width_.); |
| 1876 | if (spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_..align_cxx . . $ fmt/AlignSpec#align_. == ALIGN_RIGHTcxx . . $ fmt/ALIGN_RIGHT.) { |
| 1877 | stdcxx . . $ std/::uninitialized_fill_ncxx . . $ std/uninitialized_fill_n(209bfa086e869d1c).(out, spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_..width_cxx . . $ fmt/WidthSpec#width_. - CHAR_SIZE, fill); |
| 1878 | out += spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_..width_cxx . . $ fmt/WidthSpec#width_. - CHAR_SIZE; |
| 1879 | } |
| 1880 | else if (spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_..align_cxx . . $ fmt/AlignSpec#align_. == ALIGN_CENTERcxx . . $ fmt/ALIGN_CENTER.) { |
| 1881 | out = writer_cxx . . $ fmt/internal/ArgFormatterBase#writer_..fill_paddingcxx . . $ fmt/BasicWriter#fill_padding(2dd35c4d4c1556d3).(out, spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_..width_cxx . . $ fmt/WidthSpec#width_., |
| 1882 | internalcxx . . $ fmt/internal/::const_checkcxx . . $ fmt/internal/const_check(ada6a8422704cf8a).(CHAR_SIZE), fill); |
| 1883 | } |
| 1884 | else { |
| 1885 | stdcxx . . $ std/::uninitialized_fill_ncxx . . $ std/uninitialized_fill_n(b9ce89abc1b751f2).(out + CHAR_SIZE, |
| 1886 | spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_..width_cxx . . $ fmt/WidthSpec#width_. - CHAR_SIZE, fill); |
| 1887 | } |
| 1888 | } |
| 1889 | else { |
| 1890 | out = writer_cxx . . $ fmt/internal/ArgFormatterBase#writer_..grow_buffercxx . . $ fmt/BasicWriter#grow_buffer(6801df611ac9c5f5).(CHAR_SIZE); |
| 1891 | } |
| 1892 | *out = internalcxx . . $ fmt/internal/::CharTraitscxx . . $ fmt/internal/CharTraits#<Char>::cast(value); |
| 1893 | } |
| 1894 | |
| 1895 | void visit_cstringcxx . . $ fmt/internal/ArgFormatterBase#visit_cstring(85c52e162fed56f9).(const char *value) { |
| 1896 | if (spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_..type_cxx . . $ fmt/FormatSpec#type_. == 'p') |
| 1897 | return write_pointercxx . . $ fmt/internal/ArgFormatterBase#write_pointer(e4289f82fef2c2f9).(value); |
| 1898 | writecxx . . $ fmt/internal/ArgFormatterBase#write(85c52e162fed56f9).(value); |
| 1899 | } |
| 1900 | |
| 1901 | void visit_stringcxx . . $ fmt/internal/ArgFormatterBase#visit_string(c31ebf3a0205c7f0).(Argcxx . . $ fmt/internal/Arg#::StringValuecxx . . $ fmt/internal/Value#StringValue#<char> value) { |
| 1902 | writer_cxx . . $ fmt/internal/ArgFormatterBase#writer_..write_strcxx . . $ fmt/BasicWriter#write_str(eec3d3228bf04f22).(value, spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_.); |
| 1903 | } |
| 1904 | |
| 1905 | using ArgVisitorcxx . . $ fmt/ArgVisitor#<Impl, void>::visit_wstring; |
| 1906 | |
| 1907 | void visit_wstringcxx . . $ fmt/internal/ArgFormatterBase#visit_wstring(1100e6080eed11db).(Argcxx . . $ fmt/internal/Arg#::StringValuecxx . . $ fmt/internal/Value#StringValue#<Char> value) { |
| 1908 | writer_cxx . . $ fmt/internal/ArgFormatterBase#writer_..write_strcxx . . $ fmt/BasicWriter#write_str(eec3d3228bf04f22).(value, spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_.); |
| 1909 | } |
| 1910 | |
| 1911 | void visit_pointercxx . . $ fmt/internal/ArgFormatterBase#visit_pointer(e4289f82fef2c2f9).(const void *value) { |
| 1912 | if (spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_..type_cxx . . $ fmt/FormatSpec#type_. && spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_..type_cxx . . $ fmt/FormatSpec#type_. != 'p') |
| 1913 | report_unknown_typecxx . . $ fmt/internal/report_unknown_type(6d02e1a5f7bf8914).(spec_cxx . . $ fmt/internal/ArgFormatterBase#spec_..type_cxx . . $ fmt/FormatSpec#type_., "pointer"); |
| 1914 | write_pointercxx . . $ fmt/internal/ArgFormatterBase#write_pointer(e4289f82fef2c2f9).(value); |
| 1915 | } |
| 1916 | }; |
| 1917 | |
| 1918 | class FormatterBasecxx . . $ fmt/internal/FormatterBase# { |
| 1919 | private: |
| 1920 | ArgListcxx . . $ fmt/ArgList# args_cxx . . $ fmt/internal/FormatterBase#args_.; |
| 1921 | int next_arg_index_cxx . . $ fmt/internal/FormatterBase#next_arg_index_.; |
| 1922 | |
| 1923 | // Returns the argument with specified index. |
| 1924 | FMT_APIcxx . . $ `src/common/format.h:75:10`! Argcxx . . $ fmt/internal/Arg# do_get_argcxx . . $ fmt/internal/FormatterBase#do_get_arg(e6750e432c057443).(unsigned arg_index, const char *&error); |
| 1925 | |
| 1926 | protected: |
| 1927 | const ArgListcxx . . $ fmt/ArgList# &argscxx . . $ fmt/internal/FormatterBase#args(ab5cc86d4ab31ef3).() const { return args_cxx . . $ fmt/internal/FormatterBase#args_.; } |
| 1928 | |
| 1929 | explicit FormatterBasecxx . . $ fmt/internal/FormatterBase#FormatterBase(10fb0965a9c0bb8c).(const ArgListcxx . . $ fmt/ArgList# &args) { |
| 1930 | args_cxx . . $ fmt/internal/FormatterBase#args_. =cxx . . $ fmt/ArgList#`operator=`(f58decf1ea51598b). args; |
| 1931 | next_arg_index_cxx . . $ fmt/internal/FormatterBase#next_arg_index_. = 0; |
| 1932 | } |
| 1933 | |
| 1934 | // Returns the next argument. |
| 1935 | Argcxx . . $ fmt/internal/Arg# next_argcxx . . $ fmt/internal/FormatterBase#next_arg(706a258656295a38).(const char *&error) { |
| 1936 | if (next_arg_index_cxx . . $ fmt/internal/FormatterBase#next_arg_index_. >= 0) |
| 1937 | return do_get_argcxx . . $ fmt/internal/FormatterBase#do_get_arg(e6750e432c057443).(internalcxx . . $ fmt/internal/::to_unsignedcxx . . $ fmt/internal/to_unsigned(4de866539cf5f5fc).(next_arg_index_cxx . . $ fmt/internal/FormatterBase#next_arg_index_.++), error); |
| 1938 | error = "cannot switch from manual to automatic argument indexing"; |
| 1939 | return Argcxx . . $ fmt/internal/Arg#(); |
| 1940 | } |
| 1941 | |
| 1942 | // Checks if manual indexing is used and returns the argument with |
| 1943 | // specified index. |
| 1944 | Argcxx . . $ fmt/internal/Arg# get_argcxx . . $ fmt/internal/FormatterBase#get_arg(e6750e432c057443).(unsigned arg_index, const char *&error) { |
| 1945 | return check_no_auto_indexcxx . . $ fmt/internal/FormatterBase#check_no_auto_index(339e8548b0624983).(error) ? do_get_argcxx . . $ fmt/internal/FormatterBase#do_get_arg(e6750e432c057443).(arg_index, error) : Argcxx . . $ fmt/internal/Arg#(); |
| 1946 | } |
| 1947 | |
| 1948 | bool check_no_auto_indexcxx . . $ fmt/internal/FormatterBase#check_no_auto_index(339e8548b0624983).(const char *&error) { |
| 1949 | if (next_arg_index_cxx . . $ fmt/internal/FormatterBase#next_arg_index_. > 0) { |
| 1950 | error = "cannot switch from automatic to manual argument indexing"; |
| 1951 | return false; |
| 1952 | } |
| 1953 | next_arg_index_cxx . . $ fmt/internal/FormatterBase#next_arg_index_. = -1; |
| 1954 | return true; |
| 1955 | } |
| 1956 | |
| 1957 | template <typename Char> |
| 1958 | void writecxx . . $ fmt/internal/FormatterBase#write(b7548184d003157b).(BasicWritercxx . . $ fmt/BasicWriter#<Char> &w, const Char *start, const Char *end) { |
| 1959 | if (start != end) |
| 1960 | w << BasicStringRefcxx . . $ fmt/BasicStringRef#<Char>(start, internalcxx . . $ fmt/internal/::to_unsignedcxx . . $ fmt/internal/to_unsigned(4de866539cf5f5fc).(end - start)); |
| 1961 | } |
| 1962 | }; |
| 1963 | |
| 1964 | // A printf formatter. |
| 1965 | template <typename Char> |
| 1966 | class PrintfFormattercxx . . $ fmt/internal/PrintfFormatter# : private FormatterBasecxx . . $ fmt/internal/FormatterBase# { |
| 1967 | private: |
| 1968 | void parse_flagscxx . . $ fmt/internal/PrintfFormatter#parse_flags(34fdf22eefd20db8).(FormatSpeccxx . . $ fmt/FormatSpec# &spec, const Char *&s); |
| 1969 | |
| 1970 | // Returns the argument with specified index or, if arg_index is equal |
| 1971 | // to the maximum unsigned value, the next argument. |
| 1972 | Argcxx . . $ fmt/internal/Arg# get_argcxx . . $ fmt/internal/PrintfFormatter#get_arg(6639e3f2d4ffaf54).(const Char *s, |
| 1973 | unsigned arg_index = (stdcxx . . $ std/::numeric_limitscxx . . $ std/numeric_limits#<unsigned>::maxcxx . . $ std/numeric_limits#max(2658d6455debfaef).)()); |
| 1974 | |
| 1975 | // Parses argument index, flags and width and returns the argument index. |
| 1976 | unsigned parse_headercxx . . $ fmt/internal/PrintfFormatter#parse_header(48902020be8b8fd8).(const Char *&s, FormatSpeccxx . . $ fmt/FormatSpec# &spec); |
| 1977 | |
| 1978 | public: |
| 1979 | explicit PrintfFormattercxx . . $ fmt/internal/PrintfFormatter#`PrintfFormatter<Char>`(10fb0965a9c0bb8c).(const ArgListcxx . . $ fmt/ArgList# &args) : FormatterBasecxx . . $ fmt/internal/FormatterBase#(args) {} |
| 1980 | FMT_APIcxx . . $ `src/common/format.h:75:10`! void formatcxx . . $ fmt/internal/PrintfFormatter#format(aaacc8ac315733de).(BasicWritercxx . . $ fmt/BasicWriter#<Char> &writer, |
| 1981 | BasicCStringRefcxx . . $ fmt/BasicCStringRef#<Char> format_str); |
| 1982 | }; |
| 1983 | } // namespace internal |
| 1984 | |
| 1985 | /** |
| 1986 | \rst |
| 1987 | An argument formatter based on the `curiously recurring template pattern |
| 1988 | <http://en.wikipedia.org/wiki/Curiously_recurring_template_pattern>`_. |
| 1989 | |
| 1990 | To use `~fmt::BasicArgFormatter` define a subclass that implements some or |
| 1991 | all of the visit methods with the same signatures as the methods in |
| 1992 | `~fmt::ArgVisitor`, for example, `~fmt::ArgVisitor::visit_int()`. |
| 1993 | Pass the subclass as the *Impl* template parameter. When a formatting |
| 1994 | function processes an argument, it will dispatch to a visit method |
| 1995 | specific to the argument type. For example, if the argument type is |
| 1996 | ``double`` then the `~fmt::ArgVisitor::visit_double()` method of a subclass |
| 1997 | will be called. If the subclass doesn't contain a method with this signature, |
| 1998 | then a corresponding method of `~fmt::BasicArgFormatter` or its superclass |
| 1999 | will be called. |
| 2000 | \endrst |
| 2001 | */ |
| 2002 | template <typename Impl, typename Char> |
| 2003 | class BasicArgFormattercxx . . $ fmt/BasicArgFormatter# : public internalcxx . . $ fmt/internal/::ArgFormatterBasecxx . . $ fmt/internal/ArgFormatterBase#<Impl, Char> { |
| 2004 | private: |
| 2005 | BasicFormattercxx . . $ fmt/BasicFormatter#<Char, Impl> &formatter_cxx . . $ fmt/BasicArgFormatter#formatter_.; |
| 2006 | const Char *format_cxx . . $ fmt/BasicArgFormatter#format_.; |
| 2007 | |
| 2008 | public: |
| 2009 | /** |
| 2010 | \rst |
| 2011 | Constructs an argument formatter object. |
| 2012 | *formatter* is a reference to the main formatter object, *spec* contains |
| 2013 | format specifier information for standard argument types, and *fmt* points |
| 2014 | to the part of the format string being parsed for custom argument types. |
| 2015 | \endrst |
| 2016 | */ |
| 2017 | BasicArgFormattercxx . . $ fmt/BasicArgFormatter#`BasicArgFormatter<Impl, Char>`(a26e2c042c0908c3).(BasicFormattercxx . . $ fmt/BasicFormatter#<Char, Impl> &formatter, |
| 2018 | FormatSpeccxx . . $ fmt/FormatSpec# &spec, const Char *fmt) |
| 2019 | : internalcxx . . $ fmt/internal/::ArgFormatterBasecxx . . $ fmt/internal/ArgFormatterBase#<Impl, Char>(formatter.writercxx . . $ fmt/BasicFormatter#writer(92ccefc909fe507a).(), spec), |
| 2020 | formatter_cxx . . $ fmt/BasicArgFormatter#formatter_.(formatter), format_cxx . . $ fmt/BasicArgFormatter#format_.(fmt) {} |
| 2021 | |
| 2022 | /** Formats argument of a custom (user-defined) type. */ |
| 2023 | void visit_customcxx . . $ fmt/BasicArgFormatter#visit_custom(796649238ada7a37).(internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg#::CustomValuecxx . . $ fmt/internal/Value#CustomValue# c) { |
| 2024 | c.formatcxx . . $ fmt/internal/Value#CustomValue#format.(&formatter_cxx . . $ fmt/BasicArgFormatter#formatter_., c.valuecxx . . $ fmt/internal/Value#CustomValue#value., &format_cxx . . $ fmt/BasicArgFormatter#format_.); |
| 2025 | } |
| 2026 | }; |
| 2027 | |
| 2028 | /** The default argument formatter. */ |
| 2029 | template <typename Char> |
| 2030 | class ArgFormattercxx . . $ fmt/ArgFormatter# : public BasicArgFormattercxx . . $ fmt/BasicArgFormatter#<ArgFormattercxx . . $ fmt/ArgFormatter#<Char>, Char> { |
| 2031 | public: |
| 2032 | /** Constructs an argument formatter object. */ |
| 2033 | ArgFormattercxx . . $ fmt/ArgFormatter#`ArgFormatter<Char>`(7b8353c4e390b567).(BasicFormattercxx . . $ fmt/BasicFormatter#<Char> &formatter, |
| 2034 | FormatSpeccxx . . $ fmt/FormatSpec# &spec, const Char *fmt) |
| 2035 | : BasicArgFormattercxx . . $ fmt/BasicArgFormatter#<ArgFormattercxx . . $ fmt/ArgFormatter#<Char>, Char>(formatter, spec, fmt) {} |
| 2036 | }; |
| 2037 | |
| 2038 | /** This template formats data and writes the output to a writer. */ |
| 2039 | template <typename CharType, typename ArgFormatter> |
| 2040 | class BasicFormattercxx . . $ fmt/BasicFormatter# : private internalcxx . . $ fmt/internal/::FormatterBasecxx . . $ fmt/internal/FormatterBase# { |
| 2041 | public: |
| 2042 | /** The character type for the output. */ |
| 2043 | typedef CharType Charcxx . . $ fmt/BasicFormatter#Char#; |
| 2044 | |
| 2045 | private: |
| 2046 | BasicWritercxx . . $ fmt/BasicWriter#<Charcxx . . $ fmt/BasicFormatter#Char#> &writer_cxx . . $ fmt/BasicFormatter#writer_.; |
| 2047 | internalcxx . . $ fmt/internal/::ArgMapcxx . . $ fmt/internal/ArgMap#<Charcxx . . $ fmt/BasicFormatter#Char#> map_cxx . . $ fmt/BasicFormatter#map_.; |
| 2048 | |
| 2049 | FMT_DISALLOW_COPY_AND_ASSIGNcxx . . $ fmt/BasicFormatter#`operator=`(e2f1d0d9ed647f3d).(BasicFormatter); |
| 2050 | |
| 2051 | using internalcxx . . $ fmt/internal/::FormatterBasecxx . . $ fmt/internal/FormatterBase#::get_argcxx . . $ fmt/BasicFormatter#get_arg(e6750e432c057443).; |
| 2052 | |
| 2053 | // Checks if manual indexing is used and returns the argument with |
| 2054 | // specified name. |
| 2055 | internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg# get_argcxx . . $ fmt/BasicFormatter#get_arg(3cf793eda88c402a).(BasicStringRefcxx . . $ fmt/BasicStringRef#<Charcxx . . $ fmt/BasicFormatter#Char#> arg_name, const char *&error); |
| 2056 | |
| 2057 | // Parses argument index and returns corresponding argument. |
| 2058 | internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg# parse_arg_indexcxx . . $ fmt/BasicFormatter#parse_arg_index(4ce1381982b64b8).(const Charcxx . . $ fmt/BasicFormatter#Char# *&s); |
| 2059 | |
| 2060 | // Parses argument name and returns corresponding argument. |
| 2061 | internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg# parse_arg_namecxx . . $ fmt/BasicFormatter#parse_arg_name(4ce1381982b64b8).(const Charcxx . . $ fmt/BasicFormatter#Char# *&s); |
| 2062 | |
| 2063 | public: |
| 2064 | /** |
| 2065 | \rst |
| 2066 | Constructs a ``BasicFormatter`` object. References to the arguments and |
| 2067 | the writer are stored in the formatter object so make sure they have |
| 2068 | appropriate lifetimes. |
| 2069 | \endrst |
| 2070 | */ |
| 2071 | BasicFormattercxx . . $ fmt/BasicFormatter#`BasicFormatter<CharType, ArgFormatter>`(a83179202608882b).(const ArgListcxx . . $ fmt/ArgList# &args, BasicWritercxx . . $ fmt/BasicWriter#<Charcxx . . $ fmt/BasicFormatter#Char#> &w) |
| 2072 | : internalcxx . . $ fmt/internal/::FormatterBasecxx . . $ fmt/internal/FormatterBase#(args), writer_cxx . . $ fmt/BasicFormatter#writer_.(w) {} |
| 2073 | |
| 2074 | /** Returns a reference to the writer associated with this formatter. */ |
| 2075 | BasicWritercxx . . $ fmt/BasicWriter#<Charcxx . . $ fmt/BasicFormatter#Char#> &writercxx . . $ fmt/BasicFormatter#writer(92ccefc909fe507a).() { return writer_cxx . . $ fmt/BasicFormatter#writer_.; } |
| 2076 | |
| 2077 | /** Formats stored arguments and writes the output to the writer. */ |
| 2078 | void formatcxx . . $ fmt/BasicFormatter#format(66d672f47157ac79).(BasicCStringRefcxx . . $ fmt/BasicCStringRef#<Charcxx . . $ fmt/BasicFormatter#Char#> format_str); |
| 2079 | |
| 2080 | // Formats a single argument and advances format_str, a format string pointer. |
| 2081 | const Charcxx . . $ fmt/BasicFormatter#Char# *formatcxx . . $ fmt/BasicFormatter#format(3077b68864ed6c04).(const Charcxx . . $ fmt/BasicFormatter#Char# *&format_str, const internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg# &arg); |
| 2082 | }; |
| 2083 | |
| 2084 | // Generates a comma-separated list with results of applying f to |
| 2085 | // numbers 0..n-1. |
| 2086 | # define FMT_GENcxx . . $ `src/common/format.h:2086:10`!(n, f) FMT_GEN##n(f) |
| 2087 | # define FMT_GEN1cxx . . $ `src/common/format.h:2087:10`!(f) f(0) |
| 2088 | # define FMT_GEN2cxx . . $ `src/common/format.h:2088:10`!(f) FMT_GEN1(f), f(1) |
| 2089 | # define FMT_GEN3cxx . . $ `src/common/format.h:2089:10`!(f) FMT_GEN2(f), f(2) |
| 2090 | # define FMT_GEN4cxx . . $ `src/common/format.h:2090:10`!(f) FMT_GEN3(f), f(3) |
| 2091 | # define FMT_GEN5cxx . . $ `src/common/format.h:2091:10`!(f) FMT_GEN4(f), f(4) |
| 2092 | # define FMT_GEN6cxx . . $ `src/common/format.h:2092:10`!(f) FMT_GEN5(f), f(5) |
| 2093 | # define FMT_GEN7cxx . . $ `src/common/format.h:2093:10`!(f) FMT_GEN6(f), f(6) |
| 2094 | # define FMT_GEN8cxx . . $ `src/common/format.h:2094:10`!(f) FMT_GEN7(f), f(7) |
| 2095 | # define FMT_GEN9cxx . . $ `src/common/format.h:2095:10`!(f) FMT_GEN8(f), f(8) |
| 2096 | # define FMT_GEN10cxx . . $ `src/common/format.h:2096:10`!(f) FMT_GEN9(f), f(9) |
| 2097 | # define FMT_GEN11cxx . . $ `src/common/format.h:2097:10`!(f) FMT_GEN10(f), f(10) |
| 2098 | # define FMT_GEN12cxx . . $ `src/common/format.h:2098:10`!(f) FMT_GEN11(f), f(11) |
| 2099 | # define FMT_GEN13cxx . . $ `src/common/format.h:2099:10`!(f) FMT_GEN12(f), f(12) |
| 2100 | # define FMT_GEN14cxx . . $ `src/common/format.h:2100:10`!(f) FMT_GEN13(f), f(13) |
| 2101 | # define FMT_GEN15cxx . . $ `src/common/format.h:2101:10`!(f) FMT_GEN14(f), f(14) |
| 2102 | |
| 2103 | namespace internalcxx . . $ fmt/internal/ { |
| 2104 | inline uint64_tcxx . . $ uint64_t# make_typecxx . . $ fmt/internal/make_type(f708dce9a8856c70).() { return 0; } |
| 2105 | |
| 2106 | template <typename T> |
| 2107 | inline uint64_tcxx . . $ uint64_t# make_typecxx . . $ fmt/internal/make_type(c6bf0951926639cd).(const T &arg) { |
| 2108 | return MakeValuecxx . . $ fmt/internal/MakeValue#< BasicFormatter<char> >::typecxx . . $ fmt/internal/MakeValue#type(6506acb0ba2ae606).(arg); |
| 2109 | } |
| 2110 | |
| 2111 | template <unsigned N, bool/*IsPacked*/ = (N < ArgListcxx . . $ fmt/ArgList#::MAX_PACKED_ARGScxx . . $ fmt/ArgList#MAX_PACKED_ARGS.)> |
| 2112 | struct ArgArraycxx . . $ fmt/internal/ArgArray#; |
| 2113 | |
| 2114 | template <unsigned N> |
| 2115 | struct ArgArraycxx . . $ fmt/internal/ArgArray#<N, true/*IsPacked*/> { |
| 2116 | typedef Valuecxx . . $ fmt/internal/Value# Typecxx . . $ fmt/internal/ArgArray#Type#[N > 0 ? N : 1]; |
| 2117 | |
| 2118 | template <typename Formatter, typename T> |
| 2119 | static Valuecxx . . $ fmt/internal/Value# makecxx . . $ fmt/internal/ArgArray#make(308e0a7176bd0120).(const T &value) { |
| 2120 | #ifdef __clang__cxx . . $ `<built-in>:3:9`! |
| 2121 | Valuecxx . . $ fmt/internal/Value# result = MakeValuecxx . . $ fmt/internal/MakeValue#<Formatter>(value); |
| 2122 | // Workaround a bug in Apple LLVM version 4.2 (clang-425.0.28) of clang: |
| 2123 | // https://github.com/fmtlib/fmt/issues/276 |
| 2124 | (void)result.customcxx . . $ fmt/internal/Value#$anonymous_type_1#custom..formatcxx . . $ fmt/internal/Value#CustomValue#format.; |
| 2125 | return result; |
| 2126 | #else |
| 2127 | return MakeValue<Formatter>(value); |
| 2128 | #endif |
| 2129 | } |
| 2130 | }; |
| 2131 | |
| 2132 | template <unsigned N> |
| 2133 | struct ArgArraycxx . . $ fmt/internal/ArgArray#<N, false/*IsPacked*/> { |
| 2134 | typedef Argcxx . . $ fmt/internal/Arg# Typecxx . . $ fmt/internal/ArgArray#Type#[N + 1]; // +1 for the list end Arg::NONE |
| 2135 | |
| 2136 | template <typename Formatter, typename T> |
| 2137 | static Argcxx . . $ fmt/internal/Arg# makecxx . . $ fmt/internal/ArgArray#make(7afb14eb793e2097).(const T &value) { return MakeArgcxx . . $ fmt/internal/MakeArg#<Formatter>(value); } |
| 2138 | }; |
| 2139 | |
| 2140 | #if FMT_USE_VARIADIC_TEMPLATEScxx . . $ `src/common/format.h:138:10`! |
| 2141 | template <typename Arg, typename... Args> |
| 2142 | inline uint64_tcxx . . $ uint64_t# make_typecxx . . $ fmt/internal/make_type(18a0f60613e749de).(const Arg &first, const Args & ... tail) { |
| 2143 | return make_typecxx . . $ fmt/internal/make_type(18a0f60613e749de).(first) | (make_typecxx . . $ fmt/internal/make_type(18a0f60613e749de).(tail...) << 4); |
| 2144 | } |
| 2145 | |
| 2146 | #else |
| 2147 | |
| 2148 | struct ArgType { |
| 2149 | uint64_t type; |
| 2150 | |
| 2151 | ArgType() : type(0) {} |
| 2152 | |
| 2153 | template <typename T> |
| 2154 | ArgType(const T &arg) : type(make_type(arg)) {} |
| 2155 | }; |
| 2156 | |
| 2157 | # define FMT_ARG_TYPE_DEFAULT(n) ArgType t##n = ArgType() |
| 2158 | |
| 2159 | inline uint64_t make_type(FMT_GEN15(FMT_ARG_TYPE_DEFAULT)) { |
| 2160 | return t0.type | (t1.type << 4) | (t2.type << 8) | (t3.type << 12) | |
| 2161 | (t4.type << 16) | (t5.type << 20) | (t6.type << 24) | (t7.type << 28) | |
| 2162 | (t8.type << 32) | (t9.type << 36) | (t10.type << 40) | (t11.type << 44) | |
| 2163 | (t12.type << 48) | (t13.type << 52) | (t14.type << 56); |
| 2164 | } |
| 2165 | #endif |
| 2166 | } // namespace internal |
| 2167 | |
| 2168 | # define FMT_MAKE_TEMPLATE_ARGcxx . . $ `src/common/format.h:2168:10`!(n) typename T##n |
| 2169 | # define FMT_MAKE_ARG_TYPEcxx . . $ `src/common/format.h:2169:10`!(n) T##n |
| 2170 | # define FMT_MAKE_ARGcxx . . $ `src/common/format.h:2170:10`!(n) const T##n &v##n |
| 2171 | # define FMT_ASSIGN_charcxx . . $ `src/common/format.h:2171:10`!(n) \ |
| 2172 | arr[n] = fmt::internal::MakeValue< fmt::BasicFormatter<char> >(v##n) |
| 2173 | # define FMT_ASSIGN_wchar_tcxx . . $ `src/common/format.h:2173:10`!(n) \ |
| 2174 | arr[n] = fmt::internal::MakeValue< fmt::BasicFormatter<wchar_t> >(v##n) |
| 2175 | |
| 2176 | #if FMT_USE_VARIADIC_TEMPLATEScxx . . $ `src/common/format.h:138:10`! |
| 2177 | // Defines a variadic function returning void. |
| 2178 | # define FMT_VARIADIC_VOIDcxx . . $ `src/common/format.h:2178:10`!(func, arg_type) \ |
| 2179 | template <typename... Args> \ |
| 2180 | void func(arg_type arg0, const Args & ... args) { \ |
| 2181 | typedef fmt::internal::ArgArray<sizeof...(Args)> ArgArray; \ |
| 2182 | typename ArgArray::Type array{ \ |
| 2183 | ArgArray::template make<fmt::BasicFormatter<Char> >(args)...}; \ |
| 2184 | func(arg0, fmt::ArgList(fmt::internal::make_type(args...), array)); \ |
| 2185 | } |
| 2186 | |
| 2187 | // Defines a variadic constructor. |
| 2188 | # define FMT_VARIADIC_CTORcxx . . $ `src/common/format.h:2188:10`!(ctor, func, arg0_type, arg1_type) \ |
| 2189 | template <typename... Args> \ |
| 2190 | ctor(arg0_type arg0, arg1_type arg1, const Args & ... args) { \ |
| 2191 | typedef fmt::internal::ArgArray<sizeof...(Args)> ArgArray; \ |
| 2192 | typename ArgArray::Type array{ \ |
| 2193 | ArgArray::template make<fmt::BasicFormatter<Char> >(args)...}; \ |
| 2194 | func(arg0, arg1, fmt::ArgList(fmt::internal::make_type(args...), array)); \ |
| 2195 | } |
| 2196 | |
| 2197 | #else |
| 2198 | |
| 2199 | # define FMT_MAKE_REF(n) \ |
| 2200 | fmt::internal::MakeValue< fmt::BasicFormatter<Char> >(v##n) |
| 2201 | # define FMT_MAKE_REF2(n) v##n |
| 2202 | |
| 2203 | // Defines a wrapper for a function taking one argument of type arg_type |
| 2204 | // and n additional arguments of arbitrary types. |
| 2205 | # define FMT_WRAP1(func, arg_type, n) \ |
| 2206 | template <FMT_GEN(n, FMT_MAKE_TEMPLATE_ARG)> \ |
| 2207 | inline void func(arg_type arg1, FMT_GEN(n, FMT_MAKE_ARG)) { \ |
| 2208 | const fmt::internal::ArgArray<n>::Type array = {FMT_GEN(n, FMT_MAKE_REF)}; \ |
| 2209 | func(arg1, fmt::ArgList( \ |
| 2210 | fmt::internal::make_type(FMT_GEN(n, FMT_MAKE_REF2)), array)); \ |
| 2211 | } |
| 2212 | |
| 2213 | // Emulates a variadic function returning void on a pre-C++11 compiler. |
| 2214 | # define FMT_VARIADIC_VOID(func, arg_type) \ |
| 2215 | inline void func(arg_type arg) { func(arg, fmt::ArgList()); } \ |
| 2216 | FMT_WRAP1(func, arg_type, 1) FMT_WRAP1(func, arg_type, 2) \ |
| 2217 | FMT_WRAP1(func, arg_type, 3) FMT_WRAP1(func, arg_type, 4) \ |
| 2218 | FMT_WRAP1(func, arg_type, 5) FMT_WRAP1(func, arg_type, 6) \ |
| 2219 | FMT_WRAP1(func, arg_type, 7) FMT_WRAP1(func, arg_type, 8) \ |
| 2220 | FMT_WRAP1(func, arg_type, 9) FMT_WRAP1(func, arg_type, 10) |
| 2221 | |
| 2222 | # define FMT_CTOR(ctor, func, arg0_type, arg1_type, n) \ |
| 2223 | template <FMT_GEN(n, FMT_MAKE_TEMPLATE_ARG)> \ |
| 2224 | ctor(arg0_type arg0, arg1_type arg1, FMT_GEN(n, FMT_MAKE_ARG)) { \ |
| 2225 | const fmt::internal::ArgArray<n>::Type array = {FMT_GEN(n, FMT_MAKE_REF)}; \ |
| 2226 | func(arg0, arg1, fmt::ArgList( \ |
| 2227 | fmt::internal::make_type(FMT_GEN(n, FMT_MAKE_REF2)), array)); \ |
| 2228 | } |
| 2229 | |
| 2230 | // Emulates a variadic constructor on a pre-C++11 compiler. |
| 2231 | # define FMT_VARIADIC_CTOR(ctor, func, arg0_type, arg1_type) \ |
| 2232 | FMT_CTOR(ctor, func, arg0_type, arg1_type, 1) \ |
| 2233 | FMT_CTOR(ctor, func, arg0_type, arg1_type, 2) \ |
| 2234 | FMT_CTOR(ctor, func, arg0_type, arg1_type, 3) \ |
| 2235 | FMT_CTOR(ctor, func, arg0_type, arg1_type, 4) \ |
| 2236 | FMT_CTOR(ctor, func, arg0_type, arg1_type, 5) \ |
| 2237 | FMT_CTOR(ctor, func, arg0_type, arg1_type, 6) \ |
| 2238 | FMT_CTOR(ctor, func, arg0_type, arg1_type, 7) \ |
| 2239 | FMT_CTOR(ctor, func, arg0_type, arg1_type, 8) \ |
| 2240 | FMT_CTOR(ctor, func, arg0_type, arg1_type, 9) \ |
| 2241 | FMT_CTOR(ctor, func, arg0_type, arg1_type, 10) |
| 2242 | #endif |
| 2243 | |
| 2244 | // Generates a comma-separated list with results of applying f to pairs |
| 2245 | // (argument, index). |
| 2246 | #define FMT_FOR_EACH1cxx . . $ `src/common/format.h:2246:9`!(f, x0) f(x0, 0) |
| 2247 | #define FMT_FOR_EACH2cxx . . $ `src/common/format.h:2247:9`!(f, x0, x1) \ |
| 2248 | FMT_FOR_EACH1cxx . . $ `src/common/format.h:2246:9`!(f, x0), f(x1, 1) |
| 2249 | #define FMT_FOR_EACH3cxx . . $ `src/common/format.h:2249:9`!(f, x0, x1, x2) \ |
| 2250 | FMT_FOR_EACH2cxx . . $ `src/common/format.h:2247:9`!(f, x0 ,x1), f(x2, 2) |
| 2251 | #define FMT_FOR_EACH4cxx . . $ `src/common/format.h:2251:9`!(f, x0, x1, x2, x3) \ |
| 2252 | FMT_FOR_EACH3(f, x0, x1, x2), f(x3, 3) |
| 2253 | #define FMT_FOR_EACH5cxx . . $ `src/common/format.h:2253:9`!(f, x0, x1, x2, x3, x4) \ |
| 2254 | FMT_FOR_EACH4(f, x0, x1, x2, x3), f(x4, 4) |
| 2255 | #define FMT_FOR_EACH6cxx . . $ `src/common/format.h:2255:9`!(f, x0, x1, x2, x3, x4, x5) \ |
| 2256 | FMT_FOR_EACH5(f, x0, x1, x2, x3, x4), f(x5, 5) |
| 2257 | #define FMT_FOR_EACH7cxx . . $ `src/common/format.h:2257:9`!(f, x0, x1, x2, x3, x4, x5, x6) \ |
| 2258 | FMT_FOR_EACH6(f, x0, x1, x2, x3, x4, x5), f(x6, 6) |
| 2259 | #define FMT_FOR_EACH8cxx . . $ `src/common/format.h:2259:9`!(f, x0, x1, x2, x3, x4, x5, x6, x7) \ |
| 2260 | FMT_FOR_EACH7(f, x0, x1, x2, x3, x4, x5, x6), f(x7, 7) |
| 2261 | #define FMT_FOR_EACH9cxx . . $ `src/common/format.h:2261:9`!(f, x0, x1, x2, x3, x4, x5, x6, x7, x8) \ |
| 2262 | FMT_FOR_EACH8(f, x0, x1, x2, x3, x4, x5, x6, x7), f(x8, 8) |
| 2263 | #define FMT_FOR_EACH10cxx . . $ `src/common/format.h:2263:9`!(f, x0, x1, x2, x3, x4, x5, x6, x7, x8, x9) \ |
| 2264 | FMT_FOR_EACH9(f, x0, x1, x2, x3, x4, x5, x6, x7, x8), f(x9, 9) |
| 2265 | |
| 2266 | /** |
| 2267 | An error returned by an operating system or a language runtime, |
| 2268 | for example a file opening error. |
| 2269 | */ |
| 2270 | class SystemErrorcxx . . $ fmt/SystemError# : public internalcxx . . $ fmt/internal/::RuntimeErrorcxx . . $ fmt/internal/RuntimeError# { |
| 2271 | private: |
| 2272 | void initcxx . . $ fmt/SystemError#init(60989cf3251a0945).(int err_code, CStringRefcxx . . $ fmt/CStringRef# format_str, ArgListcxx . . $ fmt/ArgList# args); |
| 2273 | |
| 2274 | protected: |
| 2275 | int error_code_cxx . . $ fmt/SystemError#error_code_.; |
| 2276 | |
| 2277 | typedef char Charcxx . . $ fmt/SystemError#Char#; // For FMT_VARIADIC_CTOR. |
| 2278 | |
| 2279 | SystemErrorcxx . . $ fmt/SystemError#SystemError(49f6e7a06ebc5aa8).() {} |
| 2280 | |
| 2281 | public: |
| 2282 | /** |
| 2283 | \rst |
| 2284 | Constructs a :class:`fmt::SystemError` object with the description |
| 2285 | of the form |
| 2286 | |
| 2287 | .. parsed-literal:: |
| 2288 | *<message>*: *<system-message>* |
| 2289 | |
| 2290 | where *<message>* is the formatted message and *<system-message>* is |
| 2291 | the system message corresponding to the error code. |
| 2292 | *error_code* is a system error code as given by ``errno``. |
| 2293 | If *error_code* is not a valid error code such as -1, the system message |
| 2294 | may look like "Unknown error -1" and is platform-dependent. |
| 2295 | |
| 2296 | **Example**:: |
| 2297 | |
| 2298 | // This throws a SystemError with the description |
| 2299 | // cannot open file 'madeup': No such file or directory |
| 2300 | // or similar (system message may vary). |
| 2301 | const char *filename = "madeup"; |
| 2302 | std::FILE *file = std::fopen(filename, "r"); |
| 2303 | if (!file) |
| 2304 | throw fmt::SystemError(errno, "cannot open file '{}'", filename); |
| 2305 | \endrst |
| 2306 | */ |
| 2307 | SystemErrorcxx . . $ fmt/SystemError#SystemError(17d5d4411d630590).(int error_code, CStringRefcxx . . $ fmt/CStringRef# message) { |
| 2308 | initcxx . . $ fmt/SystemError#init(60989cf3251a0945).(error_code, message, ArgListcxx . . $ fmt/ArgList#()); |
| 2309 | } |
| 2310 | FMT_VARIADIC_CTORcxx . . $ fmt/internal/make_type(18a0f60613e749de).(SystemError, init, int, CStringRef) |
| 2311 | |
| 2312 | ~cxx . . $ fmt/SystemError#`~SystemError`(ced63f7c635d850d).SystemErrorcxx . . $ fmt/SystemError#() throw(); |
| 2313 | |
| 2314 | int error_codecxx . . $ fmt/SystemError#error_code(455f465bc33b4cdf).() const { return error_code_cxx . . $ fmt/SystemError#error_code_.; } |
| 2315 | }; |
| 2316 | |
| 2317 | /** |
| 2318 | \rst |
| 2319 | This template provides operations for formatting and writing data into |
| 2320 | a character stream. The output is stored in a buffer provided by a subclass |
| 2321 | such as :class:`fmt::BasicMemoryWriter`. |
| 2322 | |
| 2323 | You can use one of the following typedefs for common character types: |
| 2324 | |
| 2325 | +---------+----------------------+ |
| 2326 | | Type | Definition | |
| 2327 | +=========+======================+ |
| 2328 | | Writer | BasicWriter<char> | |
| 2329 | +---------+----------------------+ |
| 2330 | | WWriter | BasicWriter<wchar_t> | |
| 2331 | +---------+----------------------+ |
| 2332 | |
| 2333 | \endrst |
| 2334 | */ |
| 2335 | template <typename Char> |
| 2336 | class BasicWritercxx . . $ fmt/BasicWriter# { |
| 2337 | private: |
| 2338 | // Output buffer. |
| 2339 | Buffercxx . . $ fmt/Buffer#<Char> &buffer_cxx . . $ fmt/BasicWriter#buffer_.; |
| 2340 | |
| 2341 | FMT_DISALLOW_COPY_AND_ASSIGNcxx . . $ `src/common/format.h:217:10`!(BasicWriter); |
| 2342 | |
| 2343 | typedef typename internalcxx . . $ fmt/internal/::CharTraitscxx . . $ fmt/internal/CharTraits#<Char>::CharPtr CharPtrcxx . . $ fmt/BasicWriter#CharPtr#; |
| 2344 | |
| 2345 | #if FMT_SECURE_SCLcxx . . $ `src/common/format.h:46:10`! |
| 2346 | // Returns pointer value. |
| 2347 | static Char *get(CharPtr p) { return p.base(); } |
| 2348 | #else |
| 2349 | static Char *getcxx . . $ fmt/BasicWriter#get(98ea26de6545f0ca).(Char *p) { return p; } |
| 2350 | #endif |
| 2351 | |
| 2352 | // Fills the padding around the content and returns the pointer to the |
| 2353 | // content area. |
| 2354 | static CharPtrcxx . . $ fmt/BasicWriter#CharPtr# fill_paddingcxx . . $ fmt/BasicWriter#fill_padding(2dd35c4d4c1556d3).(CharPtrcxx . . $ fmt/BasicWriter#CharPtr# buffer, |
| 2355 | unsigned total_size, stdcxx . . $ std/::size_tcxx . . $ std/size_t# content_size, wchar_t fill); |
| 2356 | |
| 2357 | // Grows the buffer by n characters and returns a pointer to the newly |
| 2358 | // allocated area. |
| 2359 | CharPtrcxx . . $ fmt/BasicWriter#CharPtr# grow_buffercxx . . $ fmt/BasicWriter#grow_buffer(6801df611ac9c5f5).(stdcxx . . $ std/::size_tcxx . . $ std/size_t# n) { |
| 2360 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# size = buffer_cxx . . $ fmt/BasicWriter#buffer_..sizecxx . . $ fmt/Buffer#size(fe4d2d262d4164a8).(); |
| 2361 | buffer_cxx . . $ fmt/BasicWriter#buffer_..resizecxx . . $ fmt/Buffer#resize(2c44cd906ae4e829).(size + n); |
| 2362 | return internalcxx . . $ fmt/internal/::make_ptrcxx . . $ fmt/internal/make_ptr(1149d387c81d78d0).(&buffer_cxx . . $ fmt/BasicWriter#buffer_.[size], n); |
| 2363 | } |
| 2364 | |
| 2365 | // Writes an unsigned decimal integer. |
| 2366 | template <typename UInt> |
| 2367 | Char *write_unsigned_decimalcxx . . $ fmt/BasicWriter#write_unsigned_decimal(80680e6d4a467182).(UInt value, unsigned prefix_size = 0) { |
| 2368 | unsigned num_digits = internalcxx . . $ fmt/internal/::count_digitscxx . . $ fmt/internal/count_digits(ea88b852781e8a38).(value); |
| 2369 | Char *ptr = getcxx . . $ fmt/BasicWriter#get(98ea26de6545f0ca).(grow_buffercxx . . $ fmt/BasicWriter#grow_buffer(6801df611ac9c5f5).(prefix_size + num_digits)); |
| 2370 | internalcxx . . $ fmt/internal/::format_decimalcxx . . $ fmt/internal/format_decimal(e36525a719ed0f39).(ptr + prefix_size, value, num_digits); |
| 2371 | return ptr; |
| 2372 | } |
| 2373 | |
| 2374 | // Writes a decimal integer. |
| 2375 | template <typename Int> |
| 2376 | void write_decimalcxx . . $ fmt/BasicWriter#write_decimal(b07662a27bd562f9).(Int value) { |
| 2377 | typedef typename internalcxx . . $ fmt/internal/::IntTraitscxx . . $ fmt/internal/IntTraits#<Int>::MainType MainTypecxx . . $ fmt/BasicWriter#write_decimal(b07662a27bd562f9).MainType#; |
| 2378 | MainTypecxx . . $ fmt/BasicWriter#write_decimal(b07662a27bd562f9).MainType# abs_value = static_cast<MainTypecxx . . $ fmt/BasicWriter#write_decimal(b07662a27bd562f9).MainType#>(value); |
| 2379 | if (internalcxx . . $ fmt/internal/::is_negativecxx . . $ fmt/internal/is_negative(ee44d93984fb03e9).(value)) { |
| 2380 | abs_value = 0 - abs_value; |
| 2381 | *write_unsigned_decimalcxx . . $ fmt/BasicWriter#write_unsigned_decimal(80680e6d4a467182).(abs_value, 1) = '-'; |
| 2382 | } |
| 2383 | else { |
| 2384 | write_unsigned_decimalcxx . . $ fmt/BasicWriter#write_unsigned_decimal(80680e6d4a467182).(abs_value, 0); |
| 2385 | } |
| 2386 | } |
| 2387 | |
| 2388 | // Prepare a buffer for integer formatting. |
| 2389 | CharPtrcxx . . $ fmt/BasicWriter#CharPtr# prepare_int_buffercxx . . $ fmt/BasicWriter#prepare_int_buffer(a22cef4806bc70ce).(unsigned num_digits, |
| 2390 | const EmptySpeccxx . . $ fmt/EmptySpec# &, const char *prefix, unsigned prefix_size) { |
| 2391 | unsigned size = prefix_size + num_digits; |
| 2392 | CharPtrcxx . . $ fmt/BasicWriter#CharPtr# p = grow_buffercxx . . $ fmt/BasicWriter#grow_buffer(6801df611ac9c5f5).(size); |
| 2393 | stdcxx . . $ std/::uninitialized_copycxx . . $ std/uninitialized_copy(7316eb2979bdd03c).(prefix, prefix + prefix_size, p); |
| 2394 | return p + size - 1; |
| 2395 | } |
| 2396 | |
| 2397 | template <typename Spec> |
| 2398 | CharPtrcxx . . $ fmt/BasicWriter#CharPtr# prepare_int_buffercxx . . $ fmt/BasicWriter#prepare_int_buffer(8dc6c152543e755c).(unsigned num_digits, |
| 2399 | const Spec &spec, const char *prefix, unsigned prefix_size); |
| 2400 | |
| 2401 | // Formats an integer. |
| 2402 | template <typename T, typename Spec> |
| 2403 | void write_intcxx . . $ fmt/BasicWriter#write_int(ff2be549ebcde8b0).(T value, Spec spec); |
| 2404 | |
| 2405 | // Formats a floating-point number (double or long double). |
| 2406 | template <typename T> |
| 2407 | void write_doublecxx . . $ fmt/BasicWriter#write_double(7f39721b6698cf0).(T value, const FormatSpeccxx . . $ fmt/FormatSpec# &spec); |
| 2408 | |
| 2409 | // Writes a formatted string. |
| 2410 | template <typename StrChar> |
| 2411 | CharPtrcxx . . $ fmt/BasicWriter#CharPtr# write_strcxx . . $ fmt/BasicWriter#write_str(a85702808a6b7b2b).(const StrChar *s, stdcxx . . $ std/::size_tcxx . . $ std/size_t# size, const AlignSpeccxx . . $ fmt/AlignSpec# &spec); |
| 2412 | |
| 2413 | template <typename StrChar> |
| 2414 | void write_strcxx . . $ fmt/BasicWriter#write_str(eec3d3228bf04f22).(const internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg#::StringValuecxx . . $ fmt/internal/Value#StringValue#<StrChar> &str, |
| 2415 | const FormatSpeccxx . . $ fmt/FormatSpec# &spec); |
| 2416 | |
| 2417 | // This following methods are private to disallow writing wide characters |
| 2418 | // and strings to a char stream. If you want to print a wide string as a |
| 2419 | // pointer as std::ostream does, cast it to const void*. |
| 2420 | // Do not implement! |
| 2421 | void operatorcxx . . $ fmt/BasicWriter#`operator<<`(f635c5613211e8a5).<<(typename internalcxx . . $ fmt/internal/::WCharHelpercxx . . $ fmt/internal/WCharHelper#<wchar_t, Char>::Unsupported); |
| 2422 | void operatorcxx . . $ fmt/BasicWriter#`operator<<`(b7099a55ad4dee5f).<<( |
| 2423 | typename internalcxx . . $ fmt/internal/::WCharHelpercxx . . $ fmt/internal/WCharHelper#<const wchar_t *, Char>::Unsupported); |
| 2424 | |
| 2425 | // Appends floating-point length specifier to the format string. |
| 2426 | // The second argument is only used for overload resolution. |
| 2427 | void append_float_lengthcxx . . $ fmt/BasicWriter#append_float_length(e953fb195436e02c).(Char *&format_ptr, long double) { |
| 2428 | *format_ptr++ = 'L'; |
| 2429 | } |
| 2430 | |
| 2431 | template<typename T> |
| 2432 | void append_float_lengthcxx . . $ fmt/BasicWriter#append_float_length(48536c74046dfc41).(Char *&, T) {} |
| 2433 | |
| 2434 | template <typename Impl, typename Char_> |
| 2435 | friend class internalcxx . . $ fmt/internal/::ArgFormatterBasecxx . . $ fmt/internal/ArgFormatterBase#; |
| 2436 | |
| 2437 | friend class internalcxx . . $ fmt/internal/::PrintfArgFormattercxx . . $ fmt/internal/PrintfArgFormatter#<Char>; |
| 2438 | |
| 2439 | protected: |
| 2440 | /** |
| 2441 | Constructs a ``BasicWriter`` object. |
| 2442 | */ |
| 2443 | explicit BasicWritercxx . . $ fmt/BasicWriter#`BasicWriter<Char>`(f2987be0f02f0cd7).(Buffercxx . . $ fmt/Buffer#<Char> &b) : buffer_cxx . . $ fmt/BasicWriter#buffer_.(b) {} |
| 2444 | |
| 2445 | public: |
| 2446 | /** |
| 2447 | \rst |
| 2448 | Destroys a ``BasicWriter`` object. |
| 2449 | \endrst |
| 2450 | */ |
| 2451 | virtual ~cxx . . $ fmt/BasicWriter#`~BasicWriter<Char>`(49f6e7a06ebc5aa8).BasicWriter() {} |
| 2452 | |
| 2453 | /** |
| 2454 | Returns the total number of characters written. |
| 2455 | */ |
| 2456 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# sizecxx . . $ fmt/BasicWriter#size(fe4d2d262d4164a8).() const { return buffer_cxx . . $ fmt/BasicWriter#buffer_..sizecxx . . $ fmt/Buffer#size(fe4d2d262d4164a8).(); } |
| 2457 | |
| 2458 | /** |
| 2459 | Returns a pointer to the output buffer content. No terminating null |
| 2460 | character is appended. |
| 2461 | */ |
| 2462 | const Char *datacxx . . $ fmt/BasicWriter#data(8e614c7de0b1573e).() const FMT_NOEXCEPTcxx . . $ `src/common/format.h:188:12`! { return &buffer_cxx . . $ fmt/BasicWriter#buffer_.[0]; } |
| 2463 | |
| 2464 | /** |
| 2465 | Returns a pointer to the output buffer content with terminating null |
| 2466 | character appended. |
| 2467 | */ |
| 2468 | const Char *c_strcxx . . $ fmt/BasicWriter#c_str(1016ee5406d91ab9).() const { |
| 2469 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# size = buffer_cxx . . $ fmt/BasicWriter#buffer_..sizecxx . . $ fmt/Buffer#size(fe4d2d262d4164a8).(); |
| 2470 | buffer_cxx . . $ fmt/BasicWriter#buffer_..reservecxx . . $ fmt/Buffer#reserve(2c44cd906ae4e829).(size + 1); |
| 2471 | buffer_cxx . . $ fmt/BasicWriter#buffer_.[size] = '\0'; |
| 2472 | return &buffer_cxx . . $ fmt/BasicWriter#buffer_.[0]; |
| 2473 | } |
| 2474 | |
| 2475 | /** |
| 2476 | \rst |
| 2477 | Returns the content of the output buffer as an `std::string`. |
| 2478 | \endrst |
| 2479 | */ |
| 2480 | stdcxx . . $ std/::basic_stringcxx . . $ std/__cxx11/basic_string#<Char> strcxx . . $ fmt/BasicWriter#str(25a55eb745a1b6bc).() const { |
| 2481 | return stdcxx . . $ std/::basic_stringcxx . . $ std/__cxx11/basic_string#<Char>(&buffer_cxx . . $ fmt/BasicWriter#buffer_.[0], buffer_cxx . . $ fmt/BasicWriter#buffer_..sizecxx . . $ fmt/Buffer#size(fe4d2d262d4164a8).()); |
| 2482 | } |
| 2483 | |
| 2484 | /** |
| 2485 | \rst |
| 2486 | Writes formatted data. |
| 2487 | |
| 2488 | *args* is an argument list representing arbitrary arguments. |
| 2489 | |
| 2490 | **Example**:: |
| 2491 | |
| 2492 | MemoryWriter out; |
| 2493 | out.write("Current point:\n"); |
| 2494 | out.write("({:+f}, {:+f})", -3.14, 3.14); |
| 2495 | |
| 2496 | This will write the following output to the ``out`` object: |
| 2497 | |
| 2498 | .. code-block:: none |
| 2499 | |
| 2500 | Current point: |
| 2501 | (-3.140000, +3.140000) |
| 2502 | |
| 2503 | The output can be accessed using :func:`data()`, :func:`c_str` or |
| 2504 | :func:`str` methods. |
| 2505 | |
| 2506 | See also :ref:`syntax`. |
| 2507 | \endrst |
| 2508 | */ |
| 2509 | void writecxx . . $ fmt/BasicWriter#write(b7238e95b93927f0).(BasicCStringRefcxx . . $ fmt/BasicCStringRef#<Char> format, ArgListcxx . . $ fmt/ArgList# args) { |
| 2510 | BasicFormattercxx . . $ fmt/BasicFormatter#<Char>(args, *this).formatcxx . . $ fmt/BasicFormatter#format(66d672f47157ac79).(format); |
| 2511 | } |
| 2512 | FMT_VARIADIC_VOIDcxx . . $ fmt/ArgList#(write, BasicCStringRef<Char>) |
| 2513 | |
| 2514 | BasicWriter &operatorcxx . . $ fmt/BasicWriter#`operator<<`(650b44d5e358551d).<<(int value) { |
| 2515 | write_decimalcxx . . $ fmt/BasicWriter#write_decimal(b07662a27bd562f9).(value); |
| 2516 | return *this; |
| 2517 | } |
| 2518 | BasicWriter &operatorcxx . . $ fmt/BasicWriter#`operator<<`(727b7a08498581f7).<<(unsigned value) { |
| 2519 | return *this << IntFormatSpeccxx . . $ fmt/IntFormatSpec#<unsigned>(value); |
| 2520 | } |
| 2521 | BasicWriter &operatorcxx . . $ fmt/BasicWriter#`operator<<`(2b2b664493312c80).<<(long value) { |
| 2522 | write_decimalcxx . . $ fmt/BasicWriter#write_decimal(b07662a27bd562f9).(value); |
| 2523 | return *this; |
| 2524 | } |
| 2525 | BasicWriter &operatorcxx . . $ fmt/BasicWriter#`operator<<`(4360d0144ce1791f).<<(unsigned long value) { |
| 2526 | return *this << IntFormatSpeccxx . . $ fmt/IntFormatSpec#<unsigned long>(value); |
| 2527 | } |
| 2528 | BasicWriter &operatorcxx . . $ fmt/BasicWriter#`operator<<`(a2a29fdc9ffb5107).<<(LongLongcxx . . $ fmt/LongLong# value) { |
| 2529 | write_decimalcxx . . $ fmt/BasicWriter#write_decimal(b07662a27bd562f9).(value); |
| 2530 | return *this; |
| 2531 | } |
| 2532 | |
| 2533 | /** |
| 2534 | \rst |
| 2535 | Formats *value* and writes it to the stream. |
| 2536 | \endrst |
| 2537 | */ |
| 2538 | BasicWriter &operatorcxx . . $ fmt/BasicWriter#`operator<<`(de29ebdac06fd36f).<<(ULongLongcxx . . $ fmt/ULongLong# value) { |
| 2539 | return *this << IntFormatSpeccxx . . $ fmt/IntFormatSpec#<ULongLongcxx . . $ fmt/ULongLong#>(value); |
| 2540 | } |
| 2541 | |
| 2542 | BasicWriter &operatorcxx . . $ fmt/BasicWriter#`operator<<`(986cfb432237c2d8).<<(double value) { |
| 2543 | write_doublecxx . . $ fmt/BasicWriter#write_double(7f39721b6698cf0).(value, FormatSpeccxx . . $ fmt/FormatSpec#()); |
| 2544 | return *this; |
| 2545 | } |
| 2546 | |
| 2547 | /** |
| 2548 | \rst |
| 2549 | Formats *value* using the general format for floating-point numbers |
| 2550 | (``'g'``) and writes it to the stream. |
| 2551 | \endrst |
| 2552 | */ |
| 2553 | BasicWriter &operatorcxx . . $ fmt/BasicWriter#`operator<<`(4cc6a5056e211313).<<(long double value) { |
| 2554 | write_doublecxx . . $ fmt/BasicWriter#write_double(7f39721b6698cf0).(value, FormatSpeccxx . . $ fmt/FormatSpec#FormatSpec(38cf5fc7ed65b972).()); |
| 2555 | return *this; |
| 2556 | } |
| 2557 | |
| 2558 | /** |
| 2559 | Writes a character to the stream. |
| 2560 | */ |
| 2561 | BasicWriter &operatorcxx . . $ fmt/BasicWriter#`operator<<`(5d63ba784f8cac6).<<(char value) { |
| 2562 | buffer_cxx . . $ fmt/BasicWriter#buffer_..push_backcxx . . $ fmt/Buffer#push_back(77d9f17553126ecb).(value); |
| 2563 | return *this; |
| 2564 | } |
| 2565 | |
| 2566 | BasicWriter &operatorcxx . . $ fmt/BasicWriter#`operator<<`(256659ee5af36c5a).<<( |
| 2567 | typename internalcxx . . $ fmt/internal/::WCharHelpercxx . . $ fmt/internal/WCharHelper#<wchar_t, Char>::Supported value) { |
| 2568 | buffer_cxx . . $ fmt/BasicWriter#buffer_..push_backcxx . . $ fmt/Buffer#push_back(77d9f17553126ecb).(value); |
| 2569 | return *this; |
| 2570 | } |
| 2571 | |
| 2572 | /** |
| 2573 | \rst |
| 2574 | Writes *value* to the stream. |
| 2575 | \endrst |
| 2576 | */ |
| 2577 | BasicWriter &operatorcxx . . $ fmt/BasicWriter#`operator<<`(c7404e572fb3e3df).<<(fmtcxx . . $ fmt/::BasicStringRefcxx . . $ fmt/BasicStringRef#<Char> value) { |
| 2578 | const Char *str = value.datacxx . . $ fmt/BasicStringRef#data(1016ee5406d91ab9).(); |
| 2579 | buffer_cxx . . $ fmt/BasicWriter#buffer_..appendcxx . . $ fmt/Buffer#append(780bc11a522ca03e).(str, str + value.sizecxx . . $ fmt/BasicStringRef#size(fe4d2d262d4164a8).()); |
| 2580 | return *this; |
| 2581 | } |
| 2582 | |
| 2583 | BasicWriter &operatorcxx . . $ fmt/BasicWriter#`operator<<`(658c54b77656f349).<<( |
| 2584 | typename internalcxx . . $ fmt/internal/::WCharHelpercxx . . $ fmt/internal/WCharHelper#<StringRef, Char>::Supported value) { |
| 2585 | const char *str = value.data(); |
| 2586 | buffer_cxx . . $ fmt/BasicWriter#buffer_..appendcxx . . $ fmt/Buffer#append(780bc11a522ca03e).(str, str + value.size()); |
| 2587 | return *this; |
| 2588 | } |
| 2589 | |
| 2590 | template <typename T, typename Spec, typename FillChar> |
| 2591 | BasicWriter &operatorcxx . . $ fmt/BasicWriter#`operator<<`(5f83966d465fe611).<<(IntFormatSpeccxx . . $ fmt/IntFormatSpec#<T, Spec, FillChar> spec) { |
| 2592 | internalcxx . . $ fmt/internal/::CharTraitscxx . . $ fmt/internal/CharTraits#<Char>::convert(FillChar()); |
| 2593 | write_intcxx . . $ fmt/BasicWriter#write_int(ff2be549ebcde8b0).(spec.valuecxx . . $ fmt/IntFormatSpec#value(8f5363d873dd4781).(), spec); |
| 2594 | return *this; |
| 2595 | } |
| 2596 | |
| 2597 | template <typename StrChar> |
| 2598 | BasicWriter &operatorcxx . . $ fmt/BasicWriter#`operator<<`(1247693c7156ff22).<<(const StrFormatSpeccxx . . $ fmt/StrFormatSpec#<StrChar> &spec) { |
| 2599 | const StrChar *s = spec.strcxx . . $ fmt/StrFormatSpec#str(1016ee5406d91ab9).(); |
| 2600 | write_strcxx . . $ fmt/BasicWriter#write_str(eec3d3228bf04f22).(s, stdcxx . . $ std/::char_traitscxx . . $ std/char_traits#<Char>::length(s), spec); |
| 2601 | return *this; |
| 2602 | } |
| 2603 | |
| 2604 | void clearcxx . . $ fmt/BasicWriter#clear(ced63f7c635d850d).() FMT_NOEXCEPTcxx . . $ `src/common/format.h:188:12`! { buffer_cxx . . $ fmt/BasicWriter#buffer_..clearcxx . . $ fmt/Buffer#clear(ced63f7c635d850d).(); } |
| 2605 | |
| 2606 | Buffercxx . . $ fmt/Buffer#<Char> &buffercxx . . $ fmt/BasicWriter#buffer(b101dd4061310f2a).() FMT_NOEXCEPTcxx . . $ `src/common/format.h:188:12`! { return buffer_cxx . . $ fmt/BasicWriter#buffer_.; } |
| 2607 | }; |
| 2608 | |
| 2609 | template <typename Char> |
| 2610 | template <typename StrChar> |
| 2611 | typename BasicWritercxx . . $ fmt/BasicWriter#<Char>::CharPtrcxx . . $ fmt/BasicWriter#CharPtr# BasicWritercxx . . $ fmt/BasicWriter#<Char>::write_strcxx . . $ fmt/BasicWriter#write_str(a85702808a6b7b2b).( |
| 2612 | const StrChar *s, stdcxx . . $ std/::size_tcxx . . $ std/size_t# size, const AlignSpeccxx . . $ fmt/AlignSpec# &spec) { |
| 2613 | CharPtrcxx . . $ fmt/BasicWriter#CharPtr# out = CharPtrcxx . . $ fmt/BasicWriter#CharPtr#(); |
| 2614 | if (spec.widthcxx . . $ fmt/WidthSpec#width(ddd8539a2fcdd4ce).() > size) { |
| 2615 | out = grow_buffercxx . . $ fmt/BasicWriter#grow_buffer(6801df611ac9c5f5).(spec.widthcxx . . $ fmt/WidthSpec#width(ddd8539a2fcdd4ce).()); |
| 2616 | Char fill = internalcxx . . $ fmt/internal/::CharTraitscxx . . $ fmt/internal/CharTraits#<Char>::cast(spec.fillcxx . . $ fmt/WidthSpec#fill(301fc089a05c7cd9).()); |
| 2617 | if (spec.aligncxx . . $ fmt/AlignSpec#align(8ad7b378d7859fc1).() == ALIGN_RIGHTcxx . . $ fmt/ALIGN_RIGHT.) { |
| 2618 | stdcxx . . $ std/::uninitialized_fill_ncxx . . $ std/uninitialized_fill_n(b9ce89abc1b751f2).(out, spec.widthcxx . . $ fmt/WidthSpec#width(ddd8539a2fcdd4ce).() - size, fill); |
| 2619 | out += spec.widthcxx . . $ fmt/WidthSpec#width(ddd8539a2fcdd4ce).() - size; |
| 2620 | } |
| 2621 | else if (spec.aligncxx . . $ fmt/AlignSpec#align(8ad7b378d7859fc1).() == ALIGN_CENTERcxx . . $ fmt/ALIGN_CENTER.) { |
| 2622 | out = fill_paddingcxx . . $ fmt/BasicWriter#fill_padding(2dd35c4d4c1556d3).(out, spec.widthcxx . . $ fmt/WidthSpec#width(ddd8539a2fcdd4ce).(), size, fill); |
| 2623 | } |
| 2624 | else { |
| 2625 | stdcxx . . $ std/::uninitialized_fill_ncxx . . $ std/uninitialized_fill_n(b9ce89abc1b751f2).(out + size, spec.widthcxx . . $ fmt/WidthSpec#width(ddd8539a2fcdd4ce).() - size, fill); |
| 2626 | } |
| 2627 | } |
| 2628 | else { |
| 2629 | out = grow_buffercxx . . $ fmt/BasicWriter#grow_buffer(6801df611ac9c5f5).(size); |
| 2630 | } |
| 2631 | stdcxx . . $ std/::uninitialized_copycxx . . $ std/uninitialized_copy(7316eb2979bdd03c).(s, s + size, out); |
| 2632 | return out; |
| 2633 | } |
| 2634 | |
| 2635 | template <typename Char> |
| 2636 | template <typename StrChar> |
| 2637 | void BasicWritercxx . . $ fmt/BasicWriter#<Char>::write_strcxx . . $ fmt/BasicWriter#write_str(eec3d3228bf04f22).( |
| 2638 | const internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg#::StringValuecxx . . $ fmt/internal/Value#StringValue#<StrChar> &s, const FormatSpeccxx . . $ fmt/FormatSpec# &spec) { |
| 2639 | // Check if StrChar is convertible to Char. |
| 2640 | internalcxx . . $ fmt/internal/::CharTraitscxx . . $ fmt/internal/CharTraits#<Char>::convert(StrChar()); |
| 2641 | if (spec.type_cxx . . $ fmt/FormatSpec#type_. && spec.type_cxx . . $ fmt/FormatSpec#type_. != 's') |
| 2642 | internalcxx . . $ fmt/internal/::report_unknown_typecxx . . $ fmt/internal/report_unknown_type(6d02e1a5f7bf8914).(spec.type_cxx . . $ fmt/FormatSpec#type_., "string"); |
| 2643 | const StrChar *str_value = s.valuecxx . . $ fmt/internal/Value#StringValue#value.; |
| 2644 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# str_size = s.sizecxx . . $ fmt/internal/Value#StringValue#size.; |
| 2645 | if (str_size == 0) { |
| 2646 | if (!str_value) { |
| 2647 | FMT_THROWcxx . . $ `src/common/format.h:172:11`!(FormatError("string pointer is null")); |
| 2648 | } |
| 2649 | } |
| 2650 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# precision = static_cast<stdcxx . . $ std/::size_tcxx . . $ std/size_t#>(spec.precision_cxx . . $ fmt/FormatSpec#precision_.); |
| 2651 | if (spec.precision_cxx . . $ fmt/FormatSpec#precision_. >= 0 && precision < str_size) |
| 2652 | str_size = precision; |
| 2653 | write_strcxx . . $ fmt/BasicWriter#write_str(eec3d3228bf04f22).(str_value, str_size, spec); |
| 2654 | } |
| 2655 | |
| 2656 | template <typename Char> |
| 2657 | typename BasicWritercxx . . $ fmt/BasicWriter#<Char>::CharPtrcxx . . $ fmt/BasicWriter#CharPtr# |
| 2658 | BasicWritercxx . . $ fmt/BasicWriter#<Char>::fill_paddingcxx . . $ fmt/BasicWriter#fill_padding(2dd35c4d4c1556d3).( |
| 2659 | CharPtrcxx . . $ fmt/BasicWriter#CharPtr# buffer, unsigned total_size, |
| 2660 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# content_size, wchar_t fill) { |
| 2661 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# padding = total_size - content_size; |
| 2662 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# left_padding = padding / 2; |
| 2663 | Char fill_char = internalcxx . . $ fmt/internal/::CharTraitscxx . . $ fmt/internal/CharTraits#<Char>::cast(fill); |
| 2664 | stdcxx . . $ std/::uninitialized_fill_ncxx . . $ std/uninitialized_fill_n(b9ce89abc1b751f2).(buffer, left_padding, fill_char); |
| 2665 | buffer += left_padding; |
| 2666 | CharPtrcxx . . $ fmt/BasicWriter#CharPtr# content = buffer; |
| 2667 | stdcxx . . $ std/::uninitialized_fill_ncxx . . $ std/uninitialized_fill_n(b9ce89abc1b751f2).(buffer + content_size, |
| 2668 | padding - left_padding, fill_char); |
| 2669 | return content; |
| 2670 | } |
| 2671 | |
| 2672 | template <typename Char> |
| 2673 | template <typename Spec> |
| 2674 | typename BasicWritercxx . . $ fmt/BasicWriter#<Char>::CharPtrcxx . . $ fmt/BasicWriter#CharPtr# |
| 2675 | BasicWritercxx . . $ fmt/BasicWriter#<Char>::prepare_int_buffercxx . . $ fmt/BasicWriter#prepare_int_buffer(8dc6c152543e755c).( |
| 2676 | unsigned num_digits, const Spec &spec, |
| 2677 | const char *prefix, unsigned prefix_size) { |
| 2678 | unsigned width = spec.width(); |
| 2679 | Alignmentcxx . . $ fmt/Alignment# align = spec.align(); |
| 2680 | Char fill = internalcxx . . $ fmt/internal/::CharTraitscxx . . $ fmt/internal/CharTraits#<Char>::cast(spec.fill()); |
| 2681 | if (spec.precision() > static_cast<int>(num_digits)) { |
| 2682 | // Octal prefix '0' is counted as a digit, so ignore it if precision |
| 2683 | // is specified. |
| 2684 | if (prefix_size > 0 && prefix[prefix_size - 1] == '0') |
| 2685 | --prefix_size; |
| 2686 | unsigned number_size = |
| 2687 | prefix_size + internalcxx . . $ fmt/internal/::to_unsignedcxx . . $ fmt/internal/to_unsigned(4de866539cf5f5fc).(spec.precision()); |
| 2688 | AlignSpeccxx . . $ fmt/AlignSpec# subspeccxx . . $ fmt/AlignSpec#AlignSpec(f27b7951b0778fcc).(number_size, '0', ALIGN_NUMERICcxx . . $ fmt/ALIGN_NUMERIC.); |
| 2689 | if (number_size >= width) |
| 2690 | return prepare_int_buffercxx . . $ fmt/BasicWriter#prepare_int_buffer(a22cef4806bc70ce).(num_digits, subspec, prefix, prefix_size); |
| 2691 | buffer_cxx . . $ fmt/BasicWriter#buffer_..reservecxx . . $ fmt/Buffer#reserve(2c44cd906ae4e829).(width); |
| 2692 | unsigned fill_size = width - number_size; |
| 2693 | if (align != ALIGN_LEFTcxx . . $ fmt/ALIGN_LEFT.) { |
| 2694 | CharPtrcxx . . $ fmt/BasicWriter#CharPtr# p = grow_buffercxx . . $ fmt/BasicWriter#grow_buffer(6801df611ac9c5f5).(fill_size); |
| 2695 | stdcxx . . $ std/::uninitialized_fillcxx . . $ std/uninitialized_fill(fbdfa4cc4bf8da96).(p, p + fill_size, fill); |
| 2696 | } |
| 2697 | CharPtrcxx . . $ fmt/BasicWriter#CharPtr# result = prepare_int_buffercxx . . $ fmt/BasicWriter#prepare_int_buffer(a22cef4806bc70ce).( |
| 2698 | num_digits, subspec, prefix, prefix_size); |
| 2699 | if (align == ALIGN_LEFTcxx . . $ fmt/ALIGN_LEFT.) { |
| 2700 | CharPtrcxx . . $ fmt/BasicWriter#CharPtr# p = grow_buffercxx . . $ fmt/BasicWriter#grow_buffer(6801df611ac9c5f5).(fill_size); |
| 2701 | stdcxx . . $ std/::uninitialized_fillcxx . . $ std/uninitialized_fill(4a9bfaed88eccda7).(p, p + fill_size, fill); |
| 2702 | } |
| 2703 | return result; |
| 2704 | } |
| 2705 | unsigned size = prefix_size + num_digits; |
| 2706 | if (width <= size) { |
| 2707 | CharPtrcxx . . $ fmt/BasicWriter#CharPtr# p = grow_buffercxx . . $ fmt/BasicWriter#grow_buffer(6801df611ac9c5f5).(size); |
| 2708 | stdcxx . . $ std/::uninitialized_copycxx . . $ std/uninitialized_copy(7316eb2979bdd03c).(prefix, prefix + prefix_size, p); |
| 2709 | return p + size - 1; |
| 2710 | } |
| 2711 | CharPtrcxx . . $ fmt/BasicWriter#CharPtr# p = grow_buffercxx . . $ fmt/BasicWriter#grow_buffer(6801df611ac9c5f5).(width); |
| 2712 | CharPtrcxx . . $ fmt/BasicWriter#CharPtr# end = p + width; |
| 2713 | if (align == ALIGN_LEFTcxx . . $ fmt/ALIGN_LEFT.) { |
| 2714 | stdcxx . . $ std/::uninitialized_copycxx . . $ std/uninitialized_copy(7316eb2979bdd03c).(prefix, prefix + prefix_size, p); |
| 2715 | p += size; |
| 2716 | stdcxx . . $ std/::uninitialized_fillcxx . . $ std/uninitialized_fill(4a9bfaed88eccda7).(p, end, fill); |
| 2717 | } |
| 2718 | else if (align == ALIGN_CENTERcxx . . $ fmt/ALIGN_CENTER.) { |
| 2719 | p = fill_paddingcxx . . $ fmt/BasicWriter#fill_padding(2dd35c4d4c1556d3).(p, width, size, fill); |
| 2720 | stdcxx . . $ std/::uninitialized_copycxx . . $ std/uninitialized_copy(7316eb2979bdd03c).(prefix, prefix + prefix_size, p); |
| 2721 | p += size; |
| 2722 | } |
| 2723 | else { |
| 2724 | if (align == ALIGN_NUMERICcxx . . $ fmt/ALIGN_NUMERIC.) { |
| 2725 | if (prefix_size != 0) { |
| 2726 | p = stdcxx . . $ std/::uninitialized_copycxx . . $ std/uninitialized_copy(7316eb2979bdd03c).(prefix, prefix + prefix_size, p); |
| 2727 | size -= prefix_size; |
| 2728 | } |
| 2729 | } |
| 2730 | else { |
| 2731 | stdcxx . . $ std/::uninitialized_copycxx . . $ std/uninitialized_copy(88304b602929f6f4).(prefix, prefix + prefix_size, end - size); |
| 2732 | } |
| 2733 | stdcxx . . $ std/::uninitialized_fillcxx . . $ std/uninitialized_fill(4a9bfaed88eccda7).(p, end - size, fill); |
| 2734 | p = end; |
| 2735 | } |
| 2736 | return p - 1; |
| 2737 | } |
| 2738 | |
| 2739 | template <typename Char> |
| 2740 | template <typename T, typename Spec> |
| 2741 | void BasicWritercxx . . $ fmt/BasicWriter#<Char>::write_intcxx . . $ fmt/BasicWriter#write_int(ff2be549ebcde8b0).(T value, Spec spec) { |
| 2742 | unsigned prefix_size = 0; |
| 2743 | typedef typename internalcxx . . $ fmt/internal/::IntTraitscxx . . $ fmt/internal/IntTraits#<T>::MainType UnsignedTypecxx . . $ fmt/BasicWriter#write_int(ff2be549ebcde8b0).UnsignedType#; |
| 2744 | UnsignedTypecxx . . $ fmt/BasicWriter#write_int(ff2be549ebcde8b0).UnsignedType# abs_value = static_cast<UnsignedTypecxx . . $ fmt/BasicWriter#write_int(ff2be549ebcde8b0).UnsignedType#>(value); |
| 2745 | char prefix[4] = ""; |
| 2746 | if (internalcxx . . $ fmt/internal/::is_negativecxx . . $ fmt/internal/is_negative(ee44d93984fb03e9).(value)) { |
| 2747 | prefix[0] = '-'; |
| 2748 | ++prefix_size; |
| 2749 | abs_value = 0 - abs_value; |
| 2750 | } |
| 2751 | else if (spec.flag(SIGN_FLAGcxx . . $ fmt/SIGN_FLAG.)) { |
| 2752 | prefix[0] = spec.flag(PLUS_FLAGcxx . . $ fmt/PLUS_FLAG.) ? '+' : ' '; |
| 2753 | ++prefix_size; |
| 2754 | } |
| 2755 | switch (spec.type()) { |
| 2756 | case 0: case 'd': { |
| 2757 | unsigned num_digits = internalcxx . . $ fmt/internal/::count_digitscxx . . $ fmt/internal/count_digits(ea88b852781e8a38).(abs_value); |
| 2758 | CharPtrcxx . . $ fmt/BasicWriter#CharPtr# p = prepare_int_buffercxx . . $ fmt/BasicWriter#prepare_int_buffer(a22cef4806bc70ce).(num_digits, spec, prefix, prefix_size) + 1; |
| 2759 | internalcxx . . $ fmt/internal/::format_decimalcxx . . $ fmt/internal/format_decimal(e36525a719ed0f39).(getcxx . . $ fmt/BasicWriter#get(98ea26de6545f0ca).(p), abs_value, 0); |
| 2760 | break; |
| 2761 | } |
| 2762 | case 'x': case 'X': { |
| 2763 | UnsignedTypecxx . . $ fmt/BasicWriter#write_int(ff2be549ebcde8b0).UnsignedType# n = abs_value; |
| 2764 | if (spec.flag(HASH_FLAGcxx . . $ fmt/HASH_FLAG.)) { |
| 2765 | prefix[prefix_size++] = '0'; |
| 2766 | prefix[prefix_size++] = spec.type(); |
| 2767 | } |
| 2768 | unsigned num_digits = 0; |
| 2769 | do { |
| 2770 | ++num_digits; |
| 2771 | } while ((n >>= 4) != 0); |
| 2772 | Char *p = getcxx . . $ fmt/BasicWriter#get(98ea26de6545f0ca).(prepare_int_buffercxx . . $ fmt/BasicWriter#prepare_int_buffer(a22cef4806bc70ce).( |
| 2773 | num_digits, spec, prefix, prefix_size)); |
| 2774 | n = abs_value; |
| 2775 | const char *digits = spec.type() == 'x' ? |
| 2776 | "0123456789abcdef" : "0123456789ABCDEF"; |
| 2777 | do { |
| 2778 | *p-- = digits[n & 0xf]; |
| 2779 | } while ((n >>= 4) != 0); |
| 2780 | break; |
| 2781 | } |
| 2782 | case 'b': case 'B': { |
| 2783 | UnsignedTypecxx . . $ fmt/BasicWriter#write_int(ff2be549ebcde8b0).UnsignedType# n = abs_value; |
| 2784 | if (spec.flag(HASH_FLAGcxx . . $ fmt/HASH_FLAG.)) { |
| 2785 | prefix[prefix_size++] = '0'; |
| 2786 | prefix[prefix_size++] = spec.type(); |
| 2787 | } |
| 2788 | unsigned num_digits = 0; |
| 2789 | do { |
| 2790 | ++num_digits; |
| 2791 | } while ((n >>= 1) != 0); |
| 2792 | Char *p = getcxx . . $ fmt/BasicWriter#get(98ea26de6545f0ca).(prepare_int_buffercxx . . $ fmt/BasicWriter#prepare_int_buffer(a22cef4806bc70ce).(num_digits, spec, prefix, prefix_size)); |
| 2793 | n = abs_value; |
| 2794 | do { |
| 2795 | *p-- = static_cast<Char>('0' + (n & 1)); |
| 2796 | } while ((n >>= 1) != 0); |
| 2797 | break; |
| 2798 | } |
| 2799 | case 'o': { |
| 2800 | UnsignedTypecxx . . $ fmt/BasicWriter#write_int(ff2be549ebcde8b0).UnsignedType# n = abs_value; |
| 2801 | if (spec.flag(HASH_FLAGcxx . . $ fmt/HASH_FLAG.)) |
| 2802 | prefix[prefix_size++] = '0'; |
| 2803 | unsigned num_digits = 0; |
| 2804 | do { |
| 2805 | ++num_digits; |
| 2806 | } while ((n >>= 3) != 0); |
| 2807 | Char *p = getcxx . . $ fmt/BasicWriter#get(98ea26de6545f0ca).(prepare_int_buffercxx . . $ fmt/BasicWriter#prepare_int_buffer(a22cef4806bc70ce).(num_digits, spec, prefix, prefix_size)); |
| 2808 | n = abs_value; |
| 2809 | do { |
| 2810 | *p-- = static_cast<Char>('0' + (n & 7)); |
| 2811 | } while ((n >>= 3) != 0); |
| 2812 | break; |
| 2813 | } |
| 2814 | case 'n': { |
| 2815 | unsigned num_digits = internalcxx . . $ fmt/internal/::count_digitscxx . . $ fmt/internal/count_digits(ea88b852781e8a38).(abs_value); |
| 2816 | fmtcxx . . $ fmt/::StringRefcxx . . $ fmt/StringRef# sep = ""cxx . . $ fmt/BasicStringRef#BasicStringRef(88376428bb603c08).; |
| 2817 | #ifndef ANDROID |
| 2818 | sep =cxx . . $ fmt/BasicStringRef#`operator=`(4035675a9caf164). internalcxx . . $ fmt/internal/::thousands_sepcxx . . $ fmt/internal/thousands_sep(fdb6883f460ea402).(stdcxx . . $ std/::localeconvcxx . . $ std/localeconv(143aafff53a810b6).()); |
| 2819 | #endif |
| 2820 | unsigned size = static_cast<unsigned>( |
| 2821 | num_digits + sep.sizecxx . . $ fmt/BasicStringRef#size(fe4d2d262d4164a8).() * ((num_digits - 1) / 3)); |
| 2822 | CharPtrcxx . . $ fmt/BasicWriter#CharPtr# p = prepare_int_buffercxx . . $ fmt/BasicWriter#prepare_int_buffer(a22cef4806bc70ce).(size, spec, prefix, prefix_size) + 1; |
| 2823 | internalcxx . . $ fmt/internal/::format_decimalcxx . . $ fmt/internal/format_decimal(e36525a719ed0f39).(getcxx . . $ fmt/BasicWriter#get(98ea26de6545f0ca).(p), abs_value, 0, internalcxx . . $ fmt/internal/::ThousandsSepcxx . . $ fmt/internal/ThousandsSep#(sep)); |
| 2824 | break; |
| 2825 | } |
| 2826 | default: |
| 2827 | internalcxx . . $ fmt/internal/::report_unknown_typecxx . . $ fmt/internal/report_unknown_type(6d02e1a5f7bf8914).( |
| 2828 | spec.type(), spec.flag(CHAR_FLAGcxx . . $ fmt/CHAR_FLAG.) ? "char" : "integer"); |
| 2829 | break; |
| 2830 | } |
| 2831 | } |
| 2832 | |
| 2833 | template <typename Char> |
| 2834 | template <typename T> |
| 2835 | void BasicWritercxx . . $ fmt/BasicWriter#<Char>::write_doublecxx . . $ fmt/BasicWriter#write_double(7f39721b6698cf0).(T value, const FormatSpeccxx . . $ fmt/FormatSpec# &spec) { |
| 2836 | // Check type. |
| 2837 | char type = spec.typecxx . . $ fmt/FormatSpec#type(1b8b762cbef9c2c9).(); |
| 2838 | bool upper = false; |
| 2839 | switch (type) { |
| 2840 | case 0: |
| 2841 | type = 'g'; |
| 2842 | break; |
| 2843 | case 'e': case 'f': case 'g': case 'a': |
| 2844 | break; |
| 2845 | case 'F': |
| 2846 | #if FMT_MSC_VERcxx . . $ `src/common/format.h:56:10`! |
| 2847 | // MSVC's printf doesn't support 'F'. |
| 2848 | type = 'f'; |
| 2849 | #endif |
| 2850 | // Fall through. |
| 2851 | case 'E': case 'G': case 'A': |
| 2852 | upper = true; |
| 2853 | break; |
| 2854 | default: |
| 2855 | internalcxx . . $ fmt/internal/::report_unknown_typecxx . . $ fmt/internal/report_unknown_type(6d02e1a5f7bf8914).(type, "double"); |
| 2856 | break; |
| 2857 | } |
| 2858 | |
| 2859 | char sign = 0; |
| 2860 | // Use isnegative instead of value < 0 because the latter is always |
| 2861 | // false for NaN. |
| 2862 | if (internalcxx . . $ fmt/internal/::FPUtilcxx . . $ fmt/internal/FPUtil#::isnegativecxx . . $ std/numeric_limits#isnegative(f8197d536af80c96).(static_cast<double>(value))) { |
| 2863 | sign = '-'; |
| 2864 | value = -value; |
| 2865 | } |
| 2866 | else if (spec.flagcxx . . $ fmt/FormatSpec#flag(8de63fdb265b07c1).(SIGN_FLAGcxx . . $ fmt/SIGN_FLAG.)) { |
| 2867 | sign = spec.flagcxx . . $ fmt/FormatSpec#flag(8de63fdb265b07c1).(PLUS_FLAGcxx . . $ fmt/PLUS_FLAG.) ? '+' : ' '; |
| 2868 | } |
| 2869 | |
| 2870 | if (internalcxx . . $ fmt/internal/::FPUtilcxx . . $ fmt/internal/FPUtil#::isnotanumbercxx . . $ std/numeric_limits#isnotanumber(ee44d93984fb03e9).(value)) { |
| 2871 | // Format NaN ourselves because sprintf's output is not consistent |
| 2872 | // across platforms. |
| 2873 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# nan_size = 4; |
| 2874 | const char *nan = upper ? " NAN" : " nan"; |
| 2875 | if (!sign) { |
| 2876 | --nan_size; |
| 2877 | ++nan; |
| 2878 | } |
| 2879 | CharPtrcxx . . $ fmt/BasicWriter#CharPtr# out = write_strcxx . . $ fmt/BasicWriter#write_str(eec3d3228bf04f22).(nan, nan_size, spec); |
| 2880 | if (sign) |
| 2881 | *out = sign; |
| 2882 | return; |
| 2883 | } |
| 2884 | |
| 2885 | if (internalcxx . . $ fmt/internal/::FPUtilcxx . . $ fmt/internal/FPUtil#::isinfinitycxx . . $ std/numeric_limits#isinfinity(ee44d93984fb03e9).(value)) { |
| 2886 | // Format infinity ourselves because sprintf's output is not consistent |
| 2887 | // across platforms. |
| 2888 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# inf_size = 4; |
| 2889 | const char *inf = upper ? " INF" : " inf"; |
| 2890 | if (!sign) { |
| 2891 | --inf_size; |
| 2892 | ++inf; |
| 2893 | } |
| 2894 | CharPtrcxx . . $ fmt/BasicWriter#CharPtr# out = write_strcxx . . $ fmt/BasicWriter#write_str(eec3d3228bf04f22).(inf, inf_size, spec); |
| 2895 | if (sign) |
| 2896 | *out = sign; |
| 2897 | return; |
| 2898 | } |
| 2899 | |
| 2900 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# offset = buffer_cxx . . $ fmt/BasicWriter#buffer_..sizecxx . . $ fmt/Buffer#size(fe4d2d262d4164a8).(); |
| 2901 | unsigned width = spec.widthcxx . . $ fmt/WidthSpec#width(ddd8539a2fcdd4ce).(); |
| 2902 | if (sign) { |
| 2903 | buffer_cxx . . $ fmt/BasicWriter#buffer_..reservecxx . . $ fmt/Buffer#reserve(2c44cd906ae4e829).(buffer_cxx . . $ fmt/BasicWriter#buffer_..sizecxx . . $ fmt/Buffer#size(fe4d2d262d4164a8).() + (width > 1u ? width : 1u)); |
| 2904 | if (width > 0) |
| 2905 | --width; |
| 2906 | ++offset; |
| 2907 | } |
| 2908 | |
| 2909 | // Build format string. |
| 2910 | enumcxx . . $ fmt/BasicWriter#write_double(7f39721b6698cf0).$anonymous_type_15# { MAX_FORMAT_SIZEcxx . . $ fmt/BasicWriter#write_double(7f39721b6698cf0).MAX_FORMAT_SIZE. = 10 }; // longest format: %#-*.*Lg |
| 2911 | Char format[MAX_FORMAT_SIZEcxx . . $ fmt/BasicWriter#write_double(7f39721b6698cf0).MAX_FORMAT_SIZE.]; |
| 2912 | Char *format_ptr = format; |
| 2913 | *format_ptr++ = '%'; |
| 2914 | unsigned width_for_sprintf = width; |
| 2915 | if (spec.flagcxx . . $ fmt/FormatSpec#flag(8de63fdb265b07c1).(HASH_FLAGcxx . . $ fmt/HASH_FLAG.)) |
| 2916 | *format_ptr++ = '#'; |
| 2917 | if (spec.aligncxx . . $ fmt/AlignSpec#align(8ad7b378d7859fc1).() == ALIGN_CENTERcxx . . $ fmt/ALIGN_CENTER.) { |
| 2918 | width_for_sprintf = 0; |
| 2919 | } |
| 2920 | else { |
| 2921 | if (spec.aligncxx . . $ fmt/AlignSpec#align(8ad7b378d7859fc1).() == ALIGN_LEFTcxx . . $ fmt/ALIGN_LEFT.) |
| 2922 | *format_ptr++ = '-'; |
| 2923 | if (width != 0) |
| 2924 | *format_ptr++ = '*'; |
| 2925 | } |
| 2926 | if (spec.precisioncxx . . $ fmt/FormatSpec#precision(455f465bc33b4cdf).() >= 0) { |
| 2927 | *format_ptr++ = '.'; |
| 2928 | *format_ptr++ = '*'; |
| 2929 | } |
| 2930 | |
| 2931 | append_float_lengthcxx . . $ fmt/BasicWriter#append_float_length(48536c74046dfc41).(format_ptr, value); |
| 2932 | *format_ptr++ = type; |
| 2933 | *format_ptr = '\0'; |
| 2934 | |
| 2935 | // Format using snprintf. |
| 2936 | Char fill = internalcxx . . $ fmt/internal/::CharTraitscxx . . $ fmt/internal/CharTraits#<Char>::cast(spec.fillcxx . . $ fmt/WidthSpec#fill(301fc089a05c7cd9).()); |
| 2937 | unsigned n = 0; |
| 2938 | Char *start = 0; |
| 2939 | for (;;) { |
| 2940 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# buffer_size = buffer_cxx . . $ fmt/BasicWriter#buffer_..capacitycxx . . $ fmt/Buffer#capacity(fe4d2d262d4164a8).() - offset; |
| 2941 | #if FMT_MSC_VERcxx . . $ `src/common/format.h:56:10`! |
| 2942 | // MSVC's vsnprintf_s doesn't work with zero size, so reserve |
| 2943 | // space for at least one extra character to make the size non-zero. |
| 2944 | // Note that the buffer's capacity will increase by more than 1. |
| 2945 | if (buffer_size == 0) { |
| 2946 | buffer_.reserve(offset + 1); |
| 2947 | buffer_size = buffer_.capacity() - offset; |
| 2948 | } |
| 2949 | #endif |
| 2950 | start = &buffer_cxx . . $ fmt/BasicWriter#buffer_.[offset]; |
| 2951 | int result = internalcxx . . $ fmt/internal/::CharTraitscxx . . $ fmt/internal/CharTraits#<Char>::format_float( |
| 2952 | start, buffer_size, format, width_for_sprintf, spec.precisioncxx . . $ fmt/FormatSpec#precision(455f465bc33b4cdf).(), value); |
| 2953 | if (result >= 0) { |
| 2954 | n = internalcxx . . $ fmt/internal/::to_unsignedcxx . . $ fmt/internal/to_unsigned(4de866539cf5f5fc).(result); |
| 2955 | if (offset + n < buffer_cxx . . $ fmt/BasicWriter#buffer_..capacitycxx . . $ fmt/Buffer#capacity(fe4d2d262d4164a8).()) |
| 2956 | break; // The buffer is large enough - continue with formatting. |
| 2957 | buffer_cxx . . $ fmt/BasicWriter#buffer_..reservecxx . . $ fmt/Buffer#reserve(2c44cd906ae4e829).(offset + n + 1); |
| 2958 | } |
| 2959 | else { |
| 2960 | // If result is negative we ask to increase the capacity by at least 1, |
| 2961 | // but as std::vector, the buffer grows exponentially. |
| 2962 | buffer_cxx . . $ fmt/BasicWriter#buffer_..reservecxx . . $ fmt/Buffer#reserve(2c44cd906ae4e829).(buffer_cxx . . $ fmt/BasicWriter#buffer_..capacitycxx . . $ fmt/Buffer#capacity(fe4d2d262d4164a8).() + 1); |
| 2963 | } |
| 2964 | } |
| 2965 | if (sign) { |
| 2966 | if ((spec.aligncxx . . $ fmt/AlignSpec#align(8ad7b378d7859fc1).() != ALIGN_RIGHTcxx . . $ fmt/ALIGN_RIGHT. && spec.aligncxx . . $ fmt/AlignSpec#align(8ad7b378d7859fc1).() != ALIGN_DEFAULTcxx . . $ fmt/ALIGN_DEFAULT.) || |
| 2967 | *start != ' ') { |
| 2968 | *(start - 1) = sign; |
| 2969 | sign = 0; |
| 2970 | } |
| 2971 | else { |
| 2972 | *(start - 1) = fill; |
| 2973 | } |
| 2974 | ++n; |
| 2975 | } |
| 2976 | if (spec.aligncxx . . $ fmt/AlignSpec#align(8ad7b378d7859fc1).() == ALIGN_CENTERcxx . . $ fmt/ALIGN_CENTER. && spec.widthcxx . . $ fmt/WidthSpec#width(ddd8539a2fcdd4ce).() > n) { |
| 2977 | width = spec.widthcxx . . $ fmt/WidthSpec#width(ddd8539a2fcdd4ce).(); |
| 2978 | CharPtrcxx . . $ fmt/BasicWriter#CharPtr# p = grow_buffercxx . . $ fmt/BasicWriter#grow_buffer(6801df611ac9c5f5).(width); |
| 2979 | stdcxx . . $ std/::memmove(getcxx . . $ fmt/BasicWriter#get(98ea26de6545f0ca).(p) + (width - n) / 2, getcxx . . $ fmt/BasicWriter#get(98ea26de6545f0ca).(p), n * sizeof(Char)); |
| 2980 | fill_paddingcxx . . $ fmt/BasicWriter#fill_padding(2dd35c4d4c1556d3).(p, spec.widthcxx . . $ fmt/WidthSpec#width(ddd8539a2fcdd4ce).(), n, fill); |
| 2981 | return; |
| 2982 | } |
| 2983 | if (spec.fillcxx . . $ fmt/WidthSpec#fill(301fc089a05c7cd9).() != ' ' || sign) { |
| 2984 | while (*start == ' ') |
| 2985 | *start++ = fill; |
| 2986 | if (sign) |
| 2987 | *(start - 1) = sign; |
| 2988 | } |
| 2989 | grow_buffercxx . . $ fmt/BasicWriter#grow_buffer(6801df611ac9c5f5).(n); |
| 2990 | } |
| 2991 | |
| 2992 | /** |
| 2993 | \rst |
| 2994 | This class template provides operations for formatting and writing data |
| 2995 | into a character stream. The output is stored in a memory buffer that grows |
| 2996 | dynamically. |
| 2997 | |
| 2998 | You can use one of the following typedefs for common character types |
| 2999 | and the standard allocator: |
| 3000 | |
| 3001 | +---------------+-----------------------------------------------------+ |
| 3002 | | Type | Definition | |
| 3003 | +===============+=====================================================+ |
| 3004 | | MemoryWriter | BasicMemoryWriter<char, std::allocator<char>> | |
| 3005 | +---------------+-----------------------------------------------------+ |
| 3006 | | WMemoryWriter | BasicMemoryWriter<wchar_t, std::allocator<wchar_t>> | |
| 3007 | +---------------+-----------------------------------------------------+ |
| 3008 | |
| 3009 | **Example**:: |
| 3010 | |
| 3011 | MemoryWriter out; |
| 3012 | out << "The answer is " << 42 << "\n"; |
| 3013 | out.write("({:+f}, {:+f})", -3.14, 3.14); |
| 3014 | |
| 3015 | This will write the following output to the ``out`` object: |
| 3016 | |
| 3017 | .. code-block:: none |
| 3018 | |
| 3019 | The answer is 42 |
| 3020 | (-3.140000, +3.140000) |
| 3021 | |
| 3022 | The output can be converted to an ``std::string`` with ``out.str()`` or |
| 3023 | accessed as a C string with ``out.c_str()``. |
| 3024 | \endrst |
| 3025 | */ |
| 3026 | template <typename Char, typename Allocator = stdcxx . . $ std/::allocatorcxx . . $ std/allocator#<Char> > |
| 3027 | class BasicMemoryWritercxx . . $ fmt/BasicMemoryWriter# : public BasicWritercxx . . $ fmt/BasicWriter#<Char> { |
| 3028 | private: |
| 3029 | internalcxx . . $ fmt/internal/::MemoryBuffercxx . . $ fmt/internal/MemoryBuffer#<Char, internalcxx . . $ fmt/internal/::INLINE_BUFFER_SIZEcxx . . $ fmt/internal/INLINE_BUFFER_SIZE., Allocator> buffer_cxx . . $ fmt/BasicMemoryWriter#buffer_.; |
| 3030 | |
| 3031 | public: |
| 3032 | explicit BasicMemoryWritercxx . . $ fmt/BasicMemoryWriter#`BasicMemoryWriter<Char, Allocator>`(3496de05b827211c).(const Allocator& alloc = Allocator()) |
| 3033 | : BasicWritercxx . . $ fmt/BasicWriter#<Char>(buffer_cxx . . $ fmt/BasicMemoryWriter#buffer_.), buffer_cxx . . $ fmt/BasicMemoryWriter#buffer_.(alloc) {} |
| 3034 | |
| 3035 | #if FMT_USE_RVALUE_REFERENCEScxx . . $ `src/common/format.h:149:11`! |
| 3036 | /** |
| 3037 | \rst |
| 3038 | Constructs a :class:`fmt::BasicMemoryWriter` object moving the content |
| 3039 | of the other object to it. |
| 3040 | \endrst |
| 3041 | */ |
| 3042 | BasicMemoryWritercxx . . $ fmt/BasicMemoryWriter#`BasicMemoryWriter<Char, Allocator>`(c9c0dd0555036d2f).(BasicMemoryWriter &&other) |
| 3043 | : BasicWritercxx . . $ fmt/BasicWriter#<Char>(buffer_cxx . . $ fmt/BasicMemoryWriter#buffer_.), buffer_cxx . . $ fmt/BasicMemoryWriter#buffer_.(stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(other.buffer_cxx . . $ fmt/BasicMemoryWriter#buffer_.)) { |
| 3044 | } |
| 3045 | |
| 3046 | /** |
| 3047 | \rst |
| 3048 | Moves the content of the other ``BasicMemoryWriter`` object to this one. |
| 3049 | \endrst |
| 3050 | */ |
| 3051 | BasicMemoryWriter &operatorcxx . . $ fmt/BasicMemoryWriter#`operator=`(25913156fda20518).=(BasicMemoryWriter &&other) { |
| 3052 | buffer_cxx . . $ fmt/BasicMemoryWriter#buffer_. = stdcxx . . $ std/::movecxx . . $ std/move(e35c19a1ba7baa26).(other.buffer_cxx . . $ fmt/BasicMemoryWriter#buffer_.); |
| 3053 | return *this; |
| 3054 | } |
| 3055 | #endif |
| 3056 | }; |
| 3057 | |
| 3058 | typedef BasicMemoryWritercxx . . $ fmt/BasicMemoryWriter#<char> MemoryWritercxx . . $ fmt/MemoryWriter#; |
| 3059 | typedef BasicMemoryWritercxx . . $ fmt/BasicMemoryWriter#<wchar_t> WMemoryWritercxx . . $ fmt/WMemoryWriter#; |
| 3060 | |
| 3061 | /** |
| 3062 | \rst |
| 3063 | This class template provides operations for formatting and writing data |
| 3064 | into a fixed-size array. For writing into a dynamically growing buffer |
| 3065 | use :class:`fmt::BasicMemoryWriter`. |
| 3066 | |
| 3067 | Any write method will throw ``std::runtime_error`` if the output doesn't fit |
| 3068 | into the array. |
| 3069 | |
| 3070 | You can use one of the following typedefs for common character types: |
| 3071 | |
| 3072 | +--------------+---------------------------+ |
| 3073 | | Type | Definition | |
| 3074 | +==============+===========================+ |
| 3075 | | ArrayWriter | BasicArrayWriter<char> | |
| 3076 | +--------------+---------------------------+ |
| 3077 | | WArrayWriter | BasicArrayWriter<wchar_t> | |
| 3078 | +--------------+---------------------------+ |
| 3079 | \endrst |
| 3080 | */ |
| 3081 | template <typename Char> |
| 3082 | class BasicArrayWritercxx . . $ fmt/BasicArrayWriter# : public BasicWritercxx . . $ fmt/BasicWriter#<Char> { |
| 3083 | private: |
| 3084 | internalcxx . . $ fmt/internal/::FixedBuffercxx . . $ fmt/internal/FixedBuffer#<Char> buffer_cxx . . $ fmt/BasicArrayWriter#buffer_.; |
| 3085 | |
| 3086 | public: |
| 3087 | /** |
| 3088 | \rst |
| 3089 | Constructs a :class:`fmt::BasicArrayWriter` object for *array* of the |
| 3090 | given size. |
| 3091 | \endrst |
| 3092 | */ |
| 3093 | BasicArrayWritercxx . . $ fmt/BasicArrayWriter#`BasicArrayWriter<Char>`(afd8256c216b84b2).(Char *array, stdcxx . . $ std/::size_tcxx . . $ std/size_t# size) |
| 3094 | : BasicWritercxx . . $ fmt/BasicWriter#<Char>(buffer_cxx . . $ fmt/BasicArrayWriter#buffer_.), buffer_cxx . . $ fmt/BasicArrayWriter#buffer_.(array, size) {} |
| 3095 | |
| 3096 | /** |
| 3097 | \rst |
| 3098 | Constructs a :class:`fmt::BasicArrayWriter` object for *array* of the |
| 3099 | size known at compile time. |
| 3100 | \endrst |
| 3101 | */ |
| 3102 | template <stdcxx . . $ std/::size_tcxx . . $ std/size_t# SIZE> |
| 3103 | explicit BasicArrayWritercxx . . $ fmt/BasicArrayWriter#`BasicArrayWriter<Char>`(211af01118bfc364).(Char(&array)[SIZE]) |
| 3104 | : BasicWritercxx . . $ fmt/BasicWriter#<Char>(buffer_cxx . . $ fmt/BasicArrayWriter#buffer_.), buffer_cxx . . $ fmt/BasicArrayWriter#buffer_.(array, SIZE) {} |
| 3105 | }; |
| 3106 | |
| 3107 | typedef BasicArrayWritercxx . . $ fmt/BasicArrayWriter#<char> ArrayWritercxx . . $ fmt/ArrayWriter#; |
| 3108 | typedef BasicArrayWritercxx . . $ fmt/BasicArrayWriter#<wchar_t> WArrayWritercxx . . $ fmt/WArrayWriter#; |
| 3109 | |
| 3110 | // Reports a system error without throwing an exception. |
| 3111 | // Can be used to report errors from destructors. |
| 3112 | FMT_APIcxx . . $ `src/common/format.h:75:10`! void report_system_errorcxx . . $ fmt/report_system_error(5342d16ac7ed7db5).(int error_code, |
| 3113 | StringRefcxx . . $ fmt/StringRef# message) FMT_NOEXCEPTcxx . . $ `src/common/format.h:188:12`!; |
| 3114 | |
| 3115 | #if FMT_USE_WINDOWS_Hcxx . . $ `src/common/format.h:958:10`! |
| 3116 | |
| 3117 | /** A Windows error. */ |
| 3118 | class WindowsError : public SystemError { |
| 3119 | private: |
| 3120 | FMT_API void init(int error_code, CStringRef format_str, ArgList args); |
| 3121 | |
| 3122 | public: |
| 3123 | /** |
| 3124 | \rst |
| 3125 | Constructs a :class:`fmt::WindowsError` object with the description |
| 3126 | of the form |
| 3127 | |
| 3128 | .. parsed-literal:: |
| 3129 | *<message>*: *<system-message>* |
| 3130 | |
| 3131 | where *<message>* is the formatted message and *<system-message>* is the |
| 3132 | system message corresponding to the error code. |
| 3133 | *error_code* is a Windows error code as given by ``GetLastError``. |
| 3134 | If *error_code* is not a valid error code such as -1, the system message |
| 3135 | will look like "error -1". |
| 3136 | |
| 3137 | **Example**:: |
| 3138 | |
| 3139 | // This throws a WindowsError with the description |
| 3140 | // cannot open file 'madeup': The system cannot find the file specified. |
| 3141 | // or similar (system message may vary). |
| 3142 | const char *filename = "madeup"; |
| 3143 | LPOFSTRUCT of = LPOFSTRUCT(); |
| 3144 | HFILE file = OpenFile(filename, &of, OF_READ); |
| 3145 | if (file == HFILE_ERROR) { |
| 3146 | throw fmt::WindowsError(GetLastError(), |
| 3147 | "cannot open file '{}'", filename); |
| 3148 | } |
| 3149 | \endrst |
| 3150 | */ |
| 3151 | WindowsError(int error_code, CStringRef message) { |
| 3152 | init(error_code, message, ArgList()); |
| 3153 | } |
| 3154 | FMT_VARIADIC_CTOR(WindowsError, init, int, CStringRef) |
| 3155 | }; |
| 3156 | |
| 3157 | // Reports a Windows error without throwing an exception. |
| 3158 | // Can be used to report errors from destructors. |
| 3159 | FMT_API void report_windows_error(int error_code, |
| 3160 | StringRef message) FMT_NOEXCEPT; |
| 3161 | |
| 3162 | #endif |
| 3163 | |
| 3164 | enum Colorcxx . . $ fmt/Color# { BLACKcxx . . $ fmt/BLACK., REDcxx . . $ fmt/RED., GREENcxx . . $ fmt/GREEN., YELLOWcxx . . $ fmt/YELLOW., BLUEcxx . . $ fmt/BLUE., MAGENTAcxx . . $ fmt/MAGENTA., CYANcxx . . $ fmt/CYAN., WHITEcxx . . $ fmt/WHITE. }; |
| 3165 | |
| 3166 | /** |
| 3167 | Formats a string and prints it to stdout using ANSI escape sequences |
| 3168 | to specify color (experimental). |
| 3169 | Example: |
| 3170 | print_colored(fmt::RED, "Elapsed time: {0:.2f} seconds", 1.23); |
| 3171 | */ |
| 3172 | FMT_APIcxx . . $ `src/common/format.h:75:10`! void print_coloredcxx . . $ fmt/print_colored(eba6a579d5b12442).(Colorcxx . . $ fmt/Color# c, CStringRefcxx . . $ fmt/CStringRef# format, ArgListcxx . . $ fmt/ArgList# args); |
| 3173 | |
| 3174 | /** |
| 3175 | \rst |
| 3176 | Formats arguments and returns the result as a string. |
| 3177 | |
| 3178 | **Example**:: |
| 3179 | |
| 3180 | std::string message = format("The answer is {}", 42); |
| 3181 | \endrst |
| 3182 | */ |
| 3183 | inline stdcxx . . $ std/::stringcxx . . $ std/string# formatcxx . . $ fmt/format(d879789e7f34a190).(CStringRefcxx . . $ fmt/CStringRef# format_str, ArgListcxx . . $ fmt/ArgList# args) { |
| 3184 | MemoryWritercxx . . $ fmt/MemoryWriter# wcxx . . $ fmt/BasicMemoryWriter#BasicMemoryWriter(3496de05b827211c).; |
| 3185 | w.writecxx . . $ fmt/BasicWriter#write(b7238e95b93927f0).(format_str, args); |
| 3186 | return w.strcxx . . $ fmt/BasicWriter#str(25a55eb745a1b6bc).(); |
| 3187 | } |
| 3188 | |
| 3189 | inline stdcxx . . $ std/::wstringcxx . . $ std/wstring# formatcxx . . $ fmt/format(27f843fe23938fb7).(WCStringRefcxx . . $ fmt/WCStringRef# format_str, ArgListcxx . . $ fmt/ArgList# args) { |
| 3190 | WMemoryWritercxx . . $ fmt/WMemoryWriter# wcxx . . $ fmt/BasicMemoryWriter#BasicMemoryWriter(3496de05b827211c).; |
| 3191 | w.writecxx . . $ fmt/BasicWriter#write(b7238e95b93927f0).(format_str, args); |
| 3192 | return w.strcxx . . $ fmt/BasicWriter#str(25a55eb745a1b6bc).(); |
| 3193 | } |
| 3194 | |
| 3195 | /** |
| 3196 | \rst |
| 3197 | Prints formatted data to the file *f*. |
| 3198 | |
| 3199 | **Example**:: |
| 3200 | |
| 3201 | print(stderr, "Don't {}!", "panic"); |
| 3202 | \endrst |
| 3203 | */ |
| 3204 | FMT_APIcxx . . $ `src/common/format.h:75:10`! void printcxx . . $ fmt/print(e8f536e71f29b79e).(stdcxx . . $ std/::FILEcxx . . $ std/FILE# *f, CStringRefcxx . . $ fmt/CStringRef# format_str, ArgListcxx . . $ fmt/ArgList# args); |
| 3205 | |
| 3206 | /** |
| 3207 | \rst |
| 3208 | Prints formatted data to ``stdout``. |
| 3209 | |
| 3210 | **Example**:: |
| 3211 | |
| 3212 | print("Elapsed time: {0:.2f} seconds", 1.23); |
| 3213 | \endrst |
| 3214 | */ |
| 3215 | FMT_APIcxx . . $ `src/common/format.h:75:10`! void printcxx . . $ fmt/print(152d9752edd7c5e9).(CStringRefcxx . . $ fmt/CStringRef# format_str, ArgListcxx . . $ fmt/ArgList# args); |
| 3216 | |
| 3217 | template <typename Char> |
| 3218 | void printfcxx . . $ fmt/printf(a24296c0c844b519).(BasicWritercxx . . $ fmt/BasicWriter#<Char> &w, BasicCStringRefcxx . . $ fmt/BasicCStringRef#<Char> format, ArgListcxx . . $ fmt/ArgList# args) { |
| 3219 | internalcxx . . $ fmt/internal/::PrintfFormattercxx . . $ fmt/internal/PrintfFormatter#<Char>(args).formatcxx . . $ fmt/internal/PrintfFormatter#format(aaacc8ac315733de).(w, format); |
| 3220 | } |
| 3221 | |
| 3222 | /** |
| 3223 | \rst |
| 3224 | Formats arguments and returns the result as a string. |
| 3225 | |
| 3226 | **Example**:: |
| 3227 | |
| 3228 | std::string message = fmt::sprintf("The answer is %d", 42); |
| 3229 | \endrst |
| 3230 | */ |
| 3231 | inline stdcxx . . $ std/::stringcxx . . $ std/string# sprintfcxx . . $ fmt/sprintf(d879789e7f34a190).(CStringRefcxx . . $ fmt/CStringRef# format, ArgListcxx . . $ fmt/ArgList# args) { |
| 3232 | MemoryWritercxx . . $ fmt/MemoryWriter# wcxx . . $ fmt/BasicMemoryWriter#BasicMemoryWriter(3496de05b827211c).; |
| 3233 | printfcxx . . $ fmt/printf(a24296c0c844b519).(w, format, args); |
| 3234 | return w.strcxx . . $ fmt/BasicWriter#str(25a55eb745a1b6bc).(); |
| 3235 | } |
| 3236 | |
| 3237 | inline stdcxx . . $ std/::wstringcxx . . $ std/wstring# sprintfcxx . . $ fmt/sprintf(27f843fe23938fb7).(WCStringRefcxx . . $ fmt/WCStringRef# format, ArgListcxx . . $ fmt/ArgList# args) { |
| 3238 | WMemoryWritercxx . . $ fmt/WMemoryWriter# wcxx . . $ fmt/BasicMemoryWriter#BasicMemoryWriter(3496de05b827211c).; |
| 3239 | printfcxx . . $ fmt/printf(a24296c0c844b519).(w, format, args); |
| 3240 | return w.strcxx . . $ fmt/BasicWriter#str(25a55eb745a1b6bc).(); |
| 3241 | } |
| 3242 | |
| 3243 | /** |
| 3244 | \rst |
| 3245 | Prints formatted data to the file *f*. |
| 3246 | |
| 3247 | **Example**:: |
| 3248 | |
| 3249 | fmt::fprintf(stderr, "Don't %s!", "panic"); |
| 3250 | \endrst |
| 3251 | */ |
| 3252 | FMT_APIcxx . . $ `src/common/format.h:75:10`! int fprintfcxx . . $ fmt/fprintf(796076e824467111).(stdcxx . . $ std/::FILEcxx . . $ std/FILE# *f, CStringRefcxx . . $ fmt/CStringRef# format, ArgListcxx . . $ fmt/ArgList# args); |
| 3253 | |
| 3254 | /** |
| 3255 | \rst |
| 3256 | Prints formatted data to ``stdout``. |
| 3257 | |
| 3258 | **Example**:: |
| 3259 | |
| 3260 | fmt::printf("Elapsed time: %.2f seconds", 1.23); |
| 3261 | \endrst |
| 3262 | */ |
| 3263 | inline int printfcxx . . $ fmt/printf(4548c8ea2f90ab3a).(CStringRefcxx . . $ fmt/CStringRef# format, ArgListcxx . . $ fmt/ArgList# args) { |
| 3264 | return fprintfcxx . . $ fmt/fprintf(796076e824467111).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!, format, args); |
| 3265 | } |
| 3266 | |
| 3267 | /** |
| 3268 | Fast integer formatter. |
| 3269 | */ |
| 3270 | class FormatIntcxx . . $ fmt/FormatInt# { |
| 3271 | private: |
| 3272 | // Buffer should be large enough to hold all digits (digits10 + 1), |
| 3273 | // a sign and a null character. |
| 3274 | enumcxx . . $ fmt/FormatInt#$anonymous_type_16# { BUFFER_SIZEcxx . . $ fmt/FormatInt#BUFFER_SIZE. = stdcxx . . $ std/::numeric_limitscxx . . $ std/numeric_limits#<ULongLong>::digits10cxx . . $ std/numeric_limits#digits10. + 3 }; |
| 3275 | mutable char buffer_cxx . . $ fmt/FormatInt#buffer_.[BUFFER_SIZEcxx . . $ fmt/FormatInt#BUFFER_SIZE.]; |
| 3276 | char *str_cxx . . $ fmt/FormatInt#str_.; |
| 3277 | |
| 3278 | // Formats value in reverse and returns the number of digits. |
| 3279 | char *format_decimalcxx . . $ fmt/FormatInt#format_decimal(ee268fec028f830b).(ULongLongcxx . . $ fmt/ULongLong# value) { |
| 3280 | char *buffer_end = buffer_cxx . . $ fmt/FormatInt#buffer_. + BUFFER_SIZEcxx . . $ fmt/FormatInt#BUFFER_SIZE. - 1; |
| 3281 | while (value >= 100) { |
| 3282 | // Integer division is slow so do it for a group of two digits instead |
| 3283 | // of for every digit. The idea comes from the talk by Alexandrescu |
| 3284 | // "Three Optimization Tips for C++". See speed-test for a comparison. |
| 3285 | unsigned index = static_cast<unsigned>((value % 100) * 2); |
| 3286 | value /= 100; |
| 3287 | *--buffer_end = internalcxx . . $ fmt/internal/::Datacxx . . $ fmt/internal/Data#::DIGITScxx . . $ fmt/internal/BasicData#DIGITS.[index + 1]; |
| 3288 | *--buffer_end = internalcxx . . $ fmt/internal/::Datacxx . . $ fmt/internal/Data#::DIGITScxx . . $ fmt/internal/BasicData#DIGITS.[index]; |
| 3289 | } |
| 3290 | if (value < 10) { |
| 3291 | *--buffer_end = static_cast<char>('0' + value); |
| 3292 | return buffer_end; |
| 3293 | } |
| 3294 | unsigned index = static_cast<unsigned>(value * 2); |
| 3295 | *--buffer_end = internalcxx . . $ fmt/internal/::Datacxx . . $ fmt/internal/Data#::DIGITScxx . . $ fmt/internal/BasicData#DIGITS.[index + 1]; |
| 3296 | *--buffer_end = internalcxx . . $ fmt/internal/::Datacxx . . $ fmt/internal/Data#::DIGITScxx . . $ fmt/internal/BasicData#DIGITS.[index]; |
| 3297 | return buffer_end; |
| 3298 | } |
| 3299 | |
| 3300 | void FormatSignedcxx . . $ fmt/FormatInt#FormatSigned(35cb52607f6af42f).(LongLongcxx . . $ fmt/LongLong# value) { |
| 3301 | ULongLongcxx . . $ fmt/ULongLong# abs_value = static_cast<ULongLongcxx . . $ fmt/ULongLong#>(value); |
| 3302 | bool negative = value < 0; |
| 3303 | if (negative) |
| 3304 | abs_value = 0 - abs_value; |
| 3305 | str_cxx . . $ fmt/FormatInt#str_. = format_decimalcxx . . $ fmt/FormatInt#format_decimal(ee268fec028f830b).(abs_value); |
| 3306 | if (negative) |
| 3307 | *--str_cxx . . $ fmt/FormatInt#str_. = '-'; |
| 3308 | } |
| 3309 | |
| 3310 | public: |
| 3311 | explicit FormatIntcxx . . $ fmt/FormatInt#FormatInt(d4f767463ce0a6b3).(int value) { FormatSignedcxx . . $ fmt/FormatInt#FormatSigned(35cb52607f6af42f).(value); } |
| 3312 | explicit FormatIntcxx . . $ fmt/FormatInt#FormatInt(1624ee8275b10bda).(long value) { FormatSignedcxx . . $ fmt/FormatInt#FormatSigned(35cb52607f6af42f).(value); } |
| 3313 | explicit FormatIntcxx . . $ fmt/FormatInt#FormatInt(35cb52607f6af42f).(LongLongcxx . . $ fmt/LongLong# value) { FormatSignedcxx . . $ fmt/FormatInt#FormatSigned(35cb52607f6af42f).(value); } |
| 3314 | explicit FormatIntcxx . . $ fmt/FormatInt#FormatInt(cb2f890c2fdad230).(unsigned value) : str_cxx . . $ fmt/FormatInt#str_.(format_decimalcxx . . $ fmt/FormatInt#format_decimal(ee268fec028f830b).(value)) {} |
| 3315 | explicit FormatIntcxx . . $ fmt/FormatInt#FormatInt(2c44cd906ae4e829).(unsigned long value) : str_cxx . . $ fmt/FormatInt#str_.(format_decimalcxx . . $ fmt/FormatInt#format_decimal(ee268fec028f830b).(value)) {} |
| 3316 | explicit FormatIntcxx . . $ fmt/FormatInt#FormatInt(891dc3055356b409).(ULongLongcxx . . $ fmt/ULongLong# value) : str_cxx . . $ fmt/FormatInt#str_.(format_decimalcxx . . $ fmt/FormatInt#format_decimal(ee268fec028f830b).(value)) {} |
| 3317 | |
| 3318 | /** Returns the number of characters written to the output buffer. */ |
| 3319 | stdcxx . . $ std/::size_tcxx . . $ std/size_t# sizecxx . . $ fmt/FormatInt#size(fe4d2d262d4164a8).() const { |
| 3320 | return internalcxx . . $ fmt/internal/::to_unsignedcxx . . $ fmt/internal/to_unsigned(4de866539cf5f5fc).(buffer_cxx . . $ fmt/FormatInt#buffer_. - str_cxx . . $ fmt/FormatInt#str_. + BUFFER_SIZEcxx . . $ fmt/FormatInt#BUFFER_SIZE. - 1); |
| 3321 | } |
| 3322 | |
| 3323 | /** |
| 3324 | Returns a pointer to the output buffer content. No terminating null |
| 3325 | character is appended. |
| 3326 | */ |
| 3327 | const char *datacxx . . $ fmt/FormatInt#data(a9f41ea0e82d88cf).() const { return str_cxx . . $ fmt/FormatInt#str_.; } |
| 3328 | |
| 3329 | /** |
| 3330 | Returns a pointer to the output buffer content with terminating null |
| 3331 | character appended. |
| 3332 | */ |
| 3333 | const char *c_strcxx . . $ fmt/FormatInt#c_str(a9f41ea0e82d88cf).() const { |
| 3334 | buffer_cxx . . $ fmt/FormatInt#buffer_.[BUFFER_SIZEcxx . . $ fmt/FormatInt#BUFFER_SIZE. - 1] = '\0'; |
| 3335 | return str_cxx . . $ fmt/FormatInt#str_.; |
| 3336 | } |
| 3337 | |
| 3338 | /** |
| 3339 | \rst |
| 3340 | Returns the content of the output buffer as an ``std::string``. |
| 3341 | \endrst |
| 3342 | */ |
| 3343 | stdcxx . . $ std/::stringcxx . . $ std/string# strcxx . . $ fmt/FormatInt#str(219584694fe2b248).() const { return stdcxx . . $ std/__cxx11/basic_string#basic_string(f26a9578972d3fae).::stringcxx . . $ std/string#(str_cxx . . $ fmt/FormatInt#str_., sizecxx . . $ fmt/FormatInt#size(fe4d2d262d4164a8).()); } |
| 3344 | }; |
| 3345 | |
| 3346 | // Formats a decimal integer value writing into buffer and returns |
| 3347 | // a pointer to the end of the formatted string. This function doesn't |
| 3348 | // write a terminating null character. |
| 3349 | template <typename T> |
| 3350 | inline void format_decimalcxx . . $ fmt/format_decimal(f1d35d734a158171).(char *&buffer, T value) { |
| 3351 | typedef typename internalcxx . . $ fmt/internal/::IntTraitscxx . . $ fmt/internal/IntTraits#<T>::MainType MainTypecxx . . $ fmt/format_decimal(f1d35d734a158171).MainType#; |
| 3352 | MainTypecxx . . $ fmt/format_decimal(f1d35d734a158171).MainType# abs_value = static_cast<MainTypecxx . . $ fmt/format_decimal(f1d35d734a158171).MainType#>(value); |
| 3353 | if (internalcxx . . $ fmt/internal/::is_negativecxx . . $ fmt/internal/is_negative(ee44d93984fb03e9).(value)) { |
| 3354 | *buffer++ = '-'; |
| 3355 | abs_value = 0 - abs_value; |
| 3356 | } |
| 3357 | if (abs_value < 100) { |
| 3358 | if (abs_value < 10) { |
| 3359 | *buffer++ = static_cast<char>('0' + abs_value); |
| 3360 | return; |
| 3361 | } |
| 3362 | unsigned index = static_cast<unsigned>(abs_value * 2); |
| 3363 | *buffer++ = internalcxx . . $ fmt/internal/::Datacxx . . $ fmt/internal/Data#::DIGITScxx . . $ fmt/internal/BasicData#DIGITS.[index]; |
| 3364 | *buffer++ = internalcxx . . $ fmt/internal/::Datacxx . . $ fmt/internal/Data#::DIGITScxx . . $ fmt/internal/BasicData#DIGITS.[index + 1]; |
| 3365 | return; |
| 3366 | } |
| 3367 | unsigned num_digits = internalcxx . . $ fmt/internal/::count_digitscxx . . $ fmt/internal/count_digits(2141b656ce2cc063).(abs_value); |
| 3368 | internalcxx . . $ fmt/internal/::format_decimalcxx . . $ fmt/internal/format_decimal(e36525a719ed0f39).(buffer, abs_value, num_digits); |
| 3369 | buffer += num_digits; |
| 3370 | } |
| 3371 | |
| 3372 | /** |
| 3373 | \rst |
| 3374 | Returns a named argument for formatting functions. |
| 3375 | |
| 3376 | **Example**:: |
| 3377 | |
| 3378 | print("Elapsed time: {s:.2f} seconds", arg("s", 1.23)); |
| 3379 | |
| 3380 | \endrst |
| 3381 | */ |
| 3382 | template <typename T> |
| 3383 | inline internalcxx . . $ fmt/internal/::NamedArgcxx . . $ fmt/internal/NamedArg#<char> argcxx . . $ fmt/arg(2dd0086edb5f37ee).(StringRefcxx . . $ fmt/StringRef# name, const T &arg) { |
| 3384 | return internalcxx . . $ fmt/internal/::NamedArgcxx . . $ fmt/internal/NamedArg#<char>(name, arg); |
| 3385 | } |
| 3386 | |
| 3387 | template <typename T> |
| 3388 | inline internalcxx . . $ fmt/internal/::NamedArgcxx . . $ fmt/internal/NamedArg#<wchar_t> argcxx . . $ fmt/arg(79f96c4fa6730bca).(WStringRefcxx . . $ fmt/WStringRef# name, const T &arg) { |
| 3389 | return internalcxx . . $ fmt/internal/::NamedArgcxx . . $ fmt/internal/NamedArg#<wchar_t>(name, arg); |
| 3390 | } |
| 3391 | |
| 3392 | // The following two functions are deleted intentionally to disable |
| 3393 | // nested named arguments as in ``format("{}", arg("a", arg("b", 42)))``. |
| 3394 | template <typename Char> |
| 3395 | void argcxx . . $ fmt/arg(6143f6955ddfa1ba).(StringRefcxx . . $ fmt/StringRef#, const internalcxx . . $ fmt/internal/::NamedArgcxx . . $ fmt/internal/NamedArg#<Char>&) FMT_DELETED_OR_UNDEFINEDcxx . . $ `src/common/format.h:216:10`!; |
| 3396 | template <typename Char> |
| 3397 | void argcxx . . $ fmt/arg(7dfa94cad9d78113).(WStringRefcxx . . $ fmt/WStringRef#, const internalcxx . . $ fmt/internal/::NamedArgcxx . . $ fmt/internal/NamedArg#<Char>&) FMT_DELETED_OR_UNDEFINEDcxx . . $ `src/common/format.h:216:10`!; |
| 3398 | } |
| 3399 | |
| 3400 | #if FMT_GCC_VERSIONcxx . . $ `src/common/format.h:79:10`! |
| 3401 | // Use the system_header pragma to suppress warnings about variadic macros |
| 3402 | // because suppressing -Wvariadic-macros with the diagnostic pragma doesn't |
| 3403 | // work. It is used at the end because we want to suppress as little warnings |
| 3404 | // as possible. |
| 3405 | # pragma GCC system_header |
| 3406 | #endif |
| 3407 | |
| 3408 | // This is used to work around VC++ bugs in handling variadic macros. |
| 3409 | #define FMT_EXPANDcxx . . $ `src/common/format.h:3409:9`!(args) args |
| 3410 | |
| 3411 | // Returns the number of arguments. |
| 3412 | // Based on https://groups.google.com/forum/#!topic/comp.std.c/d-6Mj5Lko_s. |
| 3413 | #define FMT_NARGcxx . . $ `src/common/format.h:3413:9`!(...) FMT_NARG_cxx . . $ `src/common/format.h:3414:9`!(__VA_ARGS__, FMT_RSEQ_Ncxx . . $ `src/common/format.h:3416:9`!()) |
| 3414 | #define FMT_NARG_cxx . . $ `src/common/format.h:3414:9`!(...) FMT_EXPANDcxx . . $ `src/common/format.h:3409:9`!(FMT_ARG_Ncxx . . $ `src/common/format.h:3415:9`!(__VA_ARGS__)) |
| 3415 | #define FMT_ARG_Ncxx . . $ `src/common/format.h:3415:9`!(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N |
| 3416 | #define FMT_RSEQ_Ncxx . . $ `src/common/format.h:3416:9`!() 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 |
| 3417 | |
| 3418 | #define FMT_CONCATcxx . . $ `src/common/format.h:3418:9`!(a, b) a##b |
| 3419 | #define FMT_FOR_EACH_cxx . . $ `src/common/format.h:3419:9`!(N, f, ...) \ |
| 3420 | FMT_EXPANDcxx . . $ `src/common/format.h:3409:9`!(FMT_CONCATcxx . . $ `src/common/format.h:3418:9`!(FMT_FOR_EACH, N)(f, __VA_ARGS__)) |
| 3421 | #define FMT_FOR_EACHcxx . . $ `src/common/format.h:3421:9`!(f, ...) \ |
| 3422 | FMT_EXPANDcxx . . $ `src/common/format.h:3409:9`!(FMT_FOR_EACH_cxx . . $ `src/common/format.h:3419:9`!(FMT_NARGcxx . . $ `src/common/format.h:3413:9`!(__VA_ARGS__), f, __VA_ARGS__)) |
| 3423 | |
| 3424 | #define FMT_ADD_ARG_NAMEcxx . . $ `src/common/format.h:3424:9`!(type, index) type arg##index |
| 3425 | #define FMT_GET_ARG_NAMEcxx . . $ `src/common/format.h:3425:9`!(type, index) arg##index |
| 3426 | |
| 3427 | #if FMT_USE_VARIADIC_TEMPLATEScxx . . $ `src/common/format.h:138:10`! |
| 3428 | # define FMT_VARIADIC_cxx . . $ `src/common/format.h:3428:10`!(Char, ReturnType, func, call, ...) \ |
| 3429 | template <typename... Args> \ |
| 3430 | ReturnType func(FMT_FOR_EACHcxx . . $ `src/common/format.h:3421:9`!(FMT_ADD_ARG_NAMEcxx . . $ `src/common/format.h:3424:9`!, __VA_ARGS__), \ |
| 3431 | const Args & ... args) { \ |
| 3432 | typedef fmt::internal::ArgArray<sizeof...(Args)> ArgArray; \ |
| 3433 | typename ArgArray::Type array{ \ |
| 3434 | ArgArray::template make<fmt::BasicFormatter<Char> >(args)...}; \ |
| 3435 | call(FMT_FOR_EACHcxx . . $ `src/common/format.h:3421:9`!(FMT_GET_ARG_NAMEcxx . . $ `src/common/format.h:3425:9`!, __VA_ARGS__), \ |
| 3436 | fmt::ArgList(fmt::internal::make_type(args...), array)); \ |
| 3437 | } |
| 3438 | #else |
| 3439 | // Defines a wrapper for a function taking __VA_ARGS__ arguments |
| 3440 | // and n additional arguments of arbitrary types. |
| 3441 | # define FMT_WRAP(Char, ReturnType, func, call, n, ...) \ |
| 3442 | template <FMT_GEN(n, FMT_MAKE_TEMPLATE_ARG)> \ |
| 3443 | inline ReturnType func(FMT_FOR_EACH(FMT_ADD_ARG_NAME, __VA_ARGS__), \ |
| 3444 | FMT_GEN(n, FMT_MAKE_ARG)) { \ |
| 3445 | fmt::internal::ArgArray<n>::Type arr; \ |
| 3446 | FMT_GEN(n, FMT_ASSIGN_##Char); \ |
| 3447 | call(FMT_FOR_EACH(FMT_GET_ARG_NAME, __VA_ARGS__), fmt::ArgList( \ |
| 3448 | fmt::internal::make_type(FMT_GEN(n, FMT_MAKE_REF2)), arr)); \ |
| 3449 | } |
| 3450 | |
| 3451 | # define FMT_VARIADIC_(Char, ReturnType, func, call, ...) \ |
| 3452 | inline ReturnType func(FMT_FOR_EACH(FMT_ADD_ARG_NAME, __VA_ARGS__)) { \ |
| 3453 | call(FMT_FOR_EACH(FMT_GET_ARG_NAME, __VA_ARGS__), fmt::ArgList()); \ |
| 3454 | } \ |
| 3455 | FMT_WRAP(Char, ReturnType, func, call, 1, __VA_ARGS__) \ |
| 3456 | FMT_WRAP(Char, ReturnType, func, call, 2, __VA_ARGS__) \ |
| 3457 | FMT_WRAP(Char, ReturnType, func, call, 3, __VA_ARGS__) \ |
| 3458 | FMT_WRAP(Char, ReturnType, func, call, 4, __VA_ARGS__) \ |
| 3459 | FMT_WRAP(Char, ReturnType, func, call, 5, __VA_ARGS__) \ |
| 3460 | FMT_WRAP(Char, ReturnType, func, call, 6, __VA_ARGS__) \ |
| 3461 | FMT_WRAP(Char, ReturnType, func, call, 7, __VA_ARGS__) \ |
| 3462 | FMT_WRAP(Char, ReturnType, func, call, 8, __VA_ARGS__) \ |
| 3463 | FMT_WRAP(Char, ReturnType, func, call, 9, __VA_ARGS__) \ |
| 3464 | FMT_WRAP(Char, ReturnType, func, call, 10, __VA_ARGS__) \ |
| 3465 | FMT_WRAP(Char, ReturnType, func, call, 11, __VA_ARGS__) \ |
| 3466 | FMT_WRAP(Char, ReturnType, func, call, 12, __VA_ARGS__) \ |
| 3467 | FMT_WRAP(Char, ReturnType, func, call, 13, __VA_ARGS__) \ |
| 3468 | FMT_WRAP(Char, ReturnType, func, call, 14, __VA_ARGS__) \ |
| 3469 | FMT_WRAP(Char, ReturnType, func, call, 15, __VA_ARGS__) |
| 3470 | #endif // FMT_USE_VARIADIC_TEMPLATES |
| 3471 | |
| 3472 | /** |
| 3473 | \rst |
| 3474 | Defines a variadic function with the specified return type, function name |
| 3475 | and argument types passed as variable arguments to this macro. |
| 3476 | |
| 3477 | **Example**:: |
| 3478 | |
| 3479 | void print_error(const char *file, int line, const char *format, |
| 3480 | fmt::ArgList args) { |
| 3481 | fmt::print("{}: {}: ", file, line); |
| 3482 | fmt::print(format, args); |
| 3483 | } |
| 3484 | FMT_VARIADIC(void, print_error, const char *, int, const char *) |
| 3485 | |
| 3486 | ``FMT_VARIADIC`` is used for compatibility with legacy C++ compilers that |
| 3487 | don't implement variadic templates. You don't have to use this macro if |
| 3488 | you don't need legacy compiler support and can use variadic templates |
| 3489 | directly:: |
| 3490 | |
| 3491 | template <typename... Args> |
| 3492 | void print_error(const char *file, int line, const char *format, |
| 3493 | const Args & ... args) { |
| 3494 | fmt::print("{}: {}: ", file, line); |
| 3495 | fmt::print(format, args...); |
| 3496 | } |
| 3497 | \endrst |
| 3498 | */ |
| 3499 | #define FMT_VARIADICcxx . . $ `src/common/format.h:3499:9`!(ReturnType, func, ...) \ |
| 3500 | FMT_VARIADIC_cxx . . $ `src/common/format.h:3428:10`!(char, ReturnType, func, return func, __VA_ARGS__) |
| 3501 | |
| 3502 | #define FMT_VARIADIC_Wcxx . . $ `src/common/format.h:3502:9`!(ReturnType, func, ...) \ |
| 3503 | FMT_VARIADIC_cxx . . $ `src/common/format.h:3428:10`!(wchar_t, ReturnType, func, return func, __VA_ARGS__) |
| 3504 | |
| 3505 | #define FMT_CAPTURE_ARG_cxx . . $ `src/common/format.h:3505:9`!(id, index) ::fmt::arg(#id, id) |
| 3506 | |
| 3507 | #define FMT_CAPTURE_ARG_W_cxx . . $ `src/common/format.h:3507:9`!(id, index) ::fmt::arg(L###id, id) |
| 3508 | |
| 3509 | /** |
| 3510 | \rst |
| 3511 | Convenient macro to capture the arguments' names and values into several |
| 3512 | ``fmt::arg(name, value)``. |
| 3513 | |
| 3514 | **Example**:: |
| 3515 | |
| 3516 | int x = 1, y = 2; |
| 3517 | print("point: ({x}, {y})", FMT_CAPTURE(x, y)); |
| 3518 | // same as: |
| 3519 | // print("point: ({x}, {y})", arg("x", x), arg("y", y)); |
| 3520 | |
| 3521 | \endrst |
| 3522 | */ |
| 3523 | #define FMT_CAPTUREcxx . . $ `src/common/format.h:3523:9`!(...) FMT_FOR_EACH(FMT_CAPTURE_ARG_, __VA_ARGS__) |
| 3524 | |
| 3525 | #define FMT_CAPTURE_Wcxx . . $ `src/common/format.h:3525:9`!(...) FMT_FOR_EACH(FMT_CAPTURE_ARG_W_, __VA_ARGS__) |
| 3526 | |
| 3527 | namespace fmtcxx . . $ fmt/ { |
| 3528 | FMT_VARIADICcxx . . $ fmt/format(d879789e7f34a190).(std::string, format, CStringRef) |
| 3529 | FMT_VARIADIC_Wcxx . . $ fmt/BasicFormatter#(std::wstring, format, WCStringRef) |
| 3530 | FMT_VARIADICcxx . . $ `src/common/format.h:3499:9`!(void, print, CStringRef) |
| 3531 | FMT_VARIADICcxx . . $ fmt/print(48b87ac3cb87cdb4).(void, print, std::FILE *, CStringRef) |
| 3532 | |
| 3533 | FMT_VARIADICcxx . . $ fmt/internal/make_type(f708dce9a8856c70).(void, print_colored, Color, CStringRef) |
| 3534 | FMT_VARIADICcxx . . $ fmt/(std::string, sprintf, CStringRef) |
| 3535 | FMT_VARIADIC_Wcxx . . $ `src/common/format.h:3502:9`!(std::wstring, sprintf, WCStringRef) |
| 3536 | FMT_VARIADICcxx . . $ fmt/CStringRef#(int, printf, CStringRef) |
| 3537 | FMT_VARIADICcxx . . $ fmt/(int, fprintf, std::FILE *, CStringRef) |
| 3538 | |
| 3539 | namespace internalcxx . . $ fmt/internal/ { |
| 3540 | template <typename Char> |
| 3541 | inline bool is_name_startcxx . . $ fmt/internal/is_name_start(ee44d93984fb03e9).(Char c) { |
| 3542 | return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || '_' == c; |
| 3543 | } |
| 3544 | |
| 3545 | // Parses an unsigned integer advancing s to the end of the parsed input. |
| 3546 | // This function assumes that the first character of s is a digit. |
| 3547 | template <typename Char> |
| 3548 | unsigned parse_nonnegative_intcxx . . $ fmt/internal/parse_nonnegative_int(a964adceb31d1037).(const Char *&s) { |
| 3549 | assertcxx . . $ `/usr/include/assert.h:102:11`!('0' <= *s && *s <= '9'); |
| 3550 | unsigned value = 0; |
| 3551 | do { |
| 3552 | unsigned new_value = value * 10 + (*s++ - '0'); |
| 3553 | // Check if value wrapped around. |
| 3554 | if (new_value < value) { |
| 3555 | value = (stdcxx . . $ std/::numeric_limitscxx . . $ std/numeric_limits#<unsigned>::maxcxx . . $ std/numeric_limits#max(2658d6455debfaef).)(); |
| 3556 | break; |
| 3557 | } |
| 3558 | value = new_value; |
| 3559 | } while ('0' <= *s && *s <= '9'); |
| 3560 | // Convert to unsigned to prevent a warning. |
| 3561 | unsigned max_int = (stdcxx . . $ std/::numeric_limitscxx . . $ std/numeric_limits#<int>::maxcxx . . $ std/numeric_limits#max(9efc7249d839d30e).)(); |
| 3562 | if (value > max_int) |
| 3563 | FMT_THROWcxx . . $ fmt/FormatError#FormatError(330b15046e8ecb2a).(FormatError("number is too big")); |
| 3564 | return value; |
| 3565 | } |
| 3566 | |
| 3567 | inline void require_numeric_argumentcxx . . $ fmt/internal/require_numeric_argument(50006c08498df49e).(const Argcxx . . $ fmt/internal/Arg# &arg, char spec) { |
| 3568 | if (arg.typecxx . . $ fmt/internal/Arg#type. > Argcxx . . $ fmt/internal/Arg#::LAST_NUMERIC_TYPEcxx . . $ fmt/internal/Value#LAST_NUMERIC_TYPE.) { |
| 3569 | stdcxx . . $ std/::stringcxx . . $ std/string# message = |
| 3570 | fmtcxx . . $ fmt/::formatcxx . . $ fmt/format(9dfaebe7421e19ae).("format specifier '{}' requires numeric argument"cxx . . $ fmt/BasicCStringRef#BasicCStringRef(88376428bb603c08)., spec); |
| 3571 | FMT_THROWcxx . . $ fmt/FormatError#FormatError(330b15046e8ecb2a).(fmt::FormatError(message)); |
| 3572 | } |
| 3573 | } |
| 3574 | |
| 3575 | template <typename Char> |
| 3576 | void check_signcxx . . $ fmt/internal/check_sign(bccb93ef06654dc8).(const Char *&s, const Argcxx . . $ fmt/internal/Arg# &arg) { |
| 3577 | char sign = static_cast<char>(*s); |
| 3578 | require_numeric_argumentcxx . . $ fmt/internal/require_numeric_argument(50006c08498df49e).(arg, sign); |
| 3579 | if (arg.typecxx . . $ fmt/internal/Arg#type. == Argcxx . . $ fmt/internal/Arg#::UINTcxx . . $ fmt/internal/Value#UINT. || arg.typecxx . . $ fmt/internal/Arg#type. == Argcxx . . $ fmt/internal/Arg#::ULONG_LONGcxx . . $ fmt/internal/Value#ULONG_LONG.) { |
| 3580 | FMT_THROWcxx . . $ fmt/BasicCStringRef#BasicCStringRef(88376428bb603c08).(FormatError(fmt::format( |
| 3581 | "format specifier '{}' requires signed argument", sign))); |
| 3582 | } |
| 3583 | ++s; |
| 3584 | } |
| 3585 | } // namespace internal |
| 3586 | |
| 3587 | template <typename Char, typename AF> |
| 3588 | inline internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg# BasicFormattercxx . . $ fmt/BasicFormatter#<Char, AF>::get_argcxx . . $ fmt/BasicFormatter#get_arg(3cf793eda88c402a).( |
| 3589 | BasicStringRefcxx . . $ fmt/BasicStringRef#<Charcxx . . $ fmt/BasicFormatter#Char#> arg_name, const char *&error) { |
| 3590 | if (check_no_auto_indexcxx . . $ fmt/internal/FormatterBase#check_no_auto_index(339e8548b0624983).(error)) { |
| 3591 | map_cxx . . $ fmt/BasicFormatter#map_..initcxx . . $ fmt/internal/ArgMap#init(10fb0965a9c0bb8c).(argscxx . . $ fmt/internal/FormatterBase#args(ab5cc86d4ab31ef3).()); |
| 3592 | const internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg# *arg = map_cxx . . $ fmt/BasicFormatter#map_..findcxx . . $ fmt/internal/ArgMap#find(51ff5ba4c57f142f).(arg_name); |
| 3593 | if (arg) |
| 3594 | return *arg; |
| 3595 | error = "argument not found"; |
| 3596 | } |
| 3597 | return internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg#(); |
| 3598 | } |
| 3599 | |
| 3600 | template <typename Char, typename AF> |
| 3601 | inline internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg# BasicFormattercxx . . $ fmt/BasicFormatter#<Char, AF>::parse_arg_indexcxx . . $ fmt/BasicFormatter#parse_arg_index(4ce1381982b64b8).(const Charcxx . . $ fmt/BasicFormatter#Char# *&s) { |
| 3602 | const char *error = 0; |
| 3603 | internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg# arg = *s < '0' || *s > '9' ? |
| 3604 | next_argcxx . . $ fmt/internal/FormatterBase#next_arg(706a258656295a38).(error) : get_argcxx . . $ fmt/BasicFormatter#get_arg(e6750e432c057443).(internalcxx . . $ fmt/internal/::parse_nonnegative_intcxx . . $ fmt/internal/parse_nonnegative_int(a964adceb31d1037).(s), error); |
| 3605 | if (error) { |
| 3606 | FMT_THROWcxx . . $ fmt/FormatError#(FormatError( |
| 3607 | *s != '}' && *s != ':' ? "invalid format string" : error)); |
| 3608 | } |
| 3609 | return arg; |
| 3610 | } |
| 3611 | |
| 3612 | template <typename Char, typename AF> |
| 3613 | inline internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg# BasicFormattercxx . . $ fmt/BasicFormatter#<Char, AF>::parse_arg_namecxx . . $ fmt/BasicFormatter#parse_arg_name(4ce1381982b64b8).(const Charcxx . . $ fmt/BasicFormatter#Char# *&s) { |
| 3614 | assertcxx . . $ fmt/internal/(internal::is_name_start(*s)); |
| 3615 | const Charcxx . . $ fmt/BasicFormatter#Char# *start = s; |
| 3616 | Charcxx . . $ fmt/BasicFormatter#Char# c; |
| 3617 | do { |
| 3618 | c = *++s; |
| 3619 | } while (internalcxx . . $ fmt/internal/::is_name_startcxx . . $ fmt/internal/is_name_start(ee44d93984fb03e9).(c) || ('0' <= c && c <= '9')); |
| 3620 | const char *error = 0; |
| 3621 | internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg# arg = get_argcxx . . $ fmt/BasicFormatter#get_arg(e6750e432c057443).(BasicStringRefcxx . . $ fmt/BasicStringRef#<Charcxx . . $ fmt/BasicFormatter#Char#>(start, s - start), error); |
| 3622 | if (error) |
| 3623 | FMT_THROWcxx . . $ `src/common/format.h:172:11`!(FormatError(error)); |
| 3624 | return arg; |
| 3625 | } |
| 3626 | |
| 3627 | template <typename Char, typename ArgFormatter> |
| 3628 | const Char *BasicFormattercxx . . $ fmt/BasicFormatter#<Char, ArgFormatter>::formatcxx . . $ fmt/BasicFormatter#format(3077b68864ed6c04).( |
| 3629 | const Charcxx . . $ fmt/BasicFormatter#Char# *&format_str, const internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg# &arg) { |
| 3630 | using internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg#; |
| 3631 | const Charcxx . . $ fmt/BasicFormatter#Char# *s = format_str; |
| 3632 | FormatSpeccxx . . $ fmt/FormatSpec# speccxx . . $ fmt/FormatSpec#FormatSpec(38cf5fc7ed65b972).; |
| 3633 | if (*s == ':') { |
| 3634 | if (arg.typecxx . . $ fmt/internal/Arg#type. == Argcxx . . $ fmt/internal/Arg#::CUSTOMcxx . . $ fmt/internal/Value#CUSTOM.) { |
| 3635 | arg.customcxx . . $ fmt/internal/Value#$anonymous_type_1#custom..formatcxx . . $ fmt/internal/Value#CustomValue#format.(this, arg.customcxx . . $ fmt/internal/Value#$anonymous_type_1#custom..valuecxx . . $ fmt/internal/Value#CustomValue#value., &s); |
| 3636 | return s; |
| 3637 | } |
| 3638 | ++s; |
| 3639 | // Parse fill and alignment. |
| 3640 | if (Charcxx . . $ fmt/BasicFormatter#Char# c = *s) { |
| 3641 | const Charcxx . . $ fmt/BasicFormatter#Char# *p = s + 1; |
| 3642 | spec.align_cxx . . $ fmt/AlignSpec#align_. = ALIGN_DEFAULTcxx . . $ fmt/ALIGN_DEFAULT.; |
| 3643 | do { |
| 3644 | switch (*p) { |
| 3645 | case '<': |
| 3646 | spec.align_cxx . . $ fmt/AlignSpec#align_. = ALIGN_LEFTcxx . . $ fmt/ALIGN_LEFT.; |
| 3647 | break; |
| 3648 | case '>': |
| 3649 | spec.align_cxx . . $ fmt/AlignSpec#align_. = ALIGN_RIGHTcxx . . $ fmt/ALIGN_RIGHT.; |
| 3650 | break; |
| 3651 | case '=': |
| 3652 | spec.align_cxx . . $ fmt/AlignSpec#align_. = ALIGN_NUMERICcxx . . $ fmt/ALIGN_NUMERIC.; |
| 3653 | break; |
| 3654 | case '^': |
| 3655 | spec.align_cxx . . $ fmt/AlignSpec#align_. = ALIGN_CENTERcxx . . $ fmt/ALIGN_CENTER.; |
| 3656 | break; |
| 3657 | } |
| 3658 | if (spec.align_cxx . . $ fmt/AlignSpec#align_. != ALIGN_DEFAULTcxx . . $ fmt/ALIGN_DEFAULT.) { |
| 3659 | if (p != s) { |
| 3660 | if (c == '}') break; |
| 3661 | if (c == '{') |
| 3662 | FMT_THROWcxx . . $ fmt/FormatError#FormatError(330b15046e8ecb2a).(FormatError("invalid fill character '{'")); |
| 3663 | s += 2; |
| 3664 | spec.fill_cxx . . $ fmt/WidthSpec#fill_. = c; |
| 3665 | } |
| 3666 | else ++s; |
| 3667 | if (spec.align_cxx . . $ fmt/AlignSpec#align_. == ALIGN_NUMERICcxx . . $ fmt/ALIGN_NUMERIC.) |
| 3668 | require_numeric_argumentcxx . . $ fmt/internal/require_numeric_argument(50006c08498df49e).(arg, '='); |
| 3669 | break; |
| 3670 | } |
| 3671 | } while (--p >= s); |
| 3672 | } |
| 3673 | |
| 3674 | // Parse sign. |
| 3675 | switch (*s) { |
| 3676 | case '+': |
| 3677 | check_sign(s, arg); |
| 3678 | spec.flags_cxx . . $ fmt/FormatSpec#flags_. |= SIGN_FLAGcxx . . $ fmt/SIGN_FLAG. | PLUS_FLAGcxx . . $ fmt/PLUS_FLAG.; |
| 3679 | break; |
| 3680 | case '-': |
| 3681 | check_sign(s, arg); |
| 3682 | spec.flags_cxx . . $ fmt/FormatSpec#flags_. |= MINUS_FLAGcxx . . $ fmt/MINUS_FLAG.; |
| 3683 | break; |
| 3684 | case ' ': |
| 3685 | check_sign(s, arg); |
| 3686 | spec.flags_cxx . . $ fmt/FormatSpec#flags_. |= SIGN_FLAGcxx . . $ fmt/SIGN_FLAG.; |
| 3687 | break; |
| 3688 | } |
| 3689 | |
| 3690 | if (*s == '#') { |
| 3691 | require_numeric_argumentcxx . . $ fmt/internal/require_numeric_argument(50006c08498df49e).(arg, '#'); |
| 3692 | spec.flags_cxx . . $ fmt/FormatSpec#flags_. |= HASH_FLAGcxx . . $ fmt/HASH_FLAG.; |
| 3693 | ++s; |
| 3694 | } |
| 3695 | |
| 3696 | // Parse zero flag. |
| 3697 | if (*s == '0') { |
| 3698 | require_numeric_argumentcxx . . $ fmt/internal/require_numeric_argument(50006c08498df49e).(arg, '0'); |
| 3699 | spec.align_cxx . . $ fmt/AlignSpec#align_. = ALIGN_NUMERICcxx . . $ fmt/ALIGN_NUMERIC.; |
| 3700 | spec.fill_cxx . . $ fmt/WidthSpec#fill_. = '0'; |
| 3701 | ++s; |
| 3702 | } |
| 3703 | |
| 3704 | // Parse width. |
| 3705 | if ('0' <= *s && *s <= '9') { |
| 3706 | spec.width_cxx . . $ fmt/WidthSpec#width_. = internalcxx . . $ fmt/internal/::parse_nonnegative_intcxx . . $ fmt/internal/parse_nonnegative_int(a964adceb31d1037).(s); |
| 3707 | } |
| 3708 | else if (*s == '{') { |
| 3709 | ++s; |
| 3710 | Argcxx . . $ fmt/BasicFormatter#format(3077b68864ed6c04).Arg# width_arg = internalcxx . . $ fmt/internal/::is_name_startcxx . . $ fmt/internal/is_name_start(ee44d93984fb03e9).(*s) ? |
| 3711 | parse_arg_namecxx . . $ fmt/BasicFormatter#parse_arg_name(4ce1381982b64b8).(s) : parse_arg_indexcxx . . $ fmt/BasicFormatter#parse_arg_index(4ce1381982b64b8).(s); |
| 3712 | if (*s++ != '}') |
| 3713 | FMT_THROWcxx . . $ fmt/FormatError#(FormatError("invalid format string")); |
| 3714 | ULongLongcxx . . $ fmt/ULongLong# value = 0; |
| 3715 | switch (width_arg.typecxx . . $ fmt/internal/Arg#type.) { |
| 3716 | case Argcxx . . $ fmt/internal/Arg#::INTcxx . . $ fmt/internal/Value#INT.: |
| 3717 | if (width_arg.int_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#int_value. < 0) |
| 3718 | FMT_THROWcxx . . $ fmt/FormatError#(FormatError("negative width")); |
| 3719 | value = width_arg.int_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#int_value.; |
| 3720 | break; |
| 3721 | case Argcxx . . $ fmt/internal/Arg#::UINTcxx . . $ fmt/internal/Value#UINT.: |
| 3722 | value = width_arg.uint_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#uint_value.; |
| 3723 | break; |
| 3724 | case Argcxx . . $ fmt/internal/Arg#::LONG_LONGcxx . . $ fmt/internal/Value#LONG_LONG.: |
| 3725 | if (width_arg.long_long_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#long_long_value. < 0) |
| 3726 | FMT_THROWcxx . . $ `src/common/format.h:172:11`!(FormatError("negative width")); |
| 3727 | value = width_arg.long_long_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#long_long_value.; |
| 3728 | break; |
| 3729 | case Argcxx . . $ fmt/internal/Arg#::ULONG_LONGcxx . . $ fmt/internal/Value#ULONG_LONG.: |
| 3730 | value = width_arg.ulong_long_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#ulong_long_value.; |
| 3731 | break; |
| 3732 | default: |
| 3733 | FMT_THROWcxx . . $ fmt/FormatError#(FormatError("width is not integer")); |
| 3734 | } |
| 3735 | if (value >(stdcxx . . $ std/::numeric_limitscxx . . $ std/numeric_limits#<int>::maxcxx . . $ std/numeric_limits#max(9efc7249d839d30e).)()) |
| 3736 | FMT_THROWcxx . . $ fmt/FormatError#(FormatError("number is too big")); |
| 3737 | spec.width_cxx . . $ fmt/WidthSpec#width_. = static_cast<int>(value); |
| 3738 | } |
| 3739 | |
| 3740 | // Parse precision. |
| 3741 | if (*s == '.') { |
| 3742 | ++s; |
| 3743 | spec.precision_cxx . . $ fmt/FormatSpec#precision_. = 0; |
| 3744 | if ('0' <= *s && *s <= '9') { |
| 3745 | spec.precision_cxx . . $ fmt/FormatSpec#precision_. = internalcxx . . $ fmt/internal/::parse_nonnegative_intcxx . . $ fmt/internal/parse_nonnegative_int(a964adceb31d1037).(s); |
| 3746 | } |
| 3747 | else if (*s == '{') { |
| 3748 | ++s; |
| 3749 | Argcxx . . $ fmt/BasicFormatter#format(3077b68864ed6c04).Arg# precision_arg = internalcxx . . $ fmt/internal/::is_name_startcxx . . $ fmt/internal/is_name_start(ee44d93984fb03e9).(*s) ? |
| 3750 | parse_arg_namecxx . . $ fmt/BasicFormatter#parse_arg_name(4ce1381982b64b8).(s) : parse_arg_indexcxx . . $ fmt/BasicFormatter#parse_arg_index(4ce1381982b64b8).(s); |
| 3751 | if (*s++ != '}') |
| 3752 | FMT_THROWcxx . . $ fmt/BasicCStringRef#BasicCStringRef(88376428bb603c08).(FormatError("invalid format string")); |
| 3753 | ULongLongcxx . . $ fmt/ULongLong# value = 0; |
| 3754 | switch (precision_arg.typecxx . . $ fmt/internal/Arg#type.) { |
| 3755 | case Argcxx . . $ fmt/internal/Arg#::INTcxx . . $ fmt/internal/Value#INT.: |
| 3756 | if (precision_arg.int_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#int_value. < 0) |
| 3757 | FMT_THROWcxx . . $ fmt/BasicCStringRef#BasicCStringRef(88376428bb603c08).(FormatError("negative precision")); |
| 3758 | value = precision_arg.int_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#int_value.; |
| 3759 | break; |
| 3760 | case Argcxx . . $ fmt/internal/Arg#::UINTcxx . . $ fmt/internal/Value#UINT.: |
| 3761 | value = precision_arg.uint_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#uint_value.; |
| 3762 | break; |
| 3763 | case Argcxx . . $ fmt/internal/Arg#::LONG_LONGcxx . . $ fmt/internal/Value#LONG_LONG.: |
| 3764 | if (precision_arg.long_long_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#long_long_value. < 0) |
| 3765 | FMT_THROWcxx . . $ fmt/FormatError#(FormatError("negative precision")); |
| 3766 | value = precision_arg.long_long_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#long_long_value.; |
| 3767 | break; |
| 3768 | case Argcxx . . $ fmt/internal/Arg#::ULONG_LONGcxx . . $ fmt/internal/Value#ULONG_LONG.: |
| 3769 | value = precision_arg.ulong_long_valuecxx . . $ fmt/internal/Value#$anonymous_type_1#ulong_long_value.; |
| 3770 | break; |
| 3771 | default: |
| 3772 | FMT_THROWcxx . . $ fmt/BasicCStringRef#BasicCStringRef(88376428bb603c08).(FormatError("precision is not integer")); |
| 3773 | } |
| 3774 | if (value >(stdcxx . . $ std/::numeric_limitscxx . . $ std/numeric_limits#<int>::maxcxx . . $ std/numeric_limits#max(9efc7249d839d30e).)()) |
| 3775 | FMT_THROWcxx . . $ `src/common/format.h:172:11`!(FormatError("number is too big")); |
| 3776 | spec.precision_cxx . . $ fmt/FormatSpec#precision_. = static_cast<int>(value); |
| 3777 | } |
| 3778 | else { |
| 3779 | FMT_THROWcxx . . $ `src/common/format.h:172:11`!(FormatError("missing precision specifier")); |
| 3780 | } |
| 3781 | if (arg.typecxx . . $ fmt/internal/Arg#type. <= Argcxx . . $ fmt/internal/Arg#::LAST_INTEGER_TYPEcxx . . $ fmt/internal/Value#LAST_INTEGER_TYPE. || arg.typecxx . . $ fmt/internal/Arg#type. == Argcxx . . $ fmt/internal/Arg#::POINTERcxx . . $ fmt/internal/Value#POINTER.) { |
| 3782 | FMT_THROWcxx . . $ fmt/internal/Value#POINTER.(FormatError( |
| 3783 | fmt::format("precision not allowed in {} format specifier", |
| 3784 | arg.type == Arg::POINTER ? "pointer" : "integer"))); |
| 3785 | } |
| 3786 | } |
| 3787 | |
| 3788 | // Parse type. |
| 3789 | if (*s != '}' && *s) |
| 3790 | spec.type_cxx . . $ fmt/FormatSpec#type_. = static_cast<char>(*s++); |
| 3791 | } |
| 3792 | |
| 3793 | if (*s++ != '}') |
| 3794 | FMT_THROWcxx . . $ fmt/FormatError#(FormatError("missing '}' in format string")); |
| 3795 | |
| 3796 | // Format argument. |
| 3797 | ArgFormatter(*this, spec, s - 1).visit(arg); |
| 3798 | return s; |
| 3799 | } |
| 3800 | |
| 3801 | template <typename Char, typename AF> |
| 3802 | void BasicFormattercxx . . $ fmt/BasicFormatter#<Char, AF>::formatcxx . . $ fmt/BasicFormatter#format(66d672f47157ac79).(BasicCStringRefcxx . . $ fmt/BasicCStringRef#<Charcxx . . $ fmt/BasicFormatter#Char#> format_str) { |
| 3803 | const Charcxx . . $ fmt/BasicFormatter#Char# *s = format_str.c_strcxx . . $ fmt/BasicCStringRef#c_str(1016ee5406d91ab9).(); |
| 3804 | const Charcxx . . $ fmt/BasicFormatter#Char# *start = s; |
| 3805 | while (*s) { |
| 3806 | Charcxx . . $ fmt/BasicFormatter#Char# c = *s++; |
| 3807 | if (c != '{' && c != '}') continue; |
| 3808 | if (*s == c) { |
| 3809 | writecxx . . $ fmt/internal/FormatterBase#write(b7548184d003157b).(writer_cxx . . $ fmt/BasicFormatter#writer_., start, s); |
| 3810 | start = ++s; |
| 3811 | continue; |
| 3812 | } |
| 3813 | if (c == '}') |
| 3814 | FMT_THROWcxx . . $ fmt/FormatError#FormatError(330b15046e8ecb2a).(FormatError("unmatched '}' in format string")); |
| 3815 | writecxx . . $ fmt/internal/FormatterBase#write(b7548184d003157b).(writer_cxx . . $ fmt/BasicFormatter#writer_., start, s - 1); |
| 3816 | internalcxx . . $ fmt/internal/::Argcxx . . $ fmt/internal/Arg# arg = internalcxx . . $ fmt/internal/::is_name_startcxx . . $ fmt/internal/is_name_start(ee44d93984fb03e9).(*s) ? |
| 3817 | parse_arg_namecxx . . $ fmt/BasicFormatter#parse_arg_name(4ce1381982b64b8).(s) : parse_arg_indexcxx . . $ fmt/BasicFormatter#parse_arg_index(4ce1381982b64b8).(s); |
| 3818 | start = s = formatcxx . . $ fmt/BasicFormatter#format(66d672f47157ac79).(s, arg); |
| 3819 | } |
| 3820 | writecxx . . $ fmt/internal/FormatterBase#write(b7548184d003157b).(writer_cxx . . $ fmt/BasicFormatter#writer_., start, s); |
| 3821 | } |
| 3822 | } // namespace fmt |
| 3823 | |
| 3824 | #if FMT_USE_USER_DEFINED_LITERALScxx . . $ `src/common/format.h:232:10`! |
| 3825 | namespace fmtcxx . . $ fmt/ { |
| 3826 | namespace internalcxx . . $ fmt/internal/ { |
| 3827 | |
| 3828 | template <typename Char> |
| 3829 | struct UdlFormatcxx . . $ fmt/internal/UdlFormat# { |
| 3830 | const Char *strcxx . . $ fmt/internal/UdlFormat#str.; |
| 3831 | |
| 3832 | template <typename... Args> |
| 3833 | auto operatorcxx . . $ fmt/internal/UdlFormat#`operator()`(26f9ab4c2ff3c584).()(Args && ... args) const |
| 3834 | -> decltype(formatcxx . . $ fmt/format(5a34ad3b2d78700d).(strcxx . . $ fmt/internal/UdlFormat#str., stdcxx . . $ std/::forwardcxx . . $ std/forward(2d11db7e2d3d358e).<Args>(args)...)) { |
| 3835 | return formatcxx . . $ fmt/format(9dfaebe7421e19ae).(strcxx . . $ fmt/internal/UdlFormat#str., stdcxx . . $ std/::forwardcxx . . $ std/forward(2d11db7e2d3d358e).<Args>(args)...); |
| 3836 | } |
| 3837 | }; |
| 3838 | |
| 3839 | template <typename Char> |
| 3840 | struct UdlArgcxx . . $ fmt/internal/UdlArg# { |
| 3841 | const Char *strcxx . . $ fmt/internal/UdlArg#str.; |
| 3842 | |
| 3843 | template <typename T> |
| 3844 | NamedArgcxx . . $ fmt/internal/NamedArg#<Char> operatorcxx . . $ fmt/internal/UdlArg#`operator=`(ef31442f8e07463d).=(T &&value) const { |
| 3845 | return{ strcxx . . $ fmt/internal/UdlArg#str., stdcxx . . $ std/::forwardcxx . . $ std/forward(2d11db7e2d3d358e).<T>(value) }; |
| 3846 | } |
| 3847 | }; |
| 3848 | |
| 3849 | } // namespace internal |
| 3850 | |
| 3851 | inline namespace literalscxx . . $ fmt/literals/ { |
| 3852 | |
| 3853 | /** |
| 3854 | \rst |
| 3855 | C++11 literal equivalent of :func:`fmt::format`. |
| 3856 | |
| 3857 | **Example**:: |
| 3858 | |
| 3859 | using namespace fmt::literals; |
| 3860 | std::string message = "The answer is {}"_format(42); |
| 3861 | \endrst |
| 3862 | */ |
| 3863 | inline internalcxx . . $ fmt/internal/::UdlFormatcxx . . $ fmt/internal/UdlFormat#<char> |
| 3864 | operatorcxx . . $ fmt/literals/`operator""_format`(8c830cf02350b2c3)."" _format(const char *s, stdcxx . . $ std/::size_tcxx . . $ std/size_t#) { return{ s }; } |
| 3865 | inline internalcxx . . $ fmt/internal/::UdlFormatcxx . . $ fmt/internal/UdlFormat#<wchar_t> |
| 3866 | operatorcxx . . $ fmt/literals/`operator""_format`(e9d66f7a2c6f0bd1)."" _format(const wchar_t *s, stdcxx . . $ std/::size_tcxx . . $ std/size_t#) { return{ s }; } |
| 3867 | |
| 3868 | /** |
| 3869 | \rst |
| 3870 | C++11 literal equivalent of :func:`fmt::arg`. |
| 3871 | |
| 3872 | **Example**:: |
| 3873 | |
| 3874 | using namespace fmt::literals; |
| 3875 | print("Elapsed time: {s:.2f} seconds", "s"_a=1.23); |
| 3876 | \endrst |
| 3877 | */ |
| 3878 | inline internalcxx . . $ fmt/internal/::UdlArgcxx . . $ fmt/internal/UdlArg#<char> |
| 3879 | operatorcxx . . $ fmt/literals/`operator""_a`(33758bc89fbd7c9a)."" _a(const char *s, stdcxx . . $ std/::size_tcxx . . $ std/size_t#) { return{ s }; } |
| 3880 | inline internalcxx . . $ fmt/internal/::UdlArgcxx . . $ fmt/internal/UdlArg#<wchar_t> |
| 3881 | operatorcxx . . $ fmt/literals/`operator""_a`(ac90d332c1b39ca6)."" _a(const wchar_t *s, stdcxx . . $ std/::size_tcxx . . $ std/size_t#) { return{ s }; } |
| 3882 | |
| 3883 | } // inline namespace literals |
| 3884 | } // namespace fmt |
| 3885 | #endif // FMT_USE_USER_DEFINED_LITERALS |
| 3886 | |
| 3887 | // Restore warnings. |
| 3888 | #if FMT_GCC_VERSIONcxx . . $ `src/common/format.h:79:10`! >= 406 |
| 3889 | # pragma GCC diagnostic pop |
| 3890 | #endif |
| 3891 | |
| 3892 | #if defined(__clang__cxx . . $ `<built-in>:3:9`!) && !defined(FMT_ICC_VERSION) |
| 3893 | # pragma clang diagnostic pop |
| 3894 | #endif |
| 3895 | |
| 3896 | #ifdef FMT_HEADER_ONLY |
| 3897 | # define FMT_FUNC inline |
| 3898 | # include "format.cc" |
| 3899 | #else |
| 3900 | # define FMT_FUNCcxx . . $ `src/common/format.h:3900:10`! |
| 3901 | #endif |
| 3902 | |
| 3903 | #endif // FMT_FORMAT_H_ |