23 #include <string_view> 30 check_sum_.resize(kCheckSumLength,
'\0');
35 for (
int i = 0; i < kCheckSumLength; ++i) check_sum_[i] =
'\0';
39 for (
int i = 0; i < data.size(); ++i) {
40 check_sum_[(count_++) % kCheckSumLength] ^= data[i];
46 std::vector<std::string_view> StringSplitter::SplitToSv() {
47 std::vector<std::string_view> vec;
49 if (string_.empty() && !skip_empty_) {
54 vec.reserve(string_.size());
55 for (
int i = 0; i < string_.size(); ++i) {
56 vec.push_back(string_.substr(i, 1));
61 size_t prev_pos = 0, pos = 0;
62 while (pos <= string_.length()) {
63 pos = string_.find_first_of(delim_, pos);
64 if (pos == std::string_view::npos) {
65 pos = string_.length();
67 if (!skip_empty_ || pos != prev_pos) {
68 vec.push_back(string_.substr(prev_pos, pos - prev_pos));
97 bool IsAsciiSpace(
unsigned char ch) {
return std::isspace(ch); }
101 auto it = std::find_if_not(full.rbegin(), full.rend(), IsAsciiSpace);
102 return full.substr(0, full.rend() - it);
106 auto it = std::find_if_not(full->rbegin(), full->rend(), IsAsciiSpace);
107 full->erase(full->rend() - it);
void StripTrailingAsciiWhitespace(std::string *full)
internal::StringSplitter StrSplit(std::string_view full, ByAnyChar delim)
void Update(std::string_view data)