MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / substr

Method substr

source/core/StarStringView.cpp:352–372  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

350}
351
352StringView StringView::substr(size_t position, size_t n) const {
353 StringView ret;
354 auto itEnd = end();
355 auto it = begin();
356
357 for (size_t i = 0; i != position; ++i) {
358 if (it == itEnd)
359 throw OutOfRangeException(strf("out of range in StringView::substr({}, {})", position, n));
360 it++;
361 }
362
363 const auto itStart = it;
364
365 for (size_t i = 0; i != n; ++i) {
366 if (it == itEnd)
367 break;
368 ++it;
369 }
370
371 return StringView(&*itStart.base(), it.base() - itStart.base());
372}
373
374int StringView::compare(size_t selfOffset, size_t selfLen, StringView other,
375 size_t otherOffset, size_t otherLen, CaseSensitivity cs) const {

Callers 2

forEachSplitAnyViewMethod · 0.45
forEachSplitViewMethod · 0.45

Calls 4

endFunction · 0.85
beginFunction · 0.85
strfFunction · 0.85
StringViewClass · 0.85

Tested by

no test coverage detected