Changeset 875


Ignore:
Timestamp:
06/21/16 17:00:24 (8 years ago)
Author:
ymipsl
Message:

Improved format when activatin splitting.
The key %start_date% and %end_date% are analysed in the filename and substitutide by coresponding date.

%start_date% and %end_date% must appear at maximum once time each, if both are specifed, %start_date% must be specified before %end_date%.
When spliting is not activated, the substring beween %start_date% and %end_date% (including date) are not output.

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/trunk/src/node/file.cpp

    r823 r875  
    357357      { 
    358358         StdString filename = getFileOutputName(); 
     359         if (!name_suffix.isEmpty()) filename+=name_suffix.getValue(); 
     360 
     361// determine splitting format in the file name  : firstPart%start_date%middlePart%end_date%lastPart 
     362 
     363         std::string strStartDate="%start_date%" ; 
     364         std::string strEndDate="%end_date%" ; 
     365 
     366         std::string firstPart ; 
     367         std::string middlePart ; 
     368         std::string lastPart ; 
     369         size_t pos1, pos2 ; 
     370         bool hasStartDate=false ; 
     371         bool hasEndDate=false ;    
     372                   
     373         pos1=filename.find(strStartDate) ; 
     374         if (pos1!=std::string::npos) 
     375         { 
     376           firstPart=filename.substr(0,pos1) ; 
     377           pos1+=strStartDate.size() ; 
     378           hasStartDate=true ; 
     379         } 
     380         else pos1=0 ; 
     381 
     382         pos2=filename.find(strEndDate,pos1) ; 
     383         if (pos2!=std::string::npos) 
     384         { 
     385           middlePart=filename.substr(pos1,pos2-pos1) ; 
     386           cout<<pos2<<endl ; 
     387           pos2+=strEndDate.size() ; 
     388           lastPart=filename.substr(pos2,filename.size()-pos2) ; 
     389           hasEndDate=true ; 
     390         } 
     391         else middlePart=filename.substr(pos1,filename.size()) ; 
     392 
     393         if (!hasStartDate && !hasEndDate) 
     394         { 
     395           hasStartDate=true ; 
     396           hasEndDate=true; 
     397           firstPart=middlePart ; 
     398           middlePart="-" ; 
     399         } 
     400//    
     401         cout<<"filename : "<<filename<<"  firstPart : "<<firstPart<<"  middlePart : "<<middlePart<<"  lastPart : "<<lastPart<<endl ;   
     402         cout<<" hasStartDate : "<<hasStartDate<<"  hasEndDate :"<<hasEndDate ; 
    359403         StdOStringStream oss; 
    360          oss << filename; 
    361          if (!name_suffix.isEmpty()) oss << name_suffix.getValue(); 
    362404 
    363405         if (!split_freq.isEmpty()) 
     
    377419           else splitFormat = split_freq_format; 
    378420 
    379            oss << "_" << lastSplit.getStr(splitFormat) << "-" << splitEnd.getStr(splitFormat); 
     421           oss << firstPart ; 
     422           if (hasStartDate) oss << lastSplit.getStr(splitFormat) ; 
     423           oss << middlePart ; 
     424           if (hasEndDate) oss << splitEnd.getStr(splitFormat); 
     425           oss << lastPart ; 
    380426 
    381427           context->registryOut->setKey("splitStart", lastSplit); 
    382428           context->registryOut->setKey("splitEnd",   splitEnd); 
    383429         } 
     430         else oss<<firstPart<<lastPart ; 
    384431 
    385432        bool append = !this->append.isEmpty() && this->append.getValue(); 
Note: See TracChangeset for help on using the changeset viewer.