MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / explode

Function explode

src/Core/Graphics/Text.cpp:106–135  ·  view source on GitHub ↗

///////////////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

104
105 ////////////////////////////////////////////////////////////////////////////////
106 std::vector<sf::String> explode(const sf::String& string, sf::Uint32 delimiter)
107 {
108 if (string.isEmpty())
109 return std::vector<sf::String>();
110
111 // For each character in the string
112 std::vector<sf::String> result;
113 sf::String buffer;
114 for (sf::Uint32 character : string)
115 {
116 // If we've hit the delimiter character
117 if (character == delimiter)
118 {
119 // Add them to the result vector
120 result.push_back(buffer);
121 buffer.clear();
122 }
123 else
124 {
125 // Accumulate the next character into the sequence
126 buffer += character;
127 }
128 }
129
130 // Add to the result if buffer still has contents or if the last character is a delimiter
131 if (!buffer.isEmpty() || string[string.getSize() - 1] == delimiter)
132 result.push_back(buffer);
133
134 return result;
135 }
136
137 void RichText::setCharacterSize(unsigned int size)
138 {

Callers 1

Text.cppFile · 0.70

Calls 3

push_backMethod · 0.45
clearMethod · 0.45
getSizeMethod · 0.45

Tested by

no test coverage detected