Chaste
Release::3.4
|
#include <FileComparison.hpp>
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) |
Public Member Functions inherited from AbstractFileComparison | |
AbstractFileComparison (const FileFinder &rFileFinder1, const FileFinder &rFileFinder2, bool calledCollectively, bool suppressOutput) | |
AbstractFileComparison (std::string fileName1, std::string fileName2, bool calledCollectively, bool suppressOutput) | |
virtual | ~AbstractFileComparison () |
Private Attributes | |
bool | mIgnoreCommentLines |
bool | mIgnoreBlankLines |
std::vector< std::string > | mCommentLineStarts |
std::vector< std::string > | mIgnorableContent |
Additional Inherited Members | |
Protected Member Functions inherited from AbstractFileComparison | |
void | ResetFiles () |
void | SkipHeaderLines (unsigned numLinesToSkip) |
Protected Attributes inherited from AbstractFileComparison | |
std::string | mFilename1 |
std::string | mFilename2 |
std::ifstream * | mpFile1 |
std::ifstream * | mpFile2 |
unsigned | mLineNum |
bool | mCalledCollectively |
bool | mSuppressOutput |
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.
|
inline |
Specify two files to compare, and open them for reading. Actual comparison is done by calling CompareFiles.
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 75 of file FileComparison.hpp.
References SetupCommentLines().
|
inline |
Specify two files to compare, and open them for reading. Actual comparison is done by calling CompareFiles.
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 92 of file FileComparison.hpp.
References SetupCommentLines().
|
inline |
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 169 of file FileComparison.hpp.
References PetscTools::AmMaster(), AbstractFileComparison::mCalledCollectively, mCommentLineStarts, AbstractFileComparison::mFilename1, AbstractFileComparison::mFilename2, mIgnorableContent, mIgnoreBlankLines, mIgnoreCommentLines, AbstractFileComparison::mLineNum, AbstractFileComparison::mpFile1, AbstractFileComparison::mpFile2, AbstractFileComparison::mSuppressOutput, AbstractFileComparison::ResetFiles(), and AbstractFileComparison::SkipHeaderLines().
|
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.
ignore | whether to ignore blank lines appearing only in one file |
Definition at line 135 of file FileComparison.hpp.
References mIgnoreBlankLines.
|
inline |
Add the given string to mIgnorableContent, and hence ignore differences in lines which contain that text in both files.
rIgnorableText | the text indicating lines to ignore |
Definition at line 158 of file FileComparison.hpp.
References mIgnorableContent.
|
inline |
Whether or not we should ignore lines starting with a comment symbol (the default symbols are '#' and '!', set by SetupCommentLines).
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 120 of file FileComparison.hpp.
References mCommentLineStarts, and mIgnoreCommentLines.
|
inline |
Set an additional line start which should be treated as a comment and ignored (and therefore switch on mIgnoreCommentLines = true).
lineStart | the beginning of a line which should be treated as a comment |
Definition at line 146 of file FileComparison.hpp.
References mCommentLineStarts, and mIgnoreCommentLines.
|
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 105 of file FileComparison.hpp.
References mCommentLineStarts.
Referenced by FileComparison().
|
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 60 of file FileComparison.hpp.
Referenced by CompareFiles(), SetIgnoreCommentLines(), SetIgnoreLinesBeginningWith(), and SetupCommentLines().
|
private |
Any lines which (in both files) contain one of these strings will be ignored.
Definition at line 63 of file FileComparison.hpp.
Referenced by CompareFiles(), and IgnoreLinesContaining().
|
private |
Whether or not we should ignore blank lines. False by default.
Definition at line 54 of file FileComparison.hpp.
Referenced by CompareFiles(), and IgnoreBlankLines().
|
private |
Whether or not we should ignore comment lines. True by default.
Definition at line 51 of file FileComparison.hpp.
Referenced by CompareFiles(), SetIgnoreCommentLines(), and SetIgnoreLinesBeginningWith().