GLSL Struct 1.4.0
glslstruct
Loading...
Searching...
No Matches
glslstruct::base_parser< Layout > Class Template Reference

base template class of structs parser More...

#include <base_parser.hpp>

Inheritance diagram for glslstruct::base_parser< Layout >:
[legend]
Collaboration diagram for glslstruct::base_parser< Layout >:
[legend]

Public Member Functions

_GLSL_STRUCT_CONSTEXPR17 base_parser ()=default
 default constructor
_GLSL_STRUCT_CONSTEXPR17 _layout_typeadd_variable (_layout_type &layoutRef, const std::string_view type, const std::string_view name, const size_t count)
 adds variable array to layout
_GLSL_STRUCT_CONSTEXPR17 _struct_typeadd_variable (_struct_type &structRef, const std::string_view type, const std::string_view name, const size_t count)
 adds variable array to struct
_GLSL_STRUCT_CONSTEXPR17 _layout_typeadd_variable (_layout_type &layoutRef, const std::string_view type, const std::string_view name)
 adds variable to layout
_GLSL_STRUCT_CONSTEXPR17 _struct_typeadd_variable (_struct_type &structRef, const std::string_view type, const std::string_view name)
 adds variable to struct
_GLSL_STRUCT_CONSTEXPR17 _layout_typeadd_variable (_layout_type &layoutRef, const std::string_view varStr)
 adds variable to layout
_GLSL_STRUCT_CONSTEXPR17 _struct_typeadd_variable (_struct_type &structRef, const std::string_view varStr)
 adds variable to struct
_GLSL_STRUCT_CONSTEXPR17 _layout_typeadd_variables (_layout_type &layoutRef, const std::string_view varsStr)
 adds variables to layout
_GLSL_STRUCT_CONSTEXPR17 _struct_typeadd_variables (_struct_type &structRef, const std::string_view varsStr)
 adds variables to struct
_GLSL_STRUCT_CONSTEXPR17 void add_struct_definition (const std::string_view name, const std::string_view varsStr)
 adds struct definition
_GLSL_STRUCT_CONSTEXPR17 void add_struct_definition (const std::string_view structStr)
 adds struct definition
_GLSL_STRUCT_CONSTEXPR17 void add_structs_definitions (const std::string_view structsStr)
 adds structs definitions
_GLSL_STRUCT_CONSTEXPR17 _layout_type create_struct_layout (const std::string_view varsStr)
 creates layout with given variables
_GLSL_STRUCT_CONSTEXPR17 _struct_type create_struct (const std::string_view varsStr)
 creates struct with given variables
_GLSL_STRUCT_CONSTEXPR17 _layout_type get_struct_layout (const std::string_view structName)
 get layout of struct earlier defined
_GLSL_STRUCT_CONSTEXPR17 _struct_type get_struct (const std::string_view structName)
 get struct earlier defined
_GLSL_STRUCT_CONSTEXPR20 std::vector< _layout_typecreate_structs_layouts (const std::vector< std::string > &structs)
 creates layouts from strings array
_GLSL_STRUCT_CONSTEXPR17 std::vector< _layout_typecreate_structs_layouts (const std::string_view structsStr)
 creates layouts from string
_GLSL_STRUCT_CONSTEXPR17 std::vector< _struct_typecreate_structs (const std::vector< std::string > &structsStrs)
 creates structs from strings array
_GLSL_STRUCT_CONSTEXPR17 std::vector< _struct_typecreate_structs (const std::string_view structsStr)
 creates structs from string
_GLSL_STRUCT_CONSTEXPR20 std::vector< _layout_typeget_structs_layouts (const std::vector< std::string > &structsNames)
 gets layouts with names in array
_GLSL_STRUCT_CONSTEXPR20 std::vector< _struct_typeget_structs (const std::vector< std::string_view > &structsNames)
 gets structs with names in array

Private Types

using _layout_type = Layout
 layout type
using _struct_type = base_struct<Layout>
 structure type
using _base_patterns = utils::base_parser_patterns
using _ubo_pattern = utils::ubo_parser_pattern<_layout_type>
using _ssbo_pattern = utils::ssbo_parser_pattern<_layout_type>

Private Member Functions

_GLSL_STRUCT_CONSTEXPR20 std::pair< std::string, std::string > _extract_struct_data (const std::string_view structStr)
 extracts name and body of structure from string
_GLSL_STRUCT_CONSTEXPR20 std::vector< std::string > _extract_structs (const std::string_view structsStr)
 extracts struct strings from structs list
_GLSL_STRUCT_CONSTEXPR17 _layout_type _create_layout (const std::string_view varsStr)
 creates layout with variables in vars list
_GLSL_STRUCT_CONSTEXPR17 bool _load_layout (const std::string_view structName)
 loads layout from structsBodies to structsLayouts and returns if there is a layout with given name in structsLayouts
_GLSL_STRUCT_CONSTEXPR17 bool _contains_struct_body (const std::string_view name)
 returns true if struct with given name is in _structsBodies
_GLSL_STRUCT_CONSTEXPR17 bool _contains_struct_layout (const std::string_view name)
 returns true if struct with given name is in _structsLayouts
template<class S>
_GLSL_STRUCT_CONSTEXPR20 S & _add_variable (S &ref, const std::string_view type, const std::string_view name, const size_t count=0)
 adds variable of type given in string and with name and count
template<class S>
_GLSL_STRUCT_CONSTEXPR20 S & _add_variable (S &ref, const std::string_view varStr)
 adds variable given in string
template<class S>
_GLSL_STRUCT_CONSTEXPR20 S & _add_variables (S &ref, const std::string_view varsStr)
 adds variables given in var list string

Static Private Member Functions

static _GLSL_STRUCT_CONSTEXPR17 ValueType _get_value_type_from_string (const std::string_view type) noexcept
 returns ValueType based on type in string
template<class T, class S>
static _GLSL_STRUCT_CONSTEXPR17 S & _add_variable (S &ref, const std::string_view name, const size_t count)
 adds variable of type T to struct or layout (if count != 0 then it adds array of variables of type T)
template<class S>
static _GLSL_STRUCT_CONSTEXPR17 S & _add_scalar_variable (S &ref, const ValueType type, const std::string_view name, const size_t count)
 adds scalar with name and of type based on ValueType to struct or layout
template<class T, class S>
static _GLSL_STRUCT_CONSTEXPR17 S & _add_vec_variable (S &ref, const size_t length, const std::string_view name, const size_t count)
 adds vec with name and with provided length to struct or layout
template<class S>
static _GLSL_STRUCT_CONSTEXPR17 S & _add_vec_variable (S &ref, const ValueType type, const size_t length, const std::string_view name, const size_t count)
 adds vec with name and of type based on ValueType and with provided length to struct or layout
template<class T, size_t Cols, class S>
static _GLSL_STRUCT_CONSTEXPR17 S & _add_mat_variable (S &ref, const size_t rows, const std::string_view name, const size_t count)
 adds mat with name and with provided rows to struct or layout
template<class T, class S>
static _GLSL_STRUCT_CONSTEXPR17 S & _add_mat_variable (S &ref, const size_t cols, const size_t rows, const std::string_view name, const size_t count)
 adds mat with name and with provided columns and rows to struct or layout
template<class S>
static _GLSL_STRUCT_CONSTEXPR17 S & _add_mat_variable (S &ref, const ValueType type, const size_t cols, const size_t rows, const std::string_view name, const size_t count)
 adds mat with name and of type based on ValueType and with provided columns and rows to struct or layout

Private Attributes

std::unordered_map< std::string, std::string > _structsBodies
 loaded and not converted to layouts structs bodies
std::unordered_map< std::string, _layout_type_structsLayouts = {}
 loaded and converted to layouts structs

Static Private Attributes

static _GLSL_STRUCT_CONSTEXPR17 bool has_ubo_pattern = utils::has_ubo_pattern_v<_layout_type>
 returns true if given layout can be used by ubo
static _GLSL_STRUCT_CONSTEXPR17 bool has_ssbo_pattern = utils::has_ssbo_pattern_v<_layout_type>
 returns true if given layout can be used by ssbo

Detailed Description

template<utils::glsl_layout Layout>
class glslstruct::base_parser< Layout >

base template class of structs parser

Template Parameters
Layoutlayout type for parser

Member Typedef Documentation

◆ _base_patterns

template<utils::glsl_layout Layout>
using glslstruct::base_parser< Layout >::_base_patterns = utils::base_parser_patterns
private

◆ _layout_type

template<utils::glsl_layout Layout>
using glslstruct::base_parser< Layout >::_layout_type = Layout
private

layout type

◆ _ssbo_pattern

template<utils::glsl_layout Layout>
using glslstruct::base_parser< Layout >::_ssbo_pattern = utils::ssbo_parser_pattern<_layout_type>
private

◆ _struct_type

template<utils::glsl_layout Layout>
using glslstruct::base_parser< Layout >::_struct_type = base_struct<Layout>
private

structure type

◆ _ubo_pattern

template<utils::glsl_layout Layout>
using glslstruct::base_parser< Layout >::_ubo_pattern = utils::ubo_parser_pattern<_layout_type>
private

Constructor & Destructor Documentation

◆ base_parser()

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 glslstruct::base_parser< Layout >::base_parser ( )
default

default constructor

Member Function Documentation

◆ _add_mat_variable() [1/3]

template<utils::glsl_layout Layout>
template<class T, class S>
_GLSL_STRUCT_CONSTEXPR17 S & glslstruct::base_parser< Layout >::_add_mat_variable ( S & ref,
const size_t cols,
const size_t rows,
const std::string_view name,
const size_t count )
inlinestaticprivate

adds mat with name and with provided columns and rows to struct or layout

◆ _add_mat_variable() [2/3]

template<utils::glsl_layout Layout>
template<class T, size_t Cols, class S>
_GLSL_STRUCT_CONSTEXPR17 S & glslstruct::base_parser< Layout >::_add_mat_variable ( S & ref,
const size_t rows,
const std::string_view name,
const size_t count )
inlinestaticprivate

adds mat with name and with provided rows to struct or layout

◆ _add_mat_variable() [3/3]

template<utils::glsl_layout Layout>
template<class S>
_GLSL_STRUCT_CONSTEXPR17 S & glslstruct::base_parser< Layout >::_add_mat_variable ( S & ref,
const ValueType type,
const size_t cols,
const size_t rows,
const std::string_view name,
const size_t count )
inlinestaticprivate

adds mat with name and of type based on ValueType and with provided columns and rows to struct or layout

◆ _add_scalar_variable()

template<utils::glsl_layout Layout>
template<class S>
_GLSL_STRUCT_CONSTEXPR17 S & glslstruct::base_parser< Layout >::_add_scalar_variable ( S & ref,
const ValueType type,
const std::string_view name,
const size_t count )
inlinestaticprivate

adds scalar with name and of type based on ValueType to struct or layout

◆ _add_variable() [1/3]

template<utils::glsl_layout Layout>
template<class T, class S>
_GLSL_STRUCT_CONSTEXPR17 S & glslstruct::base_parser< Layout >::_add_variable ( S & ref,
const std::string_view name,
const size_t count )
inlinestaticprivate

adds variable of type T to struct or layout (if count != 0 then it adds array of variables of type T)

◆ _add_variable() [2/3]

template<utils::glsl_layout Layout>
template<class S>
_GLSL_STRUCT_CONSTEXPR20 S & glslstruct::base_parser< Layout >::_add_variable ( S & ref,
const std::string_view type,
const std::string_view name,
const size_t count = 0 )
inlineprivate

adds variable of type given in string and with name and count

◆ _add_variable() [3/3]

template<utils::glsl_layout Layout>
template<class S>
_GLSL_STRUCT_CONSTEXPR20 S & glslstruct::base_parser< Layout >::_add_variable ( S & ref,
const std::string_view varStr )
inlineprivate

adds variable given in string

◆ _add_variables()

template<utils::glsl_layout Layout>
template<class S>
_GLSL_STRUCT_CONSTEXPR20 S & glslstruct::base_parser< Layout >::_add_variables ( S & ref,
const std::string_view varsStr )
inlineprivate

adds variables given in var list string

◆ _add_vec_variable() [1/2]

template<utils::glsl_layout Layout>
template<class T, class S>
_GLSL_STRUCT_CONSTEXPR17 S & glslstruct::base_parser< Layout >::_add_vec_variable ( S & ref,
const size_t length,
const std::string_view name,
const size_t count )
inlinestaticprivate

adds vec with name and with provided length to struct or layout

◆ _add_vec_variable() [2/2]

template<utils::glsl_layout Layout>
template<class S>
_GLSL_STRUCT_CONSTEXPR17 S & glslstruct::base_parser< Layout >::_add_vec_variable ( S & ref,
const ValueType type,
const size_t length,
const std::string_view name,
const size_t count )
inlinestaticprivate

adds vec with name and of type based on ValueType and with provided length to struct or layout

◆ _contains_struct_body()

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 bool glslstruct::base_parser< Layout >::_contains_struct_body ( const std::string_view name)
inlineprivate

returns true if struct with given name is in _structsBodies

◆ _contains_struct_layout()

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 bool glslstruct::base_parser< Layout >::_contains_struct_layout ( const std::string_view name)
inlineprivate

returns true if struct with given name is in _structsLayouts

◆ _create_layout()

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 _layout_type glslstruct::base_parser< Layout >::_create_layout ( const std::string_view varsStr)
inlineprivate

creates layout with variables in vars list

◆ _extract_struct_data()

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR20 std::pair< std::string, std::string > glslstruct::base_parser< Layout >::_extract_struct_data ( const std::string_view structStr)
inlineprivate

extracts name and body of structure from string

◆ _extract_structs()

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR20 std::vector< std::string > glslstruct::base_parser< Layout >::_extract_structs ( const std::string_view structsStr)
inlineprivate

extracts struct strings from structs list

◆ _get_value_type_from_string()

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 ValueType glslstruct::base_parser< Layout >::_get_value_type_from_string ( const std::string_view type)
inlinestaticprivatenoexcept

returns ValueType based on type in string

◆ _load_layout()

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 bool glslstruct::base_parser< Layout >::_load_layout ( const std::string_view structName)
inlineprivate

loads layout from structsBodies to structsLayouts and returns if there is a layout with given name in structsLayouts

◆ add_struct_definition() [1/2]

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 void glslstruct::base_parser< Layout >::add_struct_definition ( const std::string_view name,
const std::string_view varsStr )
inline

adds struct definition

◆ add_struct_definition() [2/2]

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 void glslstruct::base_parser< Layout >::add_struct_definition ( const std::string_view structStr)
inline

adds struct definition

◆ add_structs_definitions()

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 void glslstruct::base_parser< Layout >::add_structs_definitions ( const std::string_view structsStr)
inline

adds structs definitions

◆ add_variable() [1/6]

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 _layout_type & glslstruct::base_parser< Layout >::add_variable ( _layout_type & layoutRef,
const std::string_view type,
const std::string_view name )
inline

adds variable to layout

◆ add_variable() [2/6]

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 _layout_type & glslstruct::base_parser< Layout >::add_variable ( _layout_type & layoutRef,
const std::string_view type,
const std::string_view name,
const size_t count )
inline

adds variable array to layout

◆ add_variable() [3/6]

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 _layout_type & glslstruct::base_parser< Layout >::add_variable ( _layout_type & layoutRef,
const std::string_view varStr )
inline

adds variable to layout

◆ add_variable() [4/6]

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 _struct_type & glslstruct::base_parser< Layout >::add_variable ( _struct_type & structRef,
const std::string_view type,
const std::string_view name )
inline

adds variable to struct

◆ add_variable() [5/6]

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 _struct_type & glslstruct::base_parser< Layout >::add_variable ( _struct_type & structRef,
const std::string_view type,
const std::string_view name,
const size_t count )
inline

adds variable array to struct

◆ add_variable() [6/6]

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 _struct_type & glslstruct::base_parser< Layout >::add_variable ( _struct_type & structRef,
const std::string_view varStr )
inline

adds variable to struct

◆ add_variables() [1/2]

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 _layout_type & glslstruct::base_parser< Layout >::add_variables ( _layout_type & layoutRef,
const std::string_view varsStr )
inline

adds variables to layout

◆ add_variables() [2/2]

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 _struct_type & glslstruct::base_parser< Layout >::add_variables ( _struct_type & structRef,
const std::string_view varsStr )
inline

adds variables to struct

◆ create_struct()

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 _struct_type glslstruct::base_parser< Layout >::create_struct ( const std::string_view varsStr)
inline

creates struct with given variables

◆ create_struct_layout()

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 _layout_type glslstruct::base_parser< Layout >::create_struct_layout ( const std::string_view varsStr)
inline

creates layout with given variables

◆ create_structs() [1/2]

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 std::vector< _struct_type > glslstruct::base_parser< Layout >::create_structs ( const std::string_view structsStr)
inline

creates structs from string

◆ create_structs() [2/2]

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 std::vector< _struct_type > glslstruct::base_parser< Layout >::create_structs ( const std::vector< std::string > & structsStrs)
inline

creates structs from strings array

◆ create_structs_layouts() [1/2]

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 std::vector< _layout_type > glslstruct::base_parser< Layout >::create_structs_layouts ( const std::string_view structsStr)
inline

creates layouts from string

◆ create_structs_layouts() [2/2]

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR20 std::vector< _layout_type > glslstruct::base_parser< Layout >::create_structs_layouts ( const std::vector< std::string > & structs)
inline

creates layouts from strings array

◆ get_struct()

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 _struct_type glslstruct::base_parser< Layout >::get_struct ( const std::string_view structName)
inline

get struct earlier defined

◆ get_struct_layout()

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 _layout_type glslstruct::base_parser< Layout >::get_struct_layout ( const std::string_view structName)
inline

get layout of struct earlier defined

◆ get_structs()

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR20 std::vector< _struct_type > glslstruct::base_parser< Layout >::get_structs ( const std::vector< std::string_view > & structsNames)
inline

gets structs with names in array

◆ get_structs_layouts()

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR20 std::vector< _layout_type > glslstruct::base_parser< Layout >::get_structs_layouts ( const std::vector< std::string > & structsNames)
inline

gets layouts with names in array

Member Data Documentation

◆ _structsBodies

template<utils::glsl_layout Layout>
std::unordered_map<std::string, std::string> glslstruct::base_parser< Layout >::_structsBodies
private

loaded and not converted to layouts structs bodies

◆ _structsLayouts

template<utils::glsl_layout Layout>
std::unordered_map<std::string, _layout_type> glslstruct::base_parser< Layout >::_structsLayouts = {}
private

loaded and converted to layouts structs

◆ has_ssbo_pattern

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 bool glslstruct::base_parser< Layout >::has_ssbo_pattern = utils::has_ssbo_pattern_v<_layout_type>
staticprivate

returns true if given layout can be used by ssbo

◆ has_ubo_pattern

template<utils::glsl_layout Layout>
_GLSL_STRUCT_CONSTEXPR17 bool glslstruct::base_parser< Layout >::has_ubo_pattern = utils::has_ubo_pattern_v<_layout_type>
staticprivate

returns true if given layout can be used by ubo