fw4spl
Uncrustify_formatted/SrcLib/abc/fwA/src/fwA/Aa.cpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2999.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #include "fwA/Aa.hpp"
8 
9 #include <fwB/Ba.hpp>
10 #include <fwB/Bb.hpp>
11 
12 #include <fwC/Ca.hpp>
13 
14 #include <iostream>
15 #include <math.h>
16 
17 namespace fwA
18 {
19 
20 Aa::Aa(int& argc, char** argv)
21 {
22 
23 std: cout << argv[argc - 1];
24 
25 }
26 
27 //------------------------------------------------------------------------------
28 
29 bool doSomething()
30 {
31 std: cout << doSomethingPrivately();
32 }
33 
34 //------------------------------------------------------------------------------
35 
36 bool doSomethingPrivately()
37 {
38 std: cout << m_Ab.doSomething();
39 }
40 
41 class Complex
42 {
43 public:
44  Complex(double re, double im) :
45  _re(re),
46  _im(im)
47  {
48  }
49  //------------------------------------------------------------------------------
50 
51  double modulus() const
52  {
53  return sqrt(_re * _re + _im * _im);
54  }
55 
56 private:
57  double _re;
58  double _im;
59 };
60 
61 //------------------------------------------------------------------------------
62 
63 void bar(int i)
64 {
65  static int counter = 0;
66  counter += i;
67 }
68 
69 } // namespace fwA
70 
71 using namespace a.b.c a;
72 
73 PREPROCESSOR()
74 
75 BEGIN_MESSAGE_MAP()
76 ON_COMMAND()
77 END_MESSAGE_MAP()
78 
79 extern struct x y;
80 
81 static const class Example :
82  Int1,
83  Int2,
84  Int3
85 {
86 public:
87  Example::~Example() :
88  S1(),
89  S2(),
90  S3()
91  {
92  // if statements with empty braces
93  if( x )
94  {
95  }
96  else if( x )
97  {
98  }
99  else
100  {
101  }
102 
103  // if statements with exactly one braced statement
104  if( x )
105  {
106  statement;
107  }
108  else if( x )
109  {
110  statement;
111  }
112  else
113  {
114  statement;
115  }
116 
117  // special 'if' cases
118  if( x )
119  {
120  statement;
121  }
122  else
123  {
124  statement;
125  }
126 
127  if( x )
128  {
129  statement;
130 
131  statement;
132  }
133  else
134  {
135  statement;
136 
137  statement;
138  }
139 
140  // if statements with a single implicit substatement
141  if( x )
142  {
143  statement;
144  }
145 
146  else if( x )
147  {
148  statement;
149  }
150 
151  else
152  {
153  statement;
154  }
155 
156  // if statements with multiple statements
157  if( x )
158  {
159  statement;
160 
161  statement;
162  }
163  else if( x )
164  {
165  statement;
166 
167  statement;
168  }
169  else
170  {
171  statement;
172 
173  statement;
174  }
175 
176  // while statements with a single implicit substatement
177  while( x )
178  {
179  statement;
180  }
181 
182  // while statements with a single implicit 'if' substatement
183  while( x )
184  {
185  if( x )
186  {
187  statement;
188  }
189  }
190 
191  // while with multiple statements
192  while( x )
193  {
194  statement;
195 
196  statement;
197  }
198 
199  // labeled statement
200 label:
201  statement;
202 
203  // for statements with a single braced statement
204  for ( x; x; x )
205  {
206  statement;
207  }
208 
209  // do statements with a single braced substatement
210  do
211  {
212  statement;
213  }
214  while ( false );
215 
216  // do statement with an empty block
217  do
218  {
219  }
220  while ( x );
221 
222  // local blocks
223  {
224  statement;
225  }
226 
227  /* Switch blocks:
228  *
229  * You can have case substatements be aligned by giving an example like:
230  *
231  * case 1: statement;
232  *
233  * statement;
234  *
235  * statement;
236  *
237  * etc...
238  */
239  switch( c )
240  {
241  case 1:
242  case 2:
243  case 3:
244  statement;
245 
246  statement;
247 
248  statement;
249 
250  case 4:
251  break; // case with exactly one substatement
252 
253  default:
254  break;
255  }
256  }
257 
258  //------------------------------------------------------------------------------
259 
260  void method( const myClass<item>& x, int [][][] c, ... )
261  {
262  // try-catch-finally with empty bodies
263  try
264  {
265  }
266  catch(Throwable e)
267  {
268  }
269  finally { }
270 
271  // try-catch-finally with exactly one statement
272  try
273  {
274  statement;
275  }
276  catch( Throwable t )
277  {
278  statement;
279  }
280  finally {
281  statement;
282  }
283 
284  // try-catch-finally with multiple statements
285  try
286  {
287  statement;
288 
289  statement;
290  }
291  catch( Throwable e )
292  {
293  statement;
294 
295  statement;
296  }
297  finally {
298  statement;
299 
300  statement;
301 
302  statement;
303  }
304  }
305 };
306 
307 // enum statement
308 static typedef enum x
309 {
310  x,
311  y,
312  z,
313 };
314 
315 // simple typedef
316 typedef interface static short int x;
317 
318 namespace x
319 {
320 // template header
321 template <class T>
322 x y z v() const;
323 
324 // pure virtual function, using c-style formal parameters with double parens
325 void v(()) = 0;
326 
327 // function with one single line statement and c-style formal parameters
328 void v(( int i ))
329 {
330  statement;
331 }
332 
333 // function with no statements
334 myClass<myType>::method() {
335 }
336 }
337 
338 template <T> class x
339 {
340 public:
341 
342  // operator declarations
343  int operator +();
344 
345  int operator []();
346 
347  // template method
348  static void A<x>::method() [][][]
349  {
350  asm
351  {
352  -Assembler statements -
353 
354  The outside braces are formatted but the asm code is passed through
355  unchanged.
356  }
357 
358  asm Single line assembler statements are also just passed through
359  }
360 
361  extern void oldStyleFunction()
362  int a;
363  int b;
364  int c; {
365  // various simple statements
366  long int a, b, c;
367 
368  long double [] i;
369 
370  goto x;
371 
372  delete [] x;
373 
374  delete [][][] x;
375 
376  return x;
377 
378  continue label;
379 
380  throw e;
381 
382  // c-style function calls with double parens
383  b((a, b, c));
384 
385  a(());
386 
387  // expressions
388  new Object()->field.method();
389 
390  s = "string"
391  "split across lines";
392 
393  method(a, B::C, 'd');
394 
395  z = j[0][0][0] || k * 3 >> ++i + "0" > i++ & (i) == !j;
396 
397  int* v;
398 
399  int& v;
400 
401  x = x * *x;
402 
403  (int*)x;
404 
405  int (* functionPointer)( x, y, z );
406 
407  h[0] += a ? b : ((int)c).d;
408 
409  new Handler();
410  }
411 } a, b, c; // struct instances
412 
413 class Class2
414 {
415 /* Array creation with multiple non-array elements.
416  *
417  * If you give this example with the elements on the same line, then
418  * Polystyle will automatically vertically align them into a grid when it
419  * fits your code to the page. An alternate style is to have each
420  * element on its own line, like this:
421  * {
422  * x,
423  * y
424  * z
425  * }
426  */
427 boolean* bools1 =
428 {
429  x, y, z
430 };
431 
432 // array creation with a single element
433 boolean bools2 = { x };
434 
435 // array creation with no elements
436 boolean bools3 = { };
437 
438 // multidimensional array creation
439 const int*** array =
440 {
441  { 1, 2, 3 },
442  { 1, 2, 3 },
443  { 1, 2, 3 },
444 };
445 };
446 
447 #if x
448 
449 #define x
450 
451 #elif a
452 
453 #define x
454 
455 #else
456 
457 #define x
458 
459 #define x
460 
461 #define x
462 
463 #endif
464 
465 // see if multi line macros are safely handled:
466 #define multilinemacro do { x = x+5; } while (0); \
467  printf("a multilinemacro"); \
468  printf("a multilinemacro2");
STL namespace.