blob: 5ddfbbd0d81b69af948c3039a733834e9c0f3316 [file] [log] [blame]
Dan Albert00716d72015-03-13 22:57:40 -07001/*
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
23namespace android {
24namespace base {
25
26// Splits a string using the given separator character into a vector of strings.
27// Empty strings will be omitted.
28void Split(const std::string& s, char separator,
29 std::vector<std::string>* result);
30
31// Trims whitespace off both ends of the given string.
32std::string Trim(const std::string& s);
33
34// Joins a vector of strings into a single string, using the given separator.
35template <typename StringT>
36std::string Join(const std::vector<StringT>& strings, char separator);
37
38// Tests whether 's' starts with 'prefix'.
39bool StartsWith(const std::string& s, const char* prefix);
40
41// Tests whether 's' ends with 'suffix'.
42bool EndsWith(const std::string& s, const char* suffix);
43
44} // namespace base
45} // namespace android
46
47#endif // BASE_STRINGS_H