Version 0.8.0
[marnav.git] / extern / fmt / ostream.cc
blob2890b4a8007c968a2f94131d9c3fb290b4f96111
1 /*
2 Formatting library for C++ - std::ostream support
4 Copyright (c) 2012 - 2016, Victor Zverovich
5 All rights reserved.
7 For the license information refer to format.h.
8 */
10 #include "fmt/ostream.h"
12 namespace fmt {
14 namespace internal {
15 FMT_FUNC void write(std::ostream &os, Writer &w) {
16 const char *data = w.data();
17 typedef internal::MakeUnsigned<std::streamsize>::Type UnsignedStreamSize;
18 UnsignedStreamSize size = w.size();
19 UnsignedStreamSize max_size =
20 internal::to_unsigned((std::numeric_limits<std::streamsize>::max)());
21 do {
22 UnsignedStreamSize n = size <= max_size ? size : max_size;
23 os.write(data, static_cast<std::streamsize>(n));
24 data += n;
25 size -= n;
26 } while (size != 0);
30 FMT_FUNC void print(std::ostream &os, CStringRef format_str, ArgList args) {
31 MemoryWriter w;
32 w.write(format_str, args);
33 internal::write(os, w);
35 } // namespace fmt