This function merges a vector of string components
| 121 | |
| 122 | // This function merges a vector of string components |
| 123 | void 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 | |
| 144 | std::string JoinStrings(const std::vector<std::string>& components, const StringPiece& delim) |
| 145 | { |