HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
indent.hpp
1// Copyright Take Vos 2020.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5
6#pragma once
7
8namespace tt {
9
14class indent {
15public:
22 [[nodiscard]] constexpr indent(int spaces = 4, char space = ' ') noexcept :
23 _space(space), _spaces(spaces), _depth(0) {}
24
25 [[nodiscard]] constexpr indent(indent const &other) noexcept :
26 _space(other._space), _spaces(other._spaces), _depth(other._depth) {}
27
28 [[nodiscard]] constexpr indent(indent &&other) noexcept :
29 _space(other._space), _spaces(other._spaces), _depth(other._depth) {}
30
31 [[nodiscard]] constexpr indent &operator=(indent const &other) noexcept
32 {
33 _space = other._space;
34 _spaces = other._spaces;
35 _depth = other._depth;
36 return *this;
37 }
38
39 [[nodiscard]] constexpr indent &operator=(indent &&other) noexcept
40 {
41 _space = other._space;
42 _spaces = other._spaces;
43 _depth = other._depth;
44 return *this;
45 }
46
49 [[nodiscard]] operator std::string () const noexcept
50 {
51 return std::string(_depth * _spaces, _space);
52 }
53
56 constexpr indent &operator+=(int rhs) noexcept
57 {
58 _depth += rhs;
59 return *this;
60 }
61
64 constexpr indent &operator++() noexcept
65 {
66 ++_depth;
67 return *this;
68 }
69
72 [[nodiscard]] constexpr friend indent operator+(indent lhs, int rhs) noexcept
73 {
74 lhs += rhs;
75 return lhs;
76 }
77
78private:
79 char _space;
80 int _spaces;
81 int _depth;
82};
83
84
85}
86
Indentation for writing out text files.
Definition indent.hpp:14
constexpr indent & operator+=(int rhs) noexcept
Increase the depth of this indentation.
Definition indent.hpp:56
constexpr indent & operator++() noexcept
Increment the depth of this indentation.
Definition indent.hpp:64
constexpr friend indent operator+(indent lhs, int rhs) noexcept
Get an indentation at increased depth.
Definition indent.hpp:72
constexpr indent(int spaces=4, char space=' ') noexcept
Constructor This constructor will start indentation at depth 0.
Definition indent.hpp:22