COOPY » Guide  version 0.6.5
/home/paulfitz/cvs/coopy_scm/coopy/src/libcoopy_core/Reader.cpp
Go to the documentation of this file.
00001 #include <coopy/Reader.h>
00002 
00003 using namespace coopy::format;
00004 using namespace std;
00005 
00006 string Reader::readLine(bool& eof) {
00007   bool more = false;
00008   string result = "";
00009   eof = false;
00010   do {
00011     string::size_type at = unread.find("\n");
00012     if (at==string::npos) {
00013       string x = read();
00014       if (x.length()==0) {
00015         if (unread=="") {
00016           eof = true;
00017           return "";
00018         } else {
00019           x = unread;
00020           unread = "";
00021           return x;
00022         }
00023       }
00024       unread += x;
00025       more = true;
00026     } else {
00027       result = unread.substr(0,at);
00028       unread = unread.substr(at+1,unread.length());
00029       more = false;
00030     }
00031   } while (more);
00032   if (result.length()>0) {
00033     if (result[0]=='\r') {
00034       result = result.substr(1,result.length());
00035     }
00036   }
00037   if (result.length()>0) {
00038     if (result[result.length()-1]=='\r') {
00039       result = result.substr(0,result.length()-1);
00040     }
00041   }
00042   return result;
00043 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines