HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
indent.hpp
1// Copyright Take Vos 2020, 2022.
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#pragma once
6
7#include "../utility/utility.hpp"
8#include "../macros.hpp"
9
10hi_export_module(hikogui.codec.indent);
11
12namespace hi { inline namespace v1 {
13
18hi_export class indent {
19public:
20 [[nodiscard]] constexpr ~indent() noexcept = default;
21 [[nodiscard]] constexpr indent() noexcept = default;
22 [[nodiscard]] constexpr indent(indent const& other) noexcept = default;
23 [[nodiscard]] constexpr indent(indent&& other) noexcept = default;
24 [[nodiscard]] constexpr indent& operator=(indent const& other) noexcept = default;
25 [[nodiscard]] constexpr indent& operator=(indent&& other) noexcept = default;
26
33 [[nodiscard]] constexpr indent(int spaces, char space = ' ') noexcept : _space(space), _spaces(spaces), _depth(0) {}
34
38 {
39 return std::string(narrow_cast<std::size_t>(_depth) * narrow_cast<std::size_t>(_spaces), _space);
40 }
41
44 constexpr indent &operator+=(int rhs) noexcept
45 {
46 _depth += rhs;
47 return *this;
48 }
49
53 {
54 ++_depth;
55 return *this;
56 }
57
60 [[nodiscard]] constexpr friend indent operator+(indent lhs, int rhs) noexcept
61 {
62 lhs += rhs;
63 return lhs;
64 }
65
66private:
67 char _space = ' ';
68 int _spaces = 4;
69 int _depth = 0;
70};
71
72}} // namespace hi::inline v1
@ other
The gui_event does not have associated data.
DOXYGEN BUG.
Definition algorithm.hpp:16
geometry/margins.hpp
Definition lookahead_iterator.hpp:5
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377
Indentation for writing out text files.
Definition indent.hpp:18
constexpr indent & operator+=(int rhs) noexcept
Increase the depth of this indentation.
Definition indent.hpp:44
constexpr friend indent operator+(indent lhs, int rhs) noexcept
Get an indentation at increased depth.
Definition indent.hpp:60
constexpr indent(int spaces, char space=' ') noexcept
Constructor This constructor will start indentation at depth 0.
Definition indent.hpp:33
constexpr indent & operator++() noexcept
Increment the depth of this indentation.
Definition indent.hpp:52