Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
sdl_helpers.h
Go to the documentation of this file.
1#pragma once
2
9#include "SDL/sdl_fwd.h"
10#include "Math/math_fwd.h"
11#include "Utility/traits.h"
12#include "Utility/TSpan.h"
14#include "SDL/ESdlDataType.h"
15
16#include <Common/primitive_type.h>
17
18#include <cstddef>
19#include <string>
20#include <string_view>
21#include <vector>
22#include <utility>
23#include <concepts>
24
25namespace ph::sdl
26{
27
28real load_real(std::string_view sdlRealStr);
29integer load_integer(std::string_view sdlIntegerStr);
30
34template<typename FloatType>
35FloatType load_float(std::string_view sdlFloatStr);
36
40template<typename IntType>
41IntType load_int(std::string_view sdlIntStr);
42
46template<typename NumberType>
47NumberType load_number(std::string_view sdlNumberStr);
48
49template<typename NumberType, std::size_t EXTENT = std::dynamic_extent>
50void load_numbers(std::string_view sdlNumbersStr, TSpan<NumberType, EXTENT> out_numbers);
51
52template<typename Element>
53math::TVector2<Element> load_vector2(std::string_view sdlVec2Str);
54
55template<typename Element>
56math::TVector3<Element> load_vector3(std::string_view sdlVec3Str);
57
58template<typename Element>
59math::TVector4<Element> load_vector4(std::string_view sdlVec4Str);
60
61template<typename Element>
62math::TQuaternion<Element> load_quaternion(std::string_view sdlQuatStr);
63
64template<typename NumberType>
65std::vector<NumberType> load_number_array(std::string_view sdlNumberArrayStr);
66
67template<typename Element>
68std::vector<math::TVector3<Element>> load_vector3_array(std::string_view sdlVec3ArrayStr);
69
74void save_real(real value, std::string& out_str);
75
80void save_integer(integer value, std::string& out_str);
81
87template<typename FloatType>
88void save_float(FloatType value, std::string& out_str);
89
95template<typename IntType>
96void save_int(IntType value, std::string& out_str);
97
103template<typename NumberType>
104void save_number(NumberType value, std::string& out_str);
105
110template<typename NumberType, std::size_t EXTENT = std::dynamic_extent>
111void save_numbers(TSpanView<NumberType, EXTENT> numbers, std::string& out_str);
112
117template<typename Element>
118void save_vector2(const math::TVector2<Element>& value, std::string& out_str);
119
124template<typename Element>
125void save_vector3(const math::TVector3<Element>& value, std::string& out_str);
126
131template<typename Element>
132void save_vector4(const math::TVector4<Element>& value, std::string& out_str);
133
138template<typename Element>
139void save_quaternion(const math::TQuaternion<Element>& value, std::string& out_str);
140
145template<typename NumberType>
146void save_number_array(TSpanView<NumberType> values, std::string& out_str);
147
152template<typename Element>
153void save_vector3_array(TSpanView<math::TVector3<Element>> values, std::string& out_str);
154
157void save_field_id(const SdlField* sdlField, SdlOutputClause& clause);
158
163std::string gen_pretty_name(const SdlClass* clazz);
164std::string gen_pretty_name(const SdlStruct* ztruct);
165std::string gen_pretty_name(const SdlField* field);
166std::string gen_pretty_name(const SdlFunction* func);
167std::string gen_pretty_name(const SdlClass* clazz, const SdlField* field);
169
173auto get_all_callable_functions(const SdlClass* callableParentClass)
174-> std::vector<std::pair<const SdlFunction*, const SdlClass*>>;
175
181template<typename T>
182constexpr ESdlTypeCategory category_of();
183
184template<std::integral IntType>
185constexpr ESdlDataType int_type_of();
186
187template<std::floating_point FloatType>
188constexpr ESdlDataType float_type_of();
189
190template<CNumber NumberType>
191constexpr ESdlDataType number_type_of();
192
193template<typename T>
195
204template<typename DstType, typename SrcType>
205DstType* cast_to(SrcType* srcResource);
206
212
217std::string name_to_title_case(std::string_view sdlName);
218
222std::string name_to_camel_case(std::string_view sdlName, bool capitalizedFront = false);
223
227std::string name_to_snake_case(std::string_view sdlName);
228
230
231}// end namespace ph::sdl
232
233#include "SDL/sdl_helpers.ipp"
Definition sdl_spectrum_io.cpp:17
void save_vector3(const math::TVector3< Element > &value, std::string &out_str)
Definition sdl_helpers.ipp:323
std::string name_to_camel_case(const std::string_view sdlName, const bool capitalizedFront)
Make a standard SDL name to camel case. Example: "some-sdl-name" will be "someSdlName" (if capitalize...
Definition sdl_helpers.cpp:110
std::string gen_pretty_name(const SdlClass *const clazz)
Generate a human-readable name for the SDL types. These helpers allow input types to be null.
Definition sdl_helpers.cpp:24
integer load_integer(std::string_view sdlIntegerStr)
Definition sdl_helpers.ipp:109
IntType load_int(std::string_view sdlIntStr)
Returns a integer number by processing its SDL representation. Supports ph::integer and all signed an...
Definition sdl_helpers.ipp:37
void save_number_array(TSpanView< NumberType > values, std::string &out_str)
Definition sdl_helpers.ipp:368
void save_int(IntType value, std::string &out_str)
Converts a integer number to its SDL representation. Supports ph::real, float, double,...
Definition sdl_helpers.ipp:248
void load_numbers(std::string_view sdlNumbersStr, TSpan< NumberType, EXTENT > out_numbers)
Definition sdl_helpers.ipp:65
NumberType load_number(std::string_view sdlNumberStr)
Returns a number by processing its SDL representation. Accepts all types supported by load_float() an...
Definition sdl_helpers.ipp:50
DstType * cast_to(SrcType *srcResource)
Cast between SDL resource types. Cast the input SDL resource instance of SrcType to an instance of Ds...
Definition sdl_helpers.ipp:549
void save_integer(integer value, std::string &out_str)
Definition sdl_helpers.ipp:229
std::vector< math::TVector3< Element > > load_vector3_array(std::string_view sdlVec3ArrayStr)
Definition sdl_helpers.ipp:200
void save_vector4(const math::TVector4< Element > &value, std::string &out_str)
Definition sdl_helpers.ipp:338
void save_field_id(const SdlField *const sdlField, SdlOutputClause &clause)
Save the identity of the field to output clause.
Definition sdl_helpers.cpp:16
std::string name_to_title_case(const std::string_view sdlName)
Make a standard SDL name to canonical capitalized form. Make the SDL name capitalized and separated b...
Definition sdl_helpers.cpp:78
void save_quaternion(const math::TQuaternion< Element > &value, std::string &out_str)
Definition sdl_helpers.ipp:353
constexpr ESdlDataType int_type_of()
Definition sdl_helpers.ipp:422
void save_number(NumberType value, std::string &out_str)
Converts a number to its SDL representation. Accepts all types supported by save_float() and save_int...
Definition sdl_helpers.ipp:261
constexpr ESdlTypeCategory category_of()
Statically gets the SDL category of T.
Definition sdl_helpers.ipp:409
void save_numbers(TSpanView< NumberType, EXTENT > numbers, std::string &out_str)
Definition sdl_helpers.ipp:276
void save_float(FloatType value, std::string &out_str)
Converts a floating-point number to its SDL representation. Supports ph::real, float,...
Definition sdl_helpers.ipp:235
constexpr ESdlDataType resource_type_of()
Definition sdl_helpers.ipp:492
FloatType load_float(std::string_view sdlFloatStr)
Returns a floating-point number by processing its SDL representation. Supports ph::real,...
Definition sdl_helpers.ipp:24
void save_real(real value, std::string &out_str)
Definition sdl_helpers.ipp:224
math::TQuaternion< Element > load_quaternion(std::string_view sdlQuatStr)
Definition sdl_helpers.ipp:160
auto get_all_callable_functions(const SdlClass *const callableParentClass) -> std::vector< std::pair< const SdlFunction *, const SdlClass * > >
Get a list of callable functions from the class.
Definition sdl_helpers.cpp:59
math::TVector4< Element > load_vector4(std::string_view sdlVec4Str)
Definition sdl_helpers.ipp:145
math::TVector2< Element > load_vector2(std::string_view sdlVec2Str)
Definition sdl_helpers.ipp:115
std::vector< NumberType > load_number_array(std::string_view sdlNumberArrayStr)
Definition sdl_helpers.ipp:175
std::string name_to_snake_case(const std::string_view sdlName)
Make a standard SDL name to snake case. Example: "some-sdl-name" will be "some_sdl_name".
Definition sdl_helpers.cpp:125
void save_vector3_array(TSpanView< math::TVector3< Element > > values, std::string &out_str)
Definition sdl_helpers.ipp:383
constexpr ESdlDataType number_type_of()
Definition sdl_helpers.ipp:478
void save_vector2(const math::TVector2< Element > &value, std::string &out_str)
Definition sdl_helpers.ipp:308
constexpr ESdlDataType float_type_of()
Definition sdl_helpers.ipp:464
math::TVector3< Element > load_vector3(std::string_view sdlVec3Str)
Definition sdl_helpers.ipp:130
real load_real(std::string_view sdlRealStr)
Definition sdl_helpers.ipp:104
std::span< const T, EXTENT > TSpanView
Same as TSpan, except that the objects are const-qualified. Note that for pointer types,...
Definition TSpan.h:19
std::span< T, EXTENT > TSpan
A contiguous sequence of objects of type T. Effectively the same as std::span.
Definition TSpan.h:12
ESdlDataType
Common data types used by SDL. Each listed data type has some form of one to one mapping to a specifi...
Definition ESdlDataType.h:13
ESdlTypeCategory
Definition ESdlTypeCategory.h:15