00001 #include <string>
00002
00003
00004
00005 void TestFastRead()
00006 {
00007 cout <<"TestFastRead()"<<endl;
00008 string infile = "Dummy.txt_has_10_events";
00009 cout <<"infile:\t"<<infile<<endl;
00010 string begin = "_has_";
00011 string end = "_events";
00012 int where1 = infile.find(begin);
00013 int where2 = infile.find(end);
00014
00015 int npos = infile.npos;
00016
00017 cout <<"npos:\t"<<npos<<"\twhere1:\t"<<where1<<"\twhere2:\t"<<where2<<endl;
00018
00019 int start=where1+begin.size();
00020 int stop=where2;
00021 cout <<"numbers of events is between indices: ["<<start<<","<<stop<<")"<<endl;
00022
00023 cout <<"Get number of events"<<endl;
00024 string number;
00025 for (int i=start; i<stop; ++i) {
00026 number += infile[i];
00027 }
00028
00029 int nevents = atoi(number.c_str());
00030 cout <<"Number of events as string:\t"<<number<<endl;
00031 cout <<"Number of events as int: \t"<<nevents<<endl;
00032
00033 cout <<"Done"<<endl;
00034 }