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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/gn/err.cc ('k') | tools/gn/escape.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/escape.h
diff --git a/tools/gn/escape.h b/tools/gn/escape.h
new file mode 100644
index 0000000000000000000000000000000000000000..17911613b200fed130354aba12bbf1f0eaeda679
--- /dev/null
+++ b/tools/gn/escape.h
@@ -0,0 +1,53 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef TOOLS_GN_ESCAPE_H_
+#define TOOLS_GN_ESCAPE_H_
+
+#include <iosfwd>
+
+#include "base/strings/string_piece.h"
+
+// TODO(brettw) we may need to make this a bitfield. If we want to write a
+// shell command in a ninja file, we need the shell characters to be escaped,
+// and THEN the ninja characters. Or maybe we require the caller to do two
+// passes.
+enum EscapingMode {
+ ESCAPE_NONE, // No escaping.
+ ESCAPE_NINJA, // Ninja string escaping.
+ ESCAPE_SHELL, // Shell string escaping.
+};
+
+struct EscapeOptions {
+ EscapeOptions()
+ : mode(ESCAPE_NONE),
+ convert_slashes(false),
+ inhibit_quoting(false) {
+ }
+
+ EscapingMode mode;
+
+ // When set, converts forward-slashes to system-specific path separators.
+ bool convert_slashes;
+
+ // When the escaping mode is ESCAPE_SHELL, the escaper will normally put
+ // quotes around things with spaces. If this value is set to true, we'll
+ // disable the quoting feature and just add the spaces.
+ //
+ // This mode is for when quoting is done at some higher-level. Defaults to
+ // false.
+ bool inhibit_quoting;
+};
+
+// Escapes the given input, returnining the result.
+std::string EscapeString(const base::StringPiece& str,
+ const EscapeOptions& options);
+
+// Same as EscapeString but writes the results to the given stream, saving a
+// copy.
+void EscapeStringToStream(std::ostream& out,
+ const base::StringPiece& str,
+ const EscapeOptions& options);
+
+#endif // TOOLS_GN_ESCAPE_H_
« 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