1#ifndef DUNE_FEM_STATICLISTOFINTS_HH
2#define DUNE_FEM_STATICLISTOFINTS_HH
12#define LIST_OF_INT(ListName, ...) \
14static constexpr int __VA_ARGS__; \
15typedef std::pair< std::map<int, int>, std::vector<std::string> > EntriesType; \
16static inline EntriesType& entries() { \
17static EntriesType idMap; \
18static bool initialized = false;\
20std::string str = #__VA_ARGS__; \
21int len = str.length(); \
22std::ostringstream temp; \
25for(int i = 0; i < len; ++i) { \
27 size_t c = str.find(',', i+1);\
28 std::string number = str.substr(i+1, c-(i+1));\
30 while( i < len && str[i] != ',') \
33 if(isspace(str[i])) continue; \
34 else if(str[i] == ',') { \
35 idMap.first[ id ] = n++; \
36 idMap.second.push_back(temp.str()); \
37 temp.str(std::string());\
39 else if (str[i] == '_') {\
45idMap.second.push_back( temp.str() );\
46idMap.second.back().pop_back();\
50static inline int to_id(int value){\
51 for( const auto& item : entries().first ){\
52 if( item.second == value )\
58static inline const std::vector<std::string>& names() { \
59 return entries().second;}\
60static int length() { return entries().second.size(); }\
61static std::string to_string(int value){\
62 auto it = entries().first.find( value );\
63 assert( it != entries().first.end() );\
64 assert( it->second < int(entries().second.size()) );\
65 return entries().second[ it->second ];\
71#define LIST_OF_INT_FORWARDED(ListName, ...) \
72 LIST_OF_INT(ListName, __VA_ARGS__);\
73 static const int __VA_ARGS__;