1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef BASE_STRINGS_H
18 #define BASE_STRINGS_H
19 
20 #include <string>
21 #include <vector>
22 
23 namespace android {
24 namespace base {
25 
26 // Splits a string into a vector of strings.
27 //
28 // The string is split at each occurrence of a character in delimiters.
29 //
30 // The empty string is not a valid delimiter list.
31 std::vector<std::string> Split(const std::string& s,
32                                const std::string& delimiters);
33 
34 // Trims whitespace off both ends of the given string.
35 std::string Trim(const std::string& s);
36 
37 // Joins a vector of strings into a single string, using the given separator.
38 template <typename StringT>
39 std::string Join(const std::vector<StringT>& strings, char separator);
40 
41 // Tests whether 's' starts with 'prefix'.
42 bool StartsWith(const std::string& s, const char* prefix);
43 
44 // Tests whether 's' ends with 'suffix'.
45 bool EndsWith(const std::string& s, const char* suffix);
46 
47 }  // namespace base
48 }  // namespace android
49 
50 #endif  // BASE_STRINGS_H
51