blob: 3a9ed24563f6d66dbce725376e6073e59ab7228a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "string.h"
#include <vespa/vespalib/util/stringfmt.h>
namespace vbench {
string strfmt(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
string ret = vespalib::make_string_va(fmt, ap);
va_end(ap);
return ret;
}
size_t splitstr(const string &str, const string &sep,
std::vector<string> &dst)
{
dst.clear();
string tmp;
for (size_t i = 0; i < str.size(); ++i) {
if (sep.find(str[i]) != string::npos) {
if (!tmp.empty()) {
dst.push_back(tmp);
tmp.clear();
}
} else {
tmp.push_back(str[i]);
}
}
if (!tmp.empty()) {
dst.push_back(tmp);
}
return dst.size();
}
} // namespace vbench
|