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

Side by Side Diff: base/atlconvfix.h

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « base/atlassert_unittest.cc ('k') | base/auto_any.h » ('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 2004-2009 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 // ========================================================================
15 //
16 // atlconvfix.h
17 //
18 // This file is included in the precompile headers.
19 // Do not include the base/basictypes.h here.
20
21 #ifndef OMAHA_COMMON_ATLCONVFIX_H_
22 #define OMAHA_COMMON_ATLCONVFIX_H_
23
24 #ifndef DISALLOW_EVIL_CONSTRUCTORS
25 // A macro to disallow the evil copy constructor and operator= functions
26 // This should be used in the private: declarations for a class
27 #define DISALLOW_EVIL_CONSTRUCTORS(TypeName) \
28 TypeName(const TypeName&); \
29 void operator=(const TypeName&)
30 #endif
31
32 // These use alloca which can be dangerous,
33 // so we don't allow them to be used. Use
34 // CA2[C]W, etc. instead.
35 #undef A2W
36 #undef W2A
37 #undef A2W_EX
38 #undef W2A_EX
39 #undef USES_CONVERSION
40
41 #ifdef DEBUG
42 // The DestroyBuffer template and the macros following it are
43 // all there to ensure that when the string classes get destroyed,
44 // so does the string that they return since it is no longer valid.
45 // Without them it is very easy to make simple and hard to catch mistakes
46 // when using the atl C*2[C]* string converstion classes.
47
48 // In non-debug code, the atl string macros do not need to be destroyed,
49 // so they aren't wrapped there.
50
51 template <int buffer_length, template <int buffer_length> class ConversionClass,
52 typename StringType>
53 class DestroyBuffer : public ConversionClass<buffer_length> {
54 public:
55 DestroyBuffer(StringType string) : ConversionClass<buffer_length>(string) {
56 }
57
58 DestroyBuffer(StringType string, UINT code_page) :
59 ConversionClass<buffer_length>(string, code_page) {
60 }
61
62 ~DestroyBuffer() {
63 memset(m_szBuffer, 0xdd, sizeof(m_szBuffer));
64 }
65
66 private:
67 DISALLOW_EVIL_CONSTRUCTORS(DestroyBuffer);
68 };
69
70 #define DECLARED_DESTROY_NAME(base_type) DestroyBuffer##base_type
71 #define DECLARE_DESTROY_TYPES(base_type, string_type) \
72 template <int buffer_length = 128> \
73 class DECLARED_DESTROY_NAME(base_type##EX) : \
74 public DestroyBuffer<buffer_length, base_type##EX, string_type> { \
75 public: \
76 DECLARED_DESTROY_NAME(base_type##EX)(string_type string) : \
77 DestroyBuffer<buffer_length, base_type##EX, string_type>(string) { \
78 } \
79 DECLARED_DESTROY_NAME(base_type##EX)(string_type string, \
80 UINT code_page) : \
81 DestroyBuffer<buffer_length, base_type##EX, string_type>(string, \
82 code_page) { \
83 } \
84 private: \
85 DISALLOW_EVIL_CONSTRUCTORS(DECLARED_DESTROY_NAME(base_type##EX)); \
86 }; \
87 typedef DECLARED_DESTROY_NAME(base_type##EX)<> \
88 DECLARED_DESTROY_NAME(base_type)
89
90 DECLARE_DESTROY_TYPES(CW2W, LPCWSTR);
91 DECLARE_DESTROY_TYPES(CW2A, LPCWSTR);
92 DECLARE_DESTROY_TYPES(CA2W, LPCSTR);
93 DECLARE_DESTROY_TYPES(CA2A, LPCSTR);
94
95 #define CW2WEX DECLARED_DESTROY_NAME(CW2WEX)
96 #define CW2AEX DECLARED_DESTROY_NAME(CW2AEX)
97 #define CA2WEX DECLARED_DESTROY_NAME(CA2WEX)
98 #define CA2AEX DECLARED_DESTROY_NAME(CA2AEX)
99 #define CW2W DECLARED_DESTROY_NAME(CW2W)
100 #define CW2A DECLARED_DESTROY_NAME(CW2A)
101 #define CA2W DECLARED_DESTROY_NAME(CA2W)
102 #define CA2A DECLARED_DESTROY_NAME(CA2A)
103 #endif // DEBUG
104
105 #endif // OMAHA_COMMON_ATLCONVFIX_H_
OLDNEW
« no previous file with comments | « base/atlassert_unittest.cc ('k') | base/auto_any.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698