#include <FileComparison.hpp>
Inherits AbstractFileComparison.
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 |
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.
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.
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.
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.
bool FileComparison::CompareFiles | ( | unsigned | ignoreFirstFewLines = 0 , |
|
bool | doTsAssert = true | |||
) | [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 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.
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.
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).
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).
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().
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.
bool FileComparison::mIgnoreBlankLines [private] |
Whether or not we should ignore blank lines. False by default.
Definition at line 45 of file FileComparison.hpp.
bool FileComparison::mIgnoreCommentLines [private] |
Whether or not we should ignore comment lines. True by default.
Definition at line 42 of file FileComparison.hpp.