Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages

TextFile Class Reference
[File IO]

#include <OpenMS/FORMAT/TextFile.h>

Inheritance diagram for TextFile:

List of all members.


Detailed Description

This class provides some basic file handling methods and facilitates reading, writing and handling text files.

Public Types

Type definitions
typedef iterator Iterator
 Mutable iterator.
typedef const_iterator ConstIterator
 Non-mutable iterator.
typedef reverse_iterator ReverseIterator
 Mutable reverse iterator.
typedef const_reverse_iterator ConstReverseIterator
 Non-mutable reverse iterator.

Public Member Functions

 TextFile ()
 Default constructor.
virtual ~TextFile ()
 destructor
 TextFile (const String &filename, bool trim_lines=false) throw (Exception::FileNotFound)
 Constructor with filename.
void load (const String &filename, bool trim_lines=false) throw (Exception::FileNotFound)
 Loads data from file.
void store (const String &filename) throw (Exception::UnableToCreateFile)
 Writes the data to a file.
Iterator search (const Iterator &start, const String &text, bool trim=false)
 Searches for the first line that starts with text beginning at line start.
Iterator search (const String &text, bool trim=false)
 Searches for the first line that starts with text.
Iterator searchSuffix (const Iterator &start, const String &text, bool trim=false)
 Searches for the first line that ends with text beginning at line start.
Iterator searchSuffix (const String &text, bool trim=false)
 Searches for the first line that ends with text.
ConstIterator search (const ConstIterator &start, const String &text, bool trim=false) const
 Searches for the first line that starts with text beginning at line start.
ConstIterator search (const String &text, bool trim=false) const
 Searches for the first line that starts with text.
ConstIterator searchSuffix (const ConstIterator &start, const String &text, bool trim=false) const
 Searches for the first line that ends with text beginning at line start.
ConstIterator searchSuffix (const String &text, bool trim=false) const
 Searches for the first line that ends with text.
String asString () const
 Return the content as a single String.

Member Typedef Documentation

typedef iterator Iterator

Mutable iterator.

typedef const_iterator ConstIterator

Non-mutable iterator.

typedef reverse_iterator ReverseIterator

Mutable reverse iterator.

typedef const_reverse_iterator ConstReverseIterator

Non-mutable reverse iterator.


Constructor & Destructor Documentation

TextFile (  ) 

Default constructor.

virtual ~TextFile (  )  [virtual]

destructor

TextFile ( const String filename,
bool  trim_lines = false 
) throw (Exception::FileNotFound)

Constructor with filename.

Parameters:
filename the filename
trim_lines wether or not the lines are trimmed when reading them from file


Member Function Documentation

void load ( const String filename,
bool  trim_lines = false 
) throw (Exception::FileNotFound)

Loads data from file.

Parameters:
filename the filename
trim_lines wether or not the lines are trimmed when reading them from file

void store ( const String filename  )  throw (Exception::UnableToCreateFile)

Writes the data to a file.

Note that this function uses unix-style linebreaks

Parameters:
filename the filename

Iterator search ( const Iterator start,
const String text,
bool  trim = false 
)

Searches for the first line that starts with text beginning at line start.

Parameters:
start the line to start the search in
text the text to find
trim wether the line is trimmed before
Returns:
returns an iterator to the matching line. If no line matches, end() is returned

Iterator search ( const String text,
bool  trim = false 
)

Searches for the first line that starts with text.

This is an overloaded member function, provided for convenience.
It behaves essentially like the above function but the search is start at the beginning of the file

Iterator searchSuffix ( const Iterator start,
const String text,
bool  trim = false 
)

Searches for the first line that ends with text beginning at line start.

Parameters:
start the line to start the search in
text the text to find
trim wether the line is trimmed before
Returns:
returns an iterator to the matching line. If no line matches, end() is returned

Iterator searchSuffix ( const String text,
bool  trim = false 
)

Searches for the first line that ends with text.

This is an overloaded member function, provided for convenience.

It behaves essentially like searchSuffix(const Iterator&, const String&, bool) but the search starts at the beginning of the file

ConstIterator search ( const ConstIterator start,
const String text,
bool  trim = false 
) const

Searches for the first line that starts with text beginning at line start.

Parameters:
start the line to start the search in
text the text to find
trim wether the line is trimmed before
Returns:
returns an iterator to the matching line. If no line matches, end() is returned

ConstIterator search ( const String text,
bool  trim = false 
) const

Searches for the first line that starts with text.

This is an overloaded member function, provided for convenience.
It behaves essentially like the above function but the search is start at the beginning of the file

ConstIterator searchSuffix ( const ConstIterator start,
const String text,
bool  trim = false 
) const

Searches for the first line that ends with text beginning at line start.

Parameters:
start the line to start the search in
text the text to find
trim wether the line is trimmed before
Returns:
returns an iterator to the matching line. If no line matches, end() is returned

ConstIterator searchSuffix ( const String text,
bool  trim = false 
) const

Searches for the first line that ends with text.

This is an overloaded member function, provided for convenience.

It behaves essentially like searchSuffix(const Iterator&, const String&, bool) but the search starts at the beginning of the file

String asString (  )  const

Return the content as a single String.


The documentation for this class was generated from the following file:
Generated Tue Apr 1 15:36:45 2008 -- using doxygen 1.5.4 OpenMS / TOPP 1.1