5
|
1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
2 |
<html lang="en">
|
|
3 |
<head>
|
|
4 |
<meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2007. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >
|
|
5 |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
6 |
<title>
|
|
7 |
Code templates
|
|
8 |
</title>
|
|
9 |
<link rel="stylesheet" href="../book.css" charset="ISO-8859-1" type="text/css">
|
|
10 |
<script language="JavaScript" src="PLUGINS_ROOT/org.eclipse.help/livehelp.js"> </script>
|
|
11 |
</head>
|
|
12 |
<body>
|
|
13 |
<h1>
|
|
14 |
Code templates
|
|
15 |
</h1>
|
|
16 |
<p>The
|
|
17 |
<a class="command-link" href='javascript:executeCommand("org.eclipse.ui.window.preferences(preferencePageId=org.eclipse.cdt.ui.preferences.CodeTemplatePreferencePage)")'>
|
|
18 |
<img src="PLUGINS_ROOT/org.eclipse.help/command_link.png" alt="Opens the Code Templates preference page">
|
|
19 |
<b>C/C++ > Code Style > Code Templates</b></a> preference page
|
|
20 |
lets you configure the format of newly generated code stubs, comments and files.</p>
|
|
21 |
|
|
22 |
<p>The code templates page contains templates that are used by actions that generate code and/or source files.
|
|
23 |
E.g. the New Class wizard uses source and header file templates to create new files and code templates to insert generated method stubs.
|
|
24 |
Templates contain variables that are substituted when the template is applied. Some variables are available in all templates, some are specific to templates.</p><table
|
|
25 |
border="1" cellspacing="0" cellpadding="5" width="600">
|
|
26 |
<thead>
|
|
27 |
<tr>
|
|
28 |
<th>
|
|
29 |
<p>Action</p>
|
|
30 |
</th>
|
|
31 |
<th>
|
|
32 |
<p>Description</p>
|
|
33 |
</th>
|
|
34 |
</tr>
|
|
35 |
</thead>
|
|
36 |
<tbody>
|
|
37 |
<tr>
|
|
38 |
<td valign="top" width="25%">
|
|
39 |
<p>New...</p>
|
|
40 |
</td>
|
|
41 |
<td valign="top">
|
|
42 |
<p>Opens the Code Template dialog to create a new file template.</p>
|
|
43 |
</td>
|
|
44 |
</tr>
|
|
45 |
<tr>
|
|
46 |
<td valign="top" width="25%">
|
|
47 |
<p>Edit...</p>
|
|
48 |
</td>
|
|
49 |
<td valign="top">
|
|
50 |
<p>Opens the Code Template dialog to edit the currently selected code template.</p>
|
|
51 |
</td>
|
|
52 |
</tr>
|
|
53 |
<tr>
|
|
54 |
<td valign="top" width="25%">
|
|
55 |
<p>Remove</p>
|
|
56 |
</td>
|
|
57 |
<td valign="top">
|
|
58 |
<p>Removes a user added file template. Predefined templates cannot be removed.</p>
|
|
59 |
</td>
|
|
60 |
</tr>
|
|
61 |
<tr>
|
|
62 |
<td valign="top">
|
|
63 |
<p>Import...</p>
|
|
64 |
</td>
|
|
65 |
<td valign="top">
|
|
66 |
<p>Imports templates from the file system.</p>
|
|
67 |
</td>
|
|
68 |
</tr>
|
|
69 |
<tr>
|
|
70 |
<td valign="top">
|
|
71 |
<p>Export...</p>
|
|
72 |
</td>
|
|
73 |
<td valign="top">
|
|
74 |
<p>Exports all selected templates to the file system.</p>
|
|
75 |
</td>
|
|
76 |
</tr>
|
|
77 |
<tr>
|
|
78 |
<td valign="top">
|
|
79 |
<p>Export All...</p>
|
|
80 |
</td>
|
|
81 |
<td valign="top">
|
|
82 |
<p>Exports all templates to the file system.</p>
|
|
83 |
</td>
|
|
84 |
</tr>
|
|
85 |
</tbody>
|
|
86 |
</table>
|
|
87 |
|
|
88 |
|
|
89 |
<h2>Comment Templates</h2>
|
|
90 |
|
|
91 |
<table border="1" cellspacing="0" cellpadding="5" width="600">
|
|
92 |
<thead>
|
|
93 |
<tr>
|
|
94 |
<th>
|
|
95 |
<p>Template Name</p>
|
|
96 |
</th>
|
|
97 |
<th>
|
|
98 |
<p>Specifies</p>
|
|
99 |
</th>
|
|
100 |
</tr>
|
|
101 |
</thead>
|
|
102 |
<tbody>
|
|
103 |
<tr>
|
|
104 |
<td valign="top" width="25%">
|
|
105 |
<p>Files</p>
|
|
106 |
</td>
|
|
107 |
<td valign="top">
|
|
108 |
<p>Header comment for new source or header files.</p>
|
|
109 |
<p>Note that this template can be referenced in source and header file templates with <b>${filecomment}</b>.</p>
|
|
110 |
</td>
|
|
111 |
</tr>
|
|
112 |
<tr>
|
|
113 |
<td valign="top" width="25%">
|
|
114 |
<p>Types</p>
|
|
115 |
</td>
|
|
116 |
<td valign="top">
|
|
117 |
<p>The comment for new types.</p>
|
|
118 |
<p>Note that this template can be referenced in source and header file templates with <b>${typecomment}</b>.</p>
|
|
119 |
</td>
|
|
120 |
</tr>
|
|
121 |
<tr>
|
|
122 |
<td valign="top" width="25%">
|
|
123 |
<p>Fields</p>
|
|
124 |
</td>
|
|
125 |
<td valign="top">
|
|
126 |
<p>The comment for new fields.</p>
|
|
127 |
</td>
|
|
128 |
</tr>
|
|
129 |
<tr>
|
|
130 |
<td valign="top" width="25%">
|
|
131 |
<p>Constructors</p>
|
|
132 |
</td>
|
|
133 |
<td valign="top">
|
|
134 |
<p>The comment for new constructors.</p>
|
|
135 |
</td>
|
|
136 |
</tr>
|
|
137 |
<tr>
|
|
138 |
<td valign="top" width="25%">
|
|
139 |
<p>Destructors</p>
|
|
140 |
</td>
|
|
141 |
<td valign="top">
|
|
142 |
<p>The comment for new destructors.</p>
|
|
143 |
</td>
|
|
144 |
</tr>
|
|
145 |
<tr>
|
|
146 |
<td valign="top" width="25%">
|
|
147 |
<p>Methods</p>
|
|
148 |
</td>
|
|
149 |
<td valign="top">
|
|
150 |
<p>The comment for new methods.</p>
|
|
151 |
</td>
|
|
152 |
</tr>
|
|
153 |
</tbody>
|
|
154 |
</table>
|
|
155 |
|
|
156 |
<h2>Code Templates</h2>
|
|
157 |
<p></p>
|
|
158 |
<table
|
|
159 |
border="1" cellspacing="0" cellpadding="5" width="600">
|
|
160 |
<thead>
|
|
161 |
<tr>
|
|
162 |
<th>
|
|
163 |
<p>Template Name</p>
|
|
164 |
</th>
|
|
165 |
<th>
|
|
166 |
<p>Description</p>
|
|
167 |
</th>
|
|
168 |
</tr>
|
|
169 |
</thead>
|
|
170 |
<tbody>
|
|
171 |
<tr>
|
|
172 |
<td valign="top" width="25%">
|
|
173 |
<p>Method body</p>
|
|
174 |
</td>
|
|
175 |
<td valign="top">
|
|
176 |
<p>The 'Method body' templates are used when new method is created.</p>
|
|
177 |
</td>
|
|
178 |
</tr>
|
|
179 |
<tr>
|
|
180 |
<td valign="top" width="25%">
|
|
181 |
<p>Constructor body</p>
|
|
182 |
</td>
|
|
183 |
<td valign="top">
|
|
184 |
<p>The 'Constructor body' templates are used when a constructor is created.</p>
|
|
185 |
</td>
|
|
186 |
</tr>
|
|
187 |
<tr>
|
|
188 |
<td valign="top" width="25%">
|
|
189 |
<p>Destructor body</p>
|
|
190 |
</td>
|
|
191 |
<td valign="top">
|
|
192 |
<p>The 'Destructor body' templates are used when the destructor is created.</p>
|
|
193 |
</td>
|
|
194 |
</tbody>
|
|
195 |
</table>
|
|
196 |
|
|
197 |
<h2>File Templates</h2>
|
|
198 |
File templates can not only be defined and modified for C/C++ files, but also for other content types, like Assembly files or plain text files.
|
|
199 |
The New File from Template wizard can be used to create new files based on one of the templates defined in this page.
|
|
200 |
<p></p>
|
|
201 |
<table
|
|
202 |
border="1" cellspacing="0" cellpadding="5" width="600">
|
|
203 |
<thead>
|
|
204 |
<tr>
|
|
205 |
<th>
|
|
206 |
<p>Template Name</p>
|
|
207 |
</th>
|
|
208 |
<th>
|
|
209 |
<p>Description</p>
|
|
210 |
</th>
|
|
211 |
</tr>
|
|
212 |
</thead>
|
|
213 |
<tbody>
|
|
214 |
<tr>
|
|
215 |
<td valign="top" width="25%">
|
|
216 |
<p>Default C++ source template</p>
|
|
217 |
</td>
|
|
218 |
<td valign="top">
|
|
219 |
<p>Used by the New Class wizard and the New Source File wizard when a new C++ source file is created.</p>
|
|
220 |
<p>The template can specify where comments are added. Note that the template can contain the variable <b>${typecomment}</b> and <b>${filecomment}</b> that will be substituted by the evaluation of the <b>Types</b> respectively <b>Files</b> comment template.</p>
|
|
221 |
</td>
|
|
222 |
</tr>
|
|
223 |
<tr>
|
|
224 |
<td valign="top" width="25%">
|
|
225 |
<p>Default C++ header template</p>
|
|
226 |
</td>
|
|
227 |
<td valign="top">
|
|
228 |
<p>Used by the New Class wizard and the New Header File wizard when a new C++ header file is created.</p>
|
|
229 |
<p>The template can specify where comments are added. Note that the template can contain the variable <b>${typecomment}</b> and <b>${filecomment}</b> that will be substituted by the evaluation of the <b>Types</b> respectively <b>Files</b> comment template.</p>
|
|
230 |
</td>
|
|
231 |
</tr>
|
|
232 |
<tr>
|
|
233 |
<td valign="top" width="25%">
|
|
234 |
<p>Default C source template</p>
|
|
235 |
</td>
|
|
236 |
<td valign="top">
|
|
237 |
<p>Used by the New Source File wizard when a new C source file is created.</p>
|
|
238 |
<p>The template can specify where comments are added. Note that the template can contain the variable <b>${typecomment}</b> and <b>${filecomment}</b> that will be substituted by the evaluation of the <b>Types</b> respectively <b>Files</b> comment template.</p>
|
|
239 |
</td>
|
|
240 |
</tr>
|
|
241 |
<tr>
|
|
242 |
<td valign="top" width="25%">
|
|
243 |
<p>Default C header template</p>
|
|
244 |
</td>
|
|
245 |
<td valign="top">
|
|
246 |
<p>Used by the New Header File wizard when a new C source file is created.</p>
|
|
247 |
<p>The template can specify where comments are added. Note that the template can contain the variable <b>${typecomment}</b> and <b>${filecomment}</b> that will be substituted by the evaluation of the <b>Types</b> respectively <b>Files</b> comment template.</p>
|
|
248 |
</td>
|
|
249 |
</tr>
|
|
250 |
<tr>
|
|
251 |
<td valign="top" width="25%">
|
|
252 |
<p><i>Other file templates</i></p>
|
|
253 |
</td>
|
|
254 |
<td valign="top">
|
|
255 |
<p>File templates can be defined for other content types, e.g. Assembly or plain text.</p>
|
|
256 |
</td>
|
|
257 |
</tr>
|
|
258 |
</tbody>
|
|
259 |
</table>
|
|
260 |
|
|
261 |
<h2>Edit Template dialog</h2>
|
|
262 |
|
|
263 |
<p>The following fields and buttons appear in the dialog:</p>
|
|
264 |
<table border="1" cellspacing="0" cellpadding="5" width="100%">
|
|
265 |
<thead>
|
|
266 |
<tr>
|
|
267 |
<th>
|
|
268 |
<p>Action</p>
|
|
269 |
</th>
|
|
270 |
<th>
|
|
271 |
<p>Description</p>
|
|
272 |
</th>
|
|
273 |
</tr>
|
|
274 |
</thead>
|
|
275 |
<tbody>
|
|
276 |
<tr>
|
|
277 |
<td valign="top">
|
|
278 |
<p>Name</p>
|
|
279 |
</td>
|
|
280 |
<td valign="top">
|
|
281 |
<p>The name of the template. Only available for file templates.</p>
|
|
282 |
</td>
|
|
283 |
</tr>
|
|
284 |
<tr>
|
|
285 |
<td valign="top">
|
|
286 |
<p>Type</p>
|
|
287 |
</td>
|
|
288 |
<td valign="top">
|
|
289 |
<p>The file type (content type) of the template. Only available for file templates.</p>
|
|
290 |
</td>
|
|
291 |
</tr>
|
|
292 |
<tr>
|
|
293 |
<td valign="top">
|
|
294 |
<p>Description</p>
|
|
295 |
</td>
|
|
296 |
<td valign="top">
|
|
297 |
<p>A description of the template</p>
|
|
298 |
</td>
|
|
299 |
</tr>
|
|
300 |
<tr>
|
|
301 |
<td valign="top">
|
|
302 |
<p>Pattern</p>
|
|
303 |
</td>
|
|
304 |
<td valign="top">
|
|
305 |
<p>The template pattern.</p>
|
|
306 |
</td>
|
|
307 |
</tr>
|
|
308 |
<tr>
|
|
309 |
<td valign="top">
|
|
310 |
<p>Insert Variables...</p>
|
|
311 |
</td>
|
|
312 |
<td valign="top">
|
|
313 |
<p>Displays a list of pre-defined template specific variables.</p>
|
|
314 |
</td>
|
|
315 |
</tr>
|
|
316 |
</tbody>
|
|
317 |
</table>
|
|
318 |
|
|
319 |
<p><img border="0" src="../images/ngconcepts.gif" ALT="Related concepts" width="143" height="21"> <br>
|
|
320 |
<a href="../concepts/cdt_o_code_entry.htm">Coding aids</a></p>
|
|
321 |
<p><img border="0" src="../images/ngref.gif" ALT="Related reference" width="143" height="21">
|
|
322 |
<br>
|
|
323 |
<a href="cdt_o_ceditor_pref.htm">C/C++ editor preferences</a></p>
|
|
324 |
<img src="../images/ng00_07.gif" ALT="IBM Copyright Statement" >
|
|
325 |
|
|
326 |
</body>
|
|
327 |
</html>
|