summaryrefslogtreecommitdiff
path: root/tools/streaming_proto/string_utils.cpp
diff options
context:
space:
mode:
authorYi Jin <jinyithu@google.com>2017-11-01 17:08:27 -0700
committerYi Jin <jinyithu@google.com>2017-11-10 17:34:07 -0800
commite2f7f79d023f0b3ba2fee374492dde61f525ece6 (patch)
tree8ea7efe3b552f1cb23c2f4c2ef379be6fb02f19b /tools/streaming_proto/string_utils.cpp
parent9a753af26b2ce27c10ad215aa70cf1bcd44d7915 (diff)
Implement Cpu Info Section
Support carriage return in Read class, and add a new way to parse lines which is not able to split purly by delimiters Bug: 65642861 Test: unit test and on device test Change-Id: Ib82dd4e458bb7d2fa33462b23fbe11b828325916
Diffstat (limited to 'tools/streaming_proto/string_utils.cpp')
-rw-r--r--tools/streaming_proto/string_utils.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/streaming_proto/string_utils.cpp b/tools/streaming_proto/string_utils.cpp
index bd34ab7aa44d..607d820033ff 100644
--- a/tools/streaming_proto/string_utils.cpp
+++ b/tools/streaming_proto/string_utils.cpp
@@ -108,6 +108,17 @@ split(const string& str, const char delimiter)
return result;
}
+string
+stripPrefix(const string& str, const string& prefix)
+{
+ if (str.size() <= prefix.size()) return str;
+ size_t i = 0, len = prefix.size();
+ for (; i<len; i++) {
+ if (str[i] != prefix[i]) return str;
+ }
+ return str.substr(i);
+}
+
} // namespace stream_proto
} // namespace android