23 #include <string_view> 27 std::cerr <<
"Memory allocation failed" << std::endl;
34 check_sum_.resize(kCheckSumLength,
'\0');
39 for (
int i = 0; i < kCheckSumLength; ++i) check_sum_[i] =
'\0';
43 for (
int i = 0; i < data.size(); ++i) {
44 check_sum_[(count_++) % kCheckSumLength] ^= data[i];
50 std::vector<std::string_view> StringSplitter::SplitToSv() {
51 std::vector<std::string_view> vec;
53 if (string_.empty() && !skip_empty_) {
58 vec.reserve(string_.size());
59 for (
int i = 0; i < string_.size(); ++i) {
60 vec.push_back(string_.substr(i, 1));
65 size_t prev_pos = 0, pos = 0;
66 while (pos <= string_.length()) {
67 pos = string_.find_first_of(delim_, pos);
68 if (pos == std::string_view::npos) {
69 pos = string_.length();
71 if (!skip_empty_ || pos != prev_pos) {
72 vec.push_back(string_.substr(prev_pos, pos - prev_pos));
101 bool IsAsciiSpace(
unsigned char ch) {
return std::isspace(ch); }
105 auto it = std::find_if_not(full.rbegin(), full.rend(), IsAsciiSpace);
106 return full.substr(0, full.rend() - it);
110 auto it = std::find_if_not(full->rbegin(), full->rend(), IsAsciiSpace);
111 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)