Blame view

3rdparty/boost_1_81_0/tools/quickbook/src/stream.hpp 2.73 KB
73ef4ff3   Hu Chunming   提交三方库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
  /*=============================================================================
      Copyright (c) 2009 Daniel James
  
      Use, modification and distribution is subject to the Boost Software
      License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
      http://www.boost.org/LICENSE_1_0.txt)
  =============================================================================*/
  
  // For handling native strings and streams.
  
  #if !defined(BOOST_QUICKBOOK_DETAIL_STREAM_HPP)
  #define BOOST_QUICKBOOK_DETAIL_STREAM_HPP
  
  #include <iostream>
  #include <boost/filesystem/path.hpp>
  #include "native_text.hpp"
  
  namespace quickbook
  {
      namespace fs = boost::filesystem;
  
      namespace detail
      {
          // A light wrapper around C++'s streams that gets things right
          // in the quickbook context.
          //
          // This is far from perfect but it fixes some issues.
          struct ostream
          {
              typedef stream_string string;
  #if QUICKBOOK_WIDE_STREAMS
              typedef std::wostream base_ostream;
              typedef std::wios base_ios;
  #else
              typedef std::ostream base_ostream;
              typedef std::ios base_ios;
  #endif
              base_ostream& base;
  
              explicit ostream(base_ostream& x) : base(x) {}
  
              // C strings should always be ascii.
              ostream& operator<<(char);
              ostream& operator<<(char const*);
  
              // std::string should be UTF-8 (what a mess!)
              ostream& operator<<(std::string const&);
              ostream& operator<<(quickbook::string_view);
  
              // Other value types.
              ostream& operator<<(int x);
              ostream& operator<<(unsigned int x);
              ostream& operator<<(long x);
              ostream& operator<<(unsigned long x);
  
  #if !defined(BOOST_NO_LONG_LONG)
              ostream& operator<<(boost::long_long_type x);
              ostream& operator<<(boost::ulong_long_type x);
  #endif
  
              ostream& operator<<(fs::path const&);
  
              // Modifiers
              ostream& operator<<(base_ostream& (*)(base_ostream&));
              ostream& operator<<(base_ios& (*)(base_ios&));
          };
  
          void initialise_output();
  
          ostream& out();
  
          // Preformats an error/warning message so that it can be parsed by
          // common IDEs. Set 'ms_errors' to determine if VS format
          // or GCC format. Returns the stream to continue ouput of the verbose
          // error message.
          void set_ms_errors(bool);
          ostream& outerr();
          ostream& outerr(fs::path const& file, std::ptrdiff_t line = -1);
          ostream& outwarn(fs::path const& file, std::ptrdiff_t line = -1);
          ostream& outerr(file_ptr const&, string_iterator);
          ostream& outwarn(file_ptr const&, string_iterator);
      }
  }
  
  #endif