File tree Expand file tree Collapse file tree 3 files changed +49
-16
lines changed Expand file tree Collapse file tree 3 files changed +49
-16
lines changed Original file line number Diff line number Diff line change 34
34
using namespace cifti ;
35
35
using namespace std ;
36
36
37
+ CiftiSeriesMap::Unit CiftiSeriesMap::stringToUnit (const AString& string, bool & ok)
38
+ {
39
+ ok = true ;
40
+ if (string == " SECOND" )
41
+ {
42
+ return SECOND;
43
+ } else if (string == " HERTZ" ) {
44
+ return HERTZ;
45
+ } else if (string == " METER" ) {
46
+ return METER;
47
+ } else if (string == " RADIAN" ) {
48
+ return RADIAN;
49
+ }
50
+ ok = false ;
51
+ return SECOND;
52
+ }
53
+
54
+ AString CiftiSeriesMap::unitToString (const CiftiSeriesMap::Unit& theUnit)
55
+ {
56
+ switch (theUnit)
57
+ {
58
+ case SECOND:
59
+ return " SECOND" ;
60
+ case HERTZ:
61
+ return " HERTZ" ;
62
+ case METER:
63
+ return " METER" ;
64
+ case RADIAN:
65
+ return " RADIAN" ;
66
+ }
67
+ CiftiAssert (false );
68
+ return " UNKNOWN" ;
69
+ }
70
+
71
+ vector<CiftiSeriesMap::Unit> CiftiSeriesMap::getAllUnits ()
72
+ {
73
+ vector<Unit> ret;
74
+ ret.push_back (SECOND);
75
+ ret.push_back (HERTZ);
76
+ ret.push_back (METER);
77
+ ret.push_back (RADIAN);
78
+ return ret;
79
+ }
80
+
37
81
void CiftiSeriesMap::readXML1 (XmlReader& xml)
38
82
{
39
83
vector<AString> mandAttrs (2 ), optAttrs (1 , " TimeStart" );
Original file line number Diff line number Diff line change @@ -66,6 +66,10 @@ namespace cifti
66
66
void setUnit (const Unit& unit) { m_unit = unit; }
67
67
void setLength (const int64_t & length) { CiftiAssert (length > 0 ); m_length = length; }
68
68
69
+ static Unit stringToUnit (const AString& string, bool & ok);
70
+ static AString unitToString (const Unit& theUnit);
71
+ static std::vector<Unit> getAllUnits ();
72
+
69
73
CiftiMappingType* clone () const { return new CiftiSeriesMap (*this ); }
70
74
MappingType getType () const { return SERIES; }
71
75
int64_t getLength () const { return m_length; }
Original file line number Diff line number Diff line change @@ -93,22 +93,7 @@ int main(int argc, char** argv)
93
93
cout << " Series, length " << myMap.getLength () << endl;
94
94
cout << " Start: " << myMap.getStart () << endl;
95
95
cout << " Step: " << myMap.getStep () << endl;
96
- cout << " Unit: " ;
97
- switch (myMap.getUnit ())
98
- {
99
- case CiftiSeriesMap::SECOND:
100
- cout << " Seconds" << endl;
101
- break ;
102
- case CiftiSeriesMap::HERTZ:
103
- cout << " Hertz" << endl;
104
- break ;
105
- case CiftiSeriesMap::METER:
106
- cout << " Meters" << endl;
107
- break ;
108
- case CiftiSeriesMap::RADIAN:
109
- cout << " Radians" << endl;
110
- break ;
111
- }
96
+ cout << " Unit: " << AString_to_std_string (CiftiSeriesMap::unitToString (myMap.getUnit ())) << endl;
112
97
break ;
113
98
}
114
99
}
You can’t perform that action at this time.
0 commit comments