OLD | NEW |
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_ESCAPE_H_ | 5 #ifndef TOOLS_GN_ESCAPE_H_ |
6 #define TOOLS_GN_ESCAPE_H_ | 6 #define TOOLS_GN_ESCAPE_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
11 | 11 |
12 enum EscapingMode { | 12 enum EscapingMode { |
13 // No escaping. | 13 // No escaping. |
14 ESCAPE_NONE, | 14 ESCAPE_NONE, |
15 | 15 |
16 // Ninja string escaping. | 16 // Ninja string escaping. |
17 ESCAPE_NINJA, | 17 ESCAPE_NINJA, |
18 | 18 |
19 // For writing commands to ninja files. | 19 // For writing commands to ninja files. This assumes the output is "one |
| 20 // thing" like a filename, so will escape or quote spaces as necessary for |
| 21 // both Ninja and the shell to keep that thing together. |
20 ESCAPE_NINJA_COMMAND, | 22 ESCAPE_NINJA_COMMAND, |
| 23 |
| 24 // For writing preformatted shell commands to Ninja files. This assumes the |
| 25 // output already has the proper quoting and may include special shell |
| 26 // shell characters which we want to pass to the shell (like when writing |
| 27 // tool commands). Only Ninja "$" are escaped. |
| 28 ESCAPE_NINJA_PREFORMATTED_COMMAND, |
21 }; | 29 }; |
22 | 30 |
23 enum EscapingPlatform { | 31 enum EscapingPlatform { |
24 // Do escaping for the current platform. | 32 // Do escaping for the current platform. |
25 ESCAPE_PLATFORM_CURRENT, | 33 ESCAPE_PLATFORM_CURRENT, |
26 | 34 |
27 // Force escaping for the given platform. | 35 // Force escaping for the given platform. |
28 ESCAPE_PLATFORM_POSIX, | 36 ESCAPE_PLATFORM_POSIX, |
29 ESCAPE_PLATFORM_WIN, | 37 ESCAPE_PLATFORM_WIN, |
30 }; | 38 }; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 const EscapeOptions& options, | 71 const EscapeOptions& options, |
64 bool* needed_quoting); | 72 bool* needed_quoting); |
65 | 73 |
66 // Same as EscapeString but writes the results to the given stream, saving a | 74 // Same as EscapeString but writes the results to the given stream, saving a |
67 // copy. | 75 // copy. |
68 void EscapeStringToStream(std::ostream& out, | 76 void EscapeStringToStream(std::ostream& out, |
69 const base::StringPiece& str, | 77 const base::StringPiece& str, |
70 const EscapeOptions& options); | 78 const EscapeOptions& options); |
71 | 79 |
72 #endif // TOOLS_GN_ESCAPE_H_ | 80 #endif // TOOLS_GN_ESCAPE_H_ |
OLD | NEW |