Changeset 1049 for XIOS/trunk
- Timestamp:
- 02/03/17 14:26:51 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/duration.cpp
r1028 r1049 38 38 char c = '/'; 39 39 bool invalidUnit = false; 40 CDuration sentinel = NoneDu; 41 42 #define setDuration(unit, value) \ 43 { \ 44 if (sentinel.unit) \ 45 ERROR("StdIStream& operator>>(StdIStream& in , CDuration& duration)", \ 46 << "Bad duration format: " #unit " has already been set."); \ 47 \ 48 duration.unit = value; \ 49 sentinel.unit = 1.0; \ 50 } 40 51 41 52 do … … 48 59 switch (c) 49 60 { 50 case 'y': duration.year = v;break;51 case 'd': duration.day = v;break;52 case 'h': duration.hour = v;break;53 case 's': duration.second = v;break;61 case 'y': setDuration(year, v) break; 62 case 'd': setDuration(day, v) break; 63 case 'h': setDuration(hour, v) break; 64 case 's': setDuration(second, v) break; 54 65 case 'm': 55 66 { 56 67 in >> c; 57 if (c == 'i') duration.minute = v;58 else if (c == 'o') duration.month = v;68 if (c == 'i') setDuration(minute, v) 69 else if (c == 'o') setDuration(month, v) 59 70 else invalidUnit = true; 60 71 break; … … 63 74 { 64 75 in >> c; 65 if (c == 's') duration.timestep = v;76 if (c == 's') setDuration(timestep, v) 66 77 else invalidUnit = true; 67 78 break; … … 76 87 << "Bad duration format: invalid unit, unexpected '" << c << "' character."); 77 88 } while (in.peek() != EOF); // check whether there is a next character to read 89 90 #undef setDuration 78 91 79 92 return in;
Note: See TracChangeset
for help on using the changeset viewer.