enum class conversion

Signed-off-by: Rosen Penev <rosenp@gmail.com>
main
Rosen Penev 3 years ago
parent 6e3db99755
commit 7b9ba51c4e

@ -185,7 +185,7 @@ void CiffComponent::doRead(const byte* pData, size_t size, uint32_t start, ByteO
DataLocId dl = dataLocation(); DataLocId dl = dataLocation();
if (dl == valueData) { if (dl == DataLocId::valueData) {
size_ = getULong(pData + start + 2, byteOrder); size_ = getULong(pData + start + 2, byteOrder);
offset_ = getULong(pData + start + 6, byteOrder); offset_ = getULong(pData + start + 6, byteOrder);
@ -204,7 +204,7 @@ void CiffComponent::doRead(const byte* pData, size_t size, uint32_t start, ByteO
enforce(size_ <= size - offset_, ErrorCode::kerOffsetOutOfRange); enforce(size_ <= size - offset_, ErrorCode::kerOffsetOutOfRange);
} }
} }
if (dl == directoryData) { if (dl == DataLocId::directoryData) {
size_ = 8; size_ = 8;
offset_ = start + 2; offset_ = start + 2;
} }
@ -316,7 +316,7 @@ size_t CiffEntry::doWrite(Blob& blob, ByteOrder /*byteOrder*/, size_t offset) {
} }
size_t CiffComponent::writeValueData(Blob& blob, size_t offset) { size_t CiffComponent::writeValueData(Blob& blob, size_t offset) {
if (dataLocation() == valueData) { if (dataLocation() == DataLocId::valueData) {
#ifdef EXIV2_DEBUG_MESSAGES #ifdef EXIV2_DEBUG_MESSAGES
std::cout << " Data for tag 0x" << std::hex << tagId() << ", " << std::dec << size_ << " Bytes\n"; std::cout << " Data for tag 0x" << std::hex << tagId() << ", " << std::dec << size_ << " Bytes\n";
#endif #endif
@ -382,7 +382,7 @@ void CiffComponent::writeDirEntry(Blob& blob, ByteOrder byteOrder) const {
DataLocId dl = dataLocation(); DataLocId dl = dataLocation();
if (dl == valueData) { if (dl == DataLocId::valueData) {
us2Data(buf, tag_, byteOrder); us2Data(buf, tag_, byteOrder);
append(blob, buf, 2); append(blob, buf, 2);
@ -393,7 +393,7 @@ void CiffComponent::writeDirEntry(Blob& blob, ByteOrder byteOrder) const {
append(blob, buf, 4); append(blob, buf, 4);
} }
if (dl == directoryData) { if (dl == DataLocId::directoryData) {
// Only 8 bytes fit in the directory entry // Only 8 bytes fit in the directory entry
us2Data(buf, tag_, byteOrder); us2Data(buf, tag_, byteOrder);
@ -437,7 +437,7 @@ void CiffComponent::setValue(DataBuf&& buf) {
storage_ = std::move(buf); storage_ = std::move(buf);
pData_ = storage_.c_data(); pData_ = storage_.c_data();
size_ = storage_.size(); size_ = storage_.size();
if (size_ > 8 && dataLocation() == directoryData) { if (size_ > 8 && dataLocation() == DataLocId::directoryData) {
tag_ &= 0x3fff; tag_ &= 0x3fff;
} }
} }
@ -464,9 +464,9 @@ TypeId CiffComponent::typeId(uint16_t tag) {
DataLocId CiffComponent::dataLocation(uint16_t tag) { DataLocId CiffComponent::dataLocation(uint16_t tag) {
switch (tag & 0xc000) { switch (tag & 0xc000) {
case 0x0000: case 0x0000:
return valueData; return DataLocId::valueData;
case 0x4000: case 0x4000:
return directoryData; return DataLocId::directoryData;
default: default:
throw Error(ErrorCode::kerCorruptedMetadata); throw Error(ErrorCode::kerCorruptedMetadata);
} }

@ -35,7 +35,7 @@ using CrwEncodeFct = std::function<void(const Image&, const CrwMapping*, CiffHea
using CrwDirs = std::stack<CrwSubDir>; using CrwDirs = std::stack<CrwSubDir>;
//! Type to identify where the data is stored in a directory //! Type to identify where the data is stored in a directory
enum DataLocId { valueData, directoryData, lastDataLocId }; enum class DataLocId { valueData, directoryData, lastDataLocId };
// ***************************************************************************** // *****************************************************************************
// class definitions // class definitions

Loading…
Cancel
Save