MCPcopy Create free account
hub / github.com/SFML/SFML / getStreamContents

Function getStreamContents

src/SFML/Graphics/Shader.cpp:103–122  ·  view source on GitHub ↗

Read the contents of a stream into an array of char

Source from the content-addressed store, hash-verified

101
102// Read the contents of a stream into an array of char
103bool getStreamContents(sf::InputStream& stream, std::vector<char>& buffer)
104{
105 bool success = false;
106 const std::optional size = stream.getSize();
107 if (size > std::size_t{0})
108 {
109 buffer.resize(*size);
110
111 if (!stream.seek(0).has_value())
112 {
113 sf::err() << "Failed to seek shader stream" << std::endl;
114 return false;
115 }
116
117 const std::optional read = stream.read(buffer.data(), *size);
118 success = (read == size);
119 }
120 buffer.push_back('\0');
121 return success;
122}
123
124// Transforms an array of 2D vectors into a contiguous array of scalars
125std::vector<float> flatten(const sf::Vector2f* vectorArray, std::size_t length)

Callers 1

loadFromStreamMethod · 0.85

Calls 4

getSizeMethod · 0.45
resizeMethod · 0.45
seekMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected