X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=mussa.git;a=blobdiff_plain;f=alg%2Fsequence.cpp;h=521496d3497b2b96d4786819438d170f6ac50ce4;hp=1f21bd5edc83e8e66894ffc7ee473c31bfbd170c;hb=f3c0553a22b0e4ddc39ee45f51725352d92e97f1;hpb=5e4c30bbdd87540257a0414bdb09d61ba9690ba8 diff --git a/alg/sequence.cpp b/alg/sequence.cpp index 1f21bd5..521496d 100644 --- a/alg/sequence.cpp +++ b/alg/sequence.cpp @@ -324,6 +324,21 @@ Sequence::load_annot(fs::path file_path, int start_index, int end_index) throw mussa_load_error("Error loading annotation file " + file_path.string()); } + try { + load_annot(data_stream, start_index, end_index); + } catch(annotation_load_error e) { + std::ostringstream msg; + msg << file_path.native_file_string() + << " " + << e.what(); + throw annotation_load_error(msg.str()); + } + data_stream.close(); +} + +void +Sequence::load_annot(std::istream& data_stream, int start_index, int end_index) +{ // so i should probably be passing the parse function some iterators // but the annotations files are (currently) small, so i think i can // get away with loading the whole file into memory @@ -333,17 +348,8 @@ Sequence::load_annot(fs::path file_path, int start_index, int end_index) data_stream.get(c); data.push_back(c); } - data_stream.close(); - try { - parse_annot(data, start_index, end_index); - } catch(annotation_load_error e) { - std::ostringstream msg; - msg << file_path.native_file_string() - << " " - << e.what(); - throw annotation_load_error(msg.str()); - } + parse_annot(data, start_index, end_index); } /* If this works, yikes, this is some brain hurting code.