MCPcopy Create free account
hub / github.com/NazaraEngine/NazaraEngine / GetWord

Method GetWord

src/Nazara/Core/String.cpp:2251–2286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2249 */
2250
2251 String String::GetWord(unsigned int index, UInt32 flags) const
2252 {
2253 std::size_t startPos = GetWordPosition(index, flags);
2254 if (startPos == npos)
2255 return String();
2256
2257 std::intmax_t endPos = -1;
2258 const char* ptr = &m_sharedString->string[startPos];
2259 if (flags & HandleUtf8)
2260 {
2261 utf8::unchecked::iterator<const char*> it(ptr);
2262 do
2263 {
2264 if (Detail::IsSpace(*it))
2265 {
2266 endPos = static_cast<std::intmax_t>(it.base() - m_sharedString->string.get() - 1);
2267 break;
2268 }
2269 }
2270 while (*++it);
2271 }
2272 else
2273 {
2274 do
2275 {
2276 if (Detail::IsSpace(*ptr))
2277 {
2278 endPos = static_cast<std::intmax_t>(ptr - m_sharedString->string.get() - 1);
2279 break;
2280 }
2281 }
2282 while (*++ptr);
2283 }
2284
2285 return SubString(startPos, endPos);
2286 }
2287
2288 /*!
2289 * \brief Gets the word position

Callers 5

ParseMethod · 0.80
ParseMethod · 0.80
CheckMethod · 0.80
ParseMethod · 0.80
ParseMethod · 0.80

Calls 2

IsSpaceFunction · 0.85
StringClass · 0.50

Tested by

no test coverage detected