FileComparison Class Reference

#include <FileComparison.hpp>

Inherits AbstractFileComparison.

Collaboration diagram for FileComparison:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 FileComparison (std::string fileName1, std::string fileName2, bool calledCollectively=true, bool suppressOutput=false)
 FileComparison (const FileFinder &rFileName1, const FileFinder &rFileName2, bool calledCollectively=true, bool suppressOutput=false)
void SetupCommentLines ()
void SetIgnoreCommentLines (bool ignore=true)
void IgnoreBlankLines (bool ignore=true)
void SetIgnoreLinesBeginningWith (std::string lineStart)
void IgnoreLinesContaining (const std::string &rIgnorableText)
bool CompareFiles (unsigned ignoreFirstFewLines=0, bool doTsAssert=true)

Private Attributes

bool mIgnoreCommentLines
bool mIgnoreBlankLines
std::vector< std::string > mCommentLineStarts
std::vector< std::string > mIgnorableContent

Detailed Description

Compare files to check for any differences (in numeric and/or string values).

By default this class ignores all lines which (in both files) start with '#' or '!'.

Definition at line 47 of file FileComparison.hpp.


Constructor & Destructor Documentation

FileComparison::FileComparison ( std::string  fileName1,
std::string  fileName2,
bool  calledCollectively = true,
bool  suppressOutput = false 
) [inline]

Specify two files to compare, and open them for reading. Actual comparison is done by calling CompareFiles.

Parameters:
fileName1 first file
fileName2 second file
calledCollectively if true there will be a barrier before opening files, and only master compares contents.
suppressOutput if true then no errors will go to TS_TRACE(). Should only be set for the test of this class.

Definition at line 66 of file FileComparison.hpp.

FileComparison::FileComparison ( const FileFinder rFileName1,
const FileFinder rFileName2,
bool  calledCollectively = true,
bool  suppressOutput = false 
) [inline]

Specify two files to compare, and open them for reading. Actual comparison is done by calling CompareFiles.

Parameters:
rFileName1 first file finder
rFileName2 second file finder
calledCollectively if true there will be a barrier before opening files, and only master compares contents.
suppressOutput if true then no errors will go to TS_TRACE(). Should only be set for the test of this class.

Definition at line 83 of file FileComparison.hpp.


Member Function Documentation

bool FileComparison::CompareFiles ( unsigned  ignoreFirstFewLines = 0,
bool  doTsAssert = true 
) [inline]
Returns:
true if the files are identical, barring ignored content.
Parameters:
ignoreFirstFewLines how many lines to ignore from the comparison
doTsAssert whether to throw a TS_ASSERT internally (switched off for testing only)

Definition at line 160 of file FileComparison.hpp.

void FileComparison::IgnoreBlankLines ( bool  ignore = true  )  [inline]

Set whether or not we should ignore blank lines. If only one of the files being compared has a blank line, if this mode is on we just skip that line and see if the next content line matches the other file.

Parameters:
ignore whether to ignore blank lines appearing only in one file

Definition at line 126 of file FileComparison.hpp.

void FileComparison::IgnoreLinesContaining ( const std::string &  rIgnorableText  )  [inline]

Add the given string to mIgnorableContent, and hence ignore differences in lines which contain that text in both files.

Parameters:
rIgnorableText the text indicating lines to ignore

Definition at line 149 of file FileComparison.hpp.

void FileComparison::SetIgnoreCommentLines ( bool  ignore = true  )  [inline]

Whether or not we should ignore lines starting with a comment symbol (the default symbols are '#' and '!', set by SetupCommentLines).

Parameters:
ignore whether to ignore these lines. If set to false, existing defined comment symbols are also cleared, so that an entirely new set may be defined with SetIgnoreLinesBeginningWith.

Definition at line 111 of file FileComparison.hpp.

void FileComparison::SetIgnoreLinesBeginningWith ( std::string  lineStart  )  [inline]

Set an additional line start which should be treated as a comment and ignored (and therefore switch on mIgnoreCommentLines = true).

Parameters:
lineStart the beginning of a line which should be treated as a comment

Definition at line 137 of file FileComparison.hpp.

void FileComparison::SetupCommentLines (  )  [inline]

Set some line starts that define comments in the files.

These are ignored by default and when mIgnoreCommentLines is explicitly set to true.

Definition at line 96 of file FileComparison.hpp.

References SetupCommentLines().

Referenced by SetupCommentLines().


Member Data Documentation

std::vector<std::string> FileComparison::mCommentLineStarts [private]

A list of strings, which if found at the beginning of lines when mIgnoreCommentLines is true, differences in these lines are ignored.

Definition at line 51 of file FileComparison.hpp.

std::vector<std::string> FileComparison::mIgnorableContent [private]

Any lines which (in both files) contain one of these strings will be ignored.

Definition at line 54 of file FileComparison.hpp.

Whether or not we should ignore blank lines. False by default.

Definition at line 45 of file FileComparison.hpp.

Whether or not we should ignore comment lines. True by default.

Definition at line 42 of file FileComparison.hpp.


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2