C++ Extensions (cppx) Documentation Internal Version
Main | Namespaces | Classes | NamespaceMembers | ClassMembers | Files

txt::File Class Reference

A simple container representing a text file which enables iterating over the lines in the file. Various flags can be used to enable whitespace compression, blank link skipping, and comment removal. Flag names and descriptions are listed below.

One can easily create a large string representation of a file suitable for use with the boost regular expression library, with code similar to the following:

 string targetString;
 File fin("test.dat",File::include_newlines);
 for ( File::iterator itr = fin.begin(); itr != fin.end(); ++itr )
   targetString += *itr;

Note that comment removal and whitespace compression can be done cheaply with the file class, thus making the required regular expressions simpler and more efficient.

File Class Flag List

List of all members.

Public Types

Public Methods

Constructors
Mutators
Accessors

Static Public Attributes

Friends

Detailed Documentation

Member Typedef Documentation

typedef std::string txt::File::value_type
 

typedef LineItr txt::File::iterator
 

typedef LineItr txt::File::const_iterator
 

typedef std::string& txt::File::reference
 

typedef std::string& txt::File::const_reference
 

Constructor & Destructor Documentation

txt::File::File const std::string &    filename,
int    flags = 0
[explicit]
 

Constructor which will create a text file object representing the file indicated with the filename paramter. The various flags are described in the class description. If there is an error when opening the file, then a ECannotOpenFile exception is throw.

Member Function Documentation

void txt::File::setFlags int    flags
 

Sets the flags for this file.

void txt::File::addCommentString const std::string &    commentString
 

Comments are indicated with a single comment string. The actual comment is the text between this comment string and the next newline. A user still needs to make sure that the remove_comments flag is set. This function can be called multiple times to enable multiple distinct comment strings.

int txt::File::getFlags   const
 

Get the flags for this file.

std::string txt::File::getFilename   const
 

Return the filename for this file.

const_iterator txt::File::begin   const
 

const_iterator txt::File::end   const
 

Friends And Related Function Documentation

friend class LineItr [friend]
 

Member Data Documentation

const int txt::File::skip_blank_lines = 1 [static]
 

const int txt::File::include_newlines = 1 << 1 [static]
 

const int txt::File::compress_whitespace = 1 << 2 [static]
 

const int txt::File::remove_comments = 1 << 3 [static]
 



The documentation for this class was generated from the following file:
Generated on Mon Aug 15 21:43:10 2005 by Doxygen 1.2.13-20020210 written by Dimitri van Heesch © 1997-2002