Loading...
Searching...
No Matches
lineBasedFile.h
Go to the documentation of this file.
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#ifndef BALL_FORMAT_LINEBASEDFILE_H
#define BALL_FORMAT_LINEBASEDFILE_H
#ifndef BALL_SYSTEM_FILE_H
# include <BALL/SYSTEM/file.h>
#endif
#include <vector>
namespace BALL
{
class BALL_EXPORT LineBasedFile
: public File
{
public:
LineBasedFile();
LineBasedFile(const String& filename, File::OpenMode open_mode = std::ios::in, bool trim_whitespaces = false);
void clear();
bool operator == (const LineBasedFile& f);
bool operator != (const LineBasedFile& f);
const LineBasedFile& operator = (const LineBasedFile& file);
Position getLineNumber() const;
const String& getLine() const;
String& getLine();
bool readLine();
bool skipLines(Size number = 1);
bool search(const String& text, bool return_to_start = false);
/* Search for a line starting with a given string, abort at a stop tag.
* @throw Exception::ParseError if a syntax error was encountered
*/
bool search(const String& text, const String& stop, bool return_to_start = false);
bool gotoLine(Position line_number);
void rewind();
void test(const char* file, int line, bool condition, const String& msg) const;
String getField(Index pos = 0, const String& quotes = "",
const String& delimiters = String::CHARACTER_CLASS__WHITESPACE) const;
bool startsWith(const String& text) const;
bool has(const String& text) const;
Index switchString(const std::vector<String>& data) const;
bool parseColumnFormat(const char* format, Position index, Size length, void* arg);
void enableTrimWhitespaces(bool state);
bool trimWhiteSpacesEnabled() const;
protected:
/* @name Protected Attributes
*/
//_@{
String line_;
Position line_number_;
bool trim_whitespaces_;
vector<char> col_buffer_;
//_@}
};
# ifndef BALL_NO_INLINE_FUNCTIONS
# include <BALL/FORMAT/lineBasedFile.iC>
# endif
} // namespace BALL
#endif // BALL_FORMAT_LINEBASEDFILE_H
BALL_EXPORT
#define BALL_EXPORT
Definition COMMON/global.h:50
BALL::File::File
File()
BALL::File::OpenMode
std::ios::openmode OpenMode
Definition file.h:165
BALL::LineBasedFile::getLineNumber
Position getLineNumber() const
Get the last line number in the file.
BALL::LineBasedFile::gotoLine
bool gotoLine(Position line_number)
BALL::LineBasedFile::getField
String getField(Index pos=0, const String &quotes="", const String &delimiters=String::CHARACTER_CLASS__WHITESPACE) const
BALL::LineBasedFile::startsWith
bool startsWith(const String &text) const
Test if the current line starts with text.
BALL::LineBasedFile::enableTrimWhitespaces
void enableTrimWhitespaces(bool state)
Set wheter leading and trailing whitespaces in lines shall be removed.
BALL::LineBasedFile::readLine
bool readLine()
BALL::LineBasedFile::line_
String line_
buffer for the line in use
Definition lineBasedFile.h:173
BALL::LineBasedFile::LineBasedFile
LineBasedFile()
Default constructor.
BALL::LineBasedFile::parseColumnFormat
bool parseColumnFormat(const char *format, Position index, Size length, void *arg)
BALL::LineBasedFile::LineBasedFile
LineBasedFile(const String &filename, File::OpenMode open_mode=std::ios::in, bool trim_whitespaces=false)
BALL::LineBasedFile::col_buffer_
vector< char > col_buffer_
buffer for column parsing
Definition lineBasedFile.h:181
BALL::LineBasedFile::trimWhiteSpacesEnabled
bool trimWhiteSpacesEnabled() const
BALL::LineBasedFile::getLine
String & getLine()
Return the current line.
BALL::LineBasedFile::switchString
Index switchString(const std::vector< String > &data) const
BALL::LineBasedFile::test
void test(const char *file, int line, bool condition, const String &msg) const
BALL::LineBasedFile::skipLines
bool skipLines(Size number=1)
BALL::LineBasedFile::search
bool search(const String &text, bool return_to_start=false)
BALL::LineBasedFile::clear
void clear()
BALL::LineBasedFile::search
bool search(const String &text, const String &stop, bool return_to_start=false)
BALL::LineBasedFile::rewind
void rewind()
BALL::LineBasedFile::trim_whitespaces_
bool trim_whitespaces_
Definition lineBasedFile.h:178
BALL::LineBasedFile::line_number_
Position line_number_
line number in the file
Definition lineBasedFile.h:176
BALL::LineBasedFile::getLine
const String & getLine() const
Return the current line.
BALL::LineBasedFile::has
bool has(const String &text) const
Return true if the current line contains text.
BALL::String
Definition string.h:57
BALL::String::CHARACTER_CLASS__WHITESPACE
static const char * CHARACTER_CLASS__WHITESPACE
Definition string.h:137
file.h
BALL
Definition constants.h:13
BALL::Size
BALL_SIZE_TYPE Size
Definition COMMON/global.h:114
BALL::Position
BALL_SIZE_TYPE Position
Definition COMMON/global.h:140
BALL::Index
BALL_INDEX_TYPE Index
Definition COMMON/global.h:105