Free Electron
indentation.h
1 #ifndef INDENTATION_H_62B23520_7C8E_11DE_8A39_0800200C9A66
2 #define INDENTATION_H_62B23520_7C8E_11DE_8A39_0800200C9A66
3 
4 #if defined(_MSC_VER) || \
5  (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || \
6  (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
7 #pragma once
8 #endif
9 
10 #include <iostream>
11 #include <cstddef>
12 
13 #include "yaml-cpp/ostream_wrapper.h"
14 
15 namespace YAML {
16 struct Indentation {
17  Indentation(std::size_t n_) : n(n_) {}
18  std::size_t n;
19 };
20 
21 inline ostream_wrapper& operator<<(ostream_wrapper& out,
22  const Indentation& indent) {
23  for (std::size_t i = 0; i < indent.n; i++)
24  out << ' ';
25  return out;
26 }
27 
28 struct IndentTo {
29  IndentTo(std::size_t n_) : n(n_) {}
30  std::size_t n;
31 };
32 
33 inline ostream_wrapper& operator<<(ostream_wrapper& out,
34  const IndentTo& indent) {
35  while (out.col() < indent.n)
36  out << ' ';
37  return out;
38 }
39 }
40 
41 #endif // INDENTATION_H_62B23520_7C8E_11DE_8A39_0800200C9A66
JSON_API OStream & operator<<(OStream &, const Value &root)
Output using the StyledStreamWriter.
Definition: anchor.h:12