webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
string_utils.h
Go to the documentation of this file.
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 
16 #include "common/Optional.h"
17 
18 namespace angle
19 {
20 
21 extern const char kWhitespaceASCII[];
22 
24 {
27 };
28 
30 {
33 };
34 
35 std::vector<std::string> SplitString(const std::string &input,
36  const std::string &delimiters,
37  WhitespaceHandling whitespace,
38  SplitResult resultType);
39 
41  std::vector<std::string> *tokensOut);
42 
43 std::string TrimString(const std::string &input, const std::string &trimChars);
44 
45 bool HexStringToUInt(const std::string &input, unsigned int *uintOut);
46 
47 bool ReadFileToString(const std::string &path, std::string *stringOut);
48 
49 Optional<std::vector<wchar_t>> WidenString(size_t length, const char *cString);
50 
51 // Check if the string str begins with the given prefix.
52 // Prefix may not be NULL and needs to be NULL terminated.
53 // The comparison is case sensitive.
54 bool BeginsWith(const std::string &str, const char *prefix);
55 
56 // Check if the string str begins with the given prefix.
57 // str and prefix may not be NULL and need to be NULL terminated.
58 // The comparison is case sensitive.
59 bool BeginsWith(const char *str, const char *prefix);
60 
61 // Check if the string str ends with the given suffix.
62 // Suffix may not be NUL and needs to be NULL terminated.
63 // The comparison is case sensitive.
64 bool EndsWith(const std::string& str, const char* suffix);
65 }
66 
67 #endif // LIBANGLE_STRING_UTILS_H_
SplitResult
Definition: string_utils.h:29
bool ReadFileToString(const std::string &path, std::string *stringOut)
Definition: string_utils.cpp:125
Definition: Optional.h:14
path
Definition: generate.py:74
Definition: string_utils.h:26
Optional< std::vector< wchar_t > > WidenString(size_t length, const char *cString)
Definition: string_utils.cpp:141
Definition: string_utils.h:25
Definition: Platform.h:33
Definition: string_utils.h:32
bool BeginsWith(const std::string &str, const char *prefix)
Definition: string_utils.cpp:161
Definition: xmlparse.c:154
const char kWhitespaceASCII[]
Definition: string_utils.cpp:23
str
Definition: make-dist.py:305
GLsizei const GLchar *const * string
Definition: gl2.h:479
bool HexStringToUInt(const std::string &input, unsigned int *uintOut)
Definition: string_utils.cpp:105
WhitespaceHandling
Definition: string_utils.h:23
bool EndsWith(const std::string &str, const char *suffix)
Definition: string_utils.cpp:171
std::vector< std::string > SplitString(const std::string &input, const std::string &delimiters, WhitespaceHandling whitespace, SplitResult resultType)
Definition: string_utils.cpp:25
string input
Definition: tokenizer_unittest.cc:198
std::string TrimString(const std::string &input, const std::string &trimChars)
Definition: string_utils.cpp:88
void SplitStringAlongWhitespace(const std::string &input, std::vector< std::string > *tokensOut)
Definition: string_utils.cpp:67
GLuint GLsizei GLsizei * length
Definition: gl2.h:435
Definition: string_utils.h:31