summaryrefslogtreecommitdiff
path: root/lib/common/FdGetLine.h
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2011-04-22 13:41:07 +0000
committerChris Wilson <chris+github@qwirx.com>2011-04-22 13:41:07 +0000
commit44999aec110f60912e2d2c6f02afa9591af34569 (patch)
tree627588a72b7999717437acf3a922400065cd11e7 /lib/common/FdGetLine.h
parent48cda1bd70300b09d3e3c81480c851bdc1e10e25 (diff)
Refactor GetLines to share common code, fix whitespace removal at end of line.
Diffstat (limited to 'lib/common/FdGetLine.h')
-rw-r--r--lib/common/FdGetLine.h35
1 files changed, 10 insertions, 25 deletions
diff --git a/lib/common/FdGetLine.h b/lib/common/FdGetLine.h
index df43c3c9..5ad82c64 100644
--- a/lib/common/FdGetLine.h
+++ b/lib/common/FdGetLine.h
@@ -12,19 +12,7 @@
#include <string>
-#ifdef BOX_RELEASE_BUILD
- #define FDGETLINE_BUFFER_SIZE 1024
-#elif defined WIN32
- // need enough space for at least one unicode character
- // in UTF-8 when calling console_read() from bbackupquery
- #define FDGETLINE_BUFFER_SIZE 5
-#else
- #define FDGETLINE_BUFFER_SIZE 4
-#endif
-
-// Just a very large upper bound for line size to avoid
-// people sending lots of data over sockets and causing memory problems.
-#define FDGETLINE_MAX_LINE_SIZE (1024*256)
+#include "GetLine.h"
// --------------------------------------------------------------------------
//
@@ -34,7 +22,7 @@
// Created: 2003/07/24
//
// --------------------------------------------------------------------------
-class FdGetLine
+class FdGetLine : public GetLine
{
public:
FdGetLine(int fd);
@@ -43,22 +31,19 @@ private:
FdGetLine(const FdGetLine &rToCopy);
public:
- std::string GetLine(bool Preprocess = false);
- bool IsEOF() {return mEOF;}
- int GetLineNumber() {return mLineNumber;}
-
+ virtual std::string GetLine(bool Preprocess = false);
// Call to detach, setting file pointer correctly to last bit read.
// Only works for lseek-able file descriptors.
void DetachFile();
-
+ // if we read 0 bytes from an fd, it must be end of stream,
+ // because we don't support timeouts
+ virtual bool IsStreamDataLeft() { return false; }
+
+protected:
+ int ReadMore(int Timeout = IOStream::TimeOutInfinite);
+
private:
- char mBuffer[FDGETLINE_BUFFER_SIZE];
int mFileHandle;
- int mLineNumber;
- int mBufferBegin;
- int mBytesInBuffer;
- bool mPendingEOF;
- bool mEOF;
};
#endif // FDGETLINE__H