Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
Public Member Functions | List of all members
TextFile Class Reference

This class provides some basic file handling methods for text files. More...

#include <OpenMS/FORMAT/TextFile.h>

Inheritance diagram for TextFile:
StringList CsvFile

Public Member Functions

 TextFile ()
 Default constructor. More...
 
virtual ~TextFile ()
 destructor More...
 
 TextFile (const String &filename, bool trim_lines=false, Int first_n=-1)
 Constructor with filename. More...
 
void load (const String &filename, bool trim_lines=false, Int first_n=-1)
 Loads data from a text file. More...
 
void store (const String &filename)
 Writes the data to a file. More...
 
- Public Member Functions inherited from StringList
template<typename StringType >
StringListoperator<< (const StringType &string)
 Operator for appending entries with less code. More...
 
bool contains (const String &s) const
 Returns if a string is contained in the list. More...
 
void toUpper ()
 Transforms all contained strings to upper case. More...
 
void toLower ()
 Transforms all contained strings to lower case. More...
 
String concatenate (const String &glue="") const
 Concatenate the string elements and putting the glue string between elements. More...
 
 StringList ()
 Default constructor. More...
 
 StringList (const StringList &rhs)
 Copy constructor. More...
 
 StringList (const std::vector< String > &rhs)
 Constructor from vector<String> More...
 
 StringList (const std::vector< std::string > &rhs)
 Constructor from vector<string> More...
 
 StringList (const QStringList &rhs)
 Constructor from QStringList. More...
 
StringListoperator= (const StringList &rhs)
 Assignment operator. More...
 
StringListoperator= (const std::vector< String > &rhs)
 Assignment operator from vector<String> More...
 
StringListoperator= (const std::vector< std::string > &rhs)
 Assignment operator vector<string> More...
 
Iterator search (const Iterator &start, const String &text, bool trim=false)
 Searches for the first line that starts with text beginning at line start. More...
 
Iterator search (const String &text, bool trim=false)
 Searches for the first line that starts with text. More...
 
Iterator searchSuffix (const Iterator &start, const String &text, bool trim=false)
 Searches for the first line that ends with text beginning at line start. More...
 
Iterator searchSuffix (const String &text, bool trim=false)
 Searches for the first line that ends with text. More...
 
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. More...
 
ConstIterator search (const String &text, bool trim=false) const
 Searches for the first line that starts with text. More...
 
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. More...
 
ConstIterator searchSuffix (const String &text, bool trim=false) const
 Searches for the first line that ends with text. More...
 

Additional Inherited Members

- Public Types inherited from StringList
typedef iterator Iterator
 Mutable iterator. More...
 
typedef const_iterator ConstIterator
 Non-mutable iterator. More...
 
typedef reverse_iterator ReverseIterator
 Mutable reverse iterator. More...
 
typedef const_reverse_iterator ConstReverseIterator
 Non-mutable reverse iterator. More...
 
- Static Public Member Functions inherited from StringList
static StringList create (const String &list, const char splitter= ',')
 Returns a list that is created by splitting the given (comma-separated) string (String are not trimmed!) More...
 
static StringList create (const char *const *list, UInt size)
 Returns a list that is created from an array of char*. More...
 
- Public Attributes inherited from vector< T >
elements
 STL member. More...
 

Detailed Description

This class provides some basic file handling methods for text files.

Constructor & Destructor Documentation

TextFile ( )

Default constructor.

virtual ~TextFile ( )
virtual

destructor

TextFile ( const String filename,
bool  trim_lines = false,
Int  first_n = -1 
)

Constructor with filename.

Parameters
filenameThe input file name.
trim_linesWhether or not the lines are trimmed when reading them from file.
first_nIf set, only first_n lines the lines from the beginning of the file are read.
Exceptions
Exception::FileNotFoundis thrown if the file could not be opened.

Member Function Documentation

void load ( const String filename,
bool  trim_lines = false,
Int  first_n = -1 
)

Loads data from a text file.

Parameters
filenameThe input file name.
trim_linesWhether or not the lines are trimmed when reading them from file.
first_nIf set, only first_n lines the lines from the beginning of the file are read.
Exceptions
Exception::FileNotFoundis thrown if the file could not be opened.
void store ( const String filename)

Writes the data to a file.

Note
this function uses unix-style linebreaks
Exceptions
Exception::UnableToCreateFileis thrown if the file could not be created

Referenced by FeatureFinderAlgorithmPicked< PeakType, FeatureType >::writeFeatureDebugInfo_().


OpenMS / TOPP release 1.11.1 Documentation generated on Thu Nov 14 2013 11:19:31 using doxygen 1.8.5