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

Side by Side Diff: base/win/rgs_helper.h

Issue 6041007: Move rgs_helper out of base to ceee since it's not used anywhere else.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 12 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 | Annotate | Revision Log
« no previous file with comments | « base/base.gypi ('k') | ceee/ie/broker/broker.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 (c) 2010 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.
4 //
5 // Defines a map for adding variables to rgs files. This allows COM object
6 // classes to declare the values of these variables so that we don't need to
7 // copy/paste them and manually keep them in sync.
8 // To use this, declare the registry ID of your RGS file using
9 // the DECLARE_REGISTRY_RESOURCEID_EX macro, instead of the
10 // DECLARE_REGISTRY_RESOURCEID, then add a registry map to your class
11 // using the registry map macros:
12 // BEGIN_REGISTRY_MAP(MyClassName)
13 // REGMAP_ENTRY("NAME", "MyClassName Class")
14 // REGMAP_ENTRY_UUID("CLSID", CLSID_MyClassName)
15 // END_REGISTRY_MAP()
16 //
17 // You can then refer to the names above in your RGS file as
18 // variables %NAME% and %CLSID%, respectively.
19 #ifndef BASE_WIN_RGS_HELPER_H_
20 #define BASE_WIN_RGS_HELPER_H_
21
22 #include "base/string_util.h"
23
24 struct ATLRegmapEntryHelper : public _ATL_REGMAP_ENTRY {
25 ATLRegmapEntryHelper() {
26 szKey = NULL;
27 szData = NULL;
28 }
29 ATLRegmapEntryHelper(LPCOLESTR key, LPCOLESTR data) {
30 szKey = key;
31 size_t size = lstrlen(data) + 1;
32 szData = new wchar_t[size];
33 base::wcslcpy(const_cast<wchar_t*>(szData), data, size);
34 }
35
36 ATLRegmapEntryHelper(LPCOLESTR key, UINT resid) {
37 wchar_t data[256] = {0};
38 szKey = key;
39 if (::LoadString(_pModule->m_hInstResource, resid, data,
40 arraysize(data) - 1) == 0) {
41 *data = L'\0';
42 }
43
44 size_t size = lstrlen(data) + 1;
45
46 szData = new wchar_t[size];
47 base::wcslcpy(const_cast<wchar_t*>(szData), data, size);
48 }
49
50 ATLRegmapEntryHelper(LPCOLESTR key, REFGUID guid) {
51 szKey = key;
52 static const size_t kGuidStringSize = 40;
53 szData = new wchar_t[kGuidStringSize];
54 if (szData) {
55 if (::StringFromGUID2(guid, const_cast<LPOLESTR>(szData),
56 kGuidStringSize) == 0) {
57 *const_cast<LPOLESTR>(szData) = L'\0';
58 }
59 }
60 }
61 ~ATLRegmapEntryHelper() {
62 delete [] szData;
63 }
64 };
65
66 #define BEGIN_REGISTRY_MAP(x)\
67 static struct _ATL_REGMAP_ENTRY *_GetRegistryMap() {\
68 static const ATLRegmapEntryHelper map[] = {
69 #define REGMAP_ENTRY(x, y) ATLRegmapEntryHelper(OLESTR(##x), OLESTR(##y)),
70
71 #define REGMAP_UUID(x, clsid) ATLRegmapEntryHelper(OLESTR(##x), clsid),
72
73 // This allows usage of a Resource string.
74 #define REGMAP_RESOURCE(x, resid) ATLRegmapEntryHelper(OLESTR(##x), resid),
75
76 // This allows usage of a static function to be called to provide the string.
77 #define REGMAP_FUNCTION(x, f) ATLRegmapEntryHelper(OLESTR(##x), ##f()),
78
79 #define END_REGISTRY_MAP() ATLRegmapEntryHelper() };\
80 return (_ATL_REGMAP_ENTRY*)map;\
81 }
82
83 #define DECLARE_REGISTRY_RESOURCEID_EX(x)\
84 static HRESULT WINAPI UpdateRegistry(BOOL bRegister) {\
85 return ATL::_pAtlModule->UpdateRegistryFromResource((UINT)x, bRegister, \
86 _GetRegistryMap());\
87 }
88
89 #endif // BASE_WIN_RGS_HELPER_H_
OLDNEW
« no previous file with comments | « base/base.gypi ('k') | ceee/ie/broker/broker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698