MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
types.cpp
Go to the documentation of this file.
1 // types.cpp ---
2 //
3 // Filename: types.cpp
4 // Description:
5 // Author: Subhasis Ray
6 // Maintainer:
7 // Copyright (C) 2010 Subhasis Ray, all rights reserved.
8 // Created: Wed Mar 23 10:10:45 2011 (+0530)
9 // Version:
10 // Last-Updated: Tue Jul 23 12:47:59 2013 (+0530)
11 // By: subha
12 // Update #: 93
13 // URL:
14 // Keywords:
15 // Compatibility:
16 //
17 //
18 
19 // Commentary:
20 //
21 // Some utility functions to give short character representations for
22 // particular type names.
23 //
24 //
25 
26 // Change log:
27 //
28 //
29 //
30 
31 // Code:
32 #include <string>
33 #include <map>
34 
35 using namespace std;
36 
41 char shortType(string name)
42 {
43  static map<string, char> typemap;
44  if (typemap.empty()){
45  typemap.insert(pair<string, char>("bool", 'b'));
46  typemap.insert(pair<string, char>("char", 'c'));
47  typemap.insert(pair<string, char>("int", 'i')); // python
48  typemap.insert(pair<string, char>("short", 'h')); // python
49  typemap.insert(pair<string, char>("unsigned short", 'H')); // python
50  typemap.insert(pair<string, char>("long", 'l')); // python
51  typemap.insert(pair<string, char>("long long", 'L')); // python
52  typemap.insert(pair<string, char>("unsigned int", 'I')); // python
53  typemap.insert(pair<string, char>("unsigned long", 'k')); // python
54  typemap.insert(pair<string, char>("unsigned long long", 'K')); // python
55  typemap.insert(pair<string, char>("float", 'f')); // python
56  typemap.insert(pair<string, char>("double", 'd')); // python
57  typemap.insert(pair<string, char>("string", 's')); // python
58  typemap.insert(pair<string, char>("Id", 'x')); // moose
59  typemap.insert(pair<string, char>("ObjId", 'y')); // moose
60  typemap.insert(pair<string, char>("DataId", 'z')); // moose
61  typemap.insert(pair<string, char>("vector<char>", 'C')); // moose
62  typemap.insert(pair<string, char>("vector<int>", 'v')); // moose
63  typemap.insert(pair<string, char>("vector<short>", 'w')); // moose
64  typemap.insert(pair<string, char>("vector<long>", 'M')); // moose
65  typemap.insert(pair<string, char>("vector<long long>", 'A')); // moose
66  typemap.insert(pair<string, char>("vector<unsigned long long>", 'B')); // moose
67  typemap.insert(pair<string, char>("vector<unsigned int>", 'N')); // moose
68  typemap.insert(pair<string, char>("vector<unsigned long>", 'P')); // moose
69  typemap.insert(pair<string, char>("vector<float>", 'F')); // moose
70  typemap.insert(pair<string, char>("vector<double>", 'D')); // moose
71  typemap.insert(pair<string, char>("vector<string>", 'S')); // moose
72  typemap.insert(pair<string, char>("vector<Id>", 'X')); // moose
73  typemap.insert(pair<string, char>("vector<ObjId>", 'Y')); // moose
74  typemap.insert(pair<string, char>("vector<DataId", 'Z')); //moose
75  typemap.insert(pair<string, char>("void", '_')); // moose
76  typemap.insert(pair<string, char>("vector< vector<unsigned int> >", 'T'));
77  typemap.insert(pair<string, char>("vector< vector<int> >", 'Q'));
78  typemap.insert(pair<string, char>("vector< vector<double> >", 'R'));
79  }
80  map<string, char>::iterator iter = typemap.find(name);
81  if (iter == typemap.end()){
82  return 0;
83  }
84  return iter->second;
85 }
86 
87 char shortFinfo(string finfoType)
88 {
89  static map<string, char> finfomap;
90  if (finfomap.empty()){
91  finfomap.insert(pair<string, char>("srcFinfo", 's'));
92  finfomap.insert(pair<string, char>("destFinfo", 'd'));
93  finfomap.insert(pair<string, char>("sharedFinfo", 'x'));
94  finfomap.insert(pair<string, char>("valueFinfo", 'v'));
95  finfomap.insert(pair<string, char>("lookupFinfo", 'l'));
96  }
97  map <string, char>::iterator iter = finfomap.find(finfoType);
98  if (iter == finfomap.end()){
99  return 0;
100  }
101  return iter->second;
102 }
103 
104 char innerType(char typecode){
105  static map<char, char> innerTypeMap;
106  if (innerTypeMap.empty()){
107  innerTypeMap.insert(pair<char, char>('D', 'd')); // vector<double>
108  innerTypeMap.insert(pair<char, char>('v', 'i')); // vector<int>
109  innerTypeMap.insert(pair<char, char>('M', 'l')); // vector<long>
110  innerTypeMap.insert(pair<char, char>('X', 'x')); // vector<Id>
111  innerTypeMap.insert(pair<char, char>('Y', 'y')); // vector<ObjId>
112  innerTypeMap.insert(pair<char, char>('C', 'c')); // vector<char>
113  innerTypeMap.insert(pair<char, char>('w', 'h')); // vector<short>
114  innerTypeMap.insert(pair<char, char>('N', 'I')); // vector<unsigned int>
115  innerTypeMap.insert(pair<char, char>('P', 'k')); // vector<unsigned long>
116  innerTypeMap.insert(pair<char, char>('A', 'L')); // vector<long long>
117  innerTypeMap.insert(pair<char, char>('B', 'K')); // vector<unsigned long long>
118  innerTypeMap.insert(pair<char, char>('F', 'f')); // vector<float>
119  innerTypeMap.insert(pair<char, char>('S', 's')); // vector<string>
120  innerTypeMap.insert(pair<char, char>('T', 'N')); // vector<vector<unsigned>>
121  innerTypeMap.insert(pair<char, char>('Q', 'v')); // vector<vector<int>>
122  innerTypeMap.insert(pair<char, char>('R', 'D')); // vector<vector<double>>
123  }
124  map<char, char>::iterator iter = innerTypeMap.find(typecode);
125  if (iter == innerTypeMap.end()){
126  return 0;
127  }
128  return iter->second;
129 }
130 
131 
132 //
133 // types.cpp ends here
char innerType(char typecode)
Definition: types.cpp:104
static char name[]
Definition: mfield.cpp:401
char shortType(string name)
Definition: types.cpp:41
char shortFinfo(string finfoType)
Definition: types.cpp:87