core::stream class

stream contains a type erased "stream" of memory with basic facilities to protect it from incorrect casts.

stream should be used in scenarios where something could contain various, but functionaly similar arrays of float. see core::data::geometry for an example of this.

types

enums

type
the supported internal types of the stream.
enum classclasspublicpublic

member-functions

data
returns the pointer to the head of the memory stream.
public
cdata
returns the constant pointer to the head of the memory stream.
const public
as_single
returns the type safe variant of the stream as a reference.
public
as_vec2
returns the type safe variant of the stream as a reference.
public
as_vec3
returns the type safe variant of the stream as a reference.
public
as_vec4
returns the type safe variant of the stream as a reference.
public
as_mat2
returns the type safe variant of the stream as a reference.
public
as_mat3
returns the type safe variant of the stream as a reference.
public
as_mat4
returns the type safe variant of the stream as a reference.
public
as_single
returns the type safe variant of the stream as a reference.
const public
as_vec2
returns the type safe variant of the stream as a reference.
const public
as_vec3
returns the type safe variant of the stream as a reference.
const public
as_vec4
returns the type safe variant of the stream as a reference.
const public
as_mat2
returns the type safe variant of the stream as a reference.
const public
as_mat3
returns the type safe variant of the stream as a reference.
const public
as_mat4
returns the type safe variant of the stream as a reference.
const public
size
returns the size of the stream (in unique element count).
const public
bytesize
returns the total size of the memory stream in bytes.
const public

Function documentation

void* core::stream::data()

Brief

returns the pointer to the head of the memory stream.

Returns the pointer to the head of the memory stream.

const void* core::stream::cdata() const

Brief

returns the constant pointer to the head of the memory stream.

Returns the constant pointer to the head of the memory stream.

std::optional<std::reference_wrapper<std::vector<float>>> core::stream::as_single()

Brief

returns the type safe variant of the stream as a reference.

Details

if the stream is of the correct type, it will return a valid vector, otherwise a std::nullopt

Returns either a valid stream (on success) or a std::nullopt (on failure).

std::optional<std::reference_wrapper<std::vector<psl::vec2>>> core::stream::as_vec2()

Brief

returns the type safe variant of the stream as a reference.

Details

if the stream is of the correct type, it will return a valid vector, otherwise a std::nullopt

Returns either a valid stream (on success) or a std::nullopt (on failure).

std::optional<std::reference_wrapper<std::vector<psl::vec3>>> core::stream::as_vec3()

Brief

returns the type safe variant of the stream as a reference.

Details

if the stream is of the correct type, it will return a valid vector, otherwise a std::nullopt

Returns either a valid stream (on success) or a std::nullopt (on failure).

std::optional<std::reference_wrapper<std::vector<psl::vec4>>> core::stream::as_vec4()

Brief

returns the type safe variant of the stream as a reference.

Details

if the stream is of the correct type, it will return a valid vector, otherwise a std::nullopt

Returns either a valid stream (on success) or a std::nullopt (on failure).

std::optional<std::reference_wrapper<std::vector<psl::mat2x2>>> core::stream::as_mat2()

Brief

returns the type safe variant of the stream as a reference.

Details

if the stream is of the correct type, it will return a valid vector, otherwise a std::nullopt

Returns either a valid stream (on success) or a std::nullopt (on failure).

std::optional<std::reference_wrapper<std::vector<psl::mat3x3>>> core::stream::as_mat3()

Brief

returns the type safe variant of the stream as a reference.

Details

if the stream is of the correct type, it will return a valid vector, otherwise a std::nullopt

Returns either a valid stream (on success) or a std::nullopt (on failure).

std::optional<std::reference_wrapper<std::vector<psl::mat4x4>>> core::stream::as_mat4()

Brief

returns the type safe variant of the stream as a reference.

Details

if the stream is of the correct type, it will return a valid vector, otherwise a std::nullopt

Returns either a valid stream (on success) or a std::nullopt (on failure).

std::optional<std::reference_wrapper<const std::vector<float>>> core::stream::as_single() const

Brief

returns the type safe variant of the stream as a reference.

Details

if the stream is of the correct type, it will return a valid vector, otherwise a std::nullopt

Returns either a valid stream (on success) or a std::nullopt (on failure).

std::optional<std::reference_wrapper<const std::vector<psl::vec2>>> core::stream::as_vec2() const

Brief

returns the type safe variant of the stream as a reference.

Details

if the stream is of the correct type, it will return a valid vector, otherwise a std::nullopt

Returns either a valid stream (on success) or a std::nullopt (on failure).

std::optional<std::reference_wrapper<const std::vector<psl::vec3>>> core::stream::as_vec3() const

Brief

returns the type safe variant of the stream as a reference.

Details

if the stream is of the correct type, it will return a valid vector, otherwise a std::nullopt

Returns either a valid stream (on success) or a std::nullopt (on failure).

std::optional<std::reference_wrapper<const std::vector<psl::vec4>>> core::stream::as_vec4() const

Brief

returns the type safe variant of the stream as a reference.

Details

if the stream is of the correct type, it will return a valid vector, otherwise a std::nullopt

Returns either a valid stream (on success) or a std::nullopt (on failure).

std::optional<std::reference_wrapper<const std::vector<psl::mat2x2>>> core::stream::as_mat2() const

Brief

returns the type safe variant of the stream as a reference.

Details

if the stream is of the correct type, it will return a valid vector, otherwise a std::nullopt

Returns either a valid stream (on success) or a std::nullopt (on failure).

std::optional<std::reference_wrapper<const std::vector<psl::mat3x3>>> core::stream::as_mat3() const

Brief

returns the type safe variant of the stream as a reference.

Details

if the stream is of the correct type, it will return a valid vector, otherwise a std::nullopt

Returns either a valid stream (on success) or a std::nullopt (on failure).

std::optional<std::reference_wrapper<const std::vector<psl::mat4x4>>> core::stream::as_mat4() const

Brief

returns the type safe variant of the stream as a reference.

Details

if the stream is of the correct type, it will return a valid vector, otherwise a std::nullopt

Returns either a valid stream (on success) or a std::nullopt (on failure).

size_t core::stream::size() const

Brief

returns the size of the stream (in unique element count).

Details

depending on the contained type, one "element" is bigger/smaller. This method returns the size of one element. for example if the stream contains vec2 data, one element is equal to 2 floats, and so the size() would be 2 if there were 4 floats present. similarly if the stream contained vec3 data, one element would be equivalent to 3 floats, and so a size() of 4 would be equal to 12 floats.

Returns the element count.

size_t core::stream::bytesize() const

Brief

returns the total size of the memory stream in bytes.

Returns the total size of the memory stream in bytes.