Flutter Engine
 
Loading...
Searching...
No Matches
strings.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
7namespace impeller {
8
9bool HasPrefix(const std::string& string, const std::string& prefix) {
10 return string.find(prefix) == 0u;
11}
12
13bool HasSuffix(const std::string& string, const std::string& suffix) {
14 auto position = string.rfind(suffix);
15 if (position == std::string::npos) {
16 return false;
17 }
18 return position == string.size() - suffix.size();
19}
20
21std::string StripPrefix(const std::string& string,
22 const std::string& to_strip) {
23 if (!HasPrefix(string, to_strip)) {
24 return string;
25 }
26 return string.substr(to_strip.length());
27}
28
29} // namespace impeller
bool HasPrefix(const std::string &string, const std::string &prefix)
Definition strings.cc:9
bool HasSuffix(const std::string &string, const std::string &suffix)
Definition strings.cc:13
std::string StripPrefix(const std::string &string, const std::string &to_strip)
Definition strings.cc:21