clang-tidy: use auto

Found with modernize-use-auto

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2021-05-13 17:56:43 -07:00 committed by Luis Díaz Más
parent 20dfab8036
commit b8712188bb
41 changed files with 167 additions and 170 deletions

View File

@ -577,7 +577,7 @@ namespace Jzon
void Array::Remove(size_t index)
{
if (index < children.size()) {
ChildList::iterator it = children.begin() + index;
auto it = children.begin() + index;
delete (*it);
children.erase(it);
}

View File

@ -96,7 +96,7 @@ try {
// Get a pointer to a copy of the value
v = pos->getValue();
// Downcast the Value pointer to its actual type
Exiv2::URationalValue* prv = dynamic_cast<Exiv2::URationalValue*>(v.release());
auto prv = dynamic_cast<Exiv2::URationalValue*>(v.release());
if (prv == 0) throw Exiv2::Error(Exiv2::kerErrorMessage, "Downcast failed");
rv = Exiv2::URationalValue::UniquePtr(prv);
// Modify the value directly through the interface of URationalValue

View File

@ -210,7 +210,7 @@ void push(Jzon::Node& node,const std::string& key,T i)
case Exiv2::langAlt: {
ABORT_IF_I_EMTPY
Jzon::Object l ;
const Exiv2::LangAltValue& langs = dynamic_cast<const Exiv2::LangAltValue&>(i->value());
const auto& langs = dynamic_cast<const Exiv2::LangAltValue&>(i->value());
for (auto&& lang : langs.value_) {
l.Add(lang.first, lang.second);
}
@ -246,7 +246,7 @@ void push(Jzon::Node& node,const std::string& key,T i)
void fileSystemPush(const char* path,Jzon::Node& nfs)
{
Jzon::Object& fs = (Jzon::Object&) nfs;
auto& fs = (Jzon::Object&)nfs;
fs.Add("path",path);
char resolved_path[2000]; // PATH_MAX];
fs.Add("realpath",realpath(path,resolved_path));

View File

@ -335,7 +335,7 @@ public:
// XML Parser Callbacks
static void startElement(void* userData, const char* name, const char** atts )
{
UserData* me = (UserData*) userData;
auto me = (UserData*)userData;
//for ( int i = 0 ; i < me->indent ; i++ ) printf(" ");
//printf("begin %s\n",name);
me->bTime = strcmp(name,"time")==0;
@ -357,7 +357,7 @@ static void startElement(void* userData, const char* name, const char** atts )
static void endElement(void* userData, const char* name)
{
UserData* me = (UserData*) userData;
auto me = (UserData*)userData;
me->indent-- ;
if ( strcmp(name,"trkpt")==0 ) {
@ -379,7 +379,7 @@ static void endElement(void* userData, const char* name)
void charHandler(void* userData,const char* s,int len)
{
UserData* me = (UserData*) userData;
auto me = (UserData*)userData;
if ( me->nTrkpt == 1 ) {
char buffer[100];

View File

@ -142,7 +142,7 @@ void processRemove(const std::string& line, int num, IptcData &iptcData)
const std::string key( line.substr(keyStart) );
IptcKey iptcKey(key);
IptcData::iterator iter = iptcData.findKey(iptcKey);
auto iter = iptcData.findKey(iptcKey);
if (iter != iptcData.end()) {
iptcData.erase(iter);
}
@ -174,7 +174,7 @@ void processModify(const std::string& line, int num, IptcData &iptcData)
Value::UniquePtr value = Value::create(type);
value->read(data);
IptcData::iterator iter = iptcData.findKey(iptcKey);
auto iter = iptcData.findKey(iptcKey);
if (iter != iptcData.end()) {
iter->setValue(value.get());
}

View File

@ -1718,7 +1718,7 @@ namespace Action {
return 0;
}
Exiv2::Value::UniquePtr v = pos->getValue();
const Exiv2::CommentValue* pcv = dynamic_cast<const Exiv2::CommentValue*>(v.get());
const auto pcv = dynamic_cast<const Exiv2::CommentValue*>(v.get());
if (!pcv) {
if (Params::instance().verbose_) {
std::cout << _("Found Exif user comment with unexpected value type") << "\n";

View File

@ -600,7 +600,7 @@ namespace Exiv2 {
const bool wasOpen = (p_->fp_ != 0);
const std::string lastMode(p_->openMode_);
FileIo *fileIo = dynamic_cast<FileIo*>(&src);
auto fileIo = dynamic_cast<FileIo*>(&src);
if (fileIo) {
// Optimization if src is another instance of FileIo
fileIo->close();
@ -1146,7 +1146,7 @@ namespace Exiv2 {
if (!isMalloced_) {
// Minimum size for 1st block
long size = EXV_MAX(blockSize * (1 + need / blockSize), size_);
byte* data = (byte*)std::malloc(size);
auto data = (byte*)std::malloc(size);
if ( data == NULL ) {
throw Error(kerMallocFailed);
}
@ -1205,7 +1205,7 @@ namespace Exiv2 {
void MemIo::transfer(BasicIo& src)
{
MemIo *memIo = dynamic_cast<MemIo*>(&src);
auto memIo = dynamic_cast<MemIo*>(&src);
if (memIo) {
// Optimization if src is another instance of MemIo
if (p_->isMalloced_) {
@ -1525,7 +1525,7 @@ namespace Exiv2 {
}
std::string data = orgPath.substr(base64Pos+7);
char* decodeData = new char[data.length()];
auto decodeData = new char[data.length()];
long size = base64decode(data.c_str(), decodeData, data.length());
if (size > 0) {
fs.write(decodeData, size);
@ -1645,7 +1645,7 @@ namespace Exiv2 {
if (rcount == 0) {
throw Error(kerErrorMessage, "Data By Range is empty. Please check the permission.");
}
byte* source = (byte*)data.c_str();
auto source = (byte*)data.c_str();
size_t remain = rcount, totalRead = 0;
size_t iBlock = (rcount == size_) ? 0 : lowBlock;
@ -1686,7 +1686,7 @@ namespace Exiv2 {
size_t nBlocks = (p_->size_ + p_->blockSize_ - 1) / p_->blockSize_;
p_->blocksMap_ = new BlockMap[nBlocks];
p_->isMalloced_ = true;
byte* source = (byte*)data.c_str();
auto source = (byte*)data.c_str();
size_t remain = p_->size_, iBlock = 0, totalRead = 0;
while (remain) {
size_t allow = EXV_MIN(remain, p_->blockSize_);
@ -1746,7 +1746,7 @@ namespace Exiv2 {
size_t i = 0;
size_t readCount = 0;
size_t blockSize = 0;
byte* buf = (byte*) std::malloc(p_->blockSize_);
auto buf = (byte*)std::malloc(p_->blockSize_);
size_t nBlocks = (p_->size_ + p_->blockSize_ - 1) / p_->blockSize_;
// find $left
@ -1796,7 +1796,7 @@ namespace Exiv2 {
// submit to the remote machine.
long dataSize = (long) (src.size() - left - right);
if (dataSize > 0) {
byte* data = (byte*) std::malloc(dataSize);
auto data = (byte*)std::malloc(dataSize);
src.seek(left, BasicIo::beg);
src.read(data, dataSize);
p_->writeRemote(data, (size_t)dataSize, (long)left, (long) (p_->size_ - right));
@ -1830,7 +1830,7 @@ namespace Exiv2 {
// connect to the remote machine & populate the blocks just in time.
p_->populateBlocks(lowBlock, highBlock);
byte* fakeData = (byte*) std::calloc(p_->blockSize_, sizeof(byte));
auto fakeData = (byte*)std::calloc(p_->blockSize_, sizeof(byte));
if (!fakeData) {
throw Error(kerErrorMessage, "Unable to allocate data");
}
@ -2127,7 +2127,7 @@ namespace Exiv2 {
// encode base64
size_t encodeLength = ((size + 2) / 3) * 4 + 1;
char* encodeData = new char[encodeLength];
auto encodeData = new char[encodeLength];
base64encode(data, size, encodeData, encodeLength);
// url encode
const std::string urlencodeData = urlencode(encodeData);
@ -2348,7 +2348,7 @@ namespace Exiv2 {
// encode base64
size_t encodeLength = ((size + 2) / 3) * 4 + 1;
char* encodeData = new char[encodeLength];
auto encodeData = new char[encodeLength];
base64encode(data, size, encodeData, encodeLength);
// url encode
const std::string urlencodeData = urlencode(encodeData);

View File

@ -111,7 +111,7 @@ namespace Exiv2
std::string BmffImage::toAscii(long n)
{
const char* p = (const char*)&n;
const auto p = (const char*)&n;
std::string result;
for (int i = 0; i < 4; i++) {
char c = p[isBigEndianPlatform() ? i : (3 - i)];
@ -289,7 +289,7 @@ namespace Exiv2
std::string id;
// Check that the string has a '\0' terminator.
const char* str = (const char*)data.pData_ + skip;
const size_t maxlen = static_cast<size_t>(data.size_ - skip);
const auto maxlen = static_cast<size_t>(data.size_ - skip);
enforce(strnlen(str, maxlen) < maxlen, Exiv2::kerCorruptedMetadata);
std::string name(str);
if ( !name.find("Exif") ) { // "Exif" or "ExifExif"

View File

@ -3212,7 +3212,7 @@ namespace Exiv2 {
val = -val;
}
// remove fraction
float frac = static_cast<float>(val & 0x1f);
auto frac = static_cast<float>(val & 0x1f);
val -= long(frac);
// convert 1/3 (0x0c) and 2/3 (0x14) codes
if (frac == 0x0c) {

View File

@ -526,7 +526,7 @@ namespace Exiv2 {
auto pos = exifData_->findKey(ExifKey(from));
if (pos == exifData_->end()) return;
if (!prepareXmpTarget(to)) return;
const CommentValue* cv = dynamic_cast<const CommentValue*>(&pos->value());
const auto cv = dynamic_cast<const CommentValue*>(&pos->value());
if (cv == 0) {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Failed to convert " << from << " to " << to << "\n";
@ -1530,7 +1530,7 @@ namespace {
return false;
}
std::string outstr;
EXV_ICONV_CONST char* inptr = const_cast<char*>(str.c_str());
auto inptr = const_cast<char*>(str.c_str());
size_t inbytesleft = str.length();
while (inbytesleft) {
char outbuf[256];

View File

@ -1041,7 +1041,7 @@ namespace Exiv2 {
CiffComponent* cc = pHead->findComponent(pCrwMapping->crwTagId_,
pCrwMapping->crwDir_);
if (!comment.empty()) {
uint32_t size = static_cast<uint32_t>(comment.size());
auto size = static_cast<uint32_t>(comment.size());
if (cc && cc->size() > size) size = cc->size();
DataBuf buf(size);
std::memset(buf.pData_, 0x0, buf.size_);

View File

@ -43,7 +43,7 @@ namespace {
int count)
{
for (int i = 0; i < count; ++i) {
ExifData::const_iterator pos = ed.findKey(ExifKey(keys[i]));
auto pos = ed.findKey(ExifKey(keys[i]));
if (pos != ed.end()) return pos;
}
return ed.end();
@ -127,7 +127,7 @@ namespace Exiv2 {
// Find the first ISO value which is not "0"
const int cnt = EXV_COUNTOF(keys);
ExifData::const_iterator md = ed.end();
auto md = ed.end();
long iso_val = -1;
for (int idx = 0; idx < cnt; ) {
md = findMetadatum(ed, keys + idx, cnt - idx);
@ -146,7 +146,7 @@ namespace Exiv2 {
// ISO value (see EXIF 2.3 Annex G)
long iso_tmp_val = -1;
while (iso_tmp_val == -1 && (iso_val == 65535 || md == ed.end())) {
ExifData::const_iterator md_st = findMetadatum(ed, sensitivityType, 1);
auto md_st = findMetadatum(ed, sensitivityType, 1);
// no SensitivityType? exit with existing data
if (md_st == ed.end())
break;

View File

@ -558,7 +558,7 @@ namespace Exiv2 {
Exifdatum& ExifData::operator[](const std::string& key)
{
ExifKey exifKey(key);
iterator pos = findKey(exifKey);
auto pos = findKey(exifKey);
if (pos == end()) {
add(Exifdatum(exifKey));
pos = findKey(exifKey);

View File

@ -473,7 +473,7 @@ int Params::evalGrep( const std::string& optArg)
// there was an error compiling the regexp
if( errcode ) {
size_t length = regerror (errcode, pRegex, NULL, 0);
char *buffer = new char[ length];
auto buffer = new char[length];
regerror (errcode, pRegex, buffer, length);
std::cerr << progname()
<< ": " << _("Option") << " -g: "
@ -958,7 +958,7 @@ int Params::nonoption(const std::string& argv)
static int readFileToBuf(FILE* f,Exiv2::DataBuf& buf)
{
const int buff_size = 4*1028;
Exiv2::byte* bytes = (Exiv2::byte*)::malloc(buff_size);
auto bytes = (Exiv2::byte*)::malloc(buff_size);
int nBytes = 0 ;
bool more = bytes != NULL;
while ( more ) {
@ -1039,7 +1039,7 @@ using long_t = std::map<std::string, std::string>;
int Params::getopt(int argc, char* const Argv[])
{
char** argv = new char* [argc+1];
auto argv = new char*[argc + 1];
argv[argc] = NULL;
long_t longs;
@ -1167,7 +1167,7 @@ namespace {
bool parseTime(const std::string& ts, long& time)
{
std::string hstr, mstr, sstr;
char *cts = new char[ts.length() + 1];
auto cts = new char[ts.length() + 1];
strcpy(cts, ts.c_str());
char *tmp = ::strtok(cts, ":");
if (tmp) hstr = tmp;

View File

@ -95,7 +95,7 @@ namespace Exiv2 {
const char* pstr = str;
// \todo try to use std::string for buf and avoid the creation of another string for just
// returning the final value
char* buf = new char[strlen(str) * 3 + 1];
auto buf = new char[strlen(str) * 3 + 1];
char* pbuf = buf;
while (*pstr) {
if (isalnum(*pstr) || *pstr == '-' || *pstr == '_' || *pstr == '.' || *pstr == '~')
@ -114,7 +114,7 @@ namespace Exiv2 {
char* urldecode(const char* str) {
const char* pstr = str;
char* buf = new char [(strlen(str) + 1)];
auto buf = new char[(strlen(str) + 1)];
char* pbuf = buf;
while (*pstr) {
if (*pstr == '%') {
@ -150,13 +150,13 @@ namespace Exiv2 {
'4', '5', '6', '7', '8', '9', '+', '/'};
int base64encode(const void* data_buf, size_t dataLength, char* result, size_t resultSize) {
char* encoding_table = (char*)base64_encode;
auto encoding_table = (char*)base64_encode;
size_t mod_table[] = {0, 2, 1};
size_t output_length = 4 * ((dataLength + 2) / 3);
int rc = result && data_buf && output_length < resultSize ? 1 : 0;
if ( rc ) {
const unsigned char* data = (const unsigned char*) data_buf ;
const auto data = (const unsigned char*)data_buf;
for (size_t i = 0, j = 0 ; i < dataLength;) {
uint32_t octet_a = i < dataLength ? data[i++] : 0 ;
@ -183,13 +183,13 @@ namespace Exiv2 {
size_t input_length = in ? ::strlen(in) : 0;
if (!in || input_length % 4 != 0) return result;
unsigned char* encoding_table = (unsigned char*)base64_encode;
auto encoding_table = (unsigned char*)base64_encode;
unsigned char decoding_table[256];
for (unsigned char i = 0; i < 64; i++)
decoding_table[encoding_table[i]] = i;
size_t output_length = input_length / 4 * 3;
const unsigned char* buff = (const unsigned char*) in;
const auto buff = (const unsigned char*)in;
if (buff[input_length - 1] == '=') (output_length)--;
if (buff[input_length - 2] == '=') (output_length)--;

View File

@ -228,8 +228,8 @@ namespace Exiv2 {
uint64_t Image::byteSwap(uint64_t value,bool bSwap) const
{
uint64_t result = 0;
byte* source_value = reinterpret_cast<byte *>(&value);
byte* destination_value = reinterpret_cast<byte *>(&result);
auto source_value = reinterpret_cast<byte*>(&value);
auto destination_value = reinterpret_cast<byte*>(&result);
for (int i = 0; i < 8; i++)
destination_value[i] = source_value[8 - i - 1];
@ -258,7 +258,7 @@ namespace Exiv2 {
uint16_t Image::byteSwap2(const DataBuf& buf,size_t offset,bool bSwap) const
{
uint16_t v;
char* p = (char*) &v;
auto p = (char*)&v;
p[0] = buf.pData_[offset];
p[1] = buf.pData_[offset+1];
return Image::byteSwap(v,bSwap);
@ -267,7 +267,7 @@ namespace Exiv2 {
uint32_t Image::byteSwap4(const DataBuf& buf,size_t offset,bool bSwap) const
{
uint32_t v;
char* p = (char*) &v;
auto p = (char*)&v;
p[0] = buf.pData_[offset];
p[1] = buf.pData_[offset+1];
p[2] = buf.pData_[offset+2];
@ -278,7 +278,7 @@ namespace Exiv2 {
uint64_t Image::byteSwap8(const DataBuf& buf,size_t offset,bool bSwap) const
{
uint64_t v;
byte* p = reinterpret_cast<byte *>(&v);
auto p = reinterpret_cast<byte*>(&v);
for(int i = 0; i < 8; i++)
p[i] = buf.pData_[offset + i];
@ -467,13 +467,13 @@ namespace Exiv2 {
uint32_t jump= 10 ;
byte bytes[20] ;
const char* chars = (const char*) &bytes[0] ;
const auto chars = (const char*)&bytes[0];
io.seek(offset,BasicIo::beg); // position
io.read(bytes,jump ) ; // read
bytes[jump]=0 ;
if ( ::strcmp("Nikon",chars) == 0 ) {
// tag is an embedded tiff
byte* bytes2=new byte[count-jump] ; // allocate memory
auto bytes2 = new byte[count - jump]; // allocate memory
io.read(bytes2,count-jump) ; // read
MemIo memIo(bytes2,count-jump) ; // create a file
printTiffStructure(memIo,out,option,depth);

View File

@ -61,8 +61,8 @@ namespace Exiv2
{
std::stringstream hexOutput;
unsigned long tl = (unsigned long)((size / 16) * 16);
unsigned long tl_offset = (unsigned long)(size - tl);
auto tl = (unsigned long)((size / 16) * 16);
auto tl_offset = (unsigned long)(size - tl);
for (unsigned long loop = 0; loop < (unsigned long)size; loop++) {
if (data[loop] < 16) {

View File

@ -286,7 +286,7 @@ string INIReader::MakeKey(string section, string name)
int INIReader::ValueHandler(void* user, const char* section, const char* name,
const char* value)
{
INIReader* reader = (INIReader*)user;
auto reader = (INIReader*)user;
string key = MakeKey(section, name);
if (!reader->_values[key].empty())
reader->_values[key] += "\n";

View File

@ -257,7 +257,7 @@ namespace Exiv2 {
Iptcdatum& IptcData::operator[](const std::string& key)
{
IptcKey iptcKey(key);
iterator pos = findKey(iptcKey);
auto pos = findKey(iptcKey);
if (pos == end()) {
add(Iptcdatum(iptcKey));
pos = findKey(iptcKey);
@ -268,12 +268,10 @@ namespace Exiv2 {
long IptcData::size() const
{
long newSize = 0;
const_iterator iter = iptcMetadata_.begin();
const_iterator end = iptcMetadata_.end();
for ( ; iter != end; ++iter) {
for (auto&& iptc : iptcMetadata_) {
// marker, record Id, dataset num, first 2 bytes of size
newSize += 5;
long dataSize = iter->size();
long dataSize = iptc.size();
newSize += dataSize;
if (dataSize > 32767) {
// extended dataset (we always use 4 bytes)
@ -367,7 +365,7 @@ namespace Exiv2 {
const char *IptcData::detectCharset() const
{
const_iterator pos = findKey(IptcKey("Iptc.Envelope.CharacterSet"));
auto pos = findKey(IptcKey("Iptc.Envelope.CharacterSet"));
if (pos != end()) {
const std::string value = pos->toString();
if (pos->value().ok()) {

View File

@ -185,7 +185,7 @@ namespace Exiv2
static std::string toAscii(long n)
{
const char* p = (const char*) &n;
const auto p = (const char*)&n;
std::string result;
bool bBigEndian = isBigEndian();
for ( int i = 0 ; i < 4 ; i++) {
@ -648,16 +648,16 @@ static void boxes_check(size_t b,size_t m)
long outlen = sizeof(Jp2BoxHeader) ; // now many bytes have we written to output?
long inlen = sizeof(Jp2BoxHeader) ; // how many bytes have we read from boxBuf?
enforce(sizeof(Jp2BoxHeader) <= static_cast<size_t>(output.size_), Exiv2::kerCorruptedMetadata);
Jp2BoxHeader* pBox = (Jp2BoxHeader*) boxBuf.pData_;
auto pBox = (Jp2BoxHeader*)boxBuf.pData_;
uint32_t length = getLong((byte*)&pBox->length, bigEndian);
enforce(length <= static_cast<size_t>(output.size_), Exiv2::kerCorruptedMetadata);
uint32_t count = sizeof (Jp2BoxHeader);
char* p = (char*) boxBuf.pData_;
auto p = (char*)boxBuf.pData_;
bool bWroteColor = false ;
while ( count < length || !bWroteColor ) {
enforce(sizeof(Jp2BoxHeader) <= length - count, Exiv2::kerCorruptedMetadata);
Jp2BoxHeader* pSubBox = (Jp2BoxHeader*) (p+count) ;
auto pSubBox = (Jp2BoxHeader*)(p + count);
// copy data. pointer could be into a memory mapped file which we will decode!
Jp2BoxHeader subBox ; memcpy(&subBox,pSubBox,sizeof(subBox));

View File

@ -254,7 +254,7 @@ namespace Exiv2 {
return rc;
}
Blob psBlob;
const uint32_t sizeFront = static_cast<uint32_t>(record - pPsData);
const auto sizeFront = static_cast<uint32_t>(record - pPsData);
// Write data before old record.
if (sizePsData > 0 && sizeFront > 0) {
append(psBlob, pPsData, sizeFront);
@ -749,7 +749,7 @@ namespace Exiv2 {
out << std::endl;
// allocate storage and current file position
byte* exif = new byte[size];
auto exif = new byte[size];
uint32_t restore = io_->tell();
// copy the data to memory
@ -844,10 +844,10 @@ namespace Exiv2 {
std::cout << ' ';
}
#endif
uint32_t count = (uint32_t)iptcDataSegs.size();
auto count = (uint32_t)iptcDataSegs.size();
// figure out which blocks to copy
uint64_t* pos = new uint64_t[count + 2];
auto pos = new uint64_t[count + 2];
pos[0] = 0;
// copy the data that is not iptc
auto it = iptcDataSegs.begin();

View File

@ -1145,9 +1145,9 @@ namespace Exiv2 {
// Find Exif.Nikon3.ShutterCount
TiffFinder finder(0x00a7, nikon3Id);
pRoot->accept(finder);
TiffEntryBase* te = dynamic_cast<TiffEntryBase*>(finder.result());
auto te = dynamic_cast<TiffEntryBase*>(finder.result());
if (!te || !te->pValue() || te->pValue()->count() == 0) return buf;
uint32_t count = static_cast<uint32_t>(te->pValue()->toLong());
auto count = static_cast<uint32_t>(te->pValue()->toLong());
// Find Exif.Nikon3.SerialNumber
finder.init(0x001d, nikon3Id);
@ -1155,7 +1155,7 @@ namespace Exiv2 {
te = dynamic_cast<TiffEntryBase*>(finder.result());
if (!te || !te->pValue() || te->pValue()->count() == 0) return buf;
bool ok(false);
uint32_t serial = stringTo<uint32_t>(te->pValue()->toString(), ok);
auto serial = stringTo<uint32_t>(te->pValue()->toString(), ok);
if (!ok) {
std::string model = getExifModel(pRoot);
if (model.empty()) return buf;
@ -1208,7 +1208,7 @@ namespace {
{
Exiv2::Internal::TiffFinder finder(0x0110, Exiv2::Internal::ifd0Id); // Exif.Image.Model
pRoot->accept(finder);
Exiv2::Internal::TiffEntryBase* te = dynamic_cast<Exiv2::Internal::TiffEntryBase*>(finder.result());
auto te = dynamic_cast<Exiv2::Internal::TiffEntryBase*>(finder.result());
if (!te || !te->pValue() || te->pValue()->count() == 0) return std::string();
return te->pValue()->toString();
}

View File

@ -1735,7 +1735,7 @@ namespace Exiv2 {
}
}
uint16_t val = static_cast<uint16_t>(value.toLong());
auto val = static_cast<uint16_t>(value.toLong());
if (dModel) val = (val >> 8) | ((val & 0x00ff) << 8);
if (val == 0x07ff) return os << _("All 11 Points");
@ -2924,32 +2924,35 @@ fmountlens[] = {
return os << "(" << value << ")";
}
// from https://github.com/exiftool/exiftool/blob/12.12/lib/Image/ExifTool/Nikon.pm#L4646
static const struct ZMntLens {uint16_t lid; const char *manuf, *lensname;}
zmountlens[] = {
{1 , "Nikon", "Nikkor Z 24-70mm f/4 S"},
{2 , "Nikon", "Nikkor Z 14-30mm f/4 S"},
{4 , "Nikon", "Nikkor Z 35mm f/1.8 S"},
{8 , "Nikon", "Nikkor Z 58mm f/0.95 S Noct"}, //IB
{9 , "Nikon", "Nikkor Z 50mm f/1.8 S"},
{11 , "Nikon", "Nikkor Z DX 16-50mm f/3.5-6.3 VR"},
{12 , "Nikon", "Nikkor Z DX 50-250mm f/4.5-6.3 VR"},
{13 , "Nikon", "Nikkor Z 24-70mm f/2.8 S"},
{14 , "Nikon", "Nikkor Z 85mm f/1.8 S"},
{15 , "Nikon", "Nikkor Z 24mm f/1.8 S"}, //IB
{16 , "Nikon", "Nikkor Z 70-200mm f/2.8 VR S"}, //IB
{17 , "Nikon", "Nikkor Z 20mm f/1.8 S"}, //IB
{18 , "Nikon", "Nikkor Z 24-200mm f/4-6.3 VR"}, //IB
{21 , "Nikon", "Nikkor Z 50mm f/1.2 S"}, //IB
{22 , "Nikon", "Nikkor Z 24-50mm f/4-6.3"}, //IB
{23 , "Nikon", "Nikkor Z 14-24mm f/2.8 S"}, //IB
{0 , "", ""} //end of array
};
// from https://github.com/exiftool/exiftool/blob/12.12/lib/Image/ExifTool/Nikon.pm#L4646
static const struct ZMntLens
{
uint16_t lid;
const char *manuf, *lensname;
} zmountlens[] = {
{1, "Nikon", "Nikkor Z 24-70mm f/4 S"},
{2, "Nikon", "Nikkor Z 14-30mm f/4 S"},
{4, "Nikon", "Nikkor Z 35mm f/1.8 S"},
{8, "Nikon", "Nikkor Z 58mm f/0.95 S Noct"}, // IB
{9, "Nikon", "Nikkor Z 50mm f/1.8 S"},
{11, "Nikon", "Nikkor Z DX 16-50mm f/3.5-6.3 VR"},
{12, "Nikon", "Nikkor Z DX 50-250mm f/4.5-6.3 VR"},
{13, "Nikon", "Nikkor Z 24-70mm f/2.8 S"},
{14, "Nikon", "Nikkor Z 85mm f/1.8 S"},
{15, "Nikon", "Nikkor Z 24mm f/1.8 S"}, // IB
{16, "Nikon", "Nikkor Z 70-200mm f/2.8 VR S"}, // IB
{17, "Nikon", "Nikkor Z 20mm f/1.8 S"}, // IB
{18, "Nikon", "Nikkor Z 24-200mm f/4-6.3 VR"}, // IB
{21, "Nikon", "Nikkor Z 50mm f/1.2 S"}, // IB
{22, "Nikon", "Nikkor Z 24-50mm f/4-6.3"}, // IB
{23, "Nikon", "Nikkor Z 14-24mm f/2.8 S"}, // IB
};
uint16_t lid = static_cast<uint16_t>(value.toLong());
for(int i = 0; zmountlens[i].lid != 0; ++i){
if ( zmountlens[i].lid == lid ) return os << zmountlens[i].manuf << " " << zmountlens[i].lensname;
}
auto lid = static_cast<uint16_t>(value.toLong());
auto it =
std::find_if(std::begin(zmountlens), std::end(zmountlens), [=](const ZMntLens& z) { return z.lid == lid; });
if (it != std::end(zmountlens))
return os << it->manuf << " " << it->lensname;
return os << lid;
}

View File

@ -1199,7 +1199,7 @@ namespace Exiv2 {
return os << value;
}
if (value.count() == 1) {
short l0 = (short)value.toLong(0);
auto l0 = (short)value.toLong(0);
if (l0 == 1) {
os << _("Auto");
}
@ -1208,8 +1208,8 @@ namespace Exiv2 {
}
}
else if (value.count() == 2) {
short l0 = (short)value.toLong(0);
short l1 = (short)value.toLong(1);
auto l0 = (short)value.toLong(0);
auto l1 = (short)value.toLong(1);
if (l0 == 1) {
switch (l1) {
case 0: os << _("Auto"); break;
@ -1546,8 +1546,8 @@ namespace Exiv2 {
return os << value;
}
uint16_t v0 = (uint16_t)value.toLong(0);
uint16_t v1 = (uint16_t)value.toLong(1);
auto v0 = (uint16_t)value.toLong(0);
auto v1 = (uint16_t)value.toLong(1);
for (auto&& filter : artFilters) {
if (filter.val[0] == v0 && filter.val[1] == v1) {
@ -1659,7 +1659,7 @@ value, const ExifData* metadata)
}
}
uint16_t v = (uint16_t) value.toLong(0);
auto v = (uint16_t)value.toLong(0);
if (!E3_E30model) {
for (auto&& point : afPoints) {

View File

@ -67,7 +67,7 @@ namespace Exiv2 {
static uint32_t byteSwap_(Exiv2::DataBuf& buf,size_t offset,bool bSwap)
{
uint32_t v;
char* p = (char*) &v;
auto p = (char*)&v;
int i;
for ( i = 0 ; i < 4 ; i++ ) p[i] = buf.pData_[offset+i];
uint32_t result = byteSwap_(v,bSwap);

View File

@ -193,7 +193,7 @@ namespace Exiv2 {
std::string translatedKeyText =
string_from_unterminated((const char*)(data.pData_ + keysize + 3 + languageTextSize + 1),
data.size_ - (keysize + 3 + languageTextSize + 1));
const unsigned int translatedKeyTextSize = static_cast<unsigned int>(translatedKeyText.size());
const auto translatedKeyTextSize = static_cast<unsigned int>(translatedKeyText.size());
if ((compressionFlag == 0x00) || (compressionFlag == 0x01 && compressionMethod == 0x00)) {
enforce(Safe::add(static_cast<unsigned int>(keysize + 3 + languageTextSize + 1),
@ -488,7 +488,7 @@ namespace Exiv2 {
std::string PngChunk::zlibCompress(const std::string& text)
{
uLongf compressedLen = static_cast<uLongf>(text.size() * 2); // just a starting point
auto compressedLen = static_cast<uLongf>(text.size() * 2); // just a starting point
int zlibResult;
DataBuf arr;

View File

@ -315,7 +315,7 @@ namespace Exiv2 {
if( bDump ) {
DataBuf dataBuf;
byte* data = new byte[dataOffset+1];
auto data = new byte[dataOffset + 1];
data[dataOffset] = 0;
bufRead = io_->read(data,dataOffset);
enforce(bufRead == static_cast<long>(dataOffset), kerFailedToReadImageData);
@ -369,7 +369,7 @@ namespace Exiv2 {
DataBuf s(dataBuf.size_+1); // allocate buffer with an extra byte
memcpy(s.pData_,dataBuf.pData_,dataBuf.size_);// copy in the dataBuf
s.pData_[dataBuf.size_] = 0 ; // nul terminate it
const char* str = (const char*) s.pData_; // give it name
const auto str = (const char*)s.pData_; // give it name
out << Internal::indent(depth) << (const char*) buff.pData_ << ": " << str ;
bLF=true;
}
@ -643,10 +643,9 @@ namespace Exiv2 {
if ( iccProfileDefined() ) {
DataBuf compressed;
if ( zlibToCompressed(iccProfile_.pData_,iccProfile_.size_,compressed) ) {
const byte* nullComp = (const byte*) "\0\0";
const byte* type = (const byte*) "iCCP";
const uint32_t nameLength = static_cast<uint32_t>(profileName_.size());
const auto nullComp = (const byte*)"\0\0";
const auto type = (const byte*)"iCCP";
const auto nameLength = static_cast<uint32_t>(profileName_.size());
const uint32_t chunkLength = nameLength + 2 + compressed.size_ ;
byte length[4];
ul2Data (length,chunkLength,bigEndian);

View File

@ -844,13 +844,13 @@ namespace {
prefix = "xapGImg";
}
XmpData::const_iterator imageDatum = xmpData.findKey(XmpKey("Xmp.xmp.Thumbnails[1]/" + prefix + ":image"));
auto imageDatum = xmpData.findKey(XmpKey("Xmp.xmp.Thumbnails[1]/" + prefix + ":image"));
if (imageDatum == xmpData.end()) return;
XmpData::const_iterator formatDatum = xmpData.findKey(XmpKey("Xmp.xmp.Thumbnails[1]/" + prefix + ":format"));
auto formatDatum = xmpData.findKey(XmpKey("Xmp.xmp.Thumbnails[1]/" + prefix + ":format"));
if (formatDatum == xmpData.end()) return;
XmpData::const_iterator widthDatum = xmpData.findKey(XmpKey("Xmp.xmp.Thumbnails[1]/" + prefix + ":width"));
auto widthDatum = xmpData.findKey(XmpKey("Xmp.xmp.Thumbnails[1]/" + prefix + ":width"));
if (widthDatum == xmpData.end()) return;
XmpData::const_iterator heightDatum = xmpData.findKey(XmpKey("Xmp.xmp.Thumbnails[1]/" + prefix + ":height"));
auto heightDatum = xmpData.findKey(XmpKey("Xmp.xmp.Thumbnails[1]/" + prefix + ":height"));
if (heightDatum == xmpData.end()) return;
if (formatDatum->toString() != "JPEG") return;
@ -1018,7 +1018,7 @@ namespace {
}
const std::string header = "P6\n" + toString(width) + " " + toString(height) + "\n255\n";
const byte *headerBytes = reinterpret_cast<const byte*>(header.data());
const auto headerBytes = reinterpret_cast<const byte *>(header.data());
DataBuf dest(static_cast<long>(header.size() + rgb.size_));
std::copy(headerBytes, headerBytes + header.size(), dest.pData_);

View File

@ -2515,7 +2515,7 @@ namespace Exiv2 {
// Using malloc/free for better system compatibility in case
// users don't unregister their namespaces explicitly.
XmpNsInfo xn;
char* c = static_cast<char*>(std::malloc(ns2.size() + 1));
auto c = static_cast<char*>(std::malloc(ns2.size() + 1));
std::strcpy(c, ns2.c_str());
xn.ns_ = c;
c = static_cast<char*>(std::malloc(prefix.size() + 1));
@ -2534,7 +2534,7 @@ namespace Exiv2 {
void XmpProperties::unregisterNsUnsafe(const std::string& ns)
{
NsRegistry::iterator i = nsRegistry_.find(ns);
auto i = nsRegistry_.find(ns);
if (i != nsRegistry_.end()) {
std::free(const_cast<char*>(i->second.prefix_));
std::free(const_cast<char*>(i->second.ns_));
@ -2545,9 +2545,9 @@ namespace Exiv2 {
void XmpProperties::unregisterNs()
{
std::lock_guard<std::mutex> scoped_write_lock(mutex_);
NsRegistry::iterator i = nsRegistry_.begin();
auto i = nsRegistry_.begin();
while (i != nsRegistry_.end()) {
NsRegistry::iterator kill = i++;
auto kill = i++;
unregisterNsUnsafe(kill->first);
}
}

View File

@ -323,7 +323,7 @@ namespace Exiv2 {
ExifKey::ExifKey(const TagInfo& ti)
: p_(new Impl)
{
IfdId ifdId = static_cast<IfdId>(ti.ifdId_);
auto ifdId = static_cast<IfdId>(ti.ifdId_);
if (!Internal::isExifIfd(ifdId) && !Internal::isMakerIfd(ifdId)) {
throw Error(kerInvalidIfdId, ifdId);
}

View File

@ -2556,7 +2556,7 @@ namespace Exiv2 {
uint16_t bit = 0;
uint16_t comma = 0;
for (uint16_t i = 0; i < value.count(); i++ ) { // for each element in value array
uint16_t bits = static_cast<uint16_t>(value.toLong(i));
auto bits = static_cast<uint16_t>(value.toLong(i));
for (uint16_t b = 0; b < 16; ++b) { // for every bit
if (bits & (1 << b)) {
if ( comma++ ) {

View File

@ -402,7 +402,7 @@ namespace Exiv2 {
for (int i = 0; i < pSize->count(); ++i) {
size += static_cast<uint32_t>(pSize->toLong(i));
}
uint32_t offset = static_cast<uint32_t>(pValue()->toLong(0));
auto offset = static_cast<uint32_t>(pValue()->toLong(0));
// Todo: Remove limitation of JPEG writer: strips must be contiguous
// Until then we check: last offset + last size - first offset == size?
if ( static_cast<uint32_t>(pValue()->toLong(pValue()->count()-1))
@ -457,9 +457,9 @@ namespace Exiv2 {
return;
}
for (int i = 0; i < pValue()->count(); ++i) {
const uint32_t offset = static_cast<uint32_t>(pValue()->toLong(i));
const auto offset = static_cast<uint32_t>(pValue()->toLong(i));
const byte* pStrip = pData + baseOffset + offset;
const uint32_t size = static_cast<uint32_t>(pSize->toLong(i));
const auto size = static_cast<uint32_t>(pSize->toLong(i));
if ( offset > sizeData
|| size > sizeData
@ -581,10 +581,10 @@ namespace Exiv2 {
uint32_t TiffBinaryArray::addElement(uint32_t idx, const ArrayDef& def)
{
uint16_t tag = static_cast<uint16_t>(idx / cfg()->tagStep());
auto tag = static_cast<uint16_t>(idx / cfg()->tagStep());
int32_t sz = EXV_MIN(def.size(tag, cfg()->group_), TiffEntryBase::doSize() - idx);
TiffComponent::UniquePtr tc = TiffCreator::create(tag, cfg()->group_);
TiffBinaryElement* tp = dynamic_cast<TiffBinaryElement*>(tc.get());
auto tp = dynamic_cast<TiffBinaryElement*>(tc.get());
// The assertion typically fails if a component is not configured in
// the TIFF structure table (TiffCreator::tiffTreeStruct_)
assert(tp);
@ -790,7 +790,7 @@ namespace Exiv2 {
TiffComponent* TiffSubIfd::doAddChild(TiffComponent::UniquePtr tiffComponent)
{
TiffDirectory* d = dynamic_cast<TiffDirectory*>(tiffComponent.release());
auto d = dynamic_cast<TiffDirectory*>(tiffComponent.release());
assert(d);
ifds_.push_back(d);
return d;
@ -1185,7 +1185,7 @@ namespace Exiv2 {
uint32_t& imageIdx) const
{
assert(pTiffComponent);
TiffEntryBase* pDirEntry = dynamic_cast<TiffEntryBase*>(pTiffComponent);
auto pDirEntry = dynamic_cast<TiffEntryBase*>(pTiffComponent);
assert(pDirEntry);
byte buf[8];
us2Data(buf, pDirEntry->tag(), byteOrder);
@ -1402,7 +1402,7 @@ namespace Exiv2 {
}
if (cfg()->hasFillers_ && def()) {
const ArrayDef* lastDef = def() + defSize() - 1;
uint16_t lastTag = static_cast<uint16_t>(lastDef->idx_ / cfg()->tagStep());
auto lastTag = static_cast<uint16_t>(lastDef->idx_ / cfg()->tagStep());
idx += fillGap(mioWrapper, idx, lastDef->idx_ + lastDef->size(lastTag, cfg()->group_));
}
@ -1704,7 +1704,7 @@ namespace Exiv2 {
if (cfg()->hasFillers_ && def()) {
const ArrayDef* lastDef = def() + defSize() - 1;
uint16_t lastTag = static_cast<uint16_t>(lastDef->idx_ / cfg()->tagStep());
auto lastTag = static_cast<uint16_t>(lastDef->idx_ / cfg()->tagStep());
idx = EXV_MAX(idx, lastDef->idx_ + lastDef->size(lastTag, cfg()->group_));
}
return idx;
@ -1833,7 +1833,7 @@ namespace Exiv2 {
// free functions
TypeId toTypeId(TiffType tiffType, uint16_t tag, IfdId group)
{
TypeId ti = TypeId(tiffType);
auto ti = TypeId(tiffType);
// On the fly type conversion for Exif.Photo.UserComment, Exif.GPSProcessingMethod, GPSAreaInformation
if ( const TagInfo* pTag = ti == undefined ? findTagInfo(tag,group) : NULL ) {
if ( pTag->typeId_ == comment ) {

View File

@ -1676,7 +1676,7 @@ namespace Exiv2 {
IfdId group)
{
TiffComponent::UniquePtr tc;
uint16_t tag = static_cast<uint16_t>(extendedTag & 0xffff);
auto tag = static_cast<uint16_t>(extendedTag & 0xffff);
const TiffGroupStruct* ts = find(tiffGroupStruct_,
TiffGroupStruct::Key(extendedTag, group));
if (ts && ts->newTiffCompFct_) {
@ -1805,7 +1805,7 @@ namespace Exiv2 {
BasicIo::UniquePtr tempIo(new MemIo);
assert(tempIo.get() != 0);
IoWrapper ioWrapper(*tempIo, header.pData_, header.size_, pOffsetWriter);
uint32_t imageIdx(uint32_t(-1));
auto imageIdx(uint32_t(-1));
createdTree->write(ioWrapper,
pHeader->byteOrder(),
header.size_,
@ -1873,7 +1873,7 @@ namespace Exiv2 {
for (auto&& imageGroup : imageGroups) {
TiffFinder finder(0x00fe, imageGroup);
pSourceDir->accept(finder);
TiffEntryBase* te = dynamic_cast<TiffEntryBase*>(finder.result());
auto te = dynamic_cast<TiffEntryBase*>(finder.result());
const Value* pV = te != NULL ? te->pValue() : NULL;
if (pV && pV->typeId() == unsignedLong && pV->count() == 1 && (pV->toLong() & 1) == 0) {
primaryGroups.push_back(te->group());
@ -2122,7 +2122,7 @@ namespace Exiv2 {
void OffsetWriter::setTarget(OffsetId id, uint32_t target)
{
OffsetList::iterator it = offsetList_.find(id);
auto it = offsetList_.find(id);
if (it != offsetList_.end()) it->second.target_ = target;
}

View File

@ -283,7 +283,7 @@ namespace Exiv2 {
// Find camera make by looking for tag 0x010f in IFD0
TiffFinder finder(0x010f, ifd0Id);
pRoot_->accept(finder);
TiffEntryBase* te = dynamic_cast<TiffEntryBase*>(finder.result());
auto te = dynamic_cast<TiffEntryBase*>(finder.result());
if (te && te->pValue()) {
make_ = te->pValue()->toString();
}
@ -597,7 +597,7 @@ namespace Exiv2 {
if (make_.empty() && pRoot_) {
TiffFinder finder(0x010f, ifd0Id);
pRoot_->accept(finder);
TiffEntryBase* te = dynamic_cast<TiffEntryBase*>(finder.result());
auto te = dynamic_cast<TiffEntryBase*>(finder.result());
if (te && te->pValue()) {
make_ = te->pValue()->toString();
}
@ -742,7 +742,7 @@ namespace Exiv2 {
{
assert(buf);
assert(pTiffComponent);
TiffEntryBase* pTiffEntry = dynamic_cast<TiffEntryBase*>(pTiffComponent);
auto pTiffEntry = dynamic_cast<TiffEntryBase*>(pTiffComponent);
assert(pTiffEntry);
us2Data(buf + 2, pTiffEntry->tiffType(), byteOrder);
ul2Data(buf + 4, pTiffEntry->count(), byteOrder);
@ -1028,7 +1028,7 @@ namespace Exiv2 {
if (pSourceTree_) {
TiffFinder finder(object->tag(), object->group());
pSourceTree_->accept(finder);
TiffImageEntry* ti = dynamic_cast<TiffImageEntry*>(finder.result());
auto ti = dynamic_cast<TiffImageEntry*>(finder.result());
if (ti) {
object->strips_ = ti->strips_;
}
@ -1146,7 +1146,7 @@ namespace Exiv2 {
TiffPath tiffPath;
TiffCreator::getPath(tiffPath, i->tag(), group, root);
TiffComponent* tc = pRootDir->addPath(i->tag(), tiffPath, pRootDir);
TiffEntryBase* object = dynamic_cast<TiffEntryBase*>(tc);
auto object = dynamic_cast<TiffEntryBase*>(tc);
#ifdef EXIV2_DEBUG_MESSAGES
if (object == 0) {
std::cerr << "Warning: addPath() didn't add an entry for "
@ -1171,9 +1171,9 @@ namespace Exiv2 {
TiffFinder finder(0x927c, exifId);
pRootDir->accept(finder);
TiffMnEntry* te = dynamic_cast<TiffMnEntry*>(finder.result());
auto te = dynamic_cast<TiffMnEntry*>(finder.result());
if (te) {
TiffIfdMakernote* tim = dynamic_cast<TiffIfdMakernote*>(te->mn_);
auto tim = dynamic_cast<TiffIfdMakernote*>(te->mn_);
if (tim) {
// Set Makernote byte order
ByteOrder bo = stringToByteOrder(posBo->toString());
@ -1239,7 +1239,7 @@ namespace Exiv2 {
readTiffEntry(object);
TiffFinder finder(object->szTag(), object->szGroup());
pRoot_->accept(finder);
TiffEntryBase* te = dynamic_cast<TiffEntryBase*>(finder.result());
auto te = dynamic_cast<TiffEntryBase*>(finder.result());
if (te && te->pValue()) {
object->setStrips(te->pValue(), pData_, size_, baseOffset());
}
@ -1267,7 +1267,7 @@ namespace Exiv2 {
readTiffEntry(object);
TiffFinder finder(object->dtTag(), object->dtGroup());
pRoot_->accept(finder);
TiffDataEntryBase* te = dynamic_cast<TiffDataEntryBase*>(finder.result());
auto te = dynamic_cast<TiffDataEntryBase*>(finder.result());
if (te && te->pValue()) {
te->setStrips(object->pValue(), pData_, size_, baseOffset());
}
@ -1441,7 +1441,7 @@ namespace Exiv2 {
// Find camera make
TiffFinder finder(0x010f, ifd0Id);
pRoot_->accept(finder);
TiffEntryBase* te = dynamic_cast<TiffEntryBase*>(finder.result());
auto te = dynamic_cast<TiffEntryBase*>(finder.result());
std::string make;
if (te && te->pValue()) {
make = te->pValue()->toString();
@ -1606,7 +1606,7 @@ namespace Exiv2 {
// #1143 Write a "hollow" buffer for the preview image
// Sadly: we don't know the exact location of the image in the source (it's near offset)
// And neither TiffReader nor TiffEntryBase have access to the BasicIo object being processed
byte* buffer = (byte*) ::malloc(isize);
auto buffer = (byte*)::malloc(isize);
::memset(buffer,0,isize);
v->read(buffer,isize, byteOrder());
::free(buffer);
@ -1634,7 +1634,7 @@ namespace Exiv2 {
// Check duplicates
TiffFinder finder(object->tag(), object->group());
pRoot_->accept(finder);
TiffEntryBase* te = dynamic_cast<TiffEntryBase*>(finder.result());
auto te = dynamic_cast<TiffEntryBase*>(finder.result());
if (te && te->idx() != object->idx()) {
#ifndef SUPPRESS_WARNINGS
EXV_WARNING << "Not decoding duplicate binary array tag 0x"

View File

@ -615,7 +615,7 @@ namespace Exiv2 {
long ret = stringTo<long>(s, ok);
if (ok) return ret;
float f = stringTo<float>(s, ok);
auto f = stringTo<float>(s, ok);
if (ok) return static_cast<long>(f);
Rational r = stringTo<Rational>(s, ok);
@ -636,7 +636,7 @@ namespace Exiv2 {
float parseFloat(const std::string& s, bool& ok)
{
float ret = stringTo<float>(s, ok);
auto ret = stringTo<float>(s, ok);
if (ok) return ret;
Rational r = stringTo<Rational>(s, ok);
@ -665,7 +665,7 @@ namespace Exiv2 {
if (ok)
return {l, 1};
float f = stringTo<float>(s, ok);
auto f = stringTo<float>(s, ok);
if (ok) return floatToRationalCast(f);
bool b = stringTo<bool>(s, ok);
@ -698,7 +698,7 @@ namespace Exiv2 {
den = 1;
}
const float rnd = f >= 0 ? 0.5F : -0.5F;
const int32_t nom = static_cast<int32_t>(f * den + rnd);
const auto nom = static_cast<int32_t>(f * den + rnd);
const int32_t g = gcd(nom, den);
return {nom / g, den / g};

View File

@ -761,8 +761,7 @@ namespace Exiv2 {
std::ostream& XmpArrayValue::write(std::ostream& os) const
{
for (std::vector<std::string>::const_iterator i = value_.begin();
i != value_.end(); ++i) {
for (auto i = value_.begin(); i != value_.end(); ++i) {
if (i != value_.begin()) os << ", ";
os << *i;
}
@ -861,7 +860,7 @@ namespace Exiv2 {
bool first = true;
// Write the default entry first
ValueType::const_iterator i = value_.find(x_default);
auto i = value_.find(x_default);
if (i != value_.end()) {
os << "lang=\"" << i->first << "\" " << i->second;
first = false;
@ -885,7 +884,7 @@ namespace Exiv2 {
std::string LangAltValue::toString(const std::string& qualifier) const
{
ValueType::const_iterator i = value_.find(qualifier);
auto i = value_.find(qualifier);
if (i != value_.end()) {
ok_ = true;
return i->second;

View File

@ -115,9 +115,7 @@ namespace Exiv2 {
static bool shouldOutput(const exv_grep_keys_t& greps,const char* key,const std::string& value)
{
bool bPrint = greps.empty();
for( exv_grep_keys_t::const_iterator g = greps.begin();
!bPrint && g != greps.end() ; ++g
) {
for (auto g = greps.begin(); !bPrint && g != greps.end(); ++g) {
std::string Key(key);
#if defined(EXV_HAVE_REGEX_H)
bPrint = ( 0 == regexec( &(*g), key , 0, NULL, 0)

View File

@ -464,7 +464,7 @@ namespace Exiv2 {
io_->seek(0,BasicIo::beg); // rewind
while ( !io_->eof() && (uint64_t) io_->tell() < filesize) {
uint64_t offset = (uint64_t) io_->tell();
auto offset = (uint64_t)io_->tell();
byte size_buff[WEBP_TAG_SIZE];
io_->read(chunkId.pData_, WEBP_TAG_SIZE);
io_->read(size_buff, WEBP_TAG_SIZE);

View File

@ -304,7 +304,7 @@ namespace Exiv2 {
Xmpdatum& XmpData::operator[](const std::string& key)
{
XmpKey xmpKey(key);
iterator pos = findKey(xmpKey);
auto pos = findKey(xmpKey);
if (pos == end()) {
add(Xmpdatum(xmpKey));
pos = findKey(xmpKey);
@ -499,7 +499,7 @@ namespace Exiv2 {
}
if ( bURI || bNS ) {
std::map<std::string,std::string>* p = (std::map<std::string,std::string>*) refCon;
auto p = (std::map<std::string, std::string>*)refCon;
std::map<std::string,std::string>& m = *p;
std::string b;
@ -757,7 +757,7 @@ namespace Exiv2 {
if (i.typeId() == langAlt) {
// Encode Lang Alt property
const LangAltValue* la = dynamic_cast<const LangAltValue*>(&i.value());
const auto la = dynamic_cast<const LangAltValue*>(&i.value());
if (la == 0)
throw Error(kerEncodeLangAltPropertyFailed, i.key());
@ -775,7 +775,7 @@ namespace Exiv2 {
}
// Todo: Xmpdatum should have an XmpValue, not a Value
const XmpValue* val = dynamic_cast<const XmpValue*>(&i.value());
const auto val = dynamic_cast<const XmpValue*>(&i.value());
if (val == 0)
throw Error(kerInvalidKeyXmpValue, i.key(), i.typeName());
options = xmpArrayOptionBits(val->xmpArrayType())

View File

@ -161,7 +161,7 @@ TEST(base64encode, encodesValidString)
const std::string original ("This is a unit test");
const std::string expected ("VGhpcyBpcyBhIHVuaXQgdGVzdA==");
size_t encodeLength = ((original.size() + 2) / 3) * 4 + 1;
char * result = new char [encodeLength];
auto result = new char[encodeLength];
ASSERT_EQ(1, base64encode(original.c_str(), original.size(), result, encodeLength));
ASSERT_STREQ(expected.c_str(), result);
delete [] result;
@ -171,7 +171,7 @@ TEST(base64encode, doesNotEncodeWithNotBigEnoughResultSize)
{
const std::string original ("This is a unit test");
size_t encodeLength = (original.size());
char * result = new char [encodeLength];
auto result = new char[encodeLength];
ASSERT_EQ(0, base64encode(original.c_str(), original.size(), result, encodeLength));
delete [] result;
}
@ -180,7 +180,7 @@ TEST(base64decode, decodesValidString)
{
const std::string original ("VGhpcyBpcyBhIHVuaXQgdGVzdA==");
const std::string expected ("This is a unit test");
char * result = new char [original.size()];
auto result = new char[original.size()];
ASSERT_EQ(static_cast<long>(expected.size()),
base64decode(original.c_str(), result, original.size()));
ASSERT_STREQ(expected.c_str(), result);

View File

@ -165,8 +165,8 @@ TYPED_TEST_P(slice, iteratorAccess)
{
Slice<TypeParam> sl = this->getTestSlice();
std::vector<int>::const_iterator vec_it = this->vec_.begin() + 1;
for (typename Slice<TypeParam>::const_iterator it = sl.cbegin(); it < sl.cend(); ++it, ++vec_it) {
auto vec_it = this->vec_.begin() + 1;
for (auto it = sl.cbegin(); it < sl.cend(); ++it, ++vec_it) {
ASSERT_EQ(*it, *vec_it);
}
@ -246,7 +246,7 @@ void checkConstSliceValueAt(const Slice<T>& sl, typename Slice<T>::value_type va
template <typename T>
void checkConstSliceIterator(const Slice<T>& sl, typename Slice<T>::value_type first_value)
{
for (typename Slice<T>::const_iterator it = sl.cbegin(); it < sl.cend(); ++it) {
for (auto it = sl.cbegin(); it < sl.cend(); ++it) {
ASSERT_EQ(*it, first_value++);
}
}
@ -287,7 +287,7 @@ TYPED_TEST_P(mutableSlice, iterators)
ASSERT_EQ(*sl.begin(), static_cast<typename slice_t::value_type>(1));
ASSERT_EQ(*sl.end(), static_cast<typename slice_t::value_type>(this->vec_size - 1));
for (typename slice_t::iterator it = sl.begin(); it < sl.end(); ++it) {
for (auto it = sl.begin(); it < sl.end(); ++it) {
*it = 2 * (*it);
}