2
3
4
5
6
7
8
11#ifndef _GLSL_STRUCT_PARSER_HPP_
12 #define _GLSL_STRUCT_PARSER_HPP_
14 #include <glslstruct/config.hpp>
17_GLSL_STRUCT_ERROR(
"This is only available for c++17 and greater and when parser functionality is not disabled!");
20 #include <glslstruct/struct/base_struct.hpp>
25 #pragma region BASE_PARSER_PATTERNS
28
29
30
40 pcre2cpp::
regex(R"(^\s*+(?>(?<scalar>[idbuf])?mat(?<cols>[2-4])(?>(?:x(?<rows>[2-4]))?))\s*+$)");
44 R"(^\s*+(?>(?<type>[a-zA-Z_]\w*+))\s++(?>(?<name>[a-zA-Z_]\w*+))\s*+(?>(?<array>\[\s*+(?<count>\d+)?\s*+\]))?\s*+(?>;?)\s*+$)"
49 R"((?>(?<=^|;))\s*+(?<var>[a-zA-Z_]\w*+\s++[a-zA-Z_]\w*+(?>(?:\s*+\[\s*+\d*+\s*+\])*+))\s*+(?:;|$))",
55 pcre2cpp::
regex(R"(^\s*+(?>(?>struct)\s++(?>(?<name>[a-zA-Z_]\w*+))\s*+(?>\{(?<body>[^}]*+)\})\s*+;)\s*+$)");
59 R"(\s*+(?<struct>(?>struct|layout\s*+\([^)]*+\)\s*+(?>uniform|(?:\w++\s++)?buffer))\s++(?>(?:[a-zA-Z_]\w*+))\s*+\{(?>[^}]*+)\}\s*+(?>(?:\w*+\s*+));\s*+))",
66 #pragma region UBO_PARSER_PATTERN
68
69
70
74 template<
class Layout, std::enable_if_t<is_glsl_layout_v<Layout>,
bool> =
true>
80
81
82
87 R"(^\s*+layout\s*+\((?>(?:(?:std140|set\s*+=\s*+\d++)\s*+,\s*+)?)\s*+binding\s*+=\s*+\d++\s*+\)\s*+uniform\s*+(?<name>[a-zA-Z_]\w*+)\s*+\{(?<body>[^}]*+)\}\s*+(?>(?:[a-zA-Z_]\w*+)?)\s*+;\s*+$)"
93
94
95
102
103
104
110
111
112
113 template<
class Layout,
class =
void>
114 struct has_ubo_pattern : std::false_type {};
122
123
124
125 template<
class Layout>
130 #pragma region SSBO_PARSER_PATTERN
132
133
134
138 template<
class Layout, std::enable_if_t<is_glsl_layout_v<Layout>,
bool> =
true>
144
145
146
150 R"(^\s*+layout\s*+\((?>std140(?>\s*+,\s*+set\s*+=\s*+\d++)?)\s*+,\s*+binding\s*+=\s*+\d++\s*+\)\s*+(?>(?:[a-zA-Z]++\s++)?buffer)\s++(?<name>[a-zA-Z_]\w*+)\s*+\{(?<body>[^}]*+)\}\s*+(?>(?:[a-zA-Z_]\w*+)?)\s*+;\s*+$)"
155
156
157
161 R"(^\s*+layout\s*+\((?>std430(?>\s*+,\s*+set\s*+=\s*+\d++)?)\s*+,\s*+binding\s*+=\s*+\d++\s*+\)\s*+(?>(?:[a-zA-Z]++\s++)?buffer)\s++(?<name>[a-zA-Z_]\w*+)\s*+\{(?<body>[^}]*+)\}\s*+(?>(?:[a-zA-Z_]\w*+)?)\s*+;\s*+$)"
166
167
168
172 R"(^\s*+layout\s*+\((?>scalar(?>\s*+,\s*+set\s*+=\s*+\d++)?)\s*+,\s*+binding\s*+=\s*+\d++\s*+\)\s*+(?>(?:[a-zA-Z]++\s++)?buffer)\s++(?<name>[a-zA-Z_]\w*+)\s*+\{(?<body>[^}]*+)\}\s*+(?>(?:[a-zA-Z_]\w*+)?)\s*+;\s*+$)"
178
179
180
187
188
189
195
196
197
198 template<
class Layout,
class =
void>
199 struct has_ssbo_pattern : std::false_type {};
208
209
210
211 template<
class Layout>
218
219
220
221
248 #pragma region GENERAL_VARIABLE_FUNCTIONS
267 template<
class T,
class S>
278 #pragma region SCALAR_VARIABLE
296 #pragma region VEC_VARIABLE
299 template<
class T,
class S>
326 #pragma region MAT_VARIABLE
341 template<
class T,
class S>
368 #pragma region EXTRACT_STRUCTS
409 #pragma region LAYOUT
429 #pragma region CONTAINS
451 #pragma region PARSE_AND_ADD_VARIABLES
535 #pragma region VARIABLE_PARSER
583 #pragma region STRUCTS_PARSER
683
684
685
688
689
690
693
694
695
#define _GLSL_STRUCT_HAS_PARSER
check if user want to include parser functionality
Definition config.hpp:186
#define _GLSL_STRUCT_CONSTEXPR20
constexpr keyword for c++20 and higher
Definition config.hpp:213
#define glsl_struct_assert(expression,...)
glslstruct assert
Definition assert.hpp:33
#define _GLSL_STRUCT_HAS_CXX20
check if compiler has c++ version greater or equal to c++20 and if user enabled c++20 features using ...
Definition config.hpp:142
#define _GLSL_STRUCT_CONSTEXPR17
constexpr for c++17 and higher
Definition config.hpp:196
Main namespace of glslstruct library.
Definition scalar_layout_traits.hpp:23
all parser patterns in one struct
Definition base_parser.hpp:31
static const auto structPattern
pattern to get struct data
Definition base_parser.hpp:54
static const auto vecPattern
pattern to get vec data
Definition base_parser.hpp:36
static const auto multiStructsPattern
pattern to get multiple structs
Definition base_parser.hpp:58
static const auto matPattern
pattern to get mat data
Definition base_parser.hpp:39
static const auto scalarsPattern
pattern to get scalar data
Definition base_parser.hpp:33
static const auto variablePattern
pattern to get variable data
Definition base_parser.hpp:43
static const auto multiVariablesPattern
pattern to get multiple variables
Definition base_parser.hpp:48
container for ssbo parser pattern
Definition base_parser.hpp:140
container for ubo parser pattern
Definition base_parser.hpp:76