cpp: Add internal utility function for splitting strings
* lang/cpp/src/util.h (split): New. -- This function splits a given string using the given delimiter into several strings. GnuPG-bug-id: 5904
This commit is contained in:
parent
4beb6f4199
commit
c965b45bcd
@ -177,6 +177,19 @@ static inline gpgme_sig_notation_flags_t add_to_gpgme_sig_notation_flags_t(unsi
|
||||
return static_cast<gpgme_sig_notation_flags_t>(result);
|
||||
}
|
||||
|
||||
static inline std::vector<std::string> split(const std::string &text, char delimiter)
|
||||
{
|
||||
std::vector<std::string> result;
|
||||
if (!text.empty()) {
|
||||
std::istringstream stream{text};
|
||||
std::string line;
|
||||
while (std::getline(stream, line, delimiter)) {
|
||||
result.push_back(line);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapter for passing a vector of strings as NULL-terminated array of
|
||||
* const char* to the C-interface of gpgme.
|
||||
|
Loading…
Reference in New Issue
Block a user