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
00038 LineBasedFile(const String& filename, File::OpenMode open_mode = std::ios::in, bool trim_whitespaces = false);
00039
00042 void clear();
00043
00045
00048
00051 bool operator == (const LineBasedFile& f);
00052
00055 bool operator != (const LineBasedFile& f);
00057
00061
00066 const LineBasedFile& operator = (const LineBasedFile& file);
00067
00069
00072
00074 Position getLineNumber() const;
00075
00077 const String& getLine() const;
00078
00080 String& getLine();
00081
00083
00086
00091 bool readLine();
00092
00097 bool skipLines(Size number = 1);
00098
00105 bool search(const String& text, bool return_to_start = false);
00106
00107
00108
00109
00110 bool search(const String& text, const String& stop, bool return_to_start = false);
00111
00116 bool gotoLine(Position line_number);
00117
00121 void rewind();
00122
00135 void test(const char* file, int line, bool condition, const String& msg) const;
00136
00141 String getField(Index pos = 0, const String& quotes = "",
00142 const String& delimiters = String::CHARACTER_CLASS__WHITESPACE) const;
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