inline SequenceT trim_right_copy(const SequenceT& Input, const std::locale& Loc=std::locale()) { return trim_right_copy_if( Input, is_space(Loc)); }
Renewal* Renewal::ascii_read(StatError &error , const string path , process_type type , int time , double cumul_threshold) { string buffer; size_t position; bool status; int line; DiscreteParametric *inter_event; Renewal *renew; ifstream in_file(path.c_str()); renew = NULL; error.init(); if (!in_file) { error.update(STAT_error[STATR_FILE_NAME]); } else { status = true; line = 0; inter_event = DiscreteParametric::parsing(error , in_file , line , NEGATIVE_BINOMIAL , cumul_threshold , 1); if (!inter_event) { status = false; } else { if (time < MAX(inter_event->offset , 2)) { status = false; error.update(SEQ_error[SEQR_SHORT_OBSERVATION_TIME]); } if (time > MAX_TIME) { status = false; error.update(SEQ_error[SEQR_LONG_OBSERVATION_TIME]); } } while (getline(in_file , buffer)) { line++; # ifdef DEBUG cout << line << " " << buffer << endl; # endif position = buffer.find('#'); if (position != string::npos) { buffer.erase(position); } if (!(trim_right_copy_if(buffer , is_any_of(" \t")).empty())) { status = false; error.update(STAT_parsing[STATP_FORMAT] , line); } } if (status) { DiscreteParametric dtime(UNIFORM , time , time , D_DEFAULT , D_DEFAULT); renew = new Renewal(type , dtime , *inter_event); } delete inter_event; } return renew; }