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

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

Issue 21114002: Add initial prototype for the GN meta-buildsystem. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add owners and readme Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « tools/gn/err.cc ('k') | tools/gn/escape.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef TOOLS_GN_ESCAPE_H_
6 #define TOOLS_GN_ESCAPE_H_
7
8 #include <iosfwd>
9
10 #include "base/strings/string_piece.h"
11
12 // TODO(brettw) we may need to make this a bitfield. If we want to write a
13 // shell command in a ninja file, we need the shell characters to be escaped,
14 // and THEN the ninja characters. Or maybe we require the caller to do two
15 // passes.
16 enum EscapingMode {
17 ESCAPE_NONE, // No escaping.
18 ESCAPE_NINJA, // Ninja string escaping.
19 ESCAPE_SHELL, // Shell string escaping.
20 };
21
22 struct EscapeOptions {
23 EscapeOptions()
24 : mode(ESCAPE_NONE),
25 convert_slashes(false),
26 inhibit_quoting(false) {
27 }
28
29 EscapingMode mode;
30
31 // When set, converts forward-slashes to system-specific path separators.
32 bool convert_slashes;
33
34 // When the escaping mode is ESCAPE_SHELL, the escaper will normally put
35 // quotes around things with spaces. If this value is set to true, we'll
36 // disable the quoting feature and just add the spaces.
37 //
38 // This mode is for when quoting is done at some higher-level. Defaults to
39 // false.
40 bool inhibit_quoting;
41 };
42
43 // Escapes the given input, returnining the result.
44 std::string EscapeString(const base::StringPiece& str,
45 const EscapeOptions& options);
46
47 // Same as EscapeString but writes the results to the given stream, saving a
48 // copy.
49 void EscapeStringToStream(std::ostream& out,
50 const base::StringPiece& str,
51 const EscapeOptions& options);
52
53 #endif // TOOLS_GN_ESCAPE_H_
OLDNEW
« no previous file with comments | « tools/gn/err.cc ('k') | tools/gn/escape.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698