OGLplus  (0.59.0) a C++ wrapper for rendering APIs

source_ref.hpp
Go to the documentation of this file.
1 #ifndef OGLPLUS_GLSL_SOURCE_REF_HPP
9 #define OGLPLUS_GLSL_SOURCE_REF_HPP
10 
11 #include "../gl_api/config.hpp"
12 #include <eagine/assert.hpp>
13 #include <eagine/string_span.hpp>
14 #include <cstddef>
15 
16 namespace eagine::oglp {
17 //------------------------------------------------------------------------------
21 public:
24 
27 
30 
32  constexpr glsl_source_ref(const char_type* part, int_type length) noexcept
33  : _part{part}
34  , _length{length}
35  , _count{1}
36  , _parts{&_part}
37  , _lengths{&_length} {}
38 
40  constexpr glsl_source_ref(string_view source_str) noexcept
42  memory::accomodate<const char_type>(source_str).data(),
43  eagine::limit_cast<int_type>(source_str.size())) {}
44 
47  span_size_t n,
48  const char_type** ps,
49  const int_type* ls) noexcept
50  : _count{eagine::limit_cast<sizei_type>(n)}
51  , _parts{ps}
52  , _lengths{ls} {
53  EAGINE_ASSERT(_count >= 0);
54  EAGINE_ASSERT(_parts != nullptr);
55  }
56 
60  constexpr auto count() const noexcept -> sizei_type {
61  return _count;
62  }
63 
68  constexpr auto parts() const noexcept -> const char_type** {
69  return _parts;
70  }
71 
76  auto lengths() const noexcept -> const int_type* {
77  return _lengths;
78  }
79 
80 private:
81  const char_type* _part{nullptr};
82  const int_type _length{0};
83  sizei_type _count{0};
84  const char_type** _parts{nullptr};
85  const int_type* _lengths{nullptr};
86 };
87 //------------------------------------------------------------------------------
88 } // namespace eagine::oglp
89 
90 #endif // OGLPLUS_GLSL_SOURCE_REF_HPP
GLsizei sizei_type
Signed integer size type.
Definition: config.hpp:88
GLchar char_type
String character type.
Definition: config.hpp:46
Class referencing a set of GLSL source code strings.
Definition: source_ref.hpp:20
std::ptrdiff_t span_size_t
Signed span size type used by eagine.
Definition: types.hpp:36
constexpr auto count() const noexcept -> sizei_type
Returns the number of source string fragments.
Definition: source_ref.hpp:60
GLint int_type
Signed integer type.
Definition: config.hpp:70
glsl_source_ref(span_size_t n, const char_type **ps, const int_type *ls) noexcept
Construction from C-string array and lengths array.
Definition: source_ref.hpp:46
gl_types::sizei_type sizei_type
Alias for integer type storing size values.
Definition: source_ref.hpp:29
auto lengths() const noexcept -> const int_type *
Returns the lengths of the source string fragments.
Definition: source_ref.hpp:76
constexpr auto parts() const noexcept -> const char_type **
Returns pointers to the source string fragments.
Definition: source_ref.hpp:68
gl_types::char_type char_type
Alias for character string type.
Definition: source_ref.hpp:23
constexpr glsl_source_ref(const char_type *part, int_type length) noexcept
Construction from a single C-string and length value.
Definition: source_ref.hpp:32
constexpr glsl_source_ref(string_view source_str) noexcept
Construction from a string_view.
Definition: source_ref.hpp:40
gl_types::int_type int_type
Alias for integer type.
Definition: source_ref.hpp:26

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).