Jamie Madill | 8c5aeb6 | 2015-05-21 08:17:18 -0400 | [diff] [blame] | 1 | // |
| 2 | // Copyright 2015 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | // string_utils: |
| 7 | // String helper functions. |
| 8 | // |
| 9 | |
| 10 | #ifndef LIBANGLE_STRING_UTILS_H_ |
| 11 | #define LIBANGLE_STRING_UTILS_H_ |
| 12 | |
| 13 | #include <string> |
| 14 | #include <vector> |
| 15 | |
Jamie Madill | 8b9b792 | 2016-05-19 13:13:37 -0400 | [diff] [blame^] | 16 | #include "common/Optional.h" |
| 17 | |
Jamie Madill | 8c5aeb6 | 2015-05-21 08:17:18 -0400 | [diff] [blame] | 18 | namespace angle |
| 19 | { |
| 20 | |
Corentin Wallez | 47ac69c | 2015-11-24 11:15:57 -0500 | [diff] [blame] | 21 | extern const char kWhitespaceASCII[]; |
| 22 | |
| 23 | enum WhitespaceHandling |
| 24 | { |
| 25 | KEEP_WHITESPACE, |
| 26 | TRIM_WHITESPACE, |
| 27 | }; |
| 28 | |
| 29 | enum SplitResult |
| 30 | { |
| 31 | SPLIT_WANT_ALL, |
| 32 | SPLIT_WANT_NONEMPTY, |
| 33 | }; |
| 34 | |
| 35 | std::vector<std::string> SplitString(const std::string &input, |
| 36 | const std::string &delimiters, |
| 37 | WhitespaceHandling whitespace, |
| 38 | SplitResult resultType); |
Jamie Madill | 8c5aeb6 | 2015-05-21 08:17:18 -0400 | [diff] [blame] | 39 | |
| 40 | void SplitStringAlongWhitespace(const std::string &input, |
| 41 | std::vector<std::string> *tokensOut); |
| 42 | |
Corentin Wallez | 47ac69c | 2015-11-24 11:15:57 -0500 | [diff] [blame] | 43 | std::string TrimString(const std::string &input, const std::string &trimChars); |
| 44 | |
Jamie Madill | 8c5aeb6 | 2015-05-21 08:17:18 -0400 | [diff] [blame] | 45 | bool HexStringToUInt(const std::string &input, unsigned int *uintOut); |
| 46 | |
| 47 | bool ReadFileToString(const std::string &path, std::string *stringOut); |
| 48 | |
Jamie Madill | 8b9b792 | 2016-05-19 13:13:37 -0400 | [diff] [blame^] | 49 | Optional<std::vector<wchar_t>> WidenString(size_t length, const char *cString); |
Jamie Madill | 8c5aeb6 | 2015-05-21 08:17:18 -0400 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | #endif // LIBANGLE_STRING_UTILS_H_ |