1 #ifndef OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 2 #define OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 4 #if defined(_MSC_VER) || \ 5 (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \ 6 (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4 13 #include "yaml-cpp/dll.h" 16 class YAML_CPP_API ostream_wrapper {
19 explicit ostream_wrapper(std::ostream& stream);
20 ostream_wrapper(
const ostream_wrapper&) =
delete;
21 ostream_wrapper(ostream_wrapper&&) =
delete;
22 ostream_wrapper& operator=(
const ostream_wrapper&) =
delete;
23 ostream_wrapper& operator=(ostream_wrapper&&) =
delete;
26 void write(
const std::string& str);
27 void write(
const char* str, std::size_t size);
29 void set_comment() { m_comment =
true; }
31 const char* str()
const {
35 m_buffer[m_pos] =
'\0';
40 std::size_t row()
const {
return m_row; }
41 std::size_t col()
const {
return m_col; }
42 std::size_t pos()
const {
return m_pos; }
43 bool comment()
const {
return m_comment; }
46 void update_pos(
char ch);
49 mutable std::vector<char> m_buffer;
50 std::ostream*
const m_pStream;
53 std::size_t m_row, m_col;
57 template <std::
size_t N>
58 inline ostream_wrapper&
operator<<(ostream_wrapper& stream,
59 const char (&str)[N]) {
60 stream.write(str, N - 1);
64 inline ostream_wrapper&
operator<<(ostream_wrapper& stream,
65 const std::string& str) {
70 inline ostream_wrapper&
operator<<(ostream_wrapper& stream,
char ch) {
76 #endif // OSTREAM_WRAPPER_H_62B23520_7C8E_11DE_8A39_0800200C9A66 JSON_API OStream & operator<<(OStream &, const Value &root)
Output using the StyledStreamWriter.