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

Unified Diff: base/stringize_macros.h

Issue 5103001: Add shared macros for stringizing and converting ANSI string constants... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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 | « base/base.gypi ('k') | base/stringize_macros_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/stringize_macros.h
===================================================================
--- base/stringize_macros.h (revision 0)
+++ base/stringize_macros.h (revision 0)
@@ -0,0 +1,55 @@
+// Copyright (c) 2010 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.
+//
+// This file defines preprocessor macros for stringizing preprocessor
+// symbols (or their output) and manipulating preprocessor symbols
+// that define strings.
+
+#ifndef BASE_STRINGIZE_MACROS_H_
+#define BASE_STRINGIZE_MACROS_H_
+#pragma once
+
+// This is not very useful as it does not expand defined symbols if
+// called directly. Use its counterpart without the _NO_EXPANSION
+// suffix, below.
+#define STRINGIZE_NO_EXPANSION(x) #x
+
+// Use this to quote the provided parameter, first expanding it if it
+// is a preprocessor symbol.
+//
+// For example, if:
+// #define A FOO
+// #define B(x) myobj->FunctionCall(x)
+//
+// Then:
+// STRINGIZE(A) produces "FOO"
+// STRINGIZE(B(y)) produces "myobj->FunctionCall(y)"
+#define STRINGIZE(x) STRINGIZE_NO_EXPANSION(x)
+
+// The following are defined only on Windows (for use when interacting
+// with Windows APIs) as wide strings are otherwise deprecated.
+#if defined(OS_WIN)
+
+// Second-level utility macros to let us expand symbols.
+#define LSTRINGIZE_NO_EXPANSION(x) L ## #x
+#define TO_L_STRING_NO_EXPANSION(x) L ## x
+
+// L version of STRINGIZE(). For examples above,
+// LSTRINGIZE(A) produces L"FOO"
+// LSTRINGIZE(B(y)) produces L"myobj->FunctionCall(y)"
+#define LSTRINGIZE(x) LSTRINGIZE_NO_EXPANSION(x)
+
+// Adds an L in front of an existing ASCII string constant (after
+// expanding symbols). Does not do any quoting.
+//
+// For example, if:
+// #define C "foo"
+//
+// Then:
+// TO_L_STRING(C) produces L"foo"
+#define TO_L_STRING(x) TO_L_STRING_NO_EXPANSION(x)
+
+#endif // defined(OS_WIN)
+
+#endif // BASE_STRINGIZE_MACROS_H_
Property changes on: base\stringize_macros.h
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « base/base.gypi ('k') | base/stringize_macros_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698