Skip to content

Commit

Permalink
clean-up and review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
sdierg committed Jun 18, 2024
1 parent 1d53ec9 commit 6af8c58
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
9 changes: 4 additions & 5 deletions Src/libCZI/CziParse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,16 +574,15 @@ using namespace libCZI;
libCZI::DimensionIndex dim = CCZIParse::DimensionCharToDimensionIndex(subBlkDirDV->DimensionEntries[i].Dimension, 4);
entry.coordinate.Set(dim, subBlkDirDV->DimensionEntries[i].Start);

// check all the dimensions here. cr mark
if(options.GetStoredDimensionOtherThanMMustHaveSizeOne())
if(options.GetPhysicalDimensionOtherThanMMustHaveSizeOne())
{
auto storedSize = subBlkDirDV->DimensionEntries[i].StoredSize;
if(storedSize != 1)
auto physicalSize = subBlkDirDV->DimensionEntries[i].StoredSize;
if(physicalSize != 1)
{
stringstream string_stream;
string_stream
<< "Size for stored dimension '" << Utils::DimensionToChar(dim)
<< "' is expected to be 1, but found " << storedSize
<< "' is expected to be 1, but found " << physicalSize
<< " (file-offset:" << subBlkDirDV->FilePosition << ").";
throw LibCZICZIParseException(string_stream.str().c_str(), LibCZICZIParseException::ErrorCode::NonConformingSubBlockDimensionEntry);
}

Check warning on line 588 in Src/libCZI/CziParse.cpp

View check run for this annotation

Codecov / codecov/patch

Src/libCZI/CziParse.cpp#L588

Added line #L588 was not covered by tests
Expand Down
16 changes: 8 additions & 8 deletions Src/libCZI/CziParse.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CCZIParse
{
kDimensionXyMustBePresent = 0,
kDimensionOtherThanMMustHaveSizeOne,
kStoredDimensionOtherThanMMustHaveSizeOne,
kPhysicalDimensionOtherThanMMustHaveSizeOne,
kDimensionMMustHaveSizeOneExceptForPyramidSubblocks,
kDimensionMMustHaveSizeOne,

Expand All @@ -46,10 +46,10 @@ class CCZIParse
/// \param enable True to enable, false to disable.
void SetDimensionXyMustBePresent(bool enable) { return this->SetFlag(ParseFlags::kDimensionXyMustBePresent, enable); }

/// Require that for each subblock the physical (stored) size (for all dimensions other than X, Y and M) is "1".
/// Require that for each subblock the physical size (for all dimensions other than X, Y and M) is "1".
///
/// \param enable True to enable, false to disable.
void SetStoredDimensionOtherThanMMustHaveSizeOne(bool enable) { return this->SetFlag(ParseFlags::kStoredDimensionOtherThanMMustHaveSizeOne, enable); }
void SetPhysicalDimensionOtherThanMMustHaveSizeOne(bool enable) { return this->SetFlag(ParseFlags::kPhysicalDimensionOtherThanMMustHaveSizeOne, enable); }

/// Require that for each subblock the size (for all dimensions other than X, Y and M) is "1".
///
Expand All @@ -76,10 +76,10 @@ class CCZIParse
/// \returns True if it is to be checked that the size of all dimensions other than X, Y and M is "1" for each subblock; false otherwise.
bool GetDimensionOtherThanMMustHaveSizeOne() const { return this->GetFlag(ParseFlags::kDimensionOtherThanMMustHaveSizeOne); }

/// Gets a boolean indicating whether to check that the physical (stored) size of all dimensions other than X, Y and M is "1" for each subblock.
/// Gets a boolean indicating whether to check that the physical size of all dimensions other than X, Y and M is "1" for each subblock.
///
/// \returns True if it is to be checked that the physical (stored) size of all dimensions other than X, Y and M is "1" for each subblock; false otherwise.
bool GetStoredDimensionOtherThanMMustHaveSizeOne() const { return this->GetFlag(ParseFlags::kStoredDimensionOtherThanMMustHaveSizeOne); }
/// \returns True if it is to be checked that the physical size of all dimensions other than X, Y and M is "1" for each subblock; false otherwise.
bool GetPhysicalDimensionOtherThanMMustHaveSizeOne() const { return this->GetFlag(ParseFlags::kPhysicalDimensionOtherThanMMustHaveSizeOne); }

/// Gets a boolean indicating whether to check that the size is "1" for dimension M for all non-pyramid-subblocks.
/// This flag is more specific than the flag "DimensionMMustHaveSizeOne".
Expand All @@ -97,15 +97,15 @@ class CCZIParse
{
this->SetDimensionXyMustBePresent(false);
this->SetDimensionOtherThanMMustHaveSizeOne(false);
this->SetStoredDimensionOtherThanMMustHaveSizeOne(false);
this->SetPhysicalDimensionOtherThanMMustHaveSizeOne(false);
this->SetDimensionMMustHaveSizeOne(false);
}

/// Sets strict parsing - all options are enabled.
void SetStrictParsing()
{
this->SetDimensionXyMustBePresent(true);
this->SetStoredDimensionOtherThanMMustHaveSizeOne(true);
this->SetPhysicalDimensionOtherThanMMustHaveSizeOne(true);
this->SetDimensionOtherThanMMustHaveSizeOne(true);
this->SetDimensionMMustHaveSizeOne(true);
}
Expand Down

0 comments on commit 6af8c58

Please sign in to comment.