AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
Indentation.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#ifndef AGX_INDENTATION_H
18#define AGX_INDENTATION_H
19
20#include <agx/Integer.h>
21#include <agx/String.h>
22#include <iostream>
23
24namespace agx
25{
27 {
28 public:
29 static const agx::UInt TabSize = 2;
30
31
32 Indentation() : m_level(0) {}
33 Indentation(agx::UInt level) : m_level(level) {}
34
35 agx::UInt getLevel() const { return m_level; }
36 agx::UInt getIndentation() const { return m_level * TabSize; }
37
43 String apply(const String& string);
44
45 Indentation& operator+= (int increment) { m_level += increment; return *this; }
46 Indentation& operator-= (int decrement) { m_level -= decrement; return *this; }
47
48 Indentation operator+ (int increment) const { return Indentation(m_level + increment); }
49 Indentation operator- (int decrement) const { return Indentation(m_level - decrement); }
50
51 Indentation& operator++() { m_level++; return *this; }
52 Indentation operator++(int) { m_level++; return Indentation(m_level - 1); }
53
54 Indentation& operator--() { m_level--; return *this; }
55 Indentation operator--(int) { m_level--; return Indentation(m_level + 1); }
56
57 String str() const { return String(getIndentation(), ' '); }
58 operator String() const { return str(); }
59
60 private:
61 agx::UInt m_level;
62 };
63
64
65 template<typename T>
66 AgXString<T> operator+ ( const Indentation& indentation, const AgXString<T>& str )
67 {
68 return indentation.str() + str;
69 }
70
71
72 inline std::ostream& operator<< (std::ostream& stream, const Indentation& indentation)
73 {
74 stream << indentation.str();
75 return stream;
76 }
77
78}
79
80
81#endif /* AGX_INDENTATION_H */
AGXCORE_EXPORT agx::String operator+(const std::string &str, const agx::Name &name)
#define AGXCORE_EXPORT
String str() const
Definition Indentation.h:57
Indentation operator--(int)
Definition Indentation.h:55
String apply(const String &string)
Indent a text, applied for each line in input string.
Indentation & operator--()
Definition Indentation.h:54
agx::UInt getIndentation() const
Definition Indentation.h:36
Indentation & operator++()
Definition Indentation.h:51
Indentation(agx::UInt level)
Definition Indentation.h:33
agx::UInt getLevel() const
Definition Indentation.h:35
Indentation operator++(int)
Definition Indentation.h:52
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
std::ostream & operator<<(std::ostream &os, const agx::AddedMassInteraction::Matrix6x6 &m)
uint64_t UInt
Definition Integer.h:27
AgXString< T > operator+(const Indentation &indentation, const AgXString< T > &str)
Definition Indentation.h:66