Skip to content

Commit

Permalink
clang-format adjustments for version 18
Browse files Browse the repository at this point in the history
This is preparation to add compatibility with previous versions.

Signed-off-by: Rosen Penev <[email protected]>
  • Loading branch information
neheb committed Aug 13, 2024
1 parent 85518e3 commit 1ff8317
Show file tree
Hide file tree
Showing 18 changed files with 59 additions and 88 deletions.
2 changes: 1 addition & 1 deletion include/exiv2/datasets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct EXIV2API DataSet {
TypeId type_; //!< Exiv2 default type
uint16_t recordId_; //!< Record id
const char* photoshop_; //!< Photoshop string
}; // struct DataSet
};

//! IPTC dataset reference, implemented as a static class.
class EXIV2API IptcDataSets {
Expand Down
2 changes: 1 addition & 1 deletion include/exiv2/tags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ struct EXIV2API TagInfo {
TypeId typeId_; //!< Type id
int16_t count_; //!< The number of values (not bytes!), 0=any, -1=count not known.
PrintFct printFct_; //!< Pointer to tag print function
}; // struct TagInfo
};

//! Access to Exif group and tag lists and misc. tag reference methods, implemented as a static class.
class EXIV2API ExifTags {
Expand Down
2 changes: 1 addition & 1 deletion include/exiv2/value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ class EXIV2API CommentValue : public StringValueBase {
CharsetId charsetId_; //!< Charset id
const char* name_; //!< Name of the charset
const char* code_; //!< Code of the charset
}; // struct CharsetTable
};

//! Charset information lookup functions. Implemented as a static class.
class EXIV2API CharsetInfo {
Expand Down
3 changes: 1 addition & 2 deletions samples/easyaccess-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ static void printFct(EasyAccessFct fct, Exiv2::ExifData ed, const char* label) {
if (pos != ed.end()) {
std::cout << " (" << std::setw(35) << pos->key() << ") : " << pos->print(&ed) << "\n";
} else {
std::cout << " (" << std::setw(35) << " "
<< ") : \n";
std::cout << " (" << std::setw(35) << " ) : \n";
}
}

Expand Down
9 changes: 3 additions & 6 deletions samples/getopt-test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,19 @@ class Params : public Util::Getopt {
*/
int getopt(int argc, char** const argv) {
int rc = Util::Getopt::getopt(argc, argv, ::optstring);
std::cout << "Params::getopt()"
<< " rc = " << rc << '\n';
std::cout << "Params::getopt() rc = " << rc << '\n';
return rc;
}

//! Handle options and their arguments.
int option(int opt, const std::string& optarg, int optopt) override {
std::cout << "Params::option()"
<< " opt = " << opt << " optarg = " << optarg << " optopt = " << optopt << '\n';
std::cout << "Params::option() opt = " << opt << " optarg = " << optarg << " optopt = " << optopt << '\n';
return 0;
}

//! Handle non-option parameters.
int nonoption(const std::string& argv) override {
std::cout << "Params::nonoption()"
<< " " << argv << '\n';
std::cout << "Params::nonoption() " << argv << '\n';
return 0;
}
}; // class Params
Expand Down
8 changes: 4 additions & 4 deletions samples/iptcprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ int main(int argc, char* const argv[]) try {

auto end = iptcData.end();
for (auto md = iptcData.begin(); md != end; ++md) {
std::cout << std::setw(44) << std::setfill(' ') << std::left << md->key() << " "
<< "0x" << std::setw(4) << std::setfill('0') << std::right << std::hex << md->tag() << " " << std::setw(9)
<< std::setfill(' ') << std::left << md->typeName() << " " << std::dec << std::setw(3)
<< std::setfill(' ') << std::right << md->count() << " " << std::dec << md->value() << '\n';
std::cout << std::setw(44) << std::setfill(' ') << std::left << md->key() << " 0x" << std::setw(4)
<< std::setfill('0') << std::right << std::hex << md->tag() << " " << std::setw(9) << std::setfill(' ')
<< std::left << md->typeName() << " " << std::dec << std::setw(3) << std::setfill(' ') << std::right
<< md->count() << " " << std::dec << md->value() << '\n';
}

return EXIT_SUCCESS;
Expand Down
3 changes: 1 addition & 2 deletions samples/prevtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ int main(int argc, char* const argv[]) try {
Exiv2::PreviewPropertiesList list = loader.getPreviewProperties();
for (auto&& pos : list) {
std::cout << pos.mimeType_ << " preview, type " << pos.id_ << ", " << pos.size_ << " bytes, " << pos.width_ << 'x'
<< pos.height_ << " pixels"
<< "\n";
<< pos.height_ << " pixels\n";

Exiv2::PreviewImage preview = loader.getPreviewImage(pos);
auto s = preview.writeFile(filename + "_" + std::to_string(pos.width_) + "x" + std::to_string(pos.height_));
Expand Down
10 changes: 2 additions & 8 deletions src/basicio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1482,10 +1482,7 @@ void HttpIo::HttpImpl::writeRemote(const byte* data, size_t size, size_t from, s
const std::string urlencodeData = urlencode(encodeData.data());

std::stringstream ss;
ss << "path=" << hostInfo_.Path << "&"
<< "from=" << from << "&"
<< "to=" << to << "&"
<< "data=" << urlencodeData;
ss << "path=" << hostInfo_.Path << "&from=" << from << "&to=" << to << "&data=" << urlencodeData;
std::string postData = ss.str();

// create the header
Expand Down Expand Up @@ -1664,10 +1661,7 @@ void CurlIo::CurlImpl::writeRemote(const byte* data, size_t size, size_t from, s
// url encode
const std::string urlencodeData = urlencode(encodeData.data());
std::stringstream ss;
ss << "path=" << hostInfo.Path << "&"
<< "from=" << from << "&"
<< "to=" << to << "&"
<< "data=" << urlencodeData;
ss << "path=" << hostInfo.Path << "&from=" << from << "&to=" << to << "&data=" << urlencodeData;
std::string postData = ss.str();

curl_easy_setopt(curl_, CURLOPT_POSTFIELDS, postData.c_str());
Expand Down
15 changes: 5 additions & 10 deletions src/convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1051,8 +1051,7 @@ void Converter::cnvXmpFlash(const char* from, const char* to) {
value |= fired & 1;
#ifndef SUPPRESS_WARNINGS
else
EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:Fired"
<< " to " << to << "\n";
EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:Fired to " << to << "\n";
#endif
}
pos = xmpData_->findKey(XmpKey(std::string(from) + "/exif:Return"));
Expand All @@ -1062,8 +1061,7 @@ void Converter::cnvXmpFlash(const char* from, const char* to) {
value |= (ret & 3) << 1;
#ifndef SUPPRESS_WARNINGS
else
EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:Return"
<< " to " << to << "\n";
EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:Return to " << to << "\n";
#endif
}
pos = xmpData_->findKey(XmpKey(std::string(from) + "/exif:Mode"));
Expand All @@ -1073,8 +1071,7 @@ void Converter::cnvXmpFlash(const char* from, const char* to) {
value |= (mode & 3) << 3;
#ifndef SUPPRESS_WARNINGS
else
EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:Mode"
<< " to " << to << "\n";
EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:Mode to " << to << "\n";
#endif
}
pos = xmpData_->findKey(XmpKey(std::string(from) + "/exif:Function"));
Expand All @@ -1084,8 +1081,7 @@ void Converter::cnvXmpFlash(const char* from, const char* to) {
value |= (function & 1) << 5;
#ifndef SUPPRESS_WARNINGS
else
EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:Function"
<< " to " << to << "\n";
EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:Function to " << to << "\n";
#endif
}
pos = xmpData_->findKey(XmpKey(std::string(from) + "/exif:RedEyeMode"));
Expand All @@ -1096,8 +1092,7 @@ void Converter::cnvXmpFlash(const char* from, const char* to) {
value |= (red & 1) << 6;
#ifndef SUPPRESS_WARNINGS
else
EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:RedEyeMode"
<< " to " << to << "\n";
EXV_WARNING << "Failed to convert " << std::string(from) + "/exif:RedEyeMode to " << to << "\n";
#endif
}
if (erase_)
Expand Down
11 changes: 5 additions & 6 deletions src/datasets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,12 +590,11 @@ void IptcKey::makeKey() {
std::ostream& operator<<(std::ostream& os, const DataSet& dataSet) {
std::ios::fmtflags f(os.flags());
IptcKey iptcKey(dataSet.number_, dataSet.recordId_);
os << dataSet.name_ << ", " << std::dec << dataSet.number_ << ", "
<< "0x" << std::setw(4) << std::setfill('0') << std::right << std::hex << dataSet.number_ << ", "
<< IptcDataSets::recordName(dataSet.recordId_) << ", " << std::boolalpha << dataSet.mandatory_ << ", "
<< dataSet.repeatable_ << ", " << std::dec << dataSet.minbytes_ << ", " << dataSet.maxbytes_ << ", "
<< iptcKey.key() << ", " << TypeInfo::typeName(IptcDataSets::dataSetType(dataSet.number_, dataSet.recordId_))
<< ", ";
os << dataSet.name_ << ", " << std::dec << dataSet.number_ << ", 0x" << std::setw(4) << std::setfill('0')
<< std::right << std::hex << dataSet.number_ << ", " << IptcDataSets::recordName(dataSet.recordId_) << ", "
<< std::boolalpha << dataSet.mandatory_ << ", " << dataSet.repeatable_ << ", " << std::dec << dataSet.minbytes_
<< ", " << dataSet.maxbytes_ << ", " << iptcKey.key() << ", "
<< TypeInfo::typeName(IptcDataSets::dataSetType(dataSet.number_, dataSet.recordId_)) << ", ";
// CSV encoded I am \"dead\" beat" => "I am ""dead"" beat"
char Q = '"';
os << Q;
Expand Down
14 changes: 10 additions & 4 deletions src/fff.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ be considered as real pixels */
unsigned char stripeFields; //!< Number of striped fields this image consists of
unsigned char reserved; //!< For future use - should be set to 0
unsigned short reserved1; //!< For future use - should be set to 0
} GEOMETRIC_INFO_T; //!< sizeof struct == 32 bytes

} GEOMETRIC_INFO_T; //!< sizeof struct == 32 bytes

struct IMAGEINFO_T {
unsigned long imageTime; //!< Time in seconds since 1970-01-01 00:00 (UTC)
Expand Down Expand Up @@ -233,13 +234,15 @@ struct DISTR_DATA_T {

short reserved; //!< For future use
long reserved2[3];

}; //!< sizeof struct == 64 bytes

typedef struct _pres_par_t {
signed long level; /* Level as normalized pixel value (apix), Level is defined as middle of
span (in pixel units) */
signed long span; /* Span as normalized pixel value (apix) */
BYTE reserved[40];

} PRES_PAR_T; /* sizeof struct == 48 bytes */

/**
Expand Down Expand Up @@ -282,7 +285,8 @@ struct OBJECT_PAR_T {

float relHum; //!< relative humidity
long reserved[4]; //!< For future use - should be set to 0
}; //!< sizeof struct == 48 bytes

}; //!< sizeof struct == 48 bytes

struct TEMP_CALIB_T {
long Reserved1[2];
Expand Down Expand Up @@ -344,7 +348,8 @@ struct TEMPSENSOR_DATA_T {
char pzTSName[SYSIMG_NAMELEN + 1];
ULONG captureTime; //!< TS updated; time in seconds since 1970-01-01 00:00
ULONG captureMilliTime; //!< TS updated; Milliseconds since last second
}; //!< sizeof struct == 28 bytes

}; //!< sizeof struct == 28 bytes

/** Detector parameter struct */
struct DETECTOR_PARAM_T {
Expand All @@ -360,7 +365,8 @@ struct EXTENDED_IMAGEINFO_T {
DETECTOR_PARAM_T detectorPars[20]; //!< Currently used detector parameters like
//! used bias, offsets. Usage is camera
//! dependent
}; //!< sizeof struct == 960 bytes

}; //!< sizeof struct == 960 bytes

struct _bidata_t {
GEOMETRIC_INFO_T GeometricInfo; // 32 bytes
Expand Down
15 changes: 6 additions & 9 deletions src/jp2image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,8 @@ void Jp2Image::readMetadata() {
box.length = getULong(reinterpret_cast<byte*>(&box.length), bigEndian);
box.type = getULong(reinterpret_cast<byte*>(&box.type), bigEndian);
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::Jp2Image::readMetadata: "
<< "Position: " << position << " box type: " << toAscii(box.type) << " length: " << box.length
<< '\n';
std::cout << "Exiv2::Jp2Image::readMetadata: Position: " << position << " box type: " << toAscii(box.type)
<< " length: " << box.length << '\n';
#endif
Internal::enforce(box.length <= boxHSize + io_->size() - io_->tell(), ErrorCode::kerCorruptedMetadata);

Expand Down Expand Up @@ -192,13 +191,12 @@ void Jp2Image::readMetadata() {
throw Error(ErrorCode::kerCorruptedMetadata);
}
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::Jp2Image::readMetadata: "
<< "subBox = " << toAscii(subBox.type) << " length = " << subBox.length << '\n';
std::cout << "Exiv2::Jp2Image::readMetadata: subBox = " << toAscii(subBox.type)
<< " length = " << subBox.length << '\n';
#endif
if (subBox.type == kJp2BoxTypeColorSpec && subBox.length != 15) {
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::Jp2Image::readMetadata: "
<< "Color data found" << '\n';
std::cout << "Exiv2::Jp2Image::readMetadata: Color data found\n";
#endif

const size_t pad = 3; // 3 padding bytes 2 0 0
Expand Down Expand Up @@ -727,8 +725,7 @@ void Jp2Image::doWriteMetadata(BasicIo& outIo) {
DataBuf newBuf;
encodeJp2Header(boxBuf, newBuf);
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::Jp2Image::doWriteMetadata: Write JP2Header box (length: " << box.length << ")"
<< '\n';
std::cout << "Exiv2::Jp2Image::doWriteMetadata: Write JP2Header box (length: " << box.length << ")\n";
#endif
if (outIo.write(newBuf.data(), newBuf.size()) != newBuf.size())
throw Error(ErrorCode::kerImageWriteFailed);
Expand Down
12 changes: 4 additions & 8 deletions src/photoshop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,21 @@ int Photoshop::locateIrb(const byte* pPsData, size_t sizePsData, uint16_t psTag,
position += psSize;
if (position + 4 > sizePsData) {
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "Warning: "
<< "Invalid or extended Photoshop IRB\n";
std::cerr << "Warning: Invalid or extended Photoshop IRB\n";
#endif
return -2;
}
uint32_t dataSize = getULong(pPsData + position, bigEndian);
position += 4;
if (dataSize > (sizePsData - position)) {
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "Warning: "
<< "Invalid Photoshop IRB data size " << dataSize << " or extended Photoshop IRB\n";
std::cerr << "Warning: Invalid Photoshop IRB data size " << dataSize << " or extended Photoshop IRB\n";
#endif
return -2;
}
#ifdef EXIV2_DEBUG_MESSAGES
if ((dataSize & 1) && position + dataSize == sizePsData) {
std::cerr << "Warning: "
<< "Photoshop IRB data is not padded to even size\n";
std::cerr << "Warning: Photoshop IRB data is not padded to even size\n";
}
#endif
if (type == psTag) {
Expand All @@ -94,8 +91,7 @@ int Photoshop::locateIrb(const byte* pPsData, size_t sizePsData, uint16_t psTag,
#endif
if (position < sizePsData) {
#ifdef EXIV2_DEBUG_MESSAGES
std::cerr << "Warning: "
<< "Invalid or extended Photoshop IRB\n";
std::cerr << "Warning: Invalid or extended Photoshop IRB\n";
#endif
return -2;
}
Expand Down
3 changes: 1 addition & 2 deletions src/pngchunk_int.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,7 @@ void PngChunk::parseChunkContent(Image* pImage, const byte* key, size_t keySize,
xmpPacket.assign(arr.c_str(), arr.size());
if (auto idx = xmpPacket.find_first_of('<'); idx != std::string::npos && idx > 0) {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Removing " << idx << " characters "
<< "from the beginning of the XMP packet\n";
EXV_WARNING << "Removing " << idx << " characters from the beginning of the XMP packet\n";
#endif
xmpPacket = xmpPacket.substr(idx);
}
Expand Down
6 changes: 2 additions & 4 deletions src/pngimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,7 @@ void PngImage::doWriteMetadata(BasicIo& outIo) {
throw Error(ErrorCode::kerImageWriteFailed);
}
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::PngImage::doWriteMetadata: build eXIf"
<< " chunk (length: " << blob.size() << ")" << '\n';
std::cout << "Exiv2::PngImage::doWriteMetadata: build eXIf chunk (length: " << blob.size() << ")\n";
#endif
}
}
Expand Down Expand Up @@ -631,8 +630,7 @@ void PngImage::doWriteMetadata(BasicIo& outIo) {
throw Error(ErrorCode::kerImageWriteFailed);
}
#ifdef EXIV2_DEBUG_MESSAGES
std::cout << "Exiv2::PngImage::doWriteMetadata: build iCCP"
<< " chunk (length: " << chunkLength << ")" << '\n';
std::cout << "Exiv2::PngImage::doWriteMetadata: build iCCP chunk (length: " << chunkLength << ")\n";
#endif
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/private.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ static char privatehid[] = "@(#)private.h 7.53";
#endif /* !defined TYPE_BIT */

#ifndef TYPE_SIGNED
#define TYPE_SIGNED(type) (((type)-1) < 0)
#define TYPE_SIGNED(type) (((type) - 1) < 0)
#endif /* !defined TYPE_SIGNED */

#ifndef INT_STRLEN_MAXIMUM
Expand Down
6 changes: 3 additions & 3 deletions src/tags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,9 @@ int ExifKey::idx() const {
std::ostream& operator<<(std::ostream& os, const TagInfo& ti) {
std::ios::fmtflags f(os.flags());
ExifKey exifKey(ti);
os << exifKey.tagName() << "," << std::dec << exifKey.tag() << ","
<< "0x" << std::setw(4) << std::setfill('0') << std::right << std::hex << exifKey.tag() << ","
<< exifKey.groupName() << "," << exifKey.key() << "," << TypeInfo::typeName(exifKey.defaultTypeId()) << ",";
os << exifKey.tagName() << "," << std::dec << exifKey.tag() << ",0x" << std::setw(4) << std::setfill('0')
<< std::right << std::hex << exifKey.tag() << "," << exifKey.groupName() << "," << exifKey.key() << ","
<< TypeInfo::typeName(exifKey.defaultTypeId()) << ",";
// CSV encoded I am \"dead\" beat" => "I am ""dead"" beat"
char Q = '"';
os << Q;
Expand Down
Loading

0 comments on commit 1ff8317

Please sign in to comment.