00001
00002
00003
00004
00005 #ifndef BALL_FORMAT_LINEBASEDFILE_H
00006 #define BALL_FORMAT_LINEBASEDFILE_H
00007
00008 #ifndef BALL_SYSTEM_FILE_H
00009 # include <BALL/SYSTEM/file.h>
00010 #endif
00011
00012 #include <vector>
00013
00014 namespace BALL
00015 {
00020 class BALL_EXPORT LineBasedFile
00021 : public File
00022 {
00023 public:
00024
00028
00030 LineBasedFile();
00031
00037 LineBasedFile(const String& filename, File::OpenMode open_mode = std::ios::in, bool trim_whitespaces = false)
00038 throw(Exception::FileNotFound);
00039
00042 void clear();
00043
00045
00048
00051 bool operator == (const LineBasedFile& f);
00052
00055 bool operator != (const LineBasedFile& f);
00057
00061
00065 const LineBasedFile& operator = (const LineBasedFile& file)
00066 throw(Exception::FileNotFound);
00067
00069
00072
00074 Position getLineNumber() const;
00075
00077 const String& getLine() const;
00078
00080 String& getLine();
00081
00083
00086
00090 bool readLine()
00091 throw(Exception::ParseError);
00092
00096 bool skipLines(Size number = 1)
00097 throw(Exception::ParseError);
00098
00104 bool search(const String& text, bool return_to_start = false)
00105 throw(Exception::ParseError);
00106
00107
00108
00109 bool search(const String& text, const String& stop, bool return_to_start = false)
00110 throw(Exception::ParseError);
00111
00115 bool gotoLine(Position line_number)
00116 throw(Exception::ParseError);
00117
00120 void rewind()
00121 throw(Exception::ParseError);
00122
00135 void test(const char* file, int line, bool condition, const String& msg)
00136 const throw(Exception::ParseError);
00137
00140 String getField(Index pos = 0, const String& quotes = "",
00141 const String& delimiters = String::CHARACTER_CLASS__WHITESPACE)
00142 const throw(Exception::IndexUnderflow);
00143
00145 bool startsWith(const String& text) const;
00146
00148 bool has(const String& text) const;
00149
00153 Index switchString(const std::vector<String>& data) const;
00154
00159 bool parseColumnFormat(const char* format, Position index, Size length, void* arg);
00160
00162 void enableTrimWhitespaces(bool state);
00163
00165 bool trimWhiteSpacesEnabled() const;
00166
00167 protected:
00169
00170
00171
00173 String line_;
00174
00176 Position line_number_;
00177
00178 bool trim_whitespaces_;
00179
00180 };
00181
00182
00183 # ifndef BALL_NO_INLINE_FUNCTIONS
00184 # include <BALL/FORMAT/lineBasedFile.iC>
00185 # endif
00186 }
00187
00188 #endif // BALL_FORMAT_LINEBASEDFILE_H