summaryrefslogtreecommitdiff
path: root/tools/streaming_proto/string_utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/streaming_proto/string_utils.cpp')
-rw-r--r--tools/streaming_proto/string_utils.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/tools/streaming_proto/string_utils.cpp b/tools/streaming_proto/string_utils.cpp
index cc738c4c108e..bd34ab7aa44d 100644
--- a/tools/streaming_proto/string_utils.cpp
+++ b/tools/streaming_proto/string_utils.cpp
@@ -3,7 +3,7 @@
#include <iostream>
namespace android {
-namespace javastream_proto {
+namespace stream_proto {
using namespace std;
@@ -89,7 +89,26 @@ replace_string(const string& str, const char replace, const char with)
return result;
}
-} // namespace javastream_proto
+vector<string>
+split(const string& str, const char delimiter)
+{
+ vector<string> result;
+ size_t base = 0, found = 0;
+ while (true) {
+ found = str.find_first_of(delimiter, base);
+ if (found != base) {
+ string part = str.substr(base, found - base);
+ if (!part.empty()) {
+ result.push_back(part);
+ }
+ }
+ if (found == str.npos) break;
+ base = found + 1;
+ }
+ return result;
+}
+
+} // namespace stream_proto
} // namespace android