MCPcopy Create free account
hub / github.com/chen3feng/toft / JoinStrings

Function JoinStrings

base/string/algorithm.cpp:123–142  ·  view source on GitHub ↗

This function merges a vector of string components

Source from the content-addressed store, hash-verified

121
122// This function merges a vector of string components
123void JoinStrings(
124 const std::vector<std::string>& components,
125 const StringPiece& delim,
126 std::string* result)
127{
128 size_t length = 0;
129
130 for (std::vector<std::string>::const_iterator iter = components.begin();
131 iter != components.end(); ++iter)
132 {
133 if (iter != components.begin())
134 {
135 length += delim.length();
136 }
137 length += iter->size();
138 }
139 result->reserve(length);
140 return JoinStrings<std::vector<std::string>::const_iterator>(
141 components.begin(), components.end(), delim, result);
142}
143
144std::string JoinStrings(const std::vector<std::string>& components, const StringPiece& delim)
145{

Callers

nothing calls this directly

Calls 4

beginMethod · 0.45
endMethod · 0.45
lengthMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected