Ignore:
Timestamp:
06/06/17 17:58:16 (7 years ago)
Author:
oabramkina
Message:

Two server levels: merging with trunk r1137.
There are bugs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_olga/src/duration.cpp

    r612 r1158  
    2626      } 
    2727 
     28      /*! 
     29        This operation may not serve much, it's here because of the need of operator== from generic class CType<T> 
     30      */ 
     31      bool CDuration::operator==(const CDuration& duration) 
     32      { 
     33        return (year == duration.year && month  == duration.month  && day == duration.day && 
     34                hour == duration.hour && minute == duration.minute && second == duration.second && timestep == duration.timestep);         
     35      } 
     36 
    2837      StdOStream& operator<<(StdOStream& out, const CDuration& duration) 
    2938      { 
     
    3847        char   c = '/'; 
    3948        bool   invalidUnit = false; 
     49        CDuration sentinel = NoneDu; 
     50 
     51#define setDuration(unit, value)                                                  \ 
     52        {                                                                         \ 
     53          if (sentinel.unit)                                                      \ 
     54            ERROR("StdIStream& operator>>(StdIStream& in , CDuration& duration)", \ 
     55                  << "Bad duration format: " #unit " has already been set.");      \ 
     56                                                                                  \ 
     57          duration.unit = value;                                                  \ 
     58          sentinel.unit = 1.0;                                                    \ 
     59        } 
    4060 
    4161        do 
     
    4868          switch (c) 
    4969          { 
    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; 
     70            case 'y': setDuration(year, v) break; 
     71            case 'd': setDuration(day, v) break; 
     72            case 'h': setDuration(hour, v) break; 
     73            case 's': setDuration(second, v) break; 
    5474            case 'm': 
    5575            { 
    5676              in >> c; 
    57               if      (c == 'i') duration.minute = v; 
    58               else if (c == 'o') duration.month  = v; 
     77              if      (c == 'i') setDuration(minute, v) 
     78              else if (c == 'o') setDuration(month, v) 
    5979              else invalidUnit = true; 
    6080              break; 
     
    6383            { 
    6484              in >> c; 
    65               if (c == 's') duration.timestep = v; 
     85              if (c == 's') setDuration(timestep, v) 
    6686              else invalidUnit = true; 
    6787              break; 
     
    7696                  << "Bad duration format: invalid unit, unexpected '" << c << "' character."); 
    7797        } while (in.peek() != EOF); // check whether there is a next character to read 
     98 
     99#undef setDuration 
    78100 
    79101        return in; 
Note: See TracChangeset for help on using the changeset viewer.