Remove the now unused TextButton code.
[chromium-blink-merge.git] / tools / gn / escape.h
blob6f8cf9cc3b10976186c8c6864c5e56efd193550a
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.
5 #ifndef TOOLS_GN_ESCAPE_H_
6 #define TOOLS_GN_ESCAPE_H_
8 #include <iosfwd>
10 #include "base/strings/string_piece.h"
12 enum EscapingMode {
13 // No escaping.
14 ESCAPE_NONE,
16 // Ninja string escaping.
17 ESCAPE_NINJA,
19 // For writing commands to ninja files.
20 ESCAPE_NINJA_COMMAND,
23 enum EscapingPlatform {
24 // Do escaping for the current platform.
25 ESCAPE_PLATFORM_CURRENT,
27 // Force escaping for the given platform.
28 ESCAPE_PLATFORM_POSIX,
29 ESCAPE_PLATFORM_WIN,
32 struct EscapeOptions {
33 EscapeOptions()
34 : mode(ESCAPE_NONE),
35 platform(ESCAPE_PLATFORM_CURRENT),
36 inhibit_quoting(false) {
39 EscapingMode mode;
41 // Controls how "fork" escaping is done. You will generally want to keep the
42 // default "current" platform.
43 EscapingPlatform platform;
45 // When the escaping mode is ESCAPE_SHELL, the escaper will normally put
46 // quotes around things with spaces. If this value is set to true, we'll
47 // disable the quoting feature and just add the spaces.
49 // This mode is for when quoting is done at some higher-level. Defaults to
50 // false. Note that Windows has strange behavior where the meaning of the
51 // backslashes changes according to if it is followed by a quote. The
52 // escaping rules assume that a double-quote will be appended to the result.
53 bool inhibit_quoting;
56 // Escapes the given input, returnining the result.
58 // If needed_quoting is non-null, whether the string was or should have been
59 // (if inhibit_quoting was set) quoted will be written to it. This value should
60 // be initialized to false by the caller and will be written to only if it's
61 // true (the common use-case is for chaining calls).
62 std::string EscapeString(const base::StringPiece& str,
63 const EscapeOptions& options,
64 bool* needed_quoting);
66 // Same as EscapeString but writes the results to the given stream, saving a
67 // copy.
68 void EscapeStringToStream(std::ostream& out,
69 const base::StringPiece& str,
70 const EscapeOptions& options);
72 #endif // TOOLS_GN_ESCAPE_H_