vtkbone
vtkboneMacros.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Copyright 2010-2016, Numerics88 Solutions Ltd.
4  http://www.numerics88.com/
5 
6  Copyright (c) Eric Nodwell and Steven K. Boyd
7  See Copyright.txt for details.
8 
9  This software is distributed WITHOUT ANY WARRANTY; without even
10  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11  PURPOSE. See the above copyright notice for more information.
12 =========================================================================*/
13 
14 #ifndef __vtkboneMacros_h
15 #define __vtkboneMacros_h
16 
17 // Define a function to string value for an enum.
18 // This requires:
19 // 1. An enum defined in a class, and named (enumname)_t
20 // 2. The last value of the enum must be NUMBER_OF_(enumname)
21 // 3. Declare the function like this in the header file:
22 // static const char* Get(enumname)AsString (enumname_t arg);
23 // 4. Make a list of string values for your enum in the .cxx file, like this:
24 // const char* const (enumname)_s[] = {"BLUE", "RED", "GREEN"};
25 // 5. Put this macro right after the list of string values
26 #define vtkboneGetAsStringMacro(classname,enumname) \
27 const char* classname::Get##enumname##AsString (int arg) \
28 { \
29  if (arg >=0 && arg < classname::NUMBER_OF_##enumname) \
30  { \
31  return enumname##_s[arg]; \
32  } \
33  else \
34  { \
35  return NULL; \
36  } \
37 }
38 
39 #endif