Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
SdlInputClauses.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <Common/assertion.h>
6
7#include <string>
8#include <string_view>
9#include <vector>
10#include <utility>
11
12namespace ph
13{
14
17class SdlInputClauses final
18{
19public:
22 void add(SdlInputClause clause);
23
26 void add(std::string type, std::string name, std::string value);
27
30 void add(std::string type, std::string name, std::string value, std::string tag);
31
34 void add(const SdlInputClauses& clauses);
35
38 void consume(std::size_t index);
39
42 void consumeBySwapPop(std::size_t index);
43
46 void clear();
47
50 std::size_t size() const;
51
52 std::string toString() const;
53
56 const SdlInputClause& operator [] (std::size_t index) const;
57
58private:
59 std::vector<SdlInputClause> m_clauses;
60};
61
62// In-header Implementations:
63
65{
66 m_clauses.push_back(std::move(clause));
67}
68
69inline void SdlInputClauses::add(std::string type, std::string name, std::string value)
70{
71 add(SdlInputClause(std::move(type), std::move(name), std::move(value)));
72}
73
74inline void SdlInputClauses::add(std::string type, std::string name, std::string value, std::string tag)
75{
76 add(SdlInputClause(std::move(type), std::move(name), std::move(value), std::move(tag)));
77}
78
79inline void SdlInputClauses::add(const SdlInputClauses& clauses)
80{
81 for(std::size_t ci = 0; ci < clauses.size(); ++ci)
82 {
83 add(clauses[ci]);
84 }
85}
86
87inline void SdlInputClauses::consume(const std::size_t index)
88{
89 PH_ASSERT_LT(index, m_clauses.size());
90
91 m_clauses.erase(m_clauses.begin() + index);
92}
93
94inline void SdlInputClauses::consumeBySwapPop(const std::size_t index)
95{
96 PH_ASSERT(!m_clauses.empty());
97 PH_ASSERT_LT(index, m_clauses.size());
98
99 using std::swap;
100
101 swap(m_clauses[index], m_clauses.back());
102 m_clauses.pop_back();
103}
104
106{
107 m_clauses.clear();
108}
109
110inline std::size_t SdlInputClauses::size() const
111{
112 return m_clauses.size();
113}
114
115inline std::string SdlInputClauses::toString() const
116{
117 return std::to_string(m_clauses.size()) + " value clauses";
118}
119
120inline const SdlInputClause& SdlInputClauses::operator [] (const std::size_t index) const
121{
122 PH_ASSERT_LT(index, m_clauses.size());
123 return m_clauses[index];
124}
125
126}// end namespace ph
Carries SDL representation of various data during the input process. Helps to read input data such as...
Definition SdlInputClause.h:15
Container for input clauses.
Definition SdlInputClauses.h:18
void add(SdlInputClause clause)
Add a new clause.
Definition SdlInputClauses.h:64
const SdlInputClause & operator[](std::size_t index) const
Get clause by index.
Definition SdlInputClauses.h:120
void clear()
Clear all stored data.
Definition SdlInputClauses.h:105
std::string toString() const
Definition SdlInputClauses.h:115
std::size_t size() const
Get number of clauses.
Definition SdlInputClauses.h:110
void consume(std::size_t index)
Remove a clause by index. Preserves the order of remaining clauses.
Definition SdlInputClauses.h:87
void consumeBySwapPop(std::size_t index)
Remove a clause by index. Does not preserve the order of remaining clauses.
Definition SdlInputClauses.h:94
The root for all renderer implementations.
Definition EEngineProject.h:6