Chaste Release::3.1
FileComparison Class Reference

#include <FileComparison.hpp>

Inheritance diagram for FileComparison:
Collaboration diagram for FileComparison:

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 SetIgnoreLinesBeginningWith (std::string lineStart)
bool CompareFiles (unsigned ignoreFirstFewLines=0, bool doTsAssert=true)

Private Attributes

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

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 '#'.

Definition at line 45 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:
fileName1first file
fileName2second file
calledCollectivelyIf true there will be a barrier before opening files, and only master compares contents.
suppressOutputIf true then no errors will go to TS_TRACE(). Should only be set for the test of this class.

Definition at line 68 of file FileComparison.hpp.

References SetupCommentLines().

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:
rFileName1first file finder
rFileName2second file finder
calledCollectivelyIf true there will be a barrier before opening files, and only master compares contents.
suppressOutputIf true then no errors will go to TS_TRACE(). Should only be set for the test of this class.

Definition at line 84 of file FileComparison.hpp.

References SetupCommentLines().


Member Function Documentation

bool FileComparison::CompareFiles ( unsigned  ignoreFirstFewLines = 0,
bool  doTsAssert = true 
) [inline]

Compare the files under both relative and absolute tolerances. The comparison only fails if neither tolerance holds. The default settings effectively require numbers to match exactly.

Parameters:
ignoreFirstFewLineshow many lines to ignore from the comparison
doTsAssertWhether to throw a TS_ASSERT internally (switched off for testing only)

Definition at line 132 of file FileComparison.hpp.

References PetscTools::AmMaster(), AbstractFileComparison::mCalledCollectively, mCommentLineStarts, AbstractFileComparison::mFilename1, AbstractFileComparison::mFilename2, mIgnoreCommentLines, AbstractFileComparison::mLineNum, AbstractFileComparison::mpFile1, AbstractFileComparison::mpFile2, AbstractFileComparison::mSuppressOutput, AbstractFileComparison::ResetFiles(), and AbstractFileComparison::SkipHeaderLines().

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

Whether or not we should ignore lines starting with '#'

Parameters:
ignorewhether to ignore these lines (defaults to true)

Definition at line 107 of file FileComparison.hpp.

References mIgnoreCommentLines.

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

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

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

Definition at line 118 of file FileComparison.hpp.

References mCommentLineStarts, and mIgnoreCommentLines.

void FileComparison::SetupCommentLines ( ) [inline]

Set some line starts that define comments in the files.

These are ignored by default and when mIgnoreCommentLines = true.

Definition at line 96 of file FileComparison.hpp.

References mCommentLineStarts.

Referenced by FileComparison().


Member Data Documentation

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

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

Definition at line 56 of file FileComparison.hpp.

Referenced by CompareFiles(), SetIgnoreLinesBeginningWith(), and SetupCommentLines().

Whether or not we should ignore lines starting with '#'. True by default.

Definition at line 49 of file FileComparison.hpp.

Referenced by CompareFiles(), SetIgnoreCommentLines(), and SetIgnoreLinesBeginningWith().


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