Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Side by Side Diff: tools/gn/string_utils.h

Issue 1681363003: Add spell-checking to `gn help`. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move to string_utils, add tests Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef TOOLS_GN_STRING_UTILS_H_ 5 #ifndef TOOLS_GN_STRING_UTILS_H_
6 #define TOOLS_GN_STRING_UTILS_H_ 6 #define TOOLS_GN_STRING_UTILS_H_
7 7
8 #include <vector>
9
8 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
9 11
10 class Err; 12 class Err;
11 class Scope; 13 class Scope;
12 class Token; 14 class Token;
13 class Value; 15 class Value;
14 16
15 inline std::string operator+(const std::string& a, const base::StringPiece& b) { 17 inline std::string operator+(const std::string& a, const base::StringPiece& b) {
16 std::string ret; 18 std::string ret;
17 ret.reserve(a.size() + b.size()); 19 ret.reserve(a.size() + b.size());
(...skipping 10 matching lines...) Expand all
28 return ret; 30 return ret;
29 } 31 }
30 32
31 // Unescapes and expands variables in the given literal, writing the result 33 // Unescapes and expands variables in the given literal, writing the result
32 // to the given value. On error, sets |err| and returns false. 34 // to the given value. On error, sets |err| and returns false.
33 bool ExpandStringLiteral(Scope* scope, 35 bool ExpandStringLiteral(Scope* scope,
34 const Token& literal, 36 const Token& literal,
35 Value* result, 37 Value* result,
36 Err* err); 38 Err* err);
37 39
40 // Returns the minimum number of inserts, deleted, and replacements of
41 // characters needed to transform s1 to s2, or max_edit_distance + 1 if
42 // transforming s1 into s2 isn't possible in at most max_edit_distance steps.
43 size_t EditDistance(const base::StringPiece& s1,
44 const base::StringPiece& s2,
45 size_t max_edit_distance);
46
47 // Given a string |text| and a vector of correctly-spelled strings |words|,
48 // returns the first string in |words| closest to |text|, or an empty
49 // StringPiece if none of the strings in |words| is close.
50 base::StringPiece SpellcheckString(const base::StringPiece& text,
51 const std::vector<base::StringPiece>& words);
52
38 #endif // TOOLS_GN_STRING_UTILS_H_ 53 #endif // TOOLS_GN_STRING_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698