/
TableDefinition.h
51 lines (37 loc) · 937 Bytes
/
TableDefinition.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#pragma once
#include <vector>
#include <string>
#include <memory>
namespace shaders
{
// Syntax:
// table <tablename> { [snap] [clamp] { <data>, <data>, ... } }
class TableDefinition :
public ITableDefinition
{
private:
// The block name
std::string _name;
// Raw content
std::string _blockContents;
// Whether to prevent value interpolation
bool _snap;
// Whether to prevent wrapping around at index bounds
bool _clamp;
// The actual values of this table
std::vector<float> _values;
// Whether we parsed the block contents already
bool _parsed;
public:
TableDefinition(const std::string& name, const std::string& blockContents);
const std::string& getName() const
{
return _name;
}
// Retrieve a value from this table, respecting the clamp and snap flags
float getValue(float index);
private:
void parseDefinition();
};
typedef std::shared_ptr<TableDefinition> TableDefinitionPtr;
} // namespace