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

Method substr

source/core/StarString.cpp:739–761  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

737}
738
739String String::substr(size_t position, size_t n) const {
740 auto len = size();
741 if (position > len)
742 throw OutOfRangeException(strf("out of range in String::substr({}, {})", position, n));
743
744 if (position == 0 && n >= len)
745 return *this;
746
747 String ret;
748 ret.reserve(std::min(n, len - position));
749
750 auto it = begin();
751 std::advance(it, position);
752
753 for (size_t i = 0; i < n; ++i) {
754 if (it == end())
755 break;
756 ret.append(*it);
757 ++it;
758 }
759
760 return ret;
761}
762
763void String::erase(size_t pos, size_t n) {
764 String ns;

Callers 15

replaceBehaviorTagFunction · 0.45
replaceOutputBehaviorTagFunction · 0.45
setHandFrameOverridesMethod · 0.45
handleCommandMethod · 0.45
handleIncomingPacketsMethod · 0.45
setupMethod · 0.45
parseABCMethod · 0.45
ParticleMethod · 0.45
initMethod · 0.45
orientationDrawablesMethod · 0.45
playerCidFromCommandMethod · 0.45
ArmorItemMethod · 0.45

Calls 6

sizeFunction · 0.85
strfFunction · 0.85
beginFunction · 0.85
endFunction · 0.85
reserveMethod · 0.45
appendMethod · 0.45

Tested by 7

TESTFunction · 0.36
RemoveExtensionMethod · 0.36
SplitStringFunction · 0.36
SplitEscapedStringFunction · 0.36
FormatDeathTestOutputFunction · 0.36