Removed trailing whitespace from source files

v0.27.3
Andreas Huggel 20 years ago
parent 277edf23fb
commit 06e5c0719e

@ -30,7 +30,7 @@
# #
# This makefile contains (supposedly) generic build rules to build the # This makefile contains (supposedly) generic build rules to build the
# library and applications. It includes all system specific settings # library and applications. It includes all system specific settings
# from config.mk. The idea is that configuring and porting the # from config.mk. The idea is that configuring and porting the
# software to a new platform should only require changes in config.mk. # software to a new platform should only require changes in config.mk.
# #
# Restrictions: # Restrictions:
@ -48,13 +48,13 @@ include $(top_srcdir)/config/config.mk
# Source files # Source files
# Add standalone C++ header files to this list # Add standalone C++ header files to this list
CCHDR = exv_conf.h exv_msvc.h mn.hpp rcsid.hpp CCHDR = exv_conf.h exv_msvc.h mn.hpp rcsid.hpp
# Add library C++ source files to this list # Add library C++ source files to this list
CCSRC = basicio.cpp canonmn.cpp crwimage.cpp datasets.cpp error.cpp exif.cpp \ CCSRC = basicio.cpp canonmn.cpp crwimage.cpp datasets.cpp error.cpp exif.cpp \
futils.cpp fujimn.cpp ifd.cpp image.cpp imgreg.cpp iptc.cpp jpgimage.cpp \ futils.cpp fujimn.cpp ifd.cpp image.cpp imgreg.cpp iptc.cpp jpgimage.cpp \
makernote.cpp metadatum.cpp nikonmn.cpp olympusmn.cpp panasonicmn.cpp \ makernote.cpp metadatum.cpp nikonmn.cpp olympusmn.cpp panasonicmn.cpp \
sigmamn.cpp sonymn.cpp tags.cpp types.cpp value.cpp sigmamn.cpp sonymn.cpp tags.cpp types.cpp value.cpp
# Add source files of simple applications to this list # Add source files of simple applications to this list
BINSRC = addmoddel.cpp dataarea-test.cpp exifcomment.cpp exifdata-test.cpp \ BINSRC = addmoddel.cpp dataarea-test.cpp exifcomment.cpp exifdata-test.cpp \
@ -66,7 +66,7 @@ BINSRC = addmoddel.cpp dataarea-test.cpp exifcomment.cpp exifdata-test.cpp \
EXIV2MAIN = exiv2.cpp EXIV2MAIN = exiv2.cpp
# Add additional source files of the Exiv2 application to this list # Add additional source files of the Exiv2 application to this list
EXIV2SRC = actions.cpp utils.cpp EXIV2SRC = actions.cpp utils.cpp
# C source files of the Exiv2 application # C source files of the Exiv2 application
ifndef HAVE_TIMEGM ifndef HAVE_TIMEGM
EXIVCSRC = localtime.c EXIVCSRC = localtime.c
@ -121,7 +121,7 @@ BINOBJ = $(BINSRC:.cpp=.o)
BINARY = $(BINSRC:.cpp=) BINARY = $(BINSRC:.cpp=)
EXECUTABLE = $(BINSRC:.cpp=$(EXEEXT)) EXECUTABLE = $(BINSRC:.cpp=$(EXEEXT))
EXIV2OBJ = $(EXIV2MAIN:.cpp=.o) $(EXIV2SRC:.cpp=.o) EXIV2OBJ = $(EXIV2MAIN:.cpp=.o) $(EXIV2SRC:.cpp=.o)
EXIV2COBJ = $(EXIVCSRC:.c=.o) EXIV2COBJ = $(EXIVCSRC:.c=.o)
EXIV2BIN = $(EXIV2MAIN:.cpp=) EXIV2BIN = $(EXIV2MAIN:.cpp=)
EXIV2EXE = $(EXIV2MAIN:.cpp=$(EXEEXT)) EXIV2EXE = $(EXIV2MAIN:.cpp=$(EXEEXT))
@ -130,17 +130,17 @@ MCOBJ = $(MCMAIN:.cpp=.o) $(MCSRC:.cpp=.o)
MCBIN = $(MCMAIN:.cpp=) MCBIN = $(MCMAIN:.cpp=)
MCEXE = $(MCMAIN:.cpp=$(EXEEXT)) MCEXE = $(MCMAIN:.cpp=$(EXEEXT))
# Dependency files post-process commands # Dependency files post-process commands
POSTDEPEND = if test ! -d $(DEPDIR); then mkdir $(DEPDIR); fi; \ POSTDEPEND = if test ! -d $(DEPDIR); then mkdir $(DEPDIR); fi; \
if test -e $*.d; then cp $*.d $(DEPDIR)/$*.d; \ if test -e $*.d; then cp $*.d $(DEPDIR)/$*.d; \
sed -e 's/^\#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ sed -e 's/^\#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $(DEPDIR)/$*.d; \ -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $(DEPDIR)/$*.d; \
$(RM) $*.d; fi $(RM) $*.d; fi
# Compilation shortcuts # Compilation shortcuts
COMPILE.cc = $(CXX) $(CXXFLAGS) $(CXXDEFS) $(CXXINCS) -c COMPILE.cc = $(CXX) $(CXXFLAGS) $(CXXDEFS) $(CXXINCS) -c
COMPILE.c = $(CC) $(CFLAGS) $(DEFS) $(INCS) -c COMPILE.c = $(CC) $(CFLAGS) $(DEFS) $(INCS) -c
LINK.cc = $(CXX) $(CXXFLAGS) $(LDLIBS) $(LDFLAGS) -rpath $(libdir) LINK.cc = $(CXX) $(CXXFLAGS) $(LDLIBS) $(LDFLAGS) -rpath $(libdir)
# ****************************************************************************** # ******************************************************************************
# Rules # Rules
@ -184,20 +184,20 @@ $(LIBTOOL): $(LIBTOOL_DEPS)
bin: lib $(BINARY) $(EXIV2BIN) $(MCBIN) path-test bin: lib $(BINARY) $(EXIV2BIN) $(MCBIN) path-test
lib: $(OBJ) lib: $(OBJ)
$(LIBTOOL) --mode=link $(CXX) $(LDFLAGS) $(LOBJ) -o $(LIBRARY) -rpath $(libdir) -release $(EXIV2_VERSION) $(LIBTOOL) --mode=link $(CXX) $(LDFLAGS) $(LOBJ) -o $(LIBRARY) -rpath $(libdir) -release $(EXIV2_VERSION)
@touch lib @touch lib
path-test: path-test.o utils.o path-test: path-test.o utils.o
$(CXX) $(CXXFLAGS) path-test.o utils.o -o $@ $(CXX) $(CXXFLAGS) path-test.o utils.o -o $@
$(BINARY): %: %.o lib $(BINARY): %: %.o lib
@$(LIBTOOL) --mode=link $(LINK.cc) -o $@ $@.o @$(LIBTOOL) --mode=link $(LINK.cc) -o $@ $@.o
$(EXIV2BIN): lib $(EXIV2OBJ) $(EXIV2COBJ) $(EXIV2BIN): lib $(EXIV2OBJ) $(EXIV2COBJ)
@$(LIBTOOL) --mode=link $(LINK.cc) -o $@ $(EXIV2OBJ) $(EXIV2COBJ) @$(LIBTOOL) --mode=link $(LINK.cc) -o $@ $(EXIV2OBJ) $(EXIV2COBJ)
$(MCBIN): lib $(MCOBJ) $(MCBIN): lib $(MCOBJ)
@$(LIBTOOL) --mode=link $(LINK.cc) -o $@ $(MCOBJ) @$(LIBTOOL) --mode=link $(LINK.cc) -o $@ $(MCOBJ)
install-header: install-header:
$(INSTALL_DIRS) $(incdir) $(INSTALL_DIRS) $(incdir)
@ -213,7 +213,7 @@ install-lib: lib install-header
@$(LIBTOOL) --mode=install $(INSTALL_DATA) $(LIBRARY) $(libdir)/$(LIBRARY) @$(LIBTOOL) --mode=install $(INSTALL_DATA) $(LIBRARY) $(libdir)/$(LIBRARY)
install: $(EXIV2BIN) install-lib install: $(EXIV2BIN) install-lib
$(INSTALL_DIRS) $(bindir) $(INSTALL_DIRS) $(bindir)
@$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $(EXIV2EXE) $(bindir)/$(EXIV2EXE) @$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $(EXIV2EXE) $(bindir)/$(EXIV2EXE)
uninstall-header: uninstall-header:

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -71,7 +71,7 @@ EXIV2_RCSID("@(#) $Id$");
// local declarations // local declarations
namespace { namespace {
// Convert a string "YYYY:MM:DD HH:MI:SS" to a struct tm type, // Convert a string "YYYY:MM:DD HH:MI:SS" to a struct tm type,
// returns 0 if successful // returns 0 if successful
int str2Tm(const std::string& timeStr, struct tm* tm); int str2Tm(const std::string& timeStr, struct tm* tm);
@ -87,12 +87,12 @@ namespace {
@param source Source file path @param source Source file path
@param target Target file path. An *.exv file is created if target doesn't @param target Target file path. An *.exv file is created if target doesn't
exist. exist.
@param preserve Indicates if existing metadata in the target file should @param preserve Indicates if existing metadata in the target file should
be kept. be kept.
@return 0 if successful, else an error code @return 0 if successful, else an error code
*/ */
int metacopy(const std::string& source, int metacopy(const std::string& source,
const std::string& target, const std::string& target,
bool preserve); bool preserve);
} }
@ -173,7 +173,7 @@ namespace Action {
return rc; return rc;
} }
catch(const Exiv2::AnyError& e) { catch(const Exiv2::AnyError& e) {
std::cerr << "Exiv2 exception in print action for file " std::cerr << "Exiv2 exception in print action for file "
<< path << ":\n" << e << "\n"; << path << ":\n" << e << "\n";
return 1; return 1;
} // Print::run } // Print::run
@ -310,7 +310,7 @@ namespace Action {
} }
std::cout << std::endl; std::cout << std::endl;
// Exposure mode // Exposure mode
// From ExposureProgram or Canon Makernote // From ExposureProgram or Canon Makernote
printLabel("Exposure mode"); printLabel("Exposure mode");
done = false; done = false;
@ -334,13 +334,13 @@ namespace Action {
} }
if (!done) { if (!done) {
done = 0 != printTag(exifData, "Exif.Fujifilm.Macro"); done = 0 != printTag(exifData, "Exif.Fujifilm.Macro");
} }
if (!done) { if (!done) {
done = 0 != printTag(exifData, "Exif.Olympus.Macro"); done = 0 != printTag(exifData, "Exif.Olympus.Macro");
} }
if (!done) { if (!done) {
done = 0 != printTag(exifData, "Exif.Panasonic.Macro"); done = 0 != printTag(exifData, "Exif.Panasonic.Macro");
} }
std::cout << std::endl; std::cout << std::endl;
// Image quality setting (compression) // Image quality setting (compression)
@ -421,10 +421,10 @@ namespace Action {
std::string thumbExt = exifData.thumbnailExtension(); std::string thumbExt = exifData.thumbnailExtension();
if (thumbExt.empty()) { if (thumbExt.empty()) {
std::cout << "None"; std::cout << "None";
} }
else { else {
Exiv2::DataBuf buf = exifData.copyThumbnail(); Exiv2::DataBuf buf = exifData.copyThumbnail();
std::cout << exifData.thumbnailFormat() << ", " std::cout << exifData.thumbnailFormat() << ", "
<< buf.size_ << " Bytes"; << buf.size_ << " Bytes";
} }
std::cout << std::endl; std::cout << std::endl;
@ -485,10 +485,10 @@ namespace Action {
<< md->key() << " " << md->key() << " "
<< std::setw(9) << std::setfill(' ') << std::left << std::setw(9) << std::setfill(' ') << std::left
<< md->typeName() << " " << md->typeName() << " "
<< std::dec << std::setw(3) << std::dec << std::setw(3)
<< std::setfill(' ') << std::right << std::setfill(' ') << std::right
<< md->count() << " " << md->count() << " "
<< std::dec << *md << std::dec << *md
<< std::endl; << std::endl;
} }
@ -515,17 +515,17 @@ namespace Action {
Exiv2::ExifData::const_iterator md; Exiv2::ExifData::const_iterator md;
for (md = exifData.begin(); md != end; ++md) { for (md = exifData.begin(); md != end; ++md) {
std::cout << "0x" << std::setw(4) << std::setfill('0') << std::right std::cout << "0x" << std::setw(4) << std::setfill('0') << std::right
<< std::hex << md->tag() << " " << std::hex << md->tag() << " "
<< std::setw(9) << std::setfill(' ') << std::left << std::setw(9) << std::setfill(' ') << std::left
<< md->ifdName() << " " << md->ifdName() << " "
<< std::setw(27) << std::setfill(' ') << std::left << std::setw(27) << std::setfill(' ') << std::left
<< md->tagName() << " " << md->tagName() << " "
<< std::setw(9) << std::setfill(' ') << std::left << std::setw(9) << std::setfill(' ') << std::left
<< md->typeName() << " " << md->typeName() << " "
<< std::dec << std::setw(3) << std::dec << std::setw(3)
<< std::setfill(' ') << std::right << std::setfill(' ') << std::right
<< md->count() << " " << md->count() << " "
<< std::dec << md->value() << std::dec << md->value()
<< std::endl; << std::endl;
} }
@ -555,12 +555,12 @@ namespace Action {
<< md->key() << " " << md->key() << " "
<< std::setw(9) << std::setfill(' ') << std::left << std::setw(9) << std::setfill(' ') << std::left
<< md->typeName() << " " << md->typeName() << " "
<< std::dec << std::setw(3) << std::dec << std::setw(3)
<< std::setfill(' ') << std::right << std::setfill(' ') << std::right
<< md->count() << " " << md->count() << " "
<< std::dec << md->value() << std::dec << md->value()
<< std::endl; << std::endl;
} }
return 0; return 0;
} // Print::printIptc } // Print::printIptc
@ -586,13 +586,13 @@ namespace Action {
std::cout << std::setw(4) << std::setfill(' ') << std::left std::cout << std::setw(4) << std::setfill(' ') << std::left
<< md->ifdName() << " " << md->ifdName() << " "
<< "0x" << std::setw(4) << std::setfill('0') << std::right << "0x" << std::setw(4) << std::setfill('0') << std::right
<< std::hex << md->tag() << " " << std::hex << md->tag() << " "
<< std::setw(9) << std::setfill(' ') << std::left << std::setw(9) << std::setfill(' ') << std::left
<< md->typeName() << " " << md->typeName() << " "
<< std::dec << std::setw(3) << std::dec << std::setw(3)
<< std::setfill(' ') << std::right << std::setfill(' ') << std::right
<< md->count() << " " << md->count() << " "
<< std::dec << std::setw(3) << std::dec << std::setw(3)
<< std::setfill(' ') << std::right << std::setfill(' ') << std::right
<< md->size() << " " << md->size() << " "
<< std::setw(27) << std::setfill(' ') << std::left << std::setw(27) << std::setfill(' ') << std::left
@ -608,7 +608,7 @@ namespace Action {
int Print::printComment() int Print::printComment()
{ {
if (!Exiv2::fileExists(path_, true)) { if (!Exiv2::fileExists(path_, true)) {
std::cerr << path_ std::cerr << path_
<< ": Failed to open the file\n"; << ": Failed to open the file\n";
return -1; return -1;
} }
@ -657,7 +657,7 @@ namespace Action {
} }
std::string v = md->toString(); std::string v = md->toString();
if (v.length() == 0 || v[0] == ' ') { if (v.length() == 0 || v[0] == ' ') {
std::cerr << "Image file creation timestamp not set in the file " std::cerr << "Image file creation timestamp not set in the file "
<< path << "\n"; << path << "\n";
return 1; return 1;
} }
@ -676,7 +676,7 @@ namespace Action {
<< path << "\n"; << path << "\n";
return 1; return 1;
} }
std::string newPath std::string newPath
= Util::dirname(path) + EXV_SEPERATOR_STR + basename + Util::suffix(path); = Util::dirname(path) + EXV_SEPERATOR_STR + basename + Util::suffix(path);
if ( Util::dirname(newPath) == Util::dirname(path) if ( Util::dirname(newPath) == Util::dirname(path)
&& Util::basename(newPath) == Util::basename(path)) { && Util::basename(newPath) == Util::basename(path)) {
@ -689,7 +689,7 @@ namespace Action {
bool go = true; bool go = true;
int seq = 1; int seq = 1;
std::string s; std::string s;
Params::FileExistsPolicy fileExistsPolicy Params::FileExistsPolicy fileExistsPolicy
= Params::instance().fileExistsPolicy_; = Params::instance().fileExistsPolicy_;
while (go) { while (go) {
if (Exiv2::fileExists(newPath)) { if (Exiv2::fileExists(newPath)) {
@ -698,14 +698,14 @@ namespace Action {
go = false; go = false;
break; break;
case Params::renamePolicy: case Params::renamePolicy:
newPath = Util::dirname(path) newPath = Util::dirname(path)
+ EXV_SEPERATOR_STR + basename + EXV_SEPERATOR_STR + basename
+ "_" + Exiv2::toString(seq++) + "_" + Exiv2::toString(seq++)
+ Util::suffix(path); + Util::suffix(path);
break; break;
case Params::askPolicy: case Params::askPolicy:
std::cout << Params::instance().progname() std::cout << Params::instance().progname()
<< ": File `" << newPath << ": File `" << newPath
<< "' exists. [O]verwrite, [r]ename or [s]kip? "; << "' exists. [O]verwrite, [r]ename or [s]kip? ";
std::cin >> s; std::cin >> s;
switch (s[0]) { switch (s[0]) {
@ -715,9 +715,9 @@ namespace Action {
break; break;
case 'r': case 'r':
case 'R': case 'R':
fileExistsPolicy = Params::renamePolicy; fileExistsPolicy = Params::renamePolicy;
newPath = Util::dirname(path) newPath = Util::dirname(path)
+ EXV_SEPERATOR_STR + basename + EXV_SEPERATOR_STR + basename
+ "_" + Exiv2::toString(seq++) + "_" + Exiv2::toString(seq++)
+ Util::suffix(path); + Util::suffix(path);
break; break;
@ -812,7 +812,7 @@ namespace Action {
} }
long delta = exifData.eraseThumbnail(); long delta = exifData.eraseThumbnail();
if (Params::instance().verbose_) { if (Params::instance().verbose_) {
std::cout << "Erasing " << delta std::cout << "Erasing " << delta
<< " Bytes of thumbnail data" << std::endl; << " Bytes of thumbnail data" << std::endl;
} }
return 0; return 0;
@ -821,7 +821,7 @@ namespace Action {
int Erase::eraseExifData(Exiv2::Image* image) const int Erase::eraseExifData(Exiv2::Image* image) const
{ {
if (Params::instance().verbose_ && image->exifData().count() > 0) { if (Params::instance().verbose_ && image->exifData().count() > 0) {
std::cout << "Erasing Exif data from the file" << std::endl; std::cout << "Erasing Exif data from the file" << std::endl;
} }
image->clearExifData(); image->clearExifData();
return 0; return 0;
@ -830,7 +830,7 @@ namespace Action {
int Erase::eraseIptcData(Exiv2::Image* image) const int Erase::eraseIptcData(Exiv2::Image* image) const
{ {
if (Params::instance().verbose_ && image->iptcData().count() > 0) { if (Params::instance().verbose_ && image->iptcData().count() > 0) {
std::cout << "Erasing Iptc data from the file" << std::endl; std::cout << "Erasing Iptc data from the file" << std::endl;
} }
image->clearIptcData(); image->clearIptcData();
return 0; return 0;
@ -839,7 +839,7 @@ namespace Action {
int Erase::eraseComment(Exiv2::Image* image) const int Erase::eraseComment(Exiv2::Image* image) const
{ {
if (Params::instance().verbose_ && image->comment().size() > 0) { if (Params::instance().verbose_ && image->comment().size() > 0) {
std::cout << "Erasing Jpeg comment from the file" << std::endl; std::cout << "Erasing Jpeg comment from the file" << std::endl;
} }
image->clearComment(); image->clearComment();
return 0; return 0;
@ -860,7 +860,7 @@ namespace Action {
path_ = path; path_ = path;
int rc = 0; int rc = 0;
if (Params::instance().target_ & Params::ctThumb) { if (Params::instance().target_ & Params::ctThumb) {
rc = writeThumbnail(); rc = writeThumbnail();
} }
if (Params::instance().target_ & ~Params::ctThumb) { if (Params::instance().target_ & ~Params::ctThumb) {
std::string directory = Params::instance().directory_; std::string directory = Params::instance().directory_;
@ -868,7 +868,7 @@ namespace Action {
std::string exvPath = directory + EXV_SEPERATOR_STR std::string exvPath = directory + EXV_SEPERATOR_STR
+ Util::basename(path_, true) + ".exv"; + Util::basename(path_, true) + ".exv";
if (!Params::instance().force_ && Exiv2::fileExists(exvPath)) { if (!Params::instance().force_ && Exiv2::fileExists(exvPath)) {
std::cout << Params::instance().progname() std::cout << Params::instance().progname()
<< ": Overwrite `" << exvPath << "'? "; << ": Overwrite `" << exvPath << "'? ";
std::string s; std::string s;
std::cin >> s; std::cin >> s;
@ -909,18 +909,18 @@ namespace Action {
std::string thumbExt = exifData.thumbnailExtension(); std::string thumbExt = exifData.thumbnailExtension();
int rc = 0; int rc = 0;
if (thumbExt.empty()) { if (thumbExt.empty()) {
std::cerr << path_ << ": Image does not contain an Exif thumbnail\n"; std::cerr << path_ << ": Image does not contain an Exif thumbnail\n";
} }
else { else {
if (Params::instance().verbose_) { if (Params::instance().verbose_) {
Exiv2::DataBuf buf = exifData.copyThumbnail(); Exiv2::DataBuf buf = exifData.copyThumbnail();
std::cout << "Writing " std::cout << "Writing "
<< exifData.thumbnailFormat() << " thumbnail (" << exifData.thumbnailFormat() << " thumbnail ("
<< buf.size_ << " Bytes) to file " << buf.size_ << " Bytes) to file "
<< thumb << thumbExt << std::endl; << thumb << thumbExt << std::endl;
} }
if (!Params::instance().force_ && Exiv2::fileExists(thumb + thumbExt)) { if (!Params::instance().force_ && Exiv2::fileExists(thumb + thumbExt)) {
std::cout << Params::instance().progname() std::cout << Params::instance().progname()
<< ": Overwrite `" << thumb + thumbExt << "'? "; << ": Overwrite `" << thumb + thumbExt << "'? ";
std::string s; std::string s;
std::cin >> s; std::cin >> s;
@ -998,7 +998,7 @@ namespace Action {
Exiv2::ExifData &exifData = image->exifData(); Exiv2::ExifData &exifData = image->exifData();
exifData.setJpegThumbnail(thumbPath); exifData.setJpegThumbnail(thumbPath);
image->writeMetadata(); image->writeMetadata();
return 0; return 0;
} // Insert::insertThumbnail } // Insert::insertThumbnail
@ -1060,9 +1060,9 @@ namespace Action {
{ {
if (Params::instance().verbose_) { if (Params::instance().verbose_) {
std::cout << "Add " << modifyCmd.key_ << " \"" std::cout << "Add " << modifyCmd.key_ << " \""
<< modifyCmd.value_ << "\" (" << modifyCmd.value_ << "\" ("
<< Exiv2::TypeInfo::typeName(modifyCmd.typeId_) << Exiv2::TypeInfo::typeName(modifyCmd.typeId_)
<< ")" << std::endl; << ")" << std::endl;
} }
Exiv2::Value::AutoPtr value = Exiv2::Value::create(modifyCmd.typeId_); Exiv2::Value::AutoPtr value = Exiv2::Value::create(modifyCmd.typeId_);
value->read(modifyCmd.value_); value->read(modifyCmd.value_);
@ -1078,9 +1078,9 @@ namespace Action {
{ {
if (Params::instance().verbose_) { if (Params::instance().verbose_) {
std::cout << "Set " << modifyCmd.key_ << " \"" std::cout << "Set " << modifyCmd.key_ << " \""
<< modifyCmd.value_ << "\" (" << modifyCmd.value_ << "\" ("
<< Exiv2::TypeInfo::typeName(modifyCmd.typeId_) << Exiv2::TypeInfo::typeName(modifyCmd.typeId_)
<< ")" << std::endl; << ")" << std::endl;
} }
Exiv2::ExifData &exifData = image_->exifData(); Exiv2::ExifData &exifData = image_->exifData();
@ -1107,7 +1107,7 @@ namespace Action {
void Modify::delMetadatum(const ModifyCmd& modifyCmd) void Modify::delMetadatum(const ModifyCmd& modifyCmd)
{ {
if (Params::instance().verbose_) { if (Params::instance().verbose_) {
std::cout << "Del " << modifyCmd.key_ << std::endl; std::cout << "Del " << modifyCmd.key_ << std::endl;
} }
Exiv2::ExifData &exifData = image_->exifData(); Exiv2::ExifData &exifData = image_->exifData();
@ -1177,7 +1177,7 @@ namespace Action {
} }
int Adjust::adjustDateTime(Exiv2::ExifData& exifData, int Adjust::adjustDateTime(Exiv2::ExifData& exifData,
const std::string& key, const std::string& key,
const std::string& path) const const std::string& path) const
{ {
Exiv2::ExifKey ek(key); Exiv2::ExifKey ek(key);
@ -1188,18 +1188,18 @@ namespace Action {
} }
std::string timeStr = md->toString(); std::string timeStr = md->toString();
if (timeStr == "" || timeStr[0] == ' ') { if (timeStr == "" || timeStr[0] == ' ') {
std::cerr << path << ": Timestamp of metadatum with key `" std::cerr << path << ": Timestamp of metadatum with key `"
<< ek << "' not set\n"; << ek << "' not set\n";
return 1; return 1;
} }
time_t time = str2Time(timeStr); time_t time = str2Time(timeStr);
if (time == (time_t)-1) { if (time == (time_t)-1) {
std::cerr << path << ": Failed to parse or convert timestamp `" std::cerr << path << ": Failed to parse or convert timestamp `"
<< timeStr << "'\n"; << timeStr << "'\n";
return 1; return 1;
} }
if (Params::instance().verbose_) { if (Params::instance().verbose_) {
std::cout << "Adjusting `" << ek << "' by" std::cout << "Adjusting `" << ek << "' by"
<< (adjustment_ < 0 ? " " : " +") << (adjustment_ < 0 ? " " : " +")
<< adjustment_ << " s to "; << adjustment_ << " s to ";
} }
@ -1258,7 +1258,7 @@ namespace {
if (0 == tm) return ""; if (0 == tm) return "";
std::ostringstream os; std::ostringstream os;
os << std::setfill('0') os << std::setfill('0')
<< tm->tm_year + 1900 << ":" << tm->tm_year + 1900 << ":"
<< std::setw(2) << tm->tm_mon + 1 << ":" << std::setw(2) << tm->tm_mon + 1 << ":"
<< std::setw(2) << tm->tm_mday << " " << std::setw(2) << tm->tm_mday << " "
@ -1269,9 +1269,9 @@ namespace {
return os.str(); return os.str();
} // time2Str } // time2Str
int metacopy(const std::string& source, int metacopy(const std::string& source,
const std::string& target, const std::string& target,
bool preserve) bool preserve)
{ {
if (!Exiv2::fileExists(source, true)) { if (!Exiv2::fileExists(source, true)) {
std::cerr << source std::cerr << source
@ -1289,14 +1289,14 @@ namespace {
if (preserve) targetImage->readMetadata(); if (preserve) targetImage->readMetadata();
} }
else { else {
targetImage targetImage
= Exiv2::ImageFactory::create(Exiv2::ImageType::exv, target); = Exiv2::ImageFactory::create(Exiv2::ImageType::exv, target);
assert(targetImage.get() != 0); assert(targetImage.get() != 0);
} }
if ( Params::instance().target_ & Params::ctExif if ( Params::instance().target_ & Params::ctExif
&& !sourceImage->exifData().empty()) { && !sourceImage->exifData().empty()) {
if (Params::instance().verbose_) { if (Params::instance().verbose_) {
std::cout << "Writing Exif data from " << source std::cout << "Writing Exif data from " << source
<< " to " << target << std::endl; << " to " << target << std::endl;
} }
targetImage->setExifData(sourceImage->exifData()); targetImage->setExifData(sourceImage->exifData());
@ -1304,7 +1304,7 @@ namespace {
if ( Params::instance().target_ & Params::ctIptc if ( Params::instance().target_ & Params::ctIptc
&& !sourceImage->iptcData().empty()) { && !sourceImage->iptcData().empty()) {
if (Params::instance().verbose_) { if (Params::instance().verbose_) {
std::cout << "Writing Iptc data from " << source std::cout << "Writing Iptc data from " << source
<< " to " << target << std::endl; << " to " << target << std::endl;
} }
targetImage->setIptcData(sourceImage->iptcData()); targetImage->setIptcData(sourceImage->iptcData());
@ -1312,7 +1312,7 @@ namespace {
if ( Params::instance().target_ & Params::ctComment if ( Params::instance().target_ & Params::ctComment
&& !sourceImage->comment().empty()) { && !sourceImage->comment().empty()) {
if (Params::instance().verbose_) { if (Params::instance().verbose_) {
std::cout << "Writing Jpeg comment from " << source std::cout << "Writing Jpeg comment from " << source
<< " to " << target << std::endl; << " to " << target << std::endl;
} }
targetImage->setComment(sourceImage->comment()); targetImage->setComment(sourceImage->comment());

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -161,10 +161,10 @@ namespace Action {
//! Print the Jpeg comment //! Print the Jpeg comment
int printComment(); int printComment();
//! Print uninterpreted Iptc information //! Print uninterpreted Iptc information
int printIptc(); int printIptc();
//! Print Exif summary information //! Print Exif summary information
int printSummary(); int printSummary();
//! Print the interpreted value for each Exif tag //! Print the interpreted value for each Exif tag
int printInterpreted(); int printInterpreted();
//! Print uninterpreted Exif information //! Print uninterpreted Exif information
@ -179,7 +179,7 @@ namespace Action {
@return 1 if a line was written, 0 if the key was not found. @return 1 if a line was written, 0 if the key was not found.
*/ */
int printTag(const Exiv2::ExifData& exifData, int printTag(const Exiv2::ExifData& exifData,
const std::string& key, const std::string& key,
const std::string& label ="") const; const std::string& label ="") const;
private: private:
@ -190,7 +190,7 @@ namespace Action {
}; // class Print }; // class Print
/*! /*!
@brief %Rename a file to its metadate creation timestamp, @brief %Rename a file to its metadate creation timestamp,
in the specified format. in the specified format.
*/ */
class Rename : public Task { class Rename : public Task {
@ -215,7 +215,7 @@ namespace Action {
private: private:
virtual Adjust* clone_() const; virtual Adjust* clone_() const;
int adjustDateTime(Exiv2::ExifData& exifData, int adjustDateTime(Exiv2::ExifData& exifData,
const std::string& key, const std::string& key,
const std::string& path) const; const std::string& path) const;
long adjustment_; long adjustment_;
@ -232,9 +232,9 @@ namespace Action {
AutoPtr clone() const; AutoPtr clone() const;
/*! /*!
@brief Delete the thumbnail image, incl IFD1 metadata from the file. @brief Delete the thumbnail image, incl IFD1 metadata from the file.
*/ */
int eraseThumbnail(Exiv2::Image* image) const; int eraseThumbnail(Exiv2::Image* image) const;
/*! /*!
@brief Erase the complete Exif data block from the file. @brief Erase the complete Exif data block from the file.
*/ */
@ -270,7 +270,7 @@ namespace Action {
"-thumb" and the appropriate suffix (".jpg" or ".tif"), depending "-thumb" and the appropriate suffix (".jpg" or ".tif"), depending
on the format of the Exif thumbnail image. on the format of the Exif thumbnail image.
*/ */
int writeThumbnail() const; int writeThumbnail() const;
private: private:
virtual Extract* clone_() const; virtual Extract* clone_() const;
@ -301,7 +301,7 @@ namespace Action {
}; // class Insert }; // class Insert
/*! /*!
@brief %Modify the Exif data according to the commands in the @brief %Modify the Exif data according to the commands in the
modification table. modification table.
*/ */
class Modify : public Task { class Modify : public Task {
@ -310,23 +310,23 @@ namespace Action {
virtual int run(const std::string& path); virtual int run(const std::string& path);
typedef std::auto_ptr<Modify> AutoPtr; typedef std::auto_ptr<Modify> AutoPtr;
AutoPtr clone() const; AutoPtr clone() const;
Modify() {} Modify() {}
private: private:
virtual Modify* clone_() const; virtual Modify* clone_() const;
//! Copy contructor needed because of AutoPtr member //! Copy contructor needed because of AutoPtr member
Modify(const Modify& /*src*/) {} Modify(const Modify& /*src*/) {}
//! Add a metadatum according to \em modifyCmd //! Add a metadatum according to \em modifyCmd
void addMetadatum(const ModifyCmd& modifyCmd); void addMetadatum(const ModifyCmd& modifyCmd);
//! Set a metadatum according to \em modifyCmd //! Set a metadatum according to \em modifyCmd
void setMetadatum(const ModifyCmd& modifyCmd); void setMetadatum(const ModifyCmd& modifyCmd);
//! Delete a metadatum according to \em modifyCmd //! Delete a metadatum according to \em modifyCmd
void delMetadatum(const ModifyCmd& modifyCmd); void delMetadatum(const ModifyCmd& modifyCmd);
Exiv2::Image::AutoPtr image_; //!< Image to modify Exiv2::Image::AutoPtr image_; //!< Image to modify
}; // class Modify }; // class Modify
} // namespace Action } // namespace Action
#endif // #ifndef ACTIONS_HPP_ #endif // #ifndef ACTIONS_HPP_

@ -25,7 +25,7 @@ try {
// Add to the Exif data // Add to the Exif data
// This is the quickest way to add (simple) Exif data. If a metadatum for // This is the quickest way to add (simple) Exif data. If a metadatum for
// a given key already exists, its value is overwritten. Otherwise a new // a given key already exists, its value is overwritten. Otherwise a new
// tag is added. // tag is added.
exifData["Exif.Image.Model"] = "Test 1"; // AsciiValue exifData["Exif.Image.Model"] = "Test 1"; // AsciiValue
exifData["Exif.Image.SamplesPerPixel"] = uint16_t(162); // UShortValue exifData["Exif.Image.SamplesPerPixel"] = uint16_t(162); // UShortValue
@ -46,7 +46,7 @@ try {
Exiv2::URationalValue::AutoPtr rv(new Exiv2::URationalValue); Exiv2::URationalValue::AutoPtr rv(new Exiv2::URationalValue);
// Set two rational components from a string // Set two rational components from a string
rv->read("1/2 1/3"); rv->read("1/2 1/3");
// Add more elements through the extended interface of rational value // Add more elements through the extended interface of rational value
rv->value_.push_back(std::make_pair(2,3)); rv->value_.push_back(std::make_pair(2,3));
rv->value_.push_back(std::make_pair(3,4)); rv->value_.push_back(std::make_pair(3,4));
// Add the key and value pair to the Exif data // Add the key and value pair to the Exif data
@ -63,7 +63,7 @@ try {
std::string date = tag.toString(); std::string date = tag.toString();
date.replace(0, 4, "2000"); date.replace(0, 4, "2000");
tag.setValue(date); tag.setValue(date);
std::cout << "Modified key \"" << key std::cout << "Modified key \"" << key
<< "\", new value \"" << tag.value() << "\"\n"; << "\", new value \"" << tag.value() << "\"\n";
// Alternatively, we can use findKey() // Alternatively, we can use findKey()
@ -80,7 +80,7 @@ try {
rv->value_[2] = std::make_pair(88,77); rv->value_[2] = std::make_pair(88,77);
// Copy the modified value back to the metadatum // Copy the modified value back to the metadatum
pos->setValue(rv.get()); pos->setValue(rv.get());
std::cout << "Modified key \"" << key std::cout << "Modified key \"" << key
<< "\", new value \"" << pos->value() << "\"\n"; << "\", new value \"" << pos->value() << "\"\n";
// ************************************************************************* // *************************************************************************

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -63,11 +63,11 @@ EXIV2_RCSID("@(#) $Id$");
// class member definitions // class member definitions
namespace Exiv2 { namespace Exiv2 {
FileIo::FileIo(const std::string& path) FileIo::FileIo(const std::string& path)
: path_(path), fp_(0), opMode_(opSeek) : path_(path), fp_(0), opMode_(opSeek)
{ {
} }
FileIo::~FileIo() FileIo::~FileIo()
{ {
close(); close();
@ -76,10 +76,10 @@ namespace Exiv2 {
BasicIo::AutoPtr FileIo::temporary() const BasicIo::AutoPtr FileIo::temporary() const
{ {
BasicIo::AutoPtr basicIo; BasicIo::AutoPtr basicIo;
struct stat buf; struct stat buf;
int ret = stat(path_.c_str(), &buf); int ret = stat(path_.c_str(), &buf);
// If file is > 1MB then use a file, otherwise use memory buffer // If file is > 1MB then use a file, otherwise use memory buffer
if (ret != 0 || buf.st_size > 1048576) { if (ret != 0 || buf.st_size > 1048576) {
pid_t pid = getpid(); pid_t pid = getpid();
@ -111,13 +111,13 @@ namespace Exiv2 {
case opRead: case opRead:
// Flush if current mode allows reading, else reopen (in mode "r+b" // Flush if current mode allows reading, else reopen (in mode "r+b"
// as in this case we know that we can write to the file) // as in this case we know that we can write to the file)
if ( openMode_[0] == 'r' if ( openMode_[0] == 'r'
|| openMode_.substr(0, 2) == "w+" || openMode_.substr(0, 2) == "w+"
|| openMode_.substr(0, 2) == "a+") reopen = false; || openMode_.substr(0, 2) == "a+") reopen = false;
break; break;
case opWrite: case opWrite:
// Flush if current mode allows writing, else reopen // Flush if current mode allows writing, else reopen
if ( openMode_.substr(0, 2) == "r+" if ( openMode_.substr(0, 2) == "r+"
|| openMode_[0] == 'w' || openMode_[0] == 'w'
|| openMode_[0] == 'a') reopen = false; || openMode_[0] == 'a') reopen = false;
break; break;
@ -177,7 +177,7 @@ namespace Exiv2 {
{ {
const bool wasOpen = (fp_ != 0); const bool wasOpen = (fp_ != 0);
const std::string lastMode(openMode_); const std::string lastMode(openMode_);
FileIo *fileIo = dynamic_cast<FileIo*>(&src); FileIo *fileIo = dynamic_cast<FileIo*>(&src);
if (fileIo) { if (fileIo) {
// Optimization if this is another instance of FileIo // Optimization if this is another instance of FileIo
@ -220,7 +220,7 @@ namespace Exiv2 {
if (switchMode(opWrite) != 0) return EOF; if (switchMode(opWrite) != 0) return EOF;
return putc(data, fp_); return putc(data, fp_);
} }
int FileIo::seek(long offset, Position pos) int FileIo::seek(long offset, Position pos)
{ {
assert(fp_ != 0); assert(fp_ != 0);
@ -255,9 +255,9 @@ namespace Exiv2 {
struct stat buf; struct stat buf;
int ret = stat(path_.c_str(), &buf); int ret = stat(path_.c_str(), &buf);
if (ret != 0) return -1; if (ret != 0) return -1;
return buf.st_size; return buf.st_size;
} }
int FileIo::open() int FileIo::open()
@ -283,7 +283,7 @@ namespace Exiv2 {
{ {
return fp_ != 0; return fp_ != 0;
} }
int FileIo::close() int FileIo::close()
{ {
if (fp_ != 0) { if (fp_ != 0) {
@ -292,7 +292,7 @@ namespace Exiv2 {
} }
return 0; return 0;
} }
DataBuf FileIo::read(long rcount) DataBuf FileIo::read(long rcount)
{ {
assert(fp_ != 0); assert(fp_ != 0);
@ -320,7 +320,7 @@ namespace Exiv2 {
{ {
return fp_ != 0 ? ferror(fp_) : 0; return fp_ != 0 ? ferror(fp_) : 0;
} }
bool FileIo::eof() const bool FileIo::eof() const
{ {
assert(fp_ != 0); assert(fp_ != 0);
@ -332,11 +332,11 @@ namespace Exiv2 {
return path_; return path_;
} }
MemIo::MemIo() MemIo::MemIo()
: data_(0), : data_(0),
idx_(0), idx_(0),
size_(0), size_(0),
sizeAlloced_(0), sizeAlloced_(0),
isMalloced_(false) isMalloced_(false)
{ {
} }
@ -350,10 +350,10 @@ namespace Exiv2 {
{ {
} }
MemIo::~MemIo() MemIo::~MemIo()
{ {
if (isMalloced_) { if (isMalloced_) {
std::free(data_); std::free(data_);
} }
} }
@ -361,14 +361,14 @@ namespace Exiv2 {
{ {
return BasicIo::AutoPtr(new MemIo); return BasicIo::AutoPtr(new MemIo);
} }
void MemIo::checkSize(long wcount) void MemIo::checkSize(long wcount)
{ {
long need = wcount + idx_; long need = wcount + idx_;
if (need > size_) { if (need > size_) {
if (need > sizeAlloced_) { if (need > sizeAlloced_) {
// Allocate in blocks of 32kB // Allocate in blocks of 32kB
long want = 32768 * (1 + need / 32768); long want = 32768 * (1 + need / 32768);
if (size_ > 0) { if (size_ > 0) {
if (!isMalloced_) { if (!isMalloced_) {
// "copy-on-expand" // "copy-on-expand"
@ -422,7 +422,7 @@ namespace Exiv2 {
} }
idx_ = 0; idx_ = 0;
write(src); write(src);
src.close(); src.close();
} }
if (error() || src.error()) throw Error(19, strError()); if (error() || src.error()) throw Error(19, strError());
} }
@ -431,7 +431,7 @@ namespace Exiv2 {
{ {
if (static_cast<BasicIo*>(this) == &src) return 0; if (static_cast<BasicIo*>(this) == &src) return 0;
if (!src.isopen()) return 0; if (!src.isopen()) return 0;
byte buf[4096]; byte buf[4096];
long readCount = 0; long readCount = 0;
long writeTotal = 0; long writeTotal = 0;
@ -449,11 +449,11 @@ namespace Exiv2 {
data_[idx_++] = data; data_[idx_++] = data;
return data; return data;
} }
int MemIo::seek(long offset, Position pos) int MemIo::seek(long offset, Position pos)
{ {
long newIdx = 0; long newIdx = 0;
switch (pos) { switch (pos) {
case BasicIo::cur: newIdx = idx_ + offset; break; case BasicIo::cur: newIdx = idx_ + offset; break;
case BasicIo::beg: newIdx = offset; break; case BasicIo::beg: newIdx = offset; break;
@ -474,7 +474,7 @@ namespace Exiv2 {
{ {
return size_; return size_;
} }
int MemIo::open() int MemIo::open()
{ {
idx_ = 0; idx_ = 0;
@ -485,12 +485,12 @@ namespace Exiv2 {
{ {
return true; return true;
} }
int MemIo::close() int MemIo::close()
{ {
return 0; return 0;
} }
DataBuf MemIo::read(long rcount) DataBuf MemIo::read(long rcount)
{ {
DataBuf buf(rcount); DataBuf buf(rcount);
@ -519,7 +519,7 @@ namespace Exiv2 {
{ {
return 0; return 0;
} }
bool MemIo::eof() const bool MemIo::eof() const
{ {
return idx_ == size_; return idx_ == size_;

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -22,7 +22,7 @@
@file basicio.hpp @file basicio.hpp
@brief Simple binary IO abstraction @brief Simple binary IO abstraction
@version $Rev$ @version $Rev$
@author Brad Schick (brad) @author Brad Schick (brad)
<a href="mailto:brad@robotbattle.com">brad@robotbattle.com</a> <a href="mailto:brad@robotbattle.com">brad@robotbattle.com</a>
@date 04-Dec-04, brad: created @date 04-Dec-04, brad: created
*/ */
@ -60,7 +60,7 @@ namespace Exiv2 {
//! Seek starting positions //! Seek starting positions
enum Position { beg, cur, end }; enum Position { beg, cur, end };
//! @name Creators //! @name Creators
//@{ //@{
//! Destructor //! Destructor
@ -71,13 +71,13 @@ namespace Exiv2 {
//@{ //@{
/*! /*!
@brief Open the IO source using the default access mode. The @brief Open the IO source using the default access mode. The
default mode should allow for reading and writing. default mode should allow for reading and writing.
This method can also be used to "reopen" an IO source which will This method can also be used to "reopen" an IO source which will
flush any unwritten data and reset the IO position to the start. flush any unwritten data and reset the IO position to the start.
Subclasses may provide custom methods to allow for Subclasses may provide custom methods to allow for
opening IO sources differently. opening IO sources differently.
@return 0 if successful;<BR> @return 0 if successful;<BR>
Nonzero if failure. Nonzero if failure.
*/ */
@ -93,7 +93,7 @@ namespace Exiv2 {
/*! /*!
@brief Write data to the IO source. Current IO position is advanced @brief Write data to the IO source. Current IO position is advanced
by the number of bytes written. by the number of bytes written.
@param data Pointer to data. Data must be at least \em wcount @param data Pointer to data. Data must be at least \em wcount
bytes long bytes long
@param wcount Number of bytes to be written. @param wcount Number of bytes to be written.
@return Number of bytes written to IO source successfully;<BR> @return Number of bytes written to IO source successfully;<BR>
@ -151,12 +151,12 @@ namespace Exiv2 {
virtual int getb() = 0; virtual int getb() = 0;
/*! /*!
@brief Remove all data from this object's IO source and then transfer @brief Remove all data from this object's IO source and then transfer
data from the \em src BasicIo object into this object. data from the \em src BasicIo object into this object.
The source object is invalidated by this operation and should not be The source object is invalidated by this operation and should not be
used after this method returns. This method exists primarily to used after this method returns. This method exists primarily to
be used with the BasicIo::temporary() method. be used with the BasicIo::temporary() method.
@param src Reference to another BasicIo instance. The entire contents @param src Reference to another BasicIo instance. The entire contents
of src are transferred to this object. The \em src object is of src are transferred to this object. The \em src object is
invalidated by the method. invalidated by the method.
@ -164,7 +164,7 @@ namespace Exiv2 {
*/ */
virtual void transfer(BasicIo& src) = 0; virtual void transfer(BasicIo& src) = 0;
/*! /*!
@brief Move the current IO position. @brief Move the current IO position.
@param offset Number of bytes to move the position relative @param offset Number of bytes to move the position relative
to the starting position specified by \em pos to the starting position specified by \em pos
@param pos Position from which the seek should start @param pos Position from which the seek should start
@ -177,7 +177,7 @@ namespace Exiv2 {
//! @name Accessors //! @name Accessors
//@{ //@{
/*! /*!
@brief Get the current IO position. @brief Get the current IO position.
@return Offset from the start of IO if successful;<BR> @return Offset from the start of IO if successful;<BR>
-1 if failure; -1 if failure;
*/ */
@ -202,14 +202,14 @@ namespace Exiv2 {
virtual std::string path() const =0; virtual std::string path() const =0;
/*! /*!
@brief Returns a temporary data storage location. This is often @brief Returns a temporary data storage location. This is often
needed to rewrite an IO source. needed to rewrite an IO source.
For example, data may be read from the original IO source, modified For example, data may be read from the original IO source, modified
in some way, and then saved to the temporary instance. After the in some way, and then saved to the temporary instance. After the
operation is complete, the BasicIo::transfer method can be used to operation is complete, the BasicIo::transfer method can be used to
replace the original IO source with the modified version. Subclasses replace the original IO source with the modified version. Subclasses
are free to return any class that derives from BasicIo. are free to return any class that derives from BasicIo.
@return An instance of BasicIo on success @return An instance of BasicIo on success
@throw Error In case of failure @throw Error In case of failure
*/ */
@ -234,7 +234,7 @@ namespace Exiv2 {
public: public:
//! @name Creators //! @name Creators
//@{ //@{
//! Constructor, takes a BasicIo reference //! Constructor, takes a BasicIo reference
IoCloser(BasicIo &bio) : bio_(bio) {} IoCloser(BasicIo &bio) : bio_(bio) {}
//! Destructor, closes the BasicIo reference //! Destructor, closes the BasicIo reference
~IoCloser() { close(); } ~IoCloser() { close(); }
@ -248,7 +248,7 @@ namespace Exiv2 {
// DATA // DATA
//! The BasicIo reference //! The BasicIo reference
BasicIo &bio_; BasicIo &bio_;
private: private:
// Not implemented // Not implemented
//! Copy constructor //! Copy constructor
@ -287,7 +287,7 @@ namespace Exiv2 {
unwritten data and reset the IO position to the start. Although unwritten data and reset the IO position to the start. Although
files can be opened in binary or text mode, this class has files can be opened in binary or text mode, this class has
only been tested carefully in binary mode. only been tested carefully in binary mode.
@param mode Specified that type of access allowed on the file. @param mode Specified that type of access allowed on the file.
Valid values match those of the C fopen command exactly. Valid values match those of the C fopen command exactly.
@return 0 if successful;<BR> @return 0 if successful;<BR>
@ -300,7 +300,7 @@ namespace Exiv2 {
any unwritten data and reset the IO position to the start. any unwritten data and reset the IO position to the start.
@return 0 if successful;<BR> @return 0 if successful;<BR>
Nonzero if failure. Nonzero if failure.
*/ */
virtual int open(); virtual int open();
/*! /*!
@brief Flush and unwritten data and close the file . It is @brief Flush and unwritten data and close the file . It is
@ -312,7 +312,7 @@ namespace Exiv2 {
/*! /*!
@brief Write data to the file. The file position is advanced @brief Write data to the file. The file position is advanced
by the number of bytes written. by the number of bytes written.
@param data Pointer to data. Data must be at least \em wcount @param data Pointer to data. Data must be at least \em wcount
bytes long bytes long
@param wcount Number of bytes to be written. @param wcount Number of bytes to be written.
@return Number of bytes written to the file successfully;<BR> @return Number of bytes written to the file successfully;<BR>
@ -377,7 +377,7 @@ namespace Exiv2 {
is invalidated by this operation and should not be used after this is invalidated by this operation and should not be used after this
method returns. This method exists primarily to be used with method returns. This method exists primarily to be used with
the BasicIo::temporary() method. the BasicIo::temporary() method.
@param src Reference to another BasicIo instance. The entire contents @param src Reference to another BasicIo instance. The entire contents
of src are transferred to this object. The \em src object is of src are transferred to this object. The \em src object is
invalidated by the method. invalidated by the method.
@ -385,7 +385,7 @@ namespace Exiv2 {
*/ */
virtual void transfer(BasicIo& src); virtual void transfer(BasicIo& src);
/*! /*!
@brief Move the current file position. @brief Move the current file position.
@param offset Number of bytes to move the file position @param offset Number of bytes to move the file position
relative to the starting position specified by \em pos relative to the starting position specified by \em pos
@param pos Position from which the seek should start @param pos Position from which the seek should start
@ -398,14 +398,14 @@ namespace Exiv2 {
//! @name Accessors //! @name Accessors
//@{ //@{
/*! /*!
@brief Get the current file position. @brief Get the current file position.
@return Offset from the start of the file if successful;<BR> @return Offset from the start of the file if successful;<BR>
-1 if failure; -1 if failure;
*/ */
virtual long tell() const; virtual long tell() const;
/*! /*!
@brief Flush any buffered writes and get the current file size @brief Flush any buffered writes and get the current file size
in bytes. in bytes.
@return Size of the file in bytes;<BR> @return Size of the file in bytes;<BR>
-1 if failure; -1 if failure;
*/ */
@ -429,7 +429,7 @@ namespace Exiv2 {
*/ */
virtual BasicIo::AutoPtr temporary() const; virtual BasicIo::AutoPtr temporary() const;
//@} //@}
private: private:
// NOT IMPLEMENTED // NOT IMPLEMENTED
//! Copy constructor //! Copy constructor
@ -450,7 +450,7 @@ namespace Exiv2 {
/*! /*!
@brief Switch to a new access mode, reopening the file if needed. @brief Switch to a new access mode, reopening the file if needed.
Optimized to only reopen the file when it is really necessary. Optimized to only reopen the file when it is really necessary.
@param opMode The mode to switch to. @param opMode The mode to switch to.
@return 0 if successful @return 0 if successful
*/ */
int switchMode(OpMode opMode); int switchMode(OpMode opMode);
@ -463,7 +463,7 @@ namespace Exiv2 {
any data passed to its constructors. If writes are performed, the any data passed to its constructors. If writes are performed, the
changed data can be retrieved using the read methods (since the changed data can be retrieved using the read methods (since the
data used in construction is never modified). data used in construction is never modified).
@note If read only usage of this class is common, it might be worth @note If read only usage of this class is common, it might be worth
creating a specialized readonly class or changing this one to creating a specialized readonly class or changing this one to
have a readonly mode. have a readonly mode.
@ -478,7 +478,7 @@ namespace Exiv2 {
/*! /*!
@brief Constructor that accepts a block of memory to be copied. @brief Constructor that accepts a block of memory to be copied.
IO operations are performed on the copied memory. IO operations are performed on the copied memory.
@param data Pointer to data. Data must be at least \em size @param data Pointer to data. Data must be at least \em size
bytes long bytes long
@param size Number of bytes to copy. @param size Number of bytes to copy.
*/ */
@ -494,18 +494,18 @@ namespace Exiv2 {
therefore only resets the IO position to the start. therefore only resets the IO position to the start.
@return 0 @return 0
*/ */
virtual int open(); virtual int open();
/*! /*!
@brief Does nothing on MemIo objects. @brief Does nothing on MemIo objects.
@return 0 @return 0
*/ */
virtual int close(); virtual int close();
/*! /*!
@brief Write data to the memory block. If needed, the size of the @brief Write data to the memory block. If needed, the size of the
internal memory block is expanded. The IO position is advanced internal memory block is expanded. The IO position is advanced
by the number of bytes written. by the number of bytes written.
@param data Pointer to data. Data must be at least \em wcount @param data Pointer to data. Data must be at least \em wcount
bytes long bytes long
@param wcount Number of bytes to be written. @param wcount Number of bytes to be written.
@return Number of bytes written to the memory block successfully;<BR> @return Number of bytes written to the memory block successfully;<BR>
@ -571,7 +571,7 @@ namespace Exiv2 {
is invalidated by this operation and should not be used after this is invalidated by this operation and should not be used after this
method returns. This method exists primarily to be used with method returns. This method exists primarily to be used with
the BasicIo::temporary() method. the BasicIo::temporary() method.
@param src Reference to another BasicIo instance. The entire contents @param src Reference to another BasicIo instance. The entire contents
of src are transferred to this object. The \em src object is of src are transferred to this object. The \em src object is
invalidated by the method. invalidated by the method.
@ -579,7 +579,7 @@ namespace Exiv2 {
*/ */
virtual void transfer(BasicIo& src); virtual void transfer(BasicIo& src);
/*! /*!
@brief Move the current IO position. @brief Move the current IO position.
@param offset Number of bytes to move the IO position @param offset Number of bytes to move the IO position
relative to the starting position specified by \em pos relative to the starting position specified by \em pos
@param pos Position from which the seek should start @param pos Position from which the seek should start
@ -592,12 +592,12 @@ namespace Exiv2 {
//! @name Accessors //! @name Accessors
//@{ //@{
/*! /*!
@brief Get the current IO position. @brief Get the current IO position.
@return Offset from the start of the memory block @return Offset from the start of the memory block
*/ */
virtual long tell() const; virtual long tell() const;
/*! /*!
@brief Get the current memory buffer size in bytes. @brief Get the current memory buffer size in bytes.
@return Size of the in memory data in bytes;<BR> @return Size of the in memory data in bytes;<BR>
-1 if failure; -1 if failure;
*/ */
@ -634,7 +634,7 @@ namespace Exiv2 {
// METHODS // METHODS
void checkSize(long wcount); void checkSize(long wcount);
}; // class MemIo }; // class MemIo
} // namespace Exiv2 } // namespace Exiv2
#endif // #ifndef BASICIO_HPP_ #endif // #ifndef BASICIO_HPP_

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -56,8 +56,8 @@ namespace Exiv2 {
//! @cond IGNORE //! @cond IGNORE
CanonMakerNote::RegisterMn::RegisterMn() CanonMakerNote::RegisterMn::RegisterMn()
{ {
MakerNoteFactory::registerMakerNote("Canon", "*", createCanonMakerNote); MakerNoteFactory::registerMakerNote("Canon", "*", createCanonMakerNote);
MakerNoteFactory::registerMakerNote( MakerNoteFactory::registerMakerNote(
canonIfdId, MakerNote::AutoPtr(new CanonMakerNote)); canonIfdId, MakerNote::AutoPtr(new CanonMakerNote));
MakerNoteFactory::registerMakerNote( MakerNoteFactory::registerMakerNote(
@ -191,7 +191,7 @@ namespace Exiv2 {
}; };
int CanonMakerNote::read(const byte* buf, int CanonMakerNote::read(const byte* buf,
long len, long len,
long start, long start,
ByteOrder byteOrder, ByteOrder byteOrder,
long shift) long shift)
@ -205,7 +205,7 @@ namespace Exiv2 {
for (uint16_t c = 1; cs->count() > c; ++c) { for (uint16_t c = 1; cs->count() > c; ++c) {
if (c == 23 && cs->count() > 25) { if (c == 23 && cs->count() > 25) {
// Pack related lens info into one tag // Pack related lens info into one tag
addCsEntry(canonCs1IfdId, c, cs->offset() + c*2, addCsEntry(canonCs1IfdId, c, cs->offset() + c*2,
cs->data() + c*2, 3); cs->data() + c*2, 3);
c += 2; c += 2;
} }
@ -253,9 +253,9 @@ namespace Exiv2 {
return 0; return 0;
} }
void CanonMakerNote::addCsEntry(IfdId ifdId, void CanonMakerNote::addCsEntry(IfdId ifdId,
uint16_t tag, uint16_t tag,
long offset, long offset,
const byte* data, const byte* data,
int count) int count)
{ {
@ -270,7 +270,7 @@ namespace Exiv2 {
void CanonMakerNote::add(const Entry& entry) void CanonMakerNote::add(const Entry& entry)
{ {
assert(alloc_ == entry.alloc()); assert(alloc_ == entry.alloc());
assert( entry.ifdId() == canonIfdId assert( entry.ifdId() == canonIfdId
|| entry.ifdId() == canonCs1IfdId || entry.ifdId() == canonCs1IfdId
|| entry.ifdId() == canonCs2IfdId || entry.ifdId() == canonCs2IfdId
|| entry.ifdId() == canonCfIfdId); || entry.ifdId() == canonCfIfdId);
@ -282,7 +282,7 @@ namespace Exiv2 {
{ {
if (byteOrder_ == invalidByteOrder) byteOrder_ = byteOrder; if (byteOrder_ == invalidByteOrder) byteOrder_ = byteOrder;
assert(ifd_.alloc()); assert(ifd_.alloc());
ifd_.clear(); ifd_.clear();
// Add all standard Canon entries to the IFD // Add all standard Canon entries to the IFD
@ -358,7 +358,7 @@ namespace Exiv2 {
return headerSize() + ifd.size() + ifd.dataSize(); return headerSize() + ifd.size() + ifd.dataSize();
} // CanonMakerNote::size } // CanonMakerNote::size
long CanonMakerNote::assemble(Entry& e, long CanonMakerNote::assemble(Entry& e,
IfdId ifdId, IfdId ifdId,
uint16_t tag, uint16_t tag,
ByteOrder byteOrder) const ByteOrder byteOrder) const
@ -390,7 +390,7 @@ namespace Exiv2 {
return len; return len;
} // CanonMakerNote::assemble } // CanonMakerNote::assemble
Entries::const_iterator CanonMakerNote::findIdx(int idx) const Entries::const_iterator CanonMakerNote::findIdx(int idx) const
{ {
return std::find_if(entries_.begin(), entries_.end(), return std::find_if(entries_.begin(), entries_.end(),
FindEntryByIdx(idx)); FindEntryByIdx(idx));
@ -412,9 +412,9 @@ namespace Exiv2 {
return AutoPtr(create_(alloc)); return AutoPtr(create_(alloc));
} }
CanonMakerNote* CanonMakerNote::create_(bool alloc) const CanonMakerNote* CanonMakerNote::create_(bool alloc) const
{ {
return new CanonMakerNote(alloc); return new CanonMakerNote(alloc);
} }
CanonMakerNote::AutoPtr CanonMakerNote::clone() const CanonMakerNote::AutoPtr CanonMakerNote::clone() const
@ -422,9 +422,9 @@ namespace Exiv2 {
return AutoPtr(clone_()); return AutoPtr(clone_());
} }
CanonMakerNote* CanonMakerNote::clone_() const CanonMakerNote* CanonMakerNote::clone_() const
{ {
return new CanonMakerNote(*this); return new CanonMakerNote(*this);
} }
std::ostream& CanonMakerNote::print0x0008(std::ostream& os, std::ostream& CanonMakerNote::print0x0008(std::ostream& os,
@ -432,7 +432,7 @@ namespace Exiv2 {
{ {
std::string n = value.toString(); std::string n = value.toString();
if (n.length() < 4) return os << "(" << n << ")"; if (n.length() < 4) return os << "(" << n << ")";
return os << n.substr(0, n.length() - 4) << "-" return os << n.substr(0, n.length() - 4) << "-"
<< n.substr(n.length() - 4); << n.substr(n.length() - 4);
} }
@ -442,13 +442,13 @@ namespace Exiv2 {
std::istringstream is(value.toString()); std::istringstream is(value.toString());
uint32_t l; uint32_t l;
is >> l; is >> l;
return os << std::setw(4) << std::setfill('0') << std::hex return os << std::setw(4) << std::setfill('0') << std::hex
<< ((l & 0xffff0000) >> 16) << ((l & 0xffff0000) >> 16)
<< std::setw(5) << std::setfill('0') << std::dec << std::setw(5) << std::setfill('0') << std::dec
<< (l & 0x0000ffff); << (l & 0x0000ffff);
} }
std::ostream& CanonMakerNote::printCs10x0001(std::ostream& os, std::ostream& CanonMakerNote::printCs10x0001(std::ostream& os,
const Value& value) const Value& value)
{ {
if (value.typeId() != unsignedShort) return os << value; if (value.typeId() != unsignedShort) return os << value;
@ -469,7 +469,7 @@ namespace Exiv2 {
if (l == 0) { if (l == 0) {
os << "Off"; os << "Off";
} }
else { else {
os << l / 10.0 << " s"; os << l / 10.0 << " s";
} }
return os; return os;
@ -512,7 +512,7 @@ namespace Exiv2 {
std::ostream& CanonMakerNote::printCs10x0005(std::ostream& os, std::ostream& CanonMakerNote::printCs10x0005(std::ostream& os,
const Value& value) const Value& value)
{ {
if (value.typeId() != unsignedShort) return os << value; if (value.typeId() != unsignedShort) return os << value;
long l = value.toLong(); long l = value.toLong();
switch (l) { switch (l) {
case 0: os << "Single / timer"; break; case 0: os << "Single / timer"; break;
@ -903,9 +903,9 @@ namespace Exiv2 {
// free functions // free functions
MakerNote::AutoPtr createCanonMakerNote(bool alloc, MakerNote::AutoPtr createCanonMakerNote(bool alloc,
const byte* buf, const byte* buf,
long len, long len,
ByteOrder byteOrder, ByteOrder byteOrder,
long offset) long offset)
{ {
return MakerNote::AutoPtr(new CanonMakerNote(alloc)); return MakerNote::AutoPtr(new CanonMakerNote(alloc));

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -62,27 +62,27 @@ namespace Exiv2 {
initialized to operate in the memory management model indicated. initialized to operate in the memory management model indicated.
The caller owns this copy and the auto-pointer ensures that it The caller owns this copy and the auto-pointer ensures that it
will be deleted. will be deleted.
@param alloc Memory management model for the new MakerNote. Determines if @param alloc Memory management model for the new MakerNote. Determines if
memory required to store data should be allocated and deallocated memory required to store data should be allocated and deallocated
(true) or not (false). If false, only pointers to the buffer (true) or not (false). If false, only pointers to the buffer
provided to read() will be kept. See Ifd for more background on provided to read() will be kept. See Ifd for more background on
this concept. this concept.
@param buf Pointer to the makernote character buffer (not used). @param buf Pointer to the makernote character buffer (not used).
@param len Length of the makernote character buffer (not used). @param len Length of the makernote character buffer (not used).
@param byteOrder Byte order in which the Exif data (and possibly the @param byteOrder Byte order in which the Exif data (and possibly the
makernote) is encoded (not used). makernote) is encoded (not used).
@param offset Offset from the start of the TIFF header of the makernote @param offset Offset from the start of the TIFF header of the makernote
buffer (not used). buffer (not used).
@return An auto-pointer to a newly created empty MakerNote. The caller @return An auto-pointer to a newly created empty MakerNote. The caller
owns this copy and the auto-pointer ensures that it will be owns this copy and the auto-pointer ensures that it will be
deleted. deleted.
*/ */
MakerNote::AutoPtr createCanonMakerNote(bool alloc, MakerNote::AutoPtr createCanonMakerNote(bool alloc,
const byte* buf, const byte* buf,
long len, long len,
ByteOrder byteOrder, ByteOrder byteOrder,
long offset); long offset);
// ***************************************************************************** // *****************************************************************************
@ -110,8 +110,8 @@ namespace Exiv2 {
//! @name Manipulators //! @name Manipulators
//@{ //@{
int read(const byte* buf, int read(const byte* buf,
long len, long len,
long start, long start,
ByteOrder byteOrder, ByteOrder byteOrder,
long shift); long shift);
long copy(byte* buf, ByteOrder byteOrder, long offset); long copy(byte* buf, ByteOrder byteOrder, long offset);
@ -131,7 +131,7 @@ namespace Exiv2 {
AutoPtr clone() const; AutoPtr clone() const;
//@} //@}
//! @name Print functions for Canon %MakerNote tags //! @name Print functions for Canon %MakerNote tags
//@{ //@{
//! Print the image number //! Print the image number
static std::ostream& print0x0008(std::ostream& os, const Value& value); static std::ostream& print0x0008(std::ostream& os, const Value& value);
@ -168,7 +168,7 @@ namespace Exiv2 {
static std::ostream& printCs10x0014(std::ostream& os, const Value& value); static std::ostream& printCs10x0014(std::ostream& os, const Value& value);
//! Flash activity //! Flash activity
static std::ostream& printCs10x001c(std::ostream& os, const Value& value); static std::ostream& printCs10x001c(std::ostream& os, const Value& value);
//! Flash details //! Flash details
static std::ostream& printCs10x001d(std::ostream& os, const Value& value); static std::ostream& printCs10x001d(std::ostream& os, const Value& value);
//! Focus mode (G1 seems to use this in preference to field 7) //! Focus mode (G1 seems to use this in preference to field 7)
static std::ostream& printCs10x0020(std::ostream& os, const Value& value); static std::ostream& printCs10x0020(std::ostream& os, const Value& value);
@ -205,8 +205,8 @@ namespace Exiv2 {
//! @name Manipulators //! @name Manipulators
//@{ //@{
//! Add a camera settings entry to the makernote entries //! Add a camera settings entry to the makernote entries
void addCsEntry(IfdId ifdId, void addCsEntry(IfdId ifdId,
uint16_t tag, uint16_t tag,
long offset, long offset,
const byte* data, const byte* data,
int count); int count);
@ -215,8 +215,8 @@ namespace Exiv2 {
//! @name Accessors //! @name Accessors
//@{ //@{
//! Assemble special Canon entries into an entry with the original tag //! Assemble special Canon entries into an entry with the original tag
long assemble(Entry& e, long assemble(Entry& e,
IfdId ifdId, IfdId ifdId,
uint16_t tag, uint16_t tag,
ByteOrder byteOrder) const; ByteOrder byteOrder) const;
//! Internal virtual create function. //! Internal virtual create function.
@ -244,14 +244,14 @@ namespace Exiv2 {
/*! /*!
@brief Convert Canon hex-based EV (modulo 0x20) to real number @brief Convert Canon hex-based EV (modulo 0x20) to real number
Ported from Phil Harvey's Image::ExifTool::Canon::CanonEv Ported from Phil Harvey's Image::ExifTool::Canon::CanonEv
by Will Stokes by Will Stokes
0x00 -> 0 0x00 -> 0
0x0c -> 0.33333 0x0c -> 0.33333
0x10 -> 0.5 0x10 -> 0.5
0x14 -> 0.66666 0x14 -> 0.66666
0x20 -> 1 0x20 -> 1
.. ..
160 -> 5 160 -> 5
128 -> 4 128 -> 4

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -23,7 +23,7 @@
Version: $Rev$ Version: $Rev$
Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net> Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
History: 28-Aug-05, ahu: created History: 28-Aug-05, ahu: created
*/ */
// ***************************************************************************** // *****************************************************************************
#include "rcsid.hpp" #include "rcsid.hpp"
@ -61,7 +61,7 @@ EXIV2_RCSID("@(#) $Id$");
namespace Exiv2 { namespace Exiv2 {
const byte CrwImage::blank_[] = { const byte CrwImage::blank_[] = {
0x00 0x00
}; };
CrwImage::CrwImage(BasicIo::AutoPtr io, bool create) CrwImage::CrwImage(BasicIo::AutoPtr io, bool create)
@ -96,7 +96,7 @@ namespace Exiv2 {
clearExifData(); clearExifData();
clearComment(); clearComment();
} }
void CrwImage::setMetadata(const Image& image) void CrwImage::setMetadata(const Image& image)
{ {
setExifData(image.exifData()); setExifData(image.exifData());
@ -129,7 +129,7 @@ namespace Exiv2 {
} }
void CrwImage::setComment(const std::string& comment) void CrwImage::setComment(const std::string& comment)
{ {
comment_ = comment; comment_ = comment;
} }
@ -175,9 +175,9 @@ namespace Exiv2 {
return isCrwType(iIo, advance); return isCrwType(iIo, advance);
} }
void CiffComponent::read(const byte* buf, void CiffComponent::read(const byte* buf,
uint32_t len, uint32_t len,
uint32_t start, uint32_t start,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t /*shift*/) int32_t /*shift*/)
{ {
@ -200,11 +200,11 @@ namespace Exiv2 {
pData_ = buf + offset_; pData_ = buf + offset_;
} // CiffComponent::read } // CiffComponent::read
void CiffComponent::print(std::ostream& os, void CiffComponent::print(std::ostream& os,
ByteOrder byteOrder, ByteOrder byteOrder,
const std::string& prefix) const const std::string& prefix) const
{ {
os << prefix os << prefix
<< "tag = 0x" << std::setw(4) << std::setfill('0') << "tag = 0x" << std::setw(4) << std::setfill('0')
<< std::hex << std::right << tagId() << std::hex << std::right << tagId()
<< ", dir = 0x" << std::setw(4) << std::setfill('0') << ", dir = 0x" << std::setw(4) << std::setfill('0')
@ -252,7 +252,7 @@ namespace Exiv2 {
{ {
CrwMap::extract(*this, image, byteOrder); CrwMap::extract(*this, image, byteOrder);
} // CiffEntry::extract } // CiffEntry::extract
void CiffEntry::add(RawMetadata::AutoPtr component) void CiffEntry::add(RawMetadata::AutoPtr component)
{ {
throw Error(34, "CiffEntry::add"); throw Error(34, "CiffEntry::add");
@ -272,9 +272,9 @@ namespace Exiv2 {
components_.push_back(component.release()); components_.push_back(component.release());
} // CiffDirectory::add } // CiffDirectory::add
void CiffDirectory::read(const byte* buf, void CiffDirectory::read(const byte* buf,
uint32_t len, uint32_t len,
uint32_t start, uint32_t start,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t /*shift*/) int32_t /*shift*/)
{ {
@ -291,7 +291,7 @@ namespace Exiv2 {
} }
} // CiffDirectory::extract } // CiffDirectory::extract
void CiffDirectory::print(std::ostream& os, void CiffDirectory::print(std::ostream& os,
ByteOrder byteOrder, ByteOrder byteOrder,
const std::string& prefix) const const std::string& prefix) const
{ {
@ -303,10 +303,10 @@ namespace Exiv2 {
} }
} // CiffDirectory::print } // CiffDirectory::print
void CiffDirectory::readDirectory(const byte* buf, void CiffDirectory::readDirectory(const byte* buf,
uint32_t len, uint32_t len,
uint32_t start, uint32_t start,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t /*shift*/) int32_t /*shift*/)
{ {
uint32_t dataSize = getULong(buf + len - 4, byteOrder); uint32_t dataSize = getULong(buf + len - 4, byteOrder);
@ -342,9 +342,9 @@ namespace Exiv2 {
throw Error(34, "CiffHeader::add"); throw Error(34, "CiffHeader::add");
} // CiffHeader::add } // CiffHeader::add
void CiffHeader::read(const byte* buf, void CiffHeader::read(const byte* buf,
uint32_t len, uint32_t len,
uint32_t start, uint32_t start,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t /*shift*/) int32_t /*shift*/)
{ {
@ -374,18 +374,18 @@ namespace Exiv2 {
if (rootDirectory_) rootDirectory_->extract(image, byteOrder_); if (rootDirectory_) rootDirectory_->extract(image, byteOrder_);
} // CiffHeader::extract } // CiffHeader::extract
void CiffHeader::print(std::ostream& os, void CiffHeader::print(std::ostream& os,
ByteOrder byteOrder, ByteOrder byteOrder,
const std::string& prefix) const const std::string& prefix) const
{ {
os << prefix os << prefix
<< "Header, offset = 0x" << std::setw(8) << std::setfill('0') << "Header, offset = 0x" << std::setw(8) << std::setfill('0')
<< std::hex << std::right << offset_ << "\n"; << std::hex << std::right << offset_ << "\n";
if (rootDirectory_) rootDirectory_->print(os, byteOrder_, prefix); if (rootDirectory_) rootDirectory_->print(os, byteOrder_, prefix);
} // CiffHeader::print } // CiffHeader::print
const CrwMapInfo CrwMap::crwMapInfos_[] = { const CrwMapInfo CrwMap::crwMapInfos_[] = {
CrwMapInfo(0x0805, 0x300a, 0, 0x9286, exifIfdId, extract0x0805, 0), CrwMapInfo(0x0805, 0x300a, 0, 0x9286, exifIfdId, extract0x0805, 0),
CrwMapInfo(0x080a, 0x2807, 0, 0x010f, ifd0Id, extract0x080a, 0), CrwMapInfo(0x080a, 0x2807, 0, 0x010f, ifd0Id, extract0x080a, 0),
CrwMapInfo(0x080a, 0x2807, 0, 0x0110, ifd0Id, 0, 0), CrwMapInfo(0x080a, 0x2807, 0, 0x0110, ifd0Id, 0, 0),
CrwMapInfo(0x080b, 0x3004, 0, 0x0007, canonIfdId, extractBasic, 0), CrwMapInfo(0x080b, 0x3004, 0, 0x0007, canonIfdId, extractBasic, 0),
@ -416,7 +416,7 @@ namespace Exiv2 {
CrwMapInfo(0x0000, 0x0000, 0, 0x0000, ifdIdNotSet, extractBasic, 0) CrwMapInfo(0x0000, 0x0000, 0, 0x0000, ifdIdNotSet, extractBasic, 0)
}; // CrwMap::crwMapInfos_[] }; // CrwMap::crwMapInfos_[]
void CrwMap::extract(const CiffComponent& ciffComponent, void CrwMap::extract(const CiffComponent& ciffComponent,
Image& image, Image& image,
ByteOrder byteOrder) ByteOrder byteOrder)
{ {
@ -430,7 +430,7 @@ namespace Exiv2 {
const CrwMapInfo* CrwMap::crwMapInfo(uint16_t dir, uint16_t tagId) const CrwMapInfo* CrwMap::crwMapInfo(uint16_t dir, uint16_t tagId)
{ {
for (int i = 0; crwMapInfos_[i].ifdId_ != ifdIdNotSet; ++i) { for (int i = 0; crwMapInfos_[i].ifdId_ != ifdIdNotSet; ++i) {
if ( crwMapInfos_[i].crwDir_ == dir if ( crwMapInfos_[i].crwDir_ == dir
&& crwMapInfos_[i].crwTagId_ == tagId) { && crwMapInfos_[i].crwTagId_ == tagId) {
return &(crwMapInfos_[i]); return &(crwMapInfos_[i]);
} }
@ -439,7 +439,7 @@ namespace Exiv2 {
} // CrwMap::crwMapInfo } // CrwMap::crwMapInfo
void CrwMap::extract0x0805(const CiffComponent& ciffComponent, void CrwMap::extract0x0805(const CiffComponent& ciffComponent,
const CrwMapInfo* crwMapInfo, const CrwMapInfo* crwMapInfo,
Image& image, Image& image,
ByteOrder /*byteOrder*/) ByteOrder /*byteOrder*/)
{ {
@ -448,7 +448,7 @@ namespace Exiv2 {
} // CrwMap::extract0x0805 } // CrwMap::extract0x0805
void CrwMap::extract0x080a(const CiffComponent& ciffComponent, void CrwMap::extract0x080a(const CiffComponent& ciffComponent,
const CrwMapInfo* crwMapInfo, const CrwMapInfo* crwMapInfo,
Image& image, Image& image,
ByteOrder byteOrder) ByteOrder byteOrder)
{ {
@ -460,7 +460,7 @@ namespace Exiv2 {
ExifKey key1("Exif.Image.Make"); ExifKey key1("Exif.Image.Make");
Value::AutoPtr value1 = Value::create(ciffComponent.typeId()); Value::AutoPtr value1 = Value::create(ciffComponent.typeId());
uint32_t i = 0; uint32_t i = 0;
for (; i < ciffComponent.size() for (; i < ciffComponent.size()
&& ciffComponent.pData()[i] != '\0'; ++i) { && ciffComponent.pData()[i] != '\0'; ++i) {
// empty // empty
} }
@ -471,7 +471,7 @@ namespace Exiv2 {
ExifKey key2("Exif.Image.Model"); ExifKey key2("Exif.Image.Model");
Value::AutoPtr value2 = Value::create(ciffComponent.typeId()); Value::AutoPtr value2 = Value::create(ciffComponent.typeId());
uint32_t j = i; uint32_t j = i;
for (; i < ciffComponent.size() for (; i < ciffComponent.size()
&& ciffComponent.pData()[i] != '\0'; ++i) { && ciffComponent.pData()[i] != '\0'; ++i) {
// empty // empty
} }
@ -480,7 +480,7 @@ namespace Exiv2 {
} // CrwMap::extract0x080a } // CrwMap::extract0x080a
void CrwMap::extract0x102a(const CiffComponent& ciffComponent, void CrwMap::extract0x102a(const CiffComponent& ciffComponent,
const CrwMapInfo* crwMapInfo, const CrwMapInfo* crwMapInfo,
Image& image, Image& image,
ByteOrder byteOrder) ByteOrder byteOrder)
{ {
@ -524,7 +524,7 @@ namespace Exiv2 {
} // CrwMap::extract0x102a } // CrwMap::extract0x102a
void CrwMap::extract0x102d(const CiffComponent& ciffComponent, void CrwMap::extract0x102d(const CiffComponent& ciffComponent,
const CrwMapInfo* crwMapInfo, const CrwMapInfo* crwMapInfo,
Image& image, Image& image,
ByteOrder byteOrder) ByteOrder byteOrder)
{ {
@ -546,7 +546,7 @@ namespace Exiv2 {
} // CrwMap::extract0x102d } // CrwMap::extract0x102d
void CrwMap::extract0x180e(const CiffComponent& ciffComponent, void CrwMap::extract0x180e(const CiffComponent& ciffComponent,
const CrwMapInfo* crwMapInfo, const CrwMapInfo* crwMapInfo,
Image& image, Image& image,
ByteOrder byteOrder) ByteOrder byteOrder)
{ {
@ -577,7 +577,7 @@ namespace Exiv2 {
} // CrwMap::extract0x180e } // CrwMap::extract0x180e
void CrwMap::extract0x1810(const CiffComponent& ciffComponent, void CrwMap::extract0x1810(const CiffComponent& ciffComponent,
const CrwMapInfo* crwMapInfo, const CrwMapInfo* crwMapInfo,
Image& image, Image& image,
ByteOrder byteOrder) ByteOrder byteOrder)
{ {
@ -598,16 +598,16 @@ namespace Exiv2 {
} // CrwMap::extract0x1810 } // CrwMap::extract0x1810
void CrwMap::extract0x2008(const CiffComponent& ciffComponent, void CrwMap::extract0x2008(const CiffComponent& ciffComponent,
const CrwMapInfo* /*crwMapInfo*/, const CrwMapInfo* /*crwMapInfo*/,
Image& image, Image& image,
ByteOrder /*byteOrder*/) ByteOrder /*byteOrder*/)
{ {
image.exifData().setJpegThumbnail(ciffComponent.pData(), image.exifData().setJpegThumbnail(ciffComponent.pData(),
ciffComponent.size()); ciffComponent.size());
} // CrwMap::extract0x2008 } // CrwMap::extract0x2008
void CrwMap::extractBasic(const CiffComponent& ciffComponent, void CrwMap::extractBasic(const CiffComponent& ciffComponent,
const CrwMapInfo* crwMapInfo, const CrwMapInfo* crwMapInfo,
Image& image, Image& image,
ByteOrder byteOrder) ByteOrder byteOrder)
{ {
@ -623,8 +623,8 @@ namespace Exiv2 {
} }
else if (ciffComponent.typeId() == asciiString) { else if (ciffComponent.typeId() == asciiString) {
// determine size from the data, by looking for the first 0 // determine size from the data, by looking for the first 0
uint32_t i = 0; uint32_t i = 0;
for (; i < ciffComponent.size() for (; i < ciffComponent.size()
&& ciffComponent.pData()[i] != '\0'; ++i) { && ciffComponent.pData()[i] != '\0'; ++i) {
// empty // empty
} }
@ -665,7 +665,7 @@ namespace Exiv2 {
|| ('M' == tmpBuf[0] && 'M' == tmpBuf[1]))) { || ('M' == tmpBuf[0] && 'M' == tmpBuf[1]))) {
result = false; result = false;
} }
if ( true == result if ( true == result
&& std::memcmp(tmpBuf + 6, CiffHeader::signature_, 8) != 0) { && std::memcmp(tmpBuf + 6, CiffHeader::signature_, 8) != 0) {
result = false; result = false;
} }

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -56,9 +56,9 @@ namespace Exiv2 {
// ***************************************************************************** // *****************************************************************************
// type definitions // type definitions
//! Function pointer for functions to extract Exif tags from a Crw entry //! Function pointer for functions to extract Exif tags from a Crw entry
typedef void (*CrwExtractFct)(const CiffComponent&, typedef void (*CrwExtractFct)(const CiffComponent&,
const CrwMapInfo*, const CrwMapInfo*,
Image&, Image&,
ByteOrder); ByteOrder);
@ -69,12 +69,12 @@ namespace Exiv2 {
// class definitions // class definitions
// Add Crw to the supported image formats // Add Crw to the supported image formats
namespace ImageType { namespace ImageType {
const int crw = 3; //!< Crw image type (see class CrwImage) const int crw = 3; //!< Crw image type (see class CrwImage)
} }
/*! /*!
@brief Class to access raw Canon Crw images. Only Exif metadata and a @brief Class to access raw Canon Crw images. Only Exif metadata and a
comment are supported. Crw format does not contain Iptc metadata. comment are supported. Crw format does not contain Iptc metadata.
*/ */
class CrwImage : public Image { class CrwImage : public Image {
@ -91,7 +91,7 @@ namespace Exiv2 {
public: public:
//! @name Creators //! @name Creators
//@{ //@{
/*! /*!
@brief Constructor that can either open an existing Crw image or create @brief Constructor that can either open an existing Crw image or create
a new image from scratch. If a new image is to be created, any a new image from scratch. If a new image is to be created, any
existing data is overwritten. Since the constructor can not return existing data is overwritten. Since the constructor can not return
@ -110,24 +110,24 @@ namespace Exiv2 {
//! Destructor //! Destructor
~CrwImage() {} ~CrwImage() {}
//@} //@}
//! @name Manipulators //! @name Manipulators
//@{ //@{
void readMetadata(); void readMetadata();
/*! /*!
@brief Todo: Write metadata back to the image. This method is not @brief Todo: Write metadata back to the image. This method is not
yet implemented. yet implemented.
*/ */
void writeMetadata(); void writeMetadata();
void setExifData(const ExifData& exifData); void setExifData(const ExifData& exifData);
void clearExifData(); void clearExifData();
/*! /*!
@brief Not supported. Crw format does not contain Iptc metadata. @brief Not supported. Crw format does not contain Iptc metadata.
Calling this function will raise an exception (Error). Calling this function will raise an exception (Error).
*/ */
void setIptcData(const IptcData& iptcData); void setIptcData(const IptcData& iptcData);
/*! /*!
@brief Not supported. Crw format does not contain Iptc metadata. @brief Not supported. Crw format does not contain Iptc metadata.
Calling this function will raise an exception (Error). Calling this function will raise an exception (Error).
*/ */
void clearIptcData(); void clearIptcData();
@ -164,9 +164,9 @@ namespace Exiv2 {
moved (see below). This applies only if the type matches and the moved (see below). This applies only if the type matches and the
function returns true. If the type does not match, the stream function returns true. If the type does not match, the stream
position is not changed. However, if reading from the stream fails, position is not changed. However, if reading from the stream fails,
the stream position is undefined. Consult the stream state to obtain the stream position is undefined. Consult the stream state to obtain
more information in this case. more information in this case.
@param iIo BasicIo instance to read from. @param iIo BasicIo instance to read from.
@param advance Flag indicating whether the position of the io @param advance Flag indicating whether the position of the io
should be advanced by the number of characters read to should be advanced by the number of characters read to
@ -224,9 +224,9 @@ namespace Exiv2 {
@throw Error If the component cannot be parsed. @throw Error If the component cannot be parsed.
*/ */
virtual void read(const byte* buf, virtual void read(const byte* buf,
uint32_t len, uint32_t len,
uint32_t start, uint32_t start,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t shift =0) =0; int32_t shift =0) =0;
//@} //@}
@ -236,11 +236,11 @@ namespace Exiv2 {
/*! /*!
@brief Extract metadata from the component and add it to @brief Extract metadata from the component and add it to
\em image. \em image.
@param image Image to add metadata to @param image Image to add metadata to
@param byteOrder Byte order @param byteOrder Byte order
*/ */
virtual void extract(Image& image, virtual void extract(Image& image,
ByteOrder byteOrder) const =0; ByteOrder byteOrder) const =0;
/*! /*!
@ -250,7 +250,7 @@ namespace Exiv2 {
@param byteOrder Byte order @param byteOrder Byte order
@param prefix Prefix to be written before each line of output @param prefix Prefix to be written before each line of output
*/ */
virtual void print(std::ostream& os, virtual void print(std::ostream& os,
ByteOrder byteOrder, ByteOrder byteOrder,
const std::string& prefix ="") const =0; const std::string& prefix ="") const =0;
//@} //@}
@ -280,9 +280,9 @@ namespace Exiv2 {
virtual void add(RawMetadata::AutoPtr component) =0; virtual void add(RawMetadata::AutoPtr component) =0;
// See base class comment // See base class comment
virtual void read(const byte* buf, virtual void read(const byte* buf,
uint32_t len, uint32_t len,
uint32_t start, uint32_t start,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t shift =0); int32_t shift =0);
@ -298,11 +298,11 @@ namespace Exiv2 {
//! @name Accessors //! @name Accessors
//@{ //@{
// See base class comment // See base class comment
virtual void extract(Image& image, virtual void extract(Image& image,
ByteOrder byteOrder) const =0; ByteOrder byteOrder) const =0;
// See base class comment // See base class comment
virtual void print(std::ostream& os, virtual void print(std::ostream& os,
ByteOrder byteOrder, ByteOrder byteOrder,
const std::string& prefix ="") const; const std::string& prefix ="") const;
@ -352,7 +352,7 @@ namespace Exiv2 {
@brief This class models one directory entry of a CIFF directory of @brief This class models one directory entry of a CIFF directory of
a Crw (Canon Raw data) image. a Crw (Canon Raw data) image.
*/ */
class CiffEntry : public CiffComponent { class CiffEntry : public CiffComponent {
public: public:
//! @name Creators //! @name Creators
//@{ //@{
@ -397,9 +397,9 @@ namespace Exiv2 {
virtual void add(RawMetadata::AutoPtr component); virtual void add(RawMetadata::AutoPtr component);
// See base class comment // See base class comment
virtual void read(const byte* buf, virtual void read(const byte* buf,
uint32_t len, uint32_t len,
uint32_t start, uint32_t start,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t shift =0); int32_t shift =0);
@ -412,9 +412,9 @@ namespace Exiv2 {
@param byteOrder Applicable byte order (little or big endian) @param byteOrder Applicable byte order (little or big endian)
@param shift Not used @param shift Not used
*/ */
void readDirectory(const byte* buf, void readDirectory(const byte* buf,
uint32_t len, uint32_t len,
uint32_t start, uint32_t start,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t shift =0); int32_t shift =0);
//@} //@}
@ -422,11 +422,11 @@ namespace Exiv2 {
//! @name Accessors //! @name Accessors
//@{ //@{
// See base class comment // See base class comment
virtual void extract(Image& image, virtual void extract(Image& image,
ByteOrder byteOrder) const; ByteOrder byteOrder) const;
// See base class comment // See base class comment
virtual void print(std::ostream& os, virtual void print(std::ostream& os,
ByteOrder byteOrder, ByteOrder byteOrder,
const std::string& prefix ="") const; const std::string& prefix ="") const;
//@} //@}
@ -439,14 +439,14 @@ namespace Exiv2 {
//! This class models the header of a Crw (Canon Raw data) image. //! This class models the header of a Crw (Canon Raw data) image.
class CiffHeader : public RawMetadata { class CiffHeader : public RawMetadata {
public: public:
//! @name Creators //! @name Creators
//@{ //@{
//! Default constructor //! Default constructor
CiffHeader() CiffHeader()
: rootDirectory_ (0), : rootDirectory_ (0),
byteOrder_ (littleEndian), byteOrder_ (littleEndian),
offset_ (0x0000001a) offset_ (0x0000001a)
{} {}
//! Virtual destructor //! Virtual destructor
virtual ~CiffHeader(); virtual ~CiffHeader();
@ -458,9 +458,9 @@ namespace Exiv2 {
virtual void add(RawMetadata::AutoPtr component); virtual void add(RawMetadata::AutoPtr component);
// See base class comment // See base class comment
virtual void read(const byte* buf, virtual void read(const byte* buf,
uint32_t len, uint32_t len,
uint32_t start, uint32_t start,
ByteOrder byteOrder, ByteOrder byteOrder,
int32_t shift =0); int32_t shift =0);
//@} //@}
@ -472,7 +472,7 @@ namespace Exiv2 {
ByteOrder byteOrder) const; ByteOrder byteOrder) const;
// See base class comment // See base class comment
virtual void print(std::ostream& os, virtual void print(std::ostream& os,
ByteOrder byteOrder, ByteOrder byteOrder,
const std::string& prefix ="") const; const std::string& prefix ="") const;
//@} //@}
@ -501,13 +501,13 @@ namespace Exiv2 {
IfdId ifdId, IfdId ifdId,
CrwExtractFct toExif, CrwExtractFct toExif,
CrwInsertFct fromExif) CrwInsertFct fromExif)
: crwTagId_ (crwTagId), : crwTagId_ (crwTagId),
crwDir_ (crwDir), crwDir_ (crwDir),
size_ (size), size_ (size),
tag_ (tag), tag_ (tag),
ifdId_ (ifdId), ifdId_ (ifdId),
toExif_ (toExif), toExif_ (toExif),
fromExif_ (fromExif) fromExif_ (fromExif)
{} {}
//@} //@}
@ -517,13 +517,13 @@ namespace Exiv2 {
uint32_t size_; //!< Data size (overwrites the size from the entry) uint32_t size_; //!< Data size (overwrites the size from the entry)
uint16_t tag_; //!< Exif tag to map to uint16_t tag_; //!< Exif tag to map to
IfdId ifdId_; //!< Exif Ifd id to map to IfdId ifdId_; //!< Exif Ifd id to map to
CrwExtractFct toExif_; //!< Conversion function CrwExtractFct toExif_; //!< Conversion function
CrwInsertFct fromExif_; //!< Reverse conversion function CrwInsertFct fromExif_; //!< Reverse conversion function
}; // struct CrwMapInfo }; // struct CrwMapInfo
/*! /*!
@brief Static class providing mapping functionality from Crw entries @brief Static class providing mapping functionality from Crw entries
to image metadata and vice versa to image metadata and vice versa
*/ */
class CrwMap { class CrwMap {
@ -540,11 +540,11 @@ namespace Exiv2 {
@param ciffComponent Source CIFF entry @param ciffComponent Source CIFF entry
@param image Destination image for the metadata @param image Destination image for the metadata
@param byteOrder Byte order in which the data of the entry @param byteOrder Byte order in which the data of the entry
is encoded is encoded
*/ */
static void extract(const CiffComponent& ciffComponent, static void extract(const CiffComponent& ciffComponent,
Image& image, Image& image,
ByteOrder byteOrder); ByteOrder byteOrder);
private: private:
@ -552,74 +552,74 @@ namespace Exiv2 {
static const CrwMapInfo* crwMapInfo(uint16_t dir, uint16_t tagId); static const CrwMapInfo* crwMapInfo(uint16_t dir, uint16_t tagId);
/*! /*!
@brief Standard extraction function to convert Crw entries to @brief Standard extraction function to convert Crw entries to
Exif metadata. Exif metadata.
Uses the mapping defined in the conversion structure \em crwMapInfo Uses the mapping defined in the conversion structure \em crwMapInfo
to convert the data. If the \em size field in the conversion structure to convert the data. If the \em size field in the conversion structure
is not 0, then it is used instead of the \em size provided by the is not 0, then it is used instead of the \em size provided by the
entry itself. entry itself.
*/ */
static void extractBasic(const CiffComponent& ciffComponent, static void extractBasic(const CiffComponent& ciffComponent,
const CrwMapInfo* crwMapInfo, const CrwMapInfo* crwMapInfo,
Image& image, Image& image,
ByteOrder byteOrder); ByteOrder byteOrder);
//! Extract the user comment //! Extract the user comment
static void extract0x0805(const CiffComponent& ciffComponent, static void extract0x0805(const CiffComponent& ciffComponent,
const CrwMapInfo* crwMapInfo, const CrwMapInfo* crwMapInfo,
Image& image, Image& image,
ByteOrder byteOrder); ByteOrder byteOrder);
//! Extract camera Make and Model information //! Extract camera Make and Model information
static void extract0x080a(const CiffComponent& ciffComponent, static void extract0x080a(const CiffComponent& ciffComponent,
const CrwMapInfo* crwMapInfo, const CrwMapInfo* crwMapInfo,
Image& image, Image& image,
ByteOrder byteOrder); ByteOrder byteOrder);
//! Extract Canon Camera Settings 2 //! Extract Canon Camera Settings 2
static void extract0x102a(const CiffComponent& ciffComponent, static void extract0x102a(const CiffComponent& ciffComponent,
const CrwMapInfo* crwMapInfo, const CrwMapInfo* crwMapInfo,
Image& image, Image& image,
ByteOrder byteOrder); ByteOrder byteOrder);
//! Extract Canon Camera Settings 1 //! Extract Canon Camera Settings 1
static void extract0x102d(const CiffComponent& ciffComponent, static void extract0x102d(const CiffComponent& ciffComponent,
const CrwMapInfo* crwMapInfo, const CrwMapInfo* crwMapInfo,
Image& image, Image& image,
ByteOrder byteOrder); ByteOrder byteOrder);
//! Extract the date when the picture was taken //! Extract the date when the picture was taken
static void extract0x180e(const CiffComponent& ciffComponent, static void extract0x180e(const CiffComponent& ciffComponent,
const CrwMapInfo* crwMapInfo, const CrwMapInfo* crwMapInfo,
Image& image, Image& image,
ByteOrder byteOrder); ByteOrder byteOrder);
//! Extract image width and height //! Extract image width and height
static void extract0x1810(const CiffComponent& ciffComponent, static void extract0x1810(const CiffComponent& ciffComponent,
const CrwMapInfo* crwMapInfo, const CrwMapInfo* crwMapInfo,
Image& image, Image& image,
ByteOrder byteOrder); ByteOrder byteOrder);
//! Extract the thumbnail image //! Extract the thumbnail image
static void extract0x2008(const CiffComponent& ciffComponent, static void extract0x2008(const CiffComponent& ciffComponent,
const CrwMapInfo* crwMapInfo, const CrwMapInfo* crwMapInfo,
Image& image, Image& image,
ByteOrder byteOrder); ByteOrder byteOrder);
// DATA // DATA
static const CrwMapInfo crwMapInfos_[]; //!< Metadata conversion table static const CrwMapInfo crwMapInfos_[]; //!< Metadata conversion table
}; // class CrwMap }; // class CrwMap
// ***************************************************************************** // *****************************************************************************
// template, inline and free functions // template, inline and free functions
// These could be static private functions on Image subclasses but then // These could be static private functions on Image subclasses but then
// ImageFactory needs to be made a friend. // ImageFactory needs to be made a friend.
/*! /*!
@brief Create a new CrwImage instance and return an auto-pointer to it. @brief Create a new CrwImage instance and return an auto-pointer to it.
Caller owns the returned object and the auto-pointer ensures that Caller owns the returned object and the auto-pointer ensures that
it will be deleted. it will be deleted.
*/ */
Image::AutoPtr newCrwInstance(BasicIo::AutoPtr io, bool create); Image::AutoPtr newCrwInstance(BasicIo::AutoPtr io, bool create);

@ -29,7 +29,7 @@ using namespace Exiv2;
int main(int argc, char* const argv[]) int main(int argc, char* const argv[])
{ {
try { try {
byte da1[] byte da1[]
= { 0xaa,0xbb,0xaa,0xbb,0xaa,0xbb,0xaa,0xbb, = { 0xaa,0xbb,0xaa,0xbb,0xaa,0xbb,0xaa,0xbb,
0xaa,0xbb,0xaa,0xbb,0xaa,0xbb,0xaa,0xbb, 0xaa,0xbb,0xaa,0xbb,0xaa,0xbb,0xaa,0xbb,
0xaa,0xbb,0xaa,0xbb,0xaa,0xbb,0xaa,0xbb, 0xaa,0xbb,0xaa,0xbb,0xaa,0xbb,0xaa,0xbb,
@ -38,7 +38,7 @@ try {
long len1 = 32; long len1 = 32;
byte da2[] byte da2[]
= { 0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc, = { 0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,
0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc 0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc,0xcc
}; };
@ -99,15 +99,15 @@ void print(const std::string& file)
std::cout << std::setw(35) << std::setfill(' ') << std::left std::cout << std::setw(35) << std::setfill(' ') << std::left
<< i->key() << " " << i->key() << " "
<< "0x" << std::setw(4) << std::setfill('0') << std::right << "0x" << std::setw(4) << std::setfill('0') << std::right
<< std::hex << i->tag() << " " << std::hex << i->tag() << " "
<< std::setw(12) << std::setfill(' ') << std::left << std::setw(12) << std::setfill(' ') << std::left
<< i->ifdName() << " " << i->ifdName() << " "
<< std::setw(9) << std::setfill(' ') << std::left << std::setw(9) << std::setfill(' ') << std::left
<< i->typeName() << " " << i->typeName() << " "
<< std::dec << std::setw(3) << std::dec << std::setw(3)
<< std::setfill(' ') << std::right << std::setfill(' ') << std::right
<< i->count() << " " << i->count() << " "
<< std::dec << i->value() << std::dec << i->value()
<< "\n"; << "\n";
} }
} }
@ -117,11 +117,11 @@ int read(const std::string& path)
Image::AutoPtr image = ImageFactory::open(path); Image::AutoPtr image = ImageFactory::open(path);
assert(image.get() != 0); assert(image.get() != 0);
image->readMetadata(); image->readMetadata();
if (!image->exifData().empty()) { if (!image->exifData().empty()) {
DataBuf exifData = image->exifData().copy(); DataBuf exifData = image->exifData().copy();
long size = exifData.size_; long size = exifData.size_;
// Read the TIFF header // Read the TIFF header
TiffHeader tiffHeader; TiffHeader tiffHeader;
int rc = tiffHeader.read(exifData.pData_); int rc = tiffHeader.read(exifData.pData_);
@ -143,13 +143,13 @@ int read(const std::string& path)
v->read(i->data(), i->count() * i->typeSize(), tiffHeader.byteOrder()); v->read(i->data(), i->count() * i->typeSize(), tiffHeader.byteOrder());
v->setDataArea(exifData.pData_ + v->toLong(), 32); v->setDataArea(exifData.pData_ + v->toLong(), 32);
std::cout << "Value of tag 0x8298: " << std::hex; std::cout << "Value of tag 0x8298: " << std::hex;
v->write(std::cout); v->write(std::cout);
std::cout << std::endl; std::cout << std::endl;
DataBuf buf = v->dataArea(); DataBuf buf = v->dataArea();
for (int i = 0; i< buf.size_; ++i) { for (int i = 0; i< buf.size_; ++i) {
std::cout << std::hex << (int)buf.pData_[i] << " "; std::cout << std::hex << (int)buf.pData_[i] << " ";
} }
std::cout << std::endl; std::cout << std::endl;
@ -162,13 +162,13 @@ int read(const std::string& path)
v->read(i->data(), i->count() * i->typeSize(), tiffHeader.byteOrder()); v->read(i->data(), i->count() * i->typeSize(), tiffHeader.byteOrder());
v->setDataArea(exifData.pData_ + v->toLong(), 16); v->setDataArea(exifData.pData_ + v->toLong(), 16);
std::cout << "Value of tag 0x013b: "; std::cout << "Value of tag 0x013b: ";
v->write(std::cout); v->write(std::cout);
std::cout << std::endl; std::cout << std::endl;
buf = v->dataArea(); buf = v->dataArea();
for (int i = 0; i< buf.size_; ++i) { for (int i = 0; i< buf.size_; ++i) {
std::cout << std::hex << (int)buf.pData_[i] << " "; std::cout << std::hex << (int)buf.pData_[i] << " ";
} }
std::cout << std::endl; std::cout << std::endl;

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -45,21 +45,21 @@ EXIV2_RCSID("@(#) $Id$");
namespace Exiv2 { namespace Exiv2 {
DataSet::DataSet( DataSet::DataSet(
uint16_t number, uint16_t number,
const char* name, const char* name,
const char* title, const char* title,
const char* desc, const char* desc,
bool mandatory, bool mandatory,
bool repeatable, bool repeatable,
uint32_t minbytes, uint32_t minbytes,
uint32_t maxbytes, uint32_t maxbytes,
TypeId type, TypeId type,
uint16_t recordId, uint16_t recordId,
const char* photoshop const char* photoshop
) )
: number_(number), name_(name), title_(title), desc_(desc), : number_(number), name_(name), title_(title), desc_(desc),
mandatory_(mandatory), repeatable_(repeatable), minbytes_(minbytes), mandatory_(mandatory), repeatable_(repeatable), minbytes_(minbytes),
maxbytes_(maxbytes), type_(type), recordId_(recordId), maxbytes_(maxbytes), type_(type), recordId_(recordId),
photoshop_(photoshop) photoshop_(photoshop)
{ {
} }
@ -78,7 +78,7 @@ namespace Exiv2 {
RecordInfo(IptcDataSets::envelope, "Envelope", "IIM envelope record"), RecordInfo(IptcDataSets::envelope, "Envelope", "IIM envelope record"),
RecordInfo(IptcDataSets::application2, "Application2", "IIM application record 2"), RecordInfo(IptcDataSets::application2, "Application2", "IIM application record 2"),
}; };
static const DataSet envelopeRecord[] = { static const DataSet envelopeRecord[] = {
DataSet(IptcDataSets::ModelVersion, "ModelVersion", "ModelVersion", "Version of IIM part 1", true, false, 2, 2, Exiv2::unsignedShort, IptcDataSets::envelope, ""), DataSet(IptcDataSets::ModelVersion, "ModelVersion", "ModelVersion", "Version of IIM part 1", true, false, 2, 2, Exiv2::unsignedShort, IptcDataSets::envelope, ""),
DataSet(IptcDataSets::Destination, "Destination", "Destination", "Routing information", false, true, 0, 1024, Exiv2::string, IptcDataSets::envelope, ""), DataSet(IptcDataSets::Destination, "Destination", "Destination", "Routing information", false, true, 0, 1024, Exiv2::string, IptcDataSets::envelope, ""),
@ -160,11 +160,11 @@ namespace Exiv2 {
static const DataSet unknownDataSet(0xffff, "Unknown dataset", "Unknown dataset", "Unknown dataset", false, true, 0, 0xffffffff, Exiv2::string, IptcDataSets::invalidRecord, "Unknown dataset"); static const DataSet unknownDataSet(0xffff, "Unknown dataset", "Unknown dataset", "Unknown dataset", false, true, 0, 0xffffffff, Exiv2::string, IptcDataSets::invalidRecord, "Unknown dataset");
// Dataset lookup lists.This is an array with pointers to one list per IIM4 Record. // Dataset lookup lists.This is an array with pointers to one list per IIM4 Record.
// The record id is used as the index into the array. // The record id is used as the index into the array.
const DataSet* IptcDataSets::records_[] = { const DataSet* IptcDataSets::records_[] = {
0, 0,
envelopeRecord, application2Record, envelopeRecord, application2Record,
0 0
}; };
@ -238,7 +238,7 @@ namespace Exiv2 {
return records_[recordId][idx].repeatable_; return records_[recordId][idx].repeatable_;
} }
uint16_t IptcDataSets::dataSet(const std::string& dataSetName, uint16_t IptcDataSets::dataSet(const std::string& dataSetName,
uint16_t recordId) uint16_t recordId)
{ {
uint16_t dataSet; uint16_t dataSet;
@ -258,7 +258,7 @@ namespace Exiv2 {
std::string IptcDataSets::recordName(uint16_t recordId) std::string IptcDataSets::recordName(uint16_t recordId)
{ {
if (recordId == envelope || recordId == application2) { if (recordId == envelope || recordId == application2) {
return recordInfo_[recordId].name_; return recordInfo_[recordId].name_;
} }
std::ostringstream os; std::ostringstream os;
@ -299,7 +299,7 @@ namespace Exiv2 {
} }
} }
} // IptcDataSets::dataSetList } // IptcDataSets::dataSetList
const char* IptcKey::familyName_ = "Iptc"; const char* IptcKey::familyName_ = "Iptc";
IptcKey::IptcKey(const std::string& key) IptcKey::IptcKey(const std::string& key)
@ -360,7 +360,7 @@ namespace Exiv2 {
uint16_t recId = IptcDataSets::recordId(recordName); uint16_t recId = IptcDataSets::recordId(recordName);
uint16_t dataSet = IptcDataSets::dataSet(dataSetName, recId); uint16_t dataSet = IptcDataSets::dataSet(dataSetName, recId);
// Possibly translate hex name parts (0xabcd) to real names // Possibly translate hex name parts (0xabcd) to real names
recordName = IptcDataSets::recordName(recId); recordName = IptcDataSets::recordName(recId);
dataSetName = IptcDataSets::dataSetName(dataSet, recId); dataSetName = IptcDataSets::dataSetName(dataSet, recId);
@ -379,12 +379,12 @@ namespace Exiv2 {
// ************************************************************************* // *************************************************************************
// free functions // free functions
std::ostream& operator<<(std::ostream& os, const DataSet& dataSet) std::ostream& operator<<(std::ostream& os, const DataSet& dataSet)
{ {
IptcKey iptcKey(dataSet.number_, dataSet.recordId_); IptcKey iptcKey(dataSet.number_, dataSet.recordId_);
return os << dataSet.name_ << ", " return os << dataSet.name_ << ", "
<< std::dec << dataSet.number_ << ", " << std::dec << dataSet.number_ << ", "
<< "0x" << std::setw(4) << std::setfill('0') << "0x" << std::setw(4) << std::setfill('0')
<< std::right << std::hex << dataSet.number_ << ", " << std::right << std::hex << dataSet.number_ << ", "
<< IptcDataSets::recordName(dataSet.recordId_) << ", " << IptcDataSets::recordName(dataSet.recordId_) << ", "
<< std::boolalpha << dataSet.mandatory_ << ", " << std::boolalpha << dataSet.mandatory_ << ", "
@ -393,7 +393,7 @@ namespace Exiv2 {
<< dataSet.maxbytes_ << ", " << dataSet.maxbytes_ << ", "
<< iptcKey.key() << ", " << iptcKey.key() << ", "
<< TypeInfo::typeName( << TypeInfo::typeName(
IptcDataSets::dataSetType(dataSet.number_, IptcDataSets::dataSetType(dataSet.number_,
dataSet.recordId_)) << ", " dataSet.recordId_)) << ", "
<< dataSet.desc_; << dataSet.desc_;
} }

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -59,13 +59,13 @@ namespace Exiv2 {
struct DataSet { struct DataSet {
//! Constructor //! Constructor
DataSet( DataSet(
uint16_t number, uint16_t number,
const char* name, const char* name,
const char* title, const char* title,
const char* desc, const char* desc,
bool mandatory, bool mandatory,
bool repeatable, bool repeatable,
uint32_t minbytes, uint32_t minbytes,
uint32_t maxbytes, uint32_t maxbytes,
TypeId type, TypeId type,
uint16_t recordId, uint16_t recordId,
@ -186,30 +186,30 @@ namespace Exiv2 {
/*! /*!
@brief Return the name of the dataset. @brief Return the name of the dataset.
@param number The dataset number @param number The dataset number
@param recordId The Iptc record Id @param recordId The Iptc record Id
@return The name of the dataset or a string containing the hexadecimal @return The name of the dataset or a string containing the hexadecimal
value of the dataset in the form "0x01ff", if this is an unknown value of the dataset in the form "0x01ff", if this is an unknown
dataset. dataset.
*/ */
static std::string dataSetName(uint16_t number, uint16_t recordId); static std::string dataSetName(uint16_t number, uint16_t recordId);
/*! /*!
@brief Return the title (label) of the dataset. @brief Return the title (label) of the dataset.
@param number The dataset number @param number The dataset number
@param recordId The Iptc record Id @param recordId The Iptc record Id
@return The title (label) of the dataset @return The title (label) of the dataset
*/ */
static const char* dataSetTitle(uint16_t number, uint16_t recordId); static const char* dataSetTitle(uint16_t number, uint16_t recordId);
/*! /*!
@brief Return the description of the dataset. @brief Return the description of the dataset.
@param number The dataset number @param number The dataset number
@param recordId The Iptc record Id @param recordId The Iptc record Id
@return The description of the dataset @return The description of the dataset
*/ */
static const char* dataSetDesc(uint16_t number, uint16_t recordId); static const char* dataSetDesc(uint16_t number, uint16_t recordId);
/*! /*!
@brief Return the photohsop name of a given dataset. @brief Return the photohsop name of a given dataset.
@param number The dataset number @param number The dataset number
@param recordId The Iptc record Id @param recordId The Iptc record Id
@return The name used by photoshop for a dataset or an empty @return The name used by photoshop for a dataset or an empty
string if photoshop does not use the dataset. string if photoshop does not use the dataset.
*/ */
@ -217,7 +217,7 @@ namespace Exiv2 {
/*! /*!
@brief Check if a given dataset is repeatable @brief Check if a given dataset is repeatable
@param number The dataset number @param number The dataset number
@param recordId The Iptc record Id @param recordId The Iptc record Id
@return true if the given dataset is repeatable otherwise false @return true if the given dataset is repeatable otherwise false
*/ */
static bool dataSetRepeatable(uint16_t number, uint16_t recordId); static bool dataSetRepeatable(uint16_t number, uint16_t recordId);
@ -278,10 +278,10 @@ namespace Exiv2 {
//! @name Creators //! @name Creators
//@{ //@{
/*! /*!
@brief Constructor to create an Iptc key from a key string. @brief Constructor to create an Iptc key from a key string.
@param key The key string. @param key The key string.
@throw Error if the first part of the key is not '<b>Iptc</b>' or @throw Error if the first part of the key is not '<b>Iptc</b>' or
the remaining parts of the key cannot be parsed and the remaining parts of the key cannot be parsed and
converted to a record name and a dataset name. converted to a record name and a dataset name.
*/ */
@ -329,7 +329,7 @@ namespace Exiv2 {
//! @name Manipulators //! @name Manipulators
//@{ //@{
/*! /*!
@brief Set the key corresponding to the dataset and record id. @brief Set the key corresponding to the dataset and record id.
The key is of the form '<b>Iptc</b>.recordName.dataSetName'. The key is of the form '<b>Iptc</b>.recordName.dataSetName'.
*/ */
void makeKey(); void makeKey();
@ -351,7 +351,7 @@ namespace Exiv2 {
static const char* familyName_; static const char* familyName_;
uint16_t tag_; //!< Tag value uint16_t tag_; //!< Tag value
uint16_t record_; //!< Record value uint16_t record_; //!< Record value
std::string key_; //!< Key std::string key_; //!< Key
}; // class IptcKey }; // class IptcKey

@ -12,28 +12,28 @@
@section overview Exiv2 Overview @section overview Exiv2 Overview
%Exiv2 comprises of a C++ library and a command line utility to access image %Exiv2 comprises of a C++ library and a command line utility to access image
metadata. %Exiv2 is free software. The homepage of %Exiv2 is at metadata. %Exiv2 is free software. The homepage of %Exiv2 is at
<A HREF="http://home.arcor.de/ahuggel/exiv2">http://home.arcor.de/ahuggel/exiv2</A>. <A HREF="http://home.arcor.de/ahuggel/exiv2">http://home.arcor.de/ahuggel/exiv2</A>.
The %Exiv2 library provides The %Exiv2 library provides
- full read and write access to the Exif and Iptc metadata of an image through - full read and write access to the Exif and Iptc metadata of an image through
%Exiv2 keys and standard C++ iterators %Exiv2 keys and standard C++ iterators
- a smart Iptc implementation that does not effect data that programs like - a smart Iptc implementation that does not effect data that programs like
Photoshop store in the same image segment Photoshop store in the same image segment
- Exif %MakerNote support: - Exif %MakerNote support:
- %MakerNote tags can be accessed just like any other Exif metadata - %MakerNote tags can be accessed just like any other Exif metadata
- a sophisticated write algorithm avoids corrupting the %MakerNote: - a sophisticated write algorithm avoids corrupting the %MakerNote:
<br>&nbsp;&nbsp;1) the %MakerNote is not re-located if possible at all, and <br>&nbsp;&nbsp;1) the %MakerNote is not re-located if possible at all, and
<br>&nbsp;&nbsp;2) %MakerNote %Ifd offsets are re-calculated if the <br>&nbsp;&nbsp;2) %MakerNote %Ifd offsets are re-calculated if the
%MakerNote needs to be moved (for known %Ifd %MakerNotes) %MakerNote needs to be moved (for known %Ifd %MakerNotes)
- new camera make/model specific %MakerNotes can be added to the library with - new camera make/model specific %MakerNotes can be added to the library with
minimum effort in OO-fashion (by subclassing %MakerNote or %IfdMakerNote) minimum effort in OO-fashion (by subclassing %MakerNote or %IfdMakerNote)
- extract and delete methods for Exif thumbnails (both, Jpeg and Tiff thumbnails) - extract and delete methods for Exif thumbnails (both, Jpeg and Tiff thumbnails)
- set methods for Exif thumbnails (Jpeg only, Tiff thumbnails can be set from - set methods for Exif thumbnails (Jpeg only, Tiff thumbnails can be set from
individual tags) individual tags)
- complete API documentation (by Doxygen) - complete API documentation (by Doxygen)
- generic lower-level classes to access %Ifd (%Image File Directory) data - generic lower-level classes to access %Ifd (%Image File Directory) data
structures structures
@section getting-started Getting started @section getting-started Getting started
@ -55,39 +55,39 @@
@section makernote MakerNote Formats and Specifications @section makernote MakerNote Formats and Specifications
A summary of <A HREF="makernote.html">MakerNote structures</A> with links to A summary of <A HREF="makernote.html">MakerNote structures</A> with links to
publicly available specifications. publicly available specifications.
@section supp Support @section supp Support
<p>There is now a <p>There is now a
<a title="Exiv2 forum" href="http://uk.groups.yahoo.com/group/exiv2">Yahoo! group for Exiv2 help and discussions</a>.</p> <a title="Exiv2 forum" href="http://uk.groups.yahoo.com/group/exiv2">Yahoo! group for Exiv2 help and discussions</a>.</p>
<p><a title="Join the Exiv2 forum" href="http://uk.groups.yahoo.com/group/exiv2/join">Join the group</a> to post and receive messages or use <em><a title="Post to the Exiv2 forum" href="http://uk.groups.yahoo.com/group/exiv2/post">exiv2user/password</a></em> to post anonymously. Bug reports can be submitted directly to the <p><a title="Join the Exiv2 forum" href="http://uk.groups.yahoo.com/group/exiv2/join">Join the group</a> to post and receive messages or use <em><a title="Post to the Exiv2 forum" href="http://uk.groups.yahoo.com/group/exiv2/post">exiv2user/password</a></em> to post anonymously. Bug reports can be submitted directly to the
<a title="Issue tracker" href="http://dev.robotbattle.com/bugs/main_page.php" <a title="Issue tracker" href="http://dev.robotbattle.com/bugs/main_page.php"
onclick="document.images['tracker'].src='http://www.whatcounter.com/dlcount.php?id=ahu&amp;url='+this.href"> onclick="document.images['tracker'].src='http://www.whatcounter.com/dlcount.php?id=ahu&amp;url='+this.href">
bug tracking system</a>.</p> bug tracking system</a>.</p>
@section devel Development @section devel Development
<p>%Exiv2 is maintained in a publicly available subversion repository. <p>%Exiv2 is maintained in a publicly available subversion repository.
There is a <a title="Last 50 commits" href="http://dev.robotbattle.com/cmtinfo_svn.php?r=10"> There is a <a title="Last 50 commits" href="http://dev.robotbattle.com/cmtinfo_svn.php?r=10">
live list with the latest commits</a> to the repository, and you can live list with the latest commits</a> to the repository, and you can
<a title="Online source code repository" href="http://dev.robotbattle.com/~cvsuser/cgi-bin/ns_viewcvs.cgi/exiv2/trunk/"> <a title="Online source code repository" href="http://dev.robotbattle.com/~cvsuser/cgi-bin/ns_viewcvs.cgi/exiv2/trunk/">
browse the source code</a> online. browse the source code</a> online.
</p> </p>
<p>To check-out the current source code from the repository, you need a <p>To check-out the current source code from the repository, you need a
<a title="Get Subversion!" <a title="Get Subversion!"
href="http://subversion.tigris.org/project_packages.html">subversion client</a>. href="http://subversion.tigris.org/project_packages.html">subversion client</a>.
If you use a command line client, change to the directory where you want to keep If you use a command line client, change to the directory where you want to keep
the source code and type:</p> the source code and type:</p>
@verbatim $ svn checkout svn://dev.robotbattle.com/exiv2/trunk . @endverbatim @verbatim $ svn checkout svn://dev.robotbattle.com/exiv2/trunk . @endverbatim
<p>To download the test data and test drivers for version 0.7 from <p>To download the test data and test drivers for version 0.7 from
the repository, change to your local exiv2-0.7 directory and use the the repository, change to your local exiv2-0.7 directory and use the
following command: following command:
</p> </p>
@verbatim $ svn export svn://dev.robotbattle.com/exiv2/tags/0.7/test @endverbatim @verbatim $ svn export svn://dev.robotbattle.com/exiv2/tags/0.7/test @endverbatim
<P>If you'd like to contribute code, please <A HREF="mailto:ahuggel@gmx.net">contact me</A>. <P>If you'd like to contribute code, please <A HREF="mailto:ahuggel@gmx.net">contact me</A>.
@ -100,12 +100,12 @@ bug tracking system</a>.</p>
terms of the <a href="gpl-license.html">GNU General Public License</a> as terms of the <a href="gpl-license.html">GNU General Public License</a> as
published by the Free Software Foundation; either version 2 of the License, or published by the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.</P> (at your option) any later version.</P>
<P>%Exiv2 is distributed in the hope that it will be useful, but WITHOUT ANY <P>%Exiv2 is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. See the GNU General Public License for more A PARTICULAR PURPOSE. See the GNU General Public License for more
details.</P> details.</P>
<P>You should have received a copy of the GNU General Public License along <P>You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc., 59 with this program; if not, write to the Free Software Foundation, Inc., 59
Temple Place - Suite 330, Boston, MA 02111-1307, USA.</P> Temple Place - Suite 330, Boston, MA 02111-1307, USA.</P>

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -51,7 +51,7 @@ namespace Exiv2 {
ErrMsg( 5, "Invalid record name `%1'"), // %1=record name ErrMsg( 5, "Invalid record name `%1'"), // %1=record name
ErrMsg( 6, "Invalid key `%1'"), // %1=key ErrMsg( 6, "Invalid key `%1'"), // %1=key
ErrMsg( 7, "Invalid tag name or ifdId `%1', ifdId %2"), // %1=tag name, %2=ifdId ErrMsg( 7, "Invalid tag name or ifdId `%1', ifdId %2"), // %1=tag name, %2=ifdId
ErrMsg( 8, "Value not set"), ErrMsg( 8, "Value not set"),
ErrMsg( 9, "%1: Failed to open the data source: %2"), // %1=path, %2=strerror ErrMsg( 9, "%1: Failed to open the data source: %2"), // %1=path, %2=strerror
ErrMsg( 10, "%1: Failed to open file (%2): %3"), // %1=path, %2=mode, %3=strerror ErrMsg( 10, "%1: Failed to open file (%2): %3"), // %1=path, %2=mode, %3=strerror
ErrMsg( 11, "%1: The file contains data of an unknown image type"), // %1=path ErrMsg( 11, "%1: The file contains data of an unknown image type"), // %1=path

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -57,15 +57,15 @@ namespace Exiv2 {
}; };
/*! /*!
@brief Error class interface. Allows the definition and use of a hierarchy @brief Error class interface. Allows the definition and use of a hierarchy
of error classes which can all be handled in one catch block. of error classes which can all be handled in one catch block.
*/ */
class AnyError { class AnyError {
public: public:
//! @name Creators //! @name Creators
//@{ //@{
//! Virtual destructor. //! Virtual destructor.
virtual ~AnyError() virtual ~AnyError()
{ {
} }
//@} //@}
@ -77,8 +77,8 @@ namespace Exiv2 {
/*! /*!
@brief Return the error message. Consider using the output operator @brief Return the error message. Consider using the output operator
operator<<(std::ostream &os, const AnyError& error) instead. operator<<(std::ostream &os, const AnyError& error) instead.
@note Unlike std::exception::what(), this function returns an @note Unlike std::exception::what(), this function returns an
std::string. std::string.
*/ */
virtual std::string what() const =0; virtual std::string what() const =0;
}; // AnyError }; // AnyError
@ -90,13 +90,13 @@ namespace Exiv2 {
} }
/*! /*!
@brief Simple error class used for exceptions. An output operator is @brief Simple error class used for exceptions. An output operator is
provided to print errors to a stream. provided to print errors to a stream.
*/ */
class Error : public AnyError { class Error : public AnyError {
public: public:
//! @name Creators //! @name Creators
//@{ //@{
//! Constructor taking only an error code //! Constructor taking only an error code
explicit Error(int code) explicit Error(int code)
: code_(code), count_(0) : code_(code), count_(0)
@ -117,9 +117,9 @@ namespace Exiv2 {
} }
//! Constructor taking an error code and three arguments //! Constructor taking an error code and three arguments
template<typename A, typename B, typename C> template<typename A, typename B, typename C>
Error(int code, const A& arg1, const B& arg2, const C& arg3) Error(int code, const A& arg1, const B& arg2, const C& arg3)
: code_(code), count_(3), : code_(code), count_(3),
arg1_(toString(arg1)), arg2_(toString(arg2)), arg3_(toString(arg3)) arg1_(toString(arg1)), arg2_(toString(arg2)), arg3_(toString(arg3))
{ {
} }
//@} //@}

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -29,8 +29,8 @@
#include "rcsid.hpp" #include "rcsid.hpp"
EXIV2_RCSID("@(#) $Id$"); EXIV2_RCSID("@(#) $Id$");
// Define DEBUG_MAKERNOTE to output debug information to std::cerr, e.g, by // Define DEBUG_MAKERNOTE to output debug information to std::cerr, e.g, by
// calling make like this: make DEFS=-DDEBUG_MAKERNOTE exif.o // calling make like this: make DEFS=-DDEBUG_MAKERNOTE exif.o
//#define DEBUG_MAKERNOTE //#define DEBUG_MAKERNOTE
// ***************************************************************************** // *****************************************************************************
@ -79,7 +79,7 @@ namespace {
void setOffsetTag(Exiv2::Ifd& ifd, void setOffsetTag(Exiv2::Ifd& ifd,
int idx, int idx,
uint16_t tag, uint16_t tag,
uint32_t offset, uint32_t offset,
Exiv2::ByteOrder byteOrder); Exiv2::ByteOrder byteOrder);
// Read file path into a DataBuf, which is returned. // Read file path into a DataBuf, which is returned.
@ -97,7 +97,7 @@ namespace Exiv2 {
setValue(e, byteOrder); setValue(e, byteOrder);
} }
Exifdatum::Exifdatum(const ExifKey& key, const Value* pValue) Exifdatum::Exifdatum(const ExifKey& key, const Value* pValue)
: key_(key.clone()) : key_(key.clone())
{ {
if (pValue) value_ = pValue->clone(); if (pValue) value_ = pValue->clone();
@ -114,10 +114,10 @@ namespace Exiv2 {
if (rhs.value_.get() != 0) value_ = rhs.value_->clone(); // deep copy if (rhs.value_.get() != 0) value_ = rhs.value_->clone(); // deep copy
} }
const Value& Exifdatum::value() const const Value& Exifdatum::value() const
{ {
if (value_.get() == 0) throw Error(8); if (value_.get() == 0) throw Error(8);
return *value_; return *value_;
} }
Exifdatum& Exifdatum::operator=(const Exifdatum& rhs) Exifdatum& Exifdatum::operator=(const Exifdatum& rhs)
@ -133,41 +133,41 @@ namespace Exiv2 {
return *this; return *this;
} // Exifdatum::operator= } // Exifdatum::operator=
Exifdatum& Exifdatum::operator=(const std::string& value) Exifdatum& Exifdatum::operator=(const std::string& value)
{ {
setValue(value); setValue(value);
return *this; return *this;
} }
Exifdatum& Exifdatum::operator=(const uint16_t& value) Exifdatum& Exifdatum::operator=(const uint16_t& value)
{ {
return Exiv2::setValue(*this, value); return Exiv2::setValue(*this, value);
} }
Exifdatum& Exifdatum::operator=(const uint32_t& value) Exifdatum& Exifdatum::operator=(const uint32_t& value)
{ {
return Exiv2::setValue(*this, value); return Exiv2::setValue(*this, value);
} }
Exifdatum& Exifdatum::operator=(const URational& value) Exifdatum& Exifdatum::operator=(const URational& value)
{ {
return Exiv2::setValue(*this, value); return Exiv2::setValue(*this, value);
} }
Exifdatum& Exifdatum::operator=(const int16_t& value) Exifdatum& Exifdatum::operator=(const int16_t& value)
{ {
return Exiv2::setValue(*this, value); return Exiv2::setValue(*this, value);
} }
Exifdatum& Exifdatum::operator=(const int32_t& value) Exifdatum& Exifdatum::operator=(const int32_t& value)
{ {
return Exiv2::setValue(*this, value); return Exiv2::setValue(*this, value);
} }
Exifdatum& Exifdatum::operator=(const Rational& value) Exifdatum& Exifdatum::operator=(const Rational& value)
{ {
return Exiv2::setValue(*this, value); return Exiv2::setValue(*this, value);
} }
Exifdatum& Exifdatum::operator=(const Value& value) Exifdatum& Exifdatum::operator=(const Value& value)
@ -200,7 +200,7 @@ namespace Exiv2 {
TiffThumbnail& TiffThumbnail::operator=(const TiffThumbnail& /*rhs*/) TiffThumbnail& TiffThumbnail::operator=(const TiffThumbnail& /*rhs*/)
{ {
return *this; return *this;
} }
int TiffThumbnail::setDataArea(ExifData& exifData, Ifd* pIfd1, int TiffThumbnail::setDataArea(ExifData& exifData, Ifd* pIfd1,
@ -218,7 +218,7 @@ namespace Exiv2 {
} }
DataBuf stripsBuf(totalSize); DataBuf stripsBuf(totalSize);
// Copy all strips into the data buffer. For each strip remember its // Copy all strips into the data buffer. For each strip remember its
// offset from the start of the data buffer // offset from the start of the data buffer
ExifData::iterator stripOffsets; ExifData::iterator stripOffsets;
key = ExifKey("Exif.Thumbnail.StripOffsets"); key = ExifKey("Exif.Thumbnail.StripOffsets");
@ -243,7 +243,7 @@ namespace Exiv2 {
currentOffset += size; currentOffset += size;
} }
// Set StripOffsets data area and relative offsets // Set StripOffsets data area and relative offsets
stripOffsets->setDataArea(stripsBuf.pData_, stripsBuf.size_); stripOffsets->setDataArea(stripsBuf.pData_, stripsBuf.size_);
stripOffsets->setValue(os.str()); stripOffsets->setValue(os.str());
@ -287,9 +287,9 @@ namespace Exiv2 {
return buf; return buf;
} }
JpegThumbnail& JpegThumbnail::operator=(const JpegThumbnail& /*rhs*/) JpegThumbnail& JpegThumbnail::operator=(const JpegThumbnail& /*rhs*/)
{ {
return *this; return *this;
} }
int JpegThumbnail::setDataArea(ExifData& exifData, Ifd* pIfd1, int JpegThumbnail::setDataArea(ExifData& exifData, Ifd* pIfd1,
@ -332,16 +332,16 @@ namespace Exiv2 {
return format->dataArea(); return format->dataArea();
} }
ExifData::ExifData() ExifData::ExifData()
: pTiffHeader_(0), : pTiffHeader_(0),
pIfd0_(0), pExifIfd_(0), pIopIfd_(0), pGpsIfd_(0), pIfd1_(0), pIfd0_(0), pExifIfd_(0), pIopIfd_(0), pGpsIfd_(0), pIfd1_(0),
pMakerNote_(0), size_(0), pData_(0), compatible_(true) pMakerNote_(0), size_(0), pData_(0), compatible_(true)
{ {
} }
ExifData::ExifData(const ExifData& rhs) ExifData::ExifData(const ExifData& rhs)
: exifMetadata_(rhs.exifMetadata_), pTiffHeader_(0), : exifMetadata_(rhs.exifMetadata_), pTiffHeader_(0),
pIfd0_(0), pExifIfd_(0), pIopIfd_(0), pGpsIfd_(0), pIfd1_(0), pIfd0_(0), pExifIfd_(0), pIopIfd_(0), pGpsIfd_(0), pIfd1_(0),
pMakerNote_(0), size_(0), pData_(0), compatible_(rhs.compatible_) pMakerNote_(0), size_(0), pData_(0), compatible_(rhs.compatible_)
{ {
pData_ = new byte[rhs.size_]; pData_ = new byte[rhs.size_];
@ -475,7 +475,7 @@ namespace Exiv2 {
// Read IFD0 // Read IFD0
delete pIfd0_; delete pIfd0_;
pIfd0_ = new Ifd(ifd0Id, 0, false); pIfd0_ = new Ifd(ifd0Id, 0, false);
assert(pIfd0_ != 0); assert(pIfd0_ != 0);
rc = pIfd0_->read(pData_, size_, pTiffHeader_->offset(), byteOrder()); rc = pIfd0_->read(pData_, size_, pTiffHeader_->offset(), byteOrder());
if (rc) return rc; if (rc) return rc;
@ -486,11 +486,11 @@ namespace Exiv2 {
// Find and read ExifIFD sub-IFD of IFD0 // Find and read ExifIFD sub-IFD of IFD0
rc = pIfd0_->readSubIfd(*pExifIfd_, pData_, size_, byteOrder(), 0x8769); rc = pIfd0_->readSubIfd(*pExifIfd_, pData_, size_, byteOrder(), 0x8769);
if (rc) return rc; if (rc) return rc;
// Find MakerNote in ExifIFD, create a MakerNote class // Find MakerNote in ExifIFD, create a MakerNote class
Ifd::iterator pos = pExifIfd_->findTag(0x927c); Ifd::iterator pos = pExifIfd_->findTag(0x927c);
Ifd::iterator make = pIfd0_->findTag(0x010f); Ifd::iterator make = pIfd0_->findTag(0x010f);
Ifd::iterator model = pIfd0_->findTag(0x0110); Ifd::iterator model = pIfd0_->findTag(0x0110);
if ( pos != pExifIfd_->end() if ( pos != pExifIfd_->end()
&& make != pIfd0_->end() && model != pIfd0_->end()) { && make != pIfd0_->end() && model != pIfd0_->end()) {
// Todo: The conversion to string assumes that there is a \0 at the end // Todo: The conversion to string assumes that there is a \0 at the end
// Todo: How to avoid the cast (is that a MSVC thing?) // Todo: How to avoid the cast (is that a MSVC thing?)
@ -498,14 +498,14 @@ namespace Exiv2 {
reinterpret_cast<const char*>(make->data()), reinterpret_cast<const char*>(make->data()),
reinterpret_cast<const char*>(model->data()), reinterpret_cast<const char*>(model->data()),
false, false,
pos->data(), pos->data(),
pos->size(), pos->size(),
byteOrder(), byteOrder(),
pExifIfd_->offset() + pos->offset()).release(); pExifIfd_->offset() + pos->offset()).release();
} }
// Read the MakerNote // Read the MakerNote
if (pMakerNote_) { if (pMakerNote_) {
rc = pMakerNote_->read(pData_, size_, rc = pMakerNote_->read(pData_, size_,
pExifIfd_->offset() + pos->offset(), pExifIfd_->offset() + pos->offset(),
byteOrder()); byteOrder());
if (rc) { if (rc) {
@ -562,11 +562,11 @@ namespace Exiv2 {
add(pIfd0_->begin(), pIfd0_->end(), byteOrder()); add(pIfd0_->begin(), pIfd0_->end(), byteOrder());
add(pExifIfd_->begin(), pExifIfd_->end(), byteOrder()); add(pExifIfd_->begin(), pExifIfd_->end(), byteOrder());
if (pMakerNote_) { if (pMakerNote_) {
add(pMakerNote_->begin(), pMakerNote_->end(), add(pMakerNote_->begin(), pMakerNote_->end(),
(pMakerNote_->byteOrder() == invalidByteOrder ? (pMakerNote_->byteOrder() == invalidByteOrder ?
byteOrder() : pMakerNote_->byteOrder())); byteOrder() : pMakerNote_->byteOrder()));
} }
add(pIopIfd_->begin(), pIopIfd_->end(), byteOrder()); add(pIopIfd_->begin(), pIopIfd_->end(), byteOrder());
add(pGpsIfd_->begin(), pGpsIfd_->end(), byteOrder()); add(pGpsIfd_->begin(), pGpsIfd_->end(), byteOrder());
add(pIfd1_->begin(), pIfd1_->end(), byteOrder()); add(pIfd1_->begin(), pIfd1_->end(), byteOrder());
// Read the thumbnail (but don't worry whether it was successful or not) // Read the thumbnail (but don't worry whether it was successful or not)
@ -612,8 +612,8 @@ namespace Exiv2 {
if (pMakerNote_) { if (pMakerNote_) {
// Build MakerNote from metadata // Build MakerNote from metadata
makerNote = pMakerNote_->create(); makerNote = pMakerNote_->create();
addToMakerNote(makerNote.get(), addToMakerNote(makerNote.get(),
begin(), end(), begin(), end(),
(pMakerNote_->byteOrder() == invalidByteOrder ? (pMakerNote_->byteOrder() == invalidByteOrder ?
byteOrder() : pMakerNote_->byteOrder())); byteOrder() : pMakerNote_->byteOrder()));
// Create a placeholder MakerNote entry of the correct size and // Create a placeholder MakerNote entry of the correct size and
@ -654,21 +654,21 @@ namespace Exiv2 {
bool addOffsetTag = false; bool addOffsetTag = false;
long exifIfdOffset = ifd0Offset + ifd0.size() + ifd0.dataSize(); long exifIfdOffset = ifd0Offset + ifd0.size() + ifd0.dataSize();
if (exifIfd.size() > 0 || iopIfd.size() > 0) { if (exifIfd.size() > 0 || iopIfd.size() > 0) {
exifIfdOffset += 12; exifIfdOffset += 12;
addOffsetTag = true; addOffsetTag = true;
} }
if (gpsIfd.size() > 0) { if (gpsIfd.size() > 0) {
exifIfdOffset += 12; exifIfdOffset += 12;
addOffsetTag = true; addOffsetTag = true;
} }
if (ifd0.size() == 0 && addOffsetTag) { if (ifd0.size() == 0 && addOffsetTag) {
exifIfdOffset += 6; exifIfdOffset += 6;
} }
addOffsetTag = false; addOffsetTag = false;
long iopIfdOffset = exifIfdOffset + exifIfd.size() + exifIfd.dataSize(); long iopIfdOffset = exifIfdOffset + exifIfd.size() + exifIfd.dataSize();
if (iopIfd.size() > 0) { if (iopIfd.size() > 0) {
iopIfdOffset += 12; iopIfdOffset += 12;
addOffsetTag = true; addOffsetTag = true;
} }
if (exifIfd.size() == 0 && addOffsetTag) { if (exifIfd.size() == 0 && addOffsetTag) {
iopIfdOffset += 6; iopIfdOffset += 6;
@ -729,7 +729,7 @@ namespace Exiv2 {
return buf; return buf;
} // ExifData::copyFromMetadata } // ExifData::copyFromMetadata
void ExifData::add(Entries::const_iterator begin, void ExifData::add(Entries::const_iterator begin,
Entries::const_iterator end, Entries::const_iterator end,
ByteOrder byteOrder) ByteOrder byteOrder)
{ {
@ -749,7 +749,7 @@ namespace Exiv2 {
if (ExifTags::isMakerIfd(exifdatum.ifdId())) { if (ExifTags::isMakerIfd(exifdatum.ifdId())) {
if (pMakerNote_ == 0) { if (pMakerNote_ == 0) {
pMakerNote_ = MakerNoteFactory::create(exifdatum.ifdId()).release(); pMakerNote_ = MakerNoteFactory::create(exifdatum.ifdId()).release();
} }
if (pMakerNote_ == 0) throw Error(23, exifdatum.ifdId()); if (pMakerNote_ == 0) throw Error(23, exifdatum.ifdId());
} }
// allow duplicates // allow duplicates
@ -804,7 +804,7 @@ namespace Exiv2 {
(*this)["Exif.Thumbnail.JPEGInterchangeFormatLength"] = uint32_t(size); (*this)["Exif.Thumbnail.JPEGInterchangeFormatLength"] = uint32_t(size);
} }
void ExifData::setJpegThumbnail(const byte* buf, long size, void ExifData::setJpegThumbnail(const byte* buf, long size,
URational xres, URational yres, uint16_t unit) URational xres, URational yres, uint16_t unit)
{ {
setJpegThumbnail(buf, size); setJpegThumbnail(buf, size);
@ -819,7 +819,7 @@ namespace Exiv2 {
setJpegThumbnail(thumb.pData_, thumb.size_); setJpegThumbnail(thumb.pData_, thumb.size_);
} }
void ExifData::setJpegThumbnail(const std::string& path, void ExifData::setJpegThumbnail(const std::string& path,
URational xres, URational yres, uint16_t unit) URational xres, URational yres, uint16_t unit)
{ {
DataBuf thumb = readFile(path); // may throw DataBuf thumb = readFile(path); // may throw
@ -830,8 +830,8 @@ namespace Exiv2 {
{ {
// First, determine if the thumbnail is at the end of the Exif data // First, determine if the thumbnail is at the end of the Exif data
bool stp = stdThumbPosition(); bool stp = stdThumbPosition();
// Delete all Exif.Thumbnail.* (IFD1) metadata // Delete all Exif.Thumbnail.* (IFD1) metadata
ExifMetadata::iterator i = begin(); ExifMetadata::iterator i = begin();
while (i != end()) { while (i != end()) {
if (i->ifdId() == ifd1Id) { if (i->ifdId() == ifd1Id) {
i = erase(i); i = erase(i);
@ -861,7 +861,7 @@ namespace Exiv2 {
bool ExifData::stdThumbPosition() const bool ExifData::stdThumbPosition() const
{ {
if ( pIfd0_ == 0 || pExifIfd_ == 0 || pIopIfd_ == 0 if ( pIfd0_ == 0 || pExifIfd_ == 0 || pIopIfd_ == 0
|| pGpsIfd_ == 0 || pIfd1_ == 0) return true; || pGpsIfd_ == 0 || pIfd1_ == 0) return true;
// Todo: There is still an invalid assumption here: The data of an IFD // Todo: There is still an invalid assumption here: The data of an IFD
@ -875,7 +875,7 @@ namespace Exiv2 {
long maxOffset; long maxOffset;
maxOffset = std::max(pIfd0_->offset(), pIfd0_->dataOffset()); maxOffset = std::max(pIfd0_->offset(), pIfd0_->dataOffset());
maxOffset = std::max(maxOffset, pExifIfd_->offset()); maxOffset = std::max(maxOffset, pExifIfd_->offset());
maxOffset = std::max(maxOffset, pExifIfd_->dataOffset() maxOffset = std::max(maxOffset, pExifIfd_->dataOffset()
+ pExifIfd_->dataSize()); + pExifIfd_->dataSize());
if (pMakerNote_) { if (pMakerNote_) {
maxOffset = std::max(maxOffset, pMakerNote_->offset() maxOffset = std::max(maxOffset, pMakerNote_->offset()
@ -909,12 +909,12 @@ namespace Exiv2 {
} // ExifData::hasMakerNote } // ExifData::hasMakerNote
ByteOrder ExifData::byteOrder() const ByteOrder ExifData::byteOrder() const
{ {
if (pTiffHeader_) return pTiffHeader_->byteOrder(); if (pTiffHeader_) return pTiffHeader_->byteOrder();
return littleEndian; return littleEndian;
} }
int ExifData::writeThumbnail(const std::string& path) const int ExifData::writeThumbnail(const std::string& path) const
{ {
Thumbnail::AutoPtr thumbnail = getThumbnail(); Thumbnail::AutoPtr thumbnail = getThumbnail();
if (thumbnail.get() == 0) return 8; if (thumbnail.get() == 0) return 8;
@ -947,7 +947,7 @@ namespace Exiv2 {
return thumbnail->format(); return thumbnail->format();
} }
const char* ExifData::thumbnailExtension() const const char* ExifData::thumbnailExtension() const
{ {
Thumbnail::AutoPtr thumbnail = getThumbnail(); Thumbnail::AutoPtr thumbnail = getThumbnail();
if (thumbnail.get() == 0) return ""; if (thumbnail.get() == 0) return "";
@ -984,7 +984,7 @@ namespace Exiv2 {
bool ExifData::updateEntries() bool ExifData::updateEntries()
{ {
if ( pIfd0_ == 0 || pExifIfd_ == 0 || pIopIfd_ == 0 if ( pIfd0_ == 0 || pExifIfd_ == 0 || pIopIfd_ == 0
|| pGpsIfd_ == 0 || pIfd1_ == 0) return false; || pGpsIfd_ == 0 || pIfd1_ == 0) return false;
if (!this->compatible()) return false; if (!this->compatible()) return false;
@ -992,8 +992,8 @@ namespace Exiv2 {
compatible &= updateRange(pIfd0_->begin(), pIfd0_->end(), byteOrder()); compatible &= updateRange(pIfd0_->begin(), pIfd0_->end(), byteOrder());
compatible &= updateRange(pExifIfd_->begin(), pExifIfd_->end(), byteOrder()); compatible &= updateRange(pExifIfd_->begin(), pExifIfd_->end(), byteOrder());
if (pMakerNote_) { if (pMakerNote_) {
compatible &= updateRange(pMakerNote_->begin(), compatible &= updateRange(pMakerNote_->begin(),
pMakerNote_->end(), pMakerNote_->end(),
(pMakerNote_->byteOrder() == invalidByteOrder ? (pMakerNote_->byteOrder() == invalidByteOrder ?
byteOrder() : pMakerNote_->byteOrder())); byteOrder() : pMakerNote_->byteOrder()));
} }
@ -1004,7 +1004,7 @@ namespace Exiv2 {
return compatible; return compatible;
} // ExifData::updateEntries } // ExifData::updateEntries
bool ExifData::updateRange(const Entries::iterator& begin, bool ExifData::updateRange(const Entries::iterator& begin,
const Entries::iterator& end, const Entries::iterator& end,
ByteOrder byteOrder) ByteOrder byteOrder)
{ {
@ -1019,7 +1019,7 @@ namespace Exiv2 {
continue; continue;
} }
if (entry->count() == 0 && md->count() == 0) { if (entry->count() == 0 && md->count() == 0) {
// Special case: don't do anything if both the entry and // Special case: don't do anything if both the entry and
// Exifdatum have no data. This is to preserve the original // Exifdatum have no data. This is to preserve the original
// data in the offset field of an IFD entry with count 0, // data in the offset field of an IFD entry with count 0,
// if the Exifdatum was not changed. // if the Exifdatum was not changed.
@ -1037,13 +1037,13 @@ namespace Exiv2 {
// header and that is currently only done in intrusive write // header and that is currently only done in intrusive write
// mode). On the other hand, it is thus now not possible to // mode). On the other hand, it is thus now not possible to
// change the offsets of an entry with a data area in // change the offsets of an entry with a data area in
// non-intrusive mode. This can be considered a bug. // non-intrusive mode. This can be considered a bug.
// Todo: Fix me! // Todo: Fix me!
if (md->sizeDataArea() == 0) { if (md->sizeDataArea() == 0) {
DataBuf buf(md->size()); DataBuf buf(md->size());
md->copy(buf.pData_, byteOrder); md->copy(buf.pData_, byteOrder);
entry->setValue(static_cast<uint16_t>(md->typeId()), entry->setValue(static_cast<uint16_t>(md->typeId()),
md->count(), md->count(),
buf.pData_, md->size()); buf.pData_, md->size());
} }
// Always set the data area // Always set the data area
@ -1069,7 +1069,7 @@ namespace Exiv2 {
} }
// Make sure that the size of the Exifdatum fits the available size // Make sure that the size of the Exifdatum fits the available size
// of the entry // of the entry
if ( md->size() > rc.second->size() if ( md->size() > rc.second->size()
|| md->sizeDataArea() > rc.second->sizeDataArea()) { || md->sizeDataArea() > rc.second->sizeDataArea()) {
compatible = false; compatible = false;
break; break;
@ -1078,7 +1078,7 @@ namespace Exiv2 {
return compatible; return compatible;
} // ExifData::compatible } // ExifData::compatible
std::pair<bool, Entries::const_iterator> std::pair<bool, Entries::const_iterator>
ExifData::findEntry(IfdId ifdId, int idx) const ExifData::findEntry(IfdId ifdId, int idx) const
{ {
Entries::const_iterator entry; Entries::const_iterator entry;
@ -1107,19 +1107,19 @@ namespace Exiv2 {
{ {
const Ifd* ifd = 0; const Ifd* ifd = 0;
switch (ifdId) { switch (ifdId) {
case ifd0Id: case ifd0Id:
ifd = pIfd0_; ifd = pIfd0_;
break; break;
case exifIfdId: case exifIfdId:
ifd = pExifIfd_; ifd = pExifIfd_;
break; break;
case iopIfdId: case iopIfdId:
ifd = pIopIfd_; ifd = pIopIfd_;
break; break;
case gpsIfdId: case gpsIfdId:
ifd = pGpsIfd_; ifd = pGpsIfd_;
break; break;
case ifd1Id: case ifd1Id:
ifd = pIfd1_; ifd = pIfd1_;
break; break;
default: default:
@ -1132,9 +1132,9 @@ namespace Exiv2 {
// ************************************************************************* // *************************************************************************
// free functions // free functions
void addToIfd(Ifd& ifd, void addToIfd(Ifd& ifd,
ExifMetadata::const_iterator begin, ExifMetadata::const_iterator begin,
ExifMetadata::const_iterator end, ExifMetadata::const_iterator end,
ByteOrder byteOrder) ByteOrder byteOrder)
{ {
for (ExifMetadata::const_iterator i = begin; i != end; ++i) { for (ExifMetadata::const_iterator i = begin; i != end; ++i) {
@ -1157,8 +1157,8 @@ namespace Exiv2 {
DataBuf buf(md.size()); DataBuf buf(md.size());
md.copy(buf.pData_, byteOrder); md.copy(buf.pData_, byteOrder);
e.setValue(static_cast<uint16_t>(md.typeId()), md.count(), e.setValue(static_cast<uint16_t>(md.typeId()), md.count(),
buf.pData_, buf.size_); buf.pData_, buf.size_);
DataBuf dataArea(md.dataArea()); DataBuf dataArea(md.dataArea());
e.setDataArea(dataArea.pData_, dataArea.size_); e.setDataArea(dataArea.pData_, dataArea.size_);
@ -1168,7 +1168,7 @@ namespace Exiv2 {
void addToMakerNote(MakerNote* makerNote, void addToMakerNote(MakerNote* makerNote,
ExifMetadata::const_iterator begin, ExifMetadata::const_iterator begin,
ExifMetadata::const_iterator end, ExifMetadata::const_iterator end,
ByteOrder byteOrder) ByteOrder byteOrder)
{ {
for (ExifMetadata::const_iterator i = begin; i != end; ++i) { for (ExifMetadata::const_iterator i = begin; i != end; ++i) {
@ -1178,8 +1178,8 @@ namespace Exiv2 {
} }
} // addToMakerNote } // addToMakerNote
void addToMakerNote(MakerNote* makerNote, void addToMakerNote(MakerNote* makerNote,
const Exifdatum& md, const Exifdatum& md,
ByteOrder byteOrder) ByteOrder byteOrder)
{ {
Entry e; Entry e;
@ -1191,7 +1191,7 @@ namespace Exiv2 {
DataBuf buf(md.size()); DataBuf buf(md.size());
md.copy(buf.pData_, byteOrder); md.copy(buf.pData_, byteOrder);
e.setValue(static_cast<uint16_t>(md.typeId()), md.count(), e.setValue(static_cast<uint16_t>(md.typeId()), md.count(),
buf.pData_, md.size()); buf.pData_, md.size());
DataBuf dataArea(md.dataArea()); DataBuf dataArea(md.dataArea());
e.setDataArea(dataArea.pData_, dataArea.size_); e.setDataArea(dataArea.pData_, dataArea.size_);
@ -1212,7 +1212,7 @@ namespace {
void setOffsetTag(Exiv2::Ifd& ifd, void setOffsetTag(Exiv2::Ifd& ifd,
int idx, int idx,
uint16_t tag, uint16_t tag,
uint32_t offset, uint32_t offset,
Exiv2::ByteOrder byteOrder) Exiv2::ByteOrder byteOrder)
{ {
Exiv2::Ifd::iterator pos = ifd.findTag(tag); Exiv2::Ifd::iterator pos = ifd.findTag(tag);
@ -1243,7 +1243,7 @@ namespace {
if (len != buf.size_) { if (len != buf.size_) {
throw Exiv2::Error(2, path, Exiv2::strError(), "FileIo::read"); throw Exiv2::Error(2, path, Exiv2::strError(), "FileIo::read");
} }
return buf; return buf;
} }
} }

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -47,7 +47,7 @@
// namespace extensions // namespace extensions
/*! /*!
@brief Provides classes and functions to encode and decode Exif and Iptc data. @brief Provides classes and functions to encode and decode Exif and Iptc data.
This namespace corresponds to the <b>libexiv2</b> library. This namespace corresponds to the <b>libexiv2</b> library.
*/ */
namespace Exiv2 { namespace Exiv2 {
@ -74,7 +74,7 @@ namespace Exiv2 {
/*! /*!
@brief Constructor for new tags created by an application. The @brief Constructor for new tags created by an application. The
%Exifdatum is created from a \em key / value pair. %Exifdatum copies %Exifdatum is created from a \em key / value pair. %Exifdatum copies
(clones) the \em key and value if one is provided. Alternatively, (clones) the \em key and value if one is provided. Alternatively,
a program can create an 'empty' %Exifdatum with only a key a program can create an 'empty' %Exifdatum with only a key
and set the value using setValue(). and set the value using setValue().
@ -99,7 +99,7 @@ namespace Exiv2 {
@brief Assign \em value to the %Exifdatum. The type of the new Value @brief Assign \em value to the %Exifdatum. The type of the new Value
is set to UShortValue. is set to UShortValue.
*/ */
Exifdatum& operator=(const uint16_t& value); Exifdatum& operator=(const uint16_t& value);
/*! /*!
@brief Assign \em value to the %Exifdatum. The type of the new Value @brief Assign \em value to the %Exifdatum. The type of the new Value
is set to ULongValue. is set to ULongValue.
@ -127,7 +127,7 @@ namespace Exiv2 {
Exifdatum& operator=(const Rational& value); Exifdatum& operator=(const Rational& value);
/*! /*!
@brief Assign \em value to the %Exifdatum. @brief Assign \em value to the %Exifdatum.
Calls setValue(const std::string&). Calls setValue(const std::string&).
*/ */
Exifdatum& operator=(const std::string& value); Exifdatum& operator=(const std::string& value);
/*! /*!
@ -152,7 +152,7 @@ namespace Exiv2 {
*/ */
void setValue(const Entry& e, ByteOrder byteOrder); void setValue(const Entry& e, ByteOrder byteOrder);
/*! /*!
@brief Set the data area by copying (cloning) the buffer pointed to @brief Set the data area by copying (cloning) the buffer pointed to
by \em buf. by \em buf.
Values may have a data area, which can contain additional Values may have a data area, which can contain additional
@ -164,14 +164,14 @@ namespace Exiv2 {
@return Return -1 if the %Exifdatum does not have a value yet or the @return Return -1 if the %Exifdatum does not have a value yet or the
value has no data area, else 0. value has no data area, else 0.
*/ */
int setDataArea(const byte* buf, long len) int setDataArea(const byte* buf, long len)
{ return value_.get() == 0 ? -1 : value_->setDataArea(buf, len); } { return value_.get() == 0 ? -1 : value_->setDataArea(buf, len); }
//@} //@}
//! @name Accessors //! @name Accessors
//@{ //@{
//! Return the key of the %Exifdatum. //! Return the key of the %Exifdatum.
std::string key() const std::string key() const
{ return key_.get() == 0 ? "" : key_->key(); } { return key_.get() == 0 ? "" : key_->key(); }
//! Return the name of the group (the second part of the key) //! Return the name of the group (the second part of the key)
std::string groupName() const std::string groupName() const
@ -183,13 +183,13 @@ namespace Exiv2 {
uint16_t tag() const uint16_t tag() const
{ return key_.get() == 0 ? 0xffff : key_->tag(); } { return key_.get() == 0 ? 0xffff : key_->tag(); }
//! Return the IFD id //! Return the IFD id
IfdId ifdId() const IfdId ifdId() const
{ return key_.get() == 0 ? ifdIdNotSet : key_->ifdId(); } { return key_.get() == 0 ? ifdIdNotSet : key_->ifdId(); }
//! Return the name of the IFD //! Return the name of the IFD
const char* ifdName() const const char* ifdName() const
{ return key_.get() == 0 ? "" : key_->ifdName(); } { return key_.get() == 0 ? "" : key_->ifdName(); }
//! Return the related image item (deprecated) //! Return the related image item (deprecated)
std::string ifdItem() const std::string ifdItem() const
{ return key_.get() == 0 ? "" : key_->ifdItem(); } { return key_.get() == 0 ? "" : key_->ifdItem(); }
//! Return the index (unique id of this key within the original IFD) //! Return the index (unique id of this key within the original IFD)
int idx() const int idx() const
@ -205,25 +205,25 @@ namespace Exiv2 {
@param byteOrder Applicable byte order (little or big endian). @param byteOrder Applicable byte order (little or big endian).
@return Number of characters written. @return Number of characters written.
*/ */
long copy(byte* buf, ByteOrder byteOrder) const long copy(byte* buf, ByteOrder byteOrder) const
{ return value_.get() == 0 ? 0 : value_->copy(buf, byteOrder); } { return value_.get() == 0 ? 0 : value_->copy(buf, byteOrder); }
//! Return the type id of the value //! Return the type id of the value
TypeId typeId() const TypeId typeId() const
{ return value_.get() == 0 ? invalidTypeId : value_->typeId(); } { return value_.get() == 0 ? invalidTypeId : value_->typeId(); }
//! Return the name of the type //! Return the name of the type
const char* typeName() const const char* typeName() const
{ return TypeInfo::typeName(typeId()); } { return TypeInfo::typeName(typeId()); }
//! Return the size in bytes of one component of this type //! Return the size in bytes of one component of this type
long typeSize() const long typeSize() const
{ return TypeInfo::typeSize(typeId()); } { return TypeInfo::typeSize(typeId()); }
//! Return the number of components in the value //! Return the number of components in the value
long count() const long count() const
{ return value_.get() == 0 ? 0 : value_->count(); } { return value_.get() == 0 ? 0 : value_->count(); }
//! Return the size of the value in bytes //! Return the size of the value in bytes
long size() const long size() const
{ return value_.get() == 0 ? 0 : value_->size(); } { return value_.get() == 0 ? 0 : value_->size(); }
//! Return the value as a string. //! Return the value as a string.
std::string toString() const std::string toString() const
{ return value_.get() == 0 ? "" : value_->toString(); } { return value_.get() == 0 ? "" : value_->toString(); }
/*! /*!
@brief Return the <EM>n</EM>-th component of the value converted to @brief Return the <EM>n</EM>-th component of the value converted to
@ -231,7 +231,7 @@ namespace Exiv2 {
not set and the behaviour of the method is undefined if there not set and the behaviour of the method is undefined if there
is no n-th component. is no n-th component.
*/ */
long toLong(long n =0) const long toLong(long n =0) const
{ return value_.get() == 0 ? -1 : value_->toLong(n); } { return value_.get() == 0 ? -1 : value_->toLong(n); }
/*! /*!
@brief Return the <EM>n</EM>-th component of the value converted to @brief Return the <EM>n</EM>-th component of the value converted to
@ -239,7 +239,7 @@ namespace Exiv2 {
not set and the behaviour of the method is undefined if there not set and the behaviour of the method is undefined if there
is no n-th component. is no n-th component.
*/ */
float toFloat(long n =0) const float toFloat(long n =0) const
{ return value_.get() == 0 ? -1 : value_->toFloat(n); } { return value_.get() == 0 ? -1 : value_->toFloat(n); }
/*! /*!
@brief Return the <EM>n</EM>-th component of the value converted to @brief Return the <EM>n</EM>-th component of the value converted to
@ -247,30 +247,30 @@ namespace Exiv2 {
Exifdatum is not set and the behaviour of the method is Exifdatum is not set and the behaviour of the method is
undefined if there is no n-th component. undefined if there is no n-th component.
*/ */
Rational toRational(long n =0) const Rational toRational(long n =0) const
{ return value_.get() == 0 ? Rational(-1, 1) : value_->toRational(n); } { return value_.get() == 0 ? Rational(-1, 1) : value_->toRational(n); }
/*! /*!
@brief Return an auto-pointer to a copy (clone) of the value. The @brief Return an auto-pointer to a copy (clone) of the value. The
caller owns this copy and the auto-pointer ensures that it will caller owns this copy and the auto-pointer ensures that it will
be deleted. be deleted.
This method is provided for users who need full control over the This method is provided for users who need full control over the
value. A caller may, e.g., downcast the pointer to the appropriate value. A caller may, e.g., downcast the pointer to the appropriate
subclass of Value to make use of the interface of the subclass to set subclass of Value to make use of the interface of the subclass to set
or modify its contents. or modify its contents.
@return An auto-pointer to a copy (clone) of the value, 0 if the value @return An auto-pointer to a copy (clone) of the value, 0 if the value
is not set. is not set.
*/ */
Value::AutoPtr getValue() const Value::AutoPtr getValue() const
{ return value_.get() == 0 ? Value::AutoPtr(0) : value_->clone(); } { return value_.get() == 0 ? Value::AutoPtr(0) : value_->clone(); }
/*! /*!
@brief Return a constant reference to the value. @brief Return a constant reference to the value.
This method is provided mostly for convenient and versatile output of This method is provided mostly for convenient and versatile output of
the value which can (to some extent) be formatted through standard the value which can (to some extent) be formatted through standard
stream manipulators. Do not attempt to write to the value through stream manipulators. Do not attempt to write to the value through
this reference. this reference.
<b>Example:</b> <br> <b>Example:</b> <br>
@code @code
@ -283,9 +283,9 @@ namespace Exiv2 {
@return A constant reference to the value. @return A constant reference to the value.
@throw Error if the value is not set. @throw Error if the value is not set.
*/ */
const Value& value() const; const Value& value() const;
//! Return the size of the data area. //! Return the size of the data area.
long sizeDataArea() const long sizeDataArea() const
{ return value_.get() == 0 ? 0 : value_->sizeDataArea(); } { return value_.get() == 0 ? 0 : value_->sizeDataArea(); }
/*! /*!
@brief Return a copy of the data area of the value. The caller owns @brief Return a copy of the data area of the value. The caller owns
@ -306,7 +306,7 @@ namespace Exiv2 {
private: private:
// DATA // DATA
ExifKey::AutoPtr key_; //!< Key ExifKey::AutoPtr key_; //!< Key
Value::AutoPtr value_; //!< Value Value::AutoPtr value_; //!< Value
}; // class Exifdatum }; // class Exifdatum
@ -320,7 +320,7 @@ namespace Exiv2 {
/*! /*!
@brief Set the value of \em exifDatum to \em value. If the object already @brief Set the value of \em exifDatum to \em value. If the object already
has a value, it is replaced. Otherwise a new ValueType\<T\> value has a value, it is replaced. Otherwise a new ValueType\<T\> value
is created and set to \em value. is created and set to \em value.
This is a helper function, called from Exifdatum members. It is meant to This is a helper function, called from Exifdatum members. It is meant to
be used with T = (u)int16_t, (u)int32_t or (U)Rational. Do not use directly. be used with T = (u)int16_t, (u)int32_t or (U)Rational. Do not use directly.
@ -350,7 +350,7 @@ namespace Exiv2 {
//@{ //@{
/*! /*!
@brief Set the image data as data area of the appropriate Exif @brief Set the image data as data area of the appropriate Exif
metadatum. Read the thumbnail image data from data buffer metadatum. Read the thumbnail image data from data buffer
\em buf. Return 0 if successful. \em buf. Return 0 if successful.
@param exifData Exif data corresponding to the data buffer. @param exifData Exif data corresponding to the data buffer.
@ -362,7 +362,7 @@ namespace Exiv2 {
1 in case of inconsistent thumbnail Exif data; or<BR> 1 in case of inconsistent thumbnail Exif data; or<BR>
2 if the data area is outside of the data buffer 2 if the data area is outside of the data buffer
*/ */
virtual int setDataArea(ExifData& exifData, virtual int setDataArea(ExifData& exifData,
Ifd* pIfd1, Ifd* pIfd1,
const byte* buf, const byte* buf,
long len) const =0; long len) const =0;
@ -372,12 +372,12 @@ namespace Exiv2 {
*/ */
virtual DataBuf copy(const ExifData& exifData) const =0; virtual DataBuf copy(const ExifData& exifData) const =0;
/*! /*!
@brief Return a short string for the format of the thumbnail @brief Return a short string for the format of the thumbnail
("TIFF", "JPEG"). ("TIFF", "JPEG").
*/ */
virtual const char* format() const =0; virtual const char* format() const =0;
/*! /*!
@brief Return the file extension for the format of the thumbnail @brief Return the file extension for the format of the thumbnail
(".tif", ".jpg"). (".tif", ".jpg").
*/ */
virtual const char* extension() const =0; virtual const char* extension() const =0;
@ -409,8 +409,8 @@ namespace Exiv2 {
//! @name Accessors //! @name Accessors
//@{ //@{
int setDataArea(ExifData& exifData, int setDataArea(ExifData& exifData,
Ifd* pIfd1, Ifd* pIfd1,
const byte* buf, const byte* buf,
long len) const; long len) const;
DataBuf copy(const ExifData& exifData) const; DataBuf copy(const ExifData& exifData) const;
@ -434,8 +434,8 @@ namespace Exiv2 {
//! @name Accessors //! @name Accessors
//@{ //@{
int setDataArea(ExifData& exifData, int setDataArea(ExifData& exifData,
Ifd* pIfd1, Ifd* pIfd1,
const byte* buf, const byte* buf,
long len) const; long len) const;
DataBuf copy(const ExifData& exifData) const; DataBuf copy(const ExifData& exifData) const;
@ -464,7 +464,7 @@ namespace Exiv2 {
private: private:
IfdId ifdId_; IfdId ifdId_;
int idx_; int idx_;
}; // class FindMetadatumByIfdIdIdx }; // class FindMetadatumByIfdIdIdx
/*! /*!
@ -474,7 +474,7 @@ namespace Exiv2 {
Provide high-level access to the Exif data of an image: Provide high-level access to the Exif data of an image:
- read Exif information from JPEG files - read Exif information from JPEG files
- access metadata through keys and standard C++ iterators - access metadata through keys and standard C++ iterators
- add, modify and delete metadata - add, modify and delete metadata
- write Exif data to JPEG files - write Exif data to JPEG files
- extract Exif metadata to files, insert from these files - extract Exif metadata to files, insert from these files
- extract and delete Exif thumbnail (JPEG and TIFF thumbnails) - extract and delete Exif thumbnail (JPEG and TIFF thumbnails)
@ -504,7 +504,7 @@ namespace Exiv2 {
@brief Load the Exif data from a byte buffer. The data buffer @brief Load the Exif data from a byte buffer. The data buffer
must start with the TIFF header. must start with the TIFF header.
@param buf Pointer to the data buffer to read from @param buf Pointer to the data buffer to read from
@param len Number of bytes in the data buffer @param len Number of bytes in the data buffer
@return 0 if successful. @return 0 if successful.
*/ */
int load(const byte* buf, long len); int load(const byte* buf, long len);
@ -544,7 +544,7 @@ namespace Exiv2 {
checks are performed, i.e., it is possible to add multiple checks are performed, i.e., it is possible to add multiple
metadata with the same key. metadata with the same key.
*/ */
void add(Entries::const_iterator begin, void add(Entries::const_iterator begin,
Entries::const_iterator end, Entries::const_iterator end,
ByteOrder byteOrder); ByteOrder byteOrder);
/*! /*!
@ -563,9 +563,9 @@ namespace Exiv2 {
*/ */
void add(const Exifdatum& exifdatum); void add(const Exifdatum& exifdatum);
/*! /*!
@brief Delete the Exifdatum at iterator position \em pos, return the @brief Delete the Exifdatum at iterator position \em pos, return the
position of the next exifdatum. Note that iterators into position of the next exifdatum. Note that iterators into
the metadata, including \em pos, are potentially invalidated the metadata, including \em pos, are potentially invalidated
by this call. by this call.
*/ */
iterator erase(iterator pos); iterator erase(iterator pos);
@ -590,7 +590,7 @@ namespace Exiv2 {
iterator findKey(const ExifKey& key); iterator findKey(const ExifKey& key);
/*! /*!
@brief Find the Exifdatum with the given \em ifdId and \em idx, @brief Find the Exifdatum with the given \em ifdId and \em idx,
return an iterator to it. return an iterator to it.
This method can be used to uniquely identify an exifdatum that was This method can be used to uniquely identify an exifdatum that was
created from an IFD or from the makernote (with idx greater than created from an IFD or from the makernote (with idx greater than
@ -613,12 +613,12 @@ namespace Exiv2 {
@note No checks on the file format or size are performed. @note No checks on the file format or size are performed.
@note Additional existing Exif thumbnail tags are not modified. @note Additional existing Exif thumbnail tags are not modified.
@note The Jpeg image inserted as thumbnail image should not @note The Jpeg image inserted as thumbnail image should not
itself contain Exif data (or other metadata), as existing itself contain Exif data (or other metadata), as existing
applications may have problems with that. (The preview applications may have problems with that. (The preview
application that comes with OS X for one.) - David Harvey. application that comes with OS X for one.) - David Harvey.
*/ */
void setJpegThumbnail(const std::string& path, void setJpegThumbnail(const std::string& path,
URational xres, URational yres, uint16_t unit); URational xres, URational yres, uint16_t unit);
/*! /*!
@brief Set the Exif thumbnail to the Jpeg image pointed to by \em buf, @brief Set the Exif thumbnail to the Jpeg image pointed to by \em buf,
@ -632,15 +632,15 @@ namespace Exiv2 {
@note No checks on the image format or size are performed. @note No checks on the image format or size are performed.
@note Additional existing Exif thumbnail tags are not modified. @note Additional existing Exif thumbnail tags are not modified.
@note The Jpeg image inserted as thumbnail image should not @note The Jpeg image inserted as thumbnail image should not
itself contain Exif data (or other metadata), as existing itself contain Exif data (or other metadata), as existing
applications may have problems with that. (The preview applications may have problems with that. (The preview
application that comes with OS X for one.) - David Harvey. application that comes with OS X for one.) - David Harvey.
*/ */
void setJpegThumbnail(const byte* buf, long size, void setJpegThumbnail(const byte* buf, long size,
URational xres, URational yres, uint16_t unit); URational xres, URational yres, uint16_t unit);
/*! /*!
@brief Set the Exif thumbnail to the Jpeg image \em path. @brief Set the Exif thumbnail to the Jpeg image \em path.
This sets only the Compression, JPEGInterchangeFormat and This sets only the Compression, JPEGInterchangeFormat and
JPEGInterchangeFormatLength tags, which is not all the thumbnail JPEGInterchangeFormatLength tags, which is not all the thumbnail
@ -655,7 +655,7 @@ namespace Exiv2 {
void setJpegThumbnail(const std::string& path); void setJpegThumbnail(const std::string& path);
/*! /*!
@brief Set the Exif thumbnail to the Jpeg image pointed to by \em buf, @brief Set the Exif thumbnail to the Jpeg image pointed to by \em buf,
and size \em size. and size \em size.
This sets only the Compression, JPEGInterchangeFormat and This sets only the Compression, JPEGInterchangeFormat and
JPEGInterchangeFormatLength tags, which is not all the thumbnail JPEGInterchangeFormatLength tags, which is not all the thumbnail
@ -698,7 +698,7 @@ namespace Exiv2 {
const_iterator findKey(const ExifKey& key) const; const_iterator findKey(const ExifKey& key) const;
/*! /*!
@brief Find the exifdatum with the given \em ifdId and \em idx, @brief Find the exifdatum with the given \em ifdId and \em idx,
return an iterator to it. return an iterator to it.
This method can be used to uniquely identify a Exifdatum that was This method can be used to uniquely identify a Exifdatum that was
created from an IFD or from the makernote (with idx greater than created from an IFD or from the makernote (with idx greater than
@ -734,14 +734,14 @@ namespace Exiv2 {
@return 0 if successful;<BR> @return 0 if successful;<BR>
8 if the Exif data does not contain a thumbnail. 8 if the Exif data does not contain a thumbnail.
*/ */
int writeThumbnail(const std::string& path) const; int writeThumbnail(const std::string& path) const;
/*! /*!
@brief Return the thumbnail image in a %DataBuf. The caller owns the @brief Return the thumbnail image in a %DataBuf. The caller owns the
data buffer and %DataBuf ensures that it will be deleted. data buffer and %DataBuf ensures that it will be deleted.
*/ */
DataBuf copyThumbnail() const; DataBuf copyThumbnail() const;
/*! /*!
@brief Return a short string describing the format of the Exif @brief Return a short string describing the format of the Exif
thumbnail ("TIFF", "JPEG"). thumbnail ("TIFF", "JPEG").
*/ */
const char* thumbnailFormat() const; const char* thumbnailFormat() const;
@ -770,7 +770,7 @@ namespace Exiv2 {
/*! /*!
@brief Check if the metadata changed and update the internal IFDs and @brief Check if the metadata changed and update the internal IFDs and
the MakerNote if the changes are compatible with the existing the MakerNote if the changes are compatible with the existing
data (non-intrusive write support). data (non-intrusive write support).
@return True if only compatible changes were detected in the metadata @return True if only compatible changes were detected in the metadata
and the internal IFDs and MakerNote (and thus the data buffer) and the internal IFDs and MakerNote (and thus the data buffer)
@ -791,7 +791,7 @@ namespace Exiv2 {
/*! /*!
@brief Write the Exif data to a data buffer the hard way, return the @brief Write the Exif data to a data buffer the hard way, return the
data buffer. The caller owns this data buffer and %DataBuf data buffer. The caller owns this data buffer and %DataBuf
ensures that it will be deleted. ensures that it will be deleted.
Rebuilds the Exif data from scratch, using the TIFF header, metadata Rebuilds the Exif data from scratch, using the TIFF header, metadata
container and thumbnail. In particular, the internal IFDs and the container and thumbnail. In particular, the internal IFDs and the
@ -821,12 +821,12 @@ namespace Exiv2 {
@return A pair of which the first part determines if a match was found @return A pair of which the first part determines if a match was found
and, if true, the second contains an iterator to the entry. and, if true, the second contains an iterator to the entry.
*/ */
std::pair<bool, Entries::const_iterator> std::pair<bool, Entries::const_iterator>
findEntry(IfdId ifdId, int idx) const; findEntry(IfdId ifdId, int idx) const;
//! Return a pointer to the internal IFD identified by its IFD id //! Return a pointer to the internal IFD identified by its IFD id
const Ifd* getIfd(IfdId ifdId) const; const Ifd* getIfd(IfdId ifdId) const;
/*! /*!
@brief Check if IFD1, the IFD1 data and thumbnail data are located at @brief Check if IFD1, the IFD1 data and thumbnail data are located at
the end of the Exif data. Return true, if they are or if there the end of the Exif data. Return true, if they are or if there
is no thumbnail at all, else return false. is no thumbnail at all, else return false.
*/ */
@ -837,7 +837,7 @@ namespace Exiv2 {
ExifMetadata exifMetadata_; ExifMetadata exifMetadata_;
// The pointers below are used only if Exif data is read from a // The pointers below are used only if Exif data is read from a
// raw data buffer // raw data buffer
TiffHeader* pTiffHeader_; //! Pointer to the TIFF header TiffHeader* pTiffHeader_; //! Pointer to the TIFF header
Ifd* pIfd0_; //! Pointer to Ifd0 Ifd* pIfd0_; //! Pointer to Ifd0
Ifd* pExifIfd_; //! Pointer to ExifIfd Ifd* pExifIfd_; //! Pointer to ExifIfd
@ -860,11 +860,11 @@ namespace Exiv2 {
// ***************************************************************************** // *****************************************************************************
// template, inline and free functions // template, inline and free functions
template<typename T> template<typename T>
Exifdatum& setValue(Exifdatum& exifDatum, const T& value) Exifdatum& setValue(Exifdatum& exifDatum, const T& value)
{ {
std::auto_ptr<ValueType<T> > v std::auto_ptr<ValueType<T> > v
= std::auto_ptr<ValueType<T> >(new ValueType<T>); = std::auto_ptr<ValueType<T> >(new ValueType<T>);
v->value_.push_back(value); v->value_.push_back(value);
exifDatum.value_ = v; exifDatum.value_ = v;
@ -878,8 +878,8 @@ namespace Exiv2 {
the same key to an IFD. the same key to an IFD.
*/ */
void addToIfd(Ifd& ifd, void addToIfd(Ifd& ifd,
ExifMetadata::const_iterator begin, ExifMetadata::const_iterator begin,
ExifMetadata::const_iterator end, ExifMetadata::const_iterator end,
ByteOrder byteOrder); ByteOrder byteOrder);
/*! /*!
@brief Add the Exifdatum to the IFD. No duplicate checks are performed, @brief Add the Exifdatum to the IFD. No duplicate checks are performed,
@ -896,7 +896,7 @@ namespace Exiv2 {
*/ */
void addToMakerNote(MakerNote* makerNote, void addToMakerNote(MakerNote* makerNote,
ExifMetadata::const_iterator begin, ExifMetadata::const_iterator begin,
ExifMetadata::const_iterator end, ExifMetadata::const_iterator end,
ByteOrder byteOrder); ByteOrder byteOrder);
/*! /*!
@brief Add the Exifdatum to makerNote, encoded in byte order byteOrder. @brief Add the Exifdatum to makerNote, encoded in byte order byteOrder.

@ -32,7 +32,7 @@ try {
Exiv2::ExifData &exifData = image->exifData(); Exiv2::ExifData &exifData = image->exifData();
/* /*
Exiv2 uses a CommentValue for Exif user comments. The format of the Exiv2 uses a CommentValue for Exif user comments. The format of the
comment string includes an optional charset specification at the beginning: comment string includes an optional charset specification at the beginning:
[charset=["]Ascii|Jis|Unicode|Undefined["] ]comment [charset=["]Ascii|Jis|Unicode|Undefined["] ]comment
@ -43,13 +43,13 @@ try {
Following are a few examples of valid comments. The last one is written to Following are a few examples of valid comments. The last one is written to
the file. the file.
*/ */
exifData["Exif.Photo.UserComment"] exifData["Exif.Photo.UserComment"]
= "charset=\"Unicode\" An Unicode Exif comment added with Exiv2"; = "charset=\"Unicode\" An Unicode Exif comment added with Exiv2";
exifData["Exif.Photo.UserComment"] exifData["Exif.Photo.UserComment"]
= "charset=\"Undefined\" An undefined Exif comment added with Exiv2"; = "charset=\"Undefined\" An undefined Exif comment added with Exiv2";
exifData["Exif.Photo.UserComment"] exifData["Exif.Photo.UserComment"]
= "Another undefined Exif comment added with Exiv2"; = "Another undefined Exif comment added with Exiv2";
exifData["Exif.Photo.UserComment"] exifData["Exif.Photo.UserComment"]
= "charset=Ascii An ASCII Exif comment added with Exiv2"; = "charset=Ascii An ASCII Exif comment added with Exiv2";
std::cout << "Writing user comment '" std::cout << "Writing user comment '"

@ -122,15 +122,15 @@ void print(const std::string& file)
std::cout << std::setw(45) << std::setfill(' ') << std::left std::cout << std::setw(45) << std::setfill(' ') << std::left
<< i->key() << " " << i->key() << " "
<< "0x" << std::setw(4) << std::setfill('0') << std::right << "0x" << std::setw(4) << std::setfill('0') << std::right
<< std::hex << i->tag() << " " << std::hex << i->tag() << " "
<< std::setw(12) << std::setfill(' ') << std::left << std::setw(12) << std::setfill(' ') << std::left
<< i->ifdName() << " " << i->ifdName() << " "
<< std::setw(9) << std::setfill(' ') << std::left << std::setw(9) << std::setfill(' ') << std::left
<< i->typeName() << " " << i->typeName() << " "
<< std::dec << std::setw(3) << std::dec << std::setw(3)
<< std::setfill(' ') << std::right << std::setfill(' ') << std::right
<< i->count() << " " << i->count() << " "
<< std::dec << i->value() << std::dec << i->value()
<< "\n"; << "\n";
} }
} }

@ -31,13 +31,13 @@ try {
std::cout << std::setw(44) << std::setfill(' ') << std::left std::cout << std::setw(44) << std::setfill(' ') << std::left
<< i->key() << " " << i->key() << " "
<< "0x" << std::setw(4) << std::setfill('0') << std::right << "0x" << std::setw(4) << std::setfill('0') << std::right
<< std::hex << i->tag() << " " << std::hex << i->tag() << " "
<< std::setw(9) << std::setfill(' ') << std::left << std::setw(9) << std::setfill(' ') << std::left
<< i->typeName() << " " << i->typeName() << " "
<< std::dec << std::setw(3) << std::dec << std::setw(3)
<< std::setfill(' ') << std::right << std::setfill(' ') << std::right
<< i->count() << " " << i->count() << " "
<< std::dec << i->value() << std::dec << i->value()
<< "\n"; << "\n";
} }

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -56,12 +56,12 @@ namespace {
//! List of all command identifiers and corresponding strings //! List of all command identifiers and corresponding strings
static const CmdIdAndString cmdIdAndString[] = { static const CmdIdAndString cmdIdAndString[] = {
{ add, "add" }, { add, "add" },
{ set, "set" }, { set, "set" },
{ del, "del" }, { del, "del" },
{ invalidCmdId, "invalidCmd" } // End of list marker { invalidCmdId, "invalidCmd" } // End of list marker
}; };
// Return a command Id for a command string // Return a command Id for a command string
CmdId commandId(const std::string& cmdString); CmdId commandId(const std::string& cmdString);
// Evaluate [-]HH[:MM[:SS]], returns true and sets time to the value // Evaluate [-]HH[:MM[:SS]], returns true and sets time to the value
@ -72,7 +72,7 @@ namespace {
@brief Parse the oparg string into a bitmap of common targets. @brief Parse the oparg string into a bitmap of common targets.
@param optarg Option arguments @param optarg Option arguments
@param action Action being processed @param action Action being processed
@return A bitmap of common targets or -1 in case of a parse error @return A bitmap of common targets or -1 in case of a parse error
*/ */
int parseCommonTargets(const std::string& optarg, int parseCommonTargets(const std::string& optarg,
const std::string& action); const std::string& action);
@ -82,7 +82,7 @@ namespace {
@param modifyCmds Reference to a structure to store the parsed commands @param modifyCmds Reference to a structure to store the parsed commands
@param cmdFiles Container with the file names @param cmdFiles Container with the file names
*/ */
bool parseCmdFiles(ModifyCmds& modifyCmds, bool parseCmdFiles(ModifyCmds& modifyCmds,
const Params::CmdFiles& cmdFiles); const Params::CmdFiles& cmdFiles);
/*! /*!
@ -90,12 +90,12 @@ namespace {
@param modifyCmds Reference to a structure to store the parsed commands @param modifyCmds Reference to a structure to store the parsed commands
@param cmdLines Container with the commands @param cmdLines Container with the commands
*/ */
bool parseCmdLines(ModifyCmds& modifyCmds, bool parseCmdLines(ModifyCmds& modifyCmds,
const Params::CmdLines& cmdLines); const Params::CmdLines& cmdLines);
/*! /*!
@brief Parse one line of the command file @brief Parse one line of the command file
@param modifyCmd Reference to a command structure to store the parsed @param modifyCmd Reference to a command structure to store the parsed
command command
@param line Input line @param line Input line
@param num Line number (used for error output) @param num Line number (used for error output)
@ -126,7 +126,7 @@ int main(int argc, char* const argv[])
// Create the required action class // Create the required action class
Action::TaskFactory& taskFactory = Action::TaskFactory::instance(); Action::TaskFactory& taskFactory = Action::TaskFactory::instance();
Action::Task::AutoPtr task Action::Task::AutoPtr task
= taskFactory.create(Action::TaskType(params.action_)); = taskFactory.create(Action::TaskType(params.action_));
assert(task.get()); assert(task.get());
@ -137,7 +137,7 @@ int main(int argc, char* const argv[])
Params::Files::const_iterator e = params.files_.end(); Params::Files::const_iterator e = params.files_.end();
for (Params::Files::const_iterator i = params.files_.begin(); i != e; ++i) { for (Params::Files::const_iterator i = params.files_.begin(); i != e; ++i) {
if (params.verbose_) { if (params.verbose_) {
std::cout << "File " << std::setw(w) << n++ << "/" << s << ": " std::cout << "File " << std::setw(w) << n++ << "/" << s << ": "
<< *i << std::endl; << *i << std::endl;
} }
task->run(*i); task->run(*i);
@ -169,7 +169,7 @@ void Params::cleanup()
void Params::version(std::ostream& os) const void Params::version(std::ostream& os) const
{ {
os << EXV_PACKAGE_STRING << ", " os << EXV_PACKAGE_STRING << ", "
<< "Copyright (C) 2004, 2005 Andreas Huggel.\n\n" << "Copyright (C) 2004, 2005 Andreas Huggel.\n\n"
<< "This is free software; see the source for copying conditions. " << "This is free software; see the source for copying conditions. "
<< "There is NO \nwarranty; not even for MERCHANTABILITY or FITNESS FOR " << "There is NO \nwarranty; not even for MERCHANTABILITY or FITNESS FOR "
@ -178,7 +178,7 @@ void Params::version(std::ostream& os) const
void Params::usage(std::ostream& os) const void Params::usage(std::ostream& os) const
{ {
os << "Usage: " << progname() os << "Usage: " << progname()
<< " [ options ] [ action ] file ...\n\n" << " [ options ] [ action ] file ...\n\n"
<< "Manipulate the Exif metadata of images.\n"; << "Manipulate the Exif metadata of images.\n";
} }
@ -225,7 +225,7 @@ void Params::help(std::ostream& os) const
<< " -e tgt Extract target(s) for the `extract' action. Possible targets\n" << " -e tgt Extract target(s) for the `extract' action. Possible targets\n"
<< " are the same as those for the -d option.\n" << " are the same as those for the -d option.\n"
<< " -r fmt Filename format for the `rename' action. The format string\n" << " -r fmt Filename format for the `rename' action. The format string\n"
<< " follows strftime(3). Default filename format is " << " follows strftime(3). Default filename format is "
<< format_ << ".\n" << format_ << ".\n"
<< " -m file Command file for the modify action. The format for commands is\n" << " -m file Command file for the modify action. The format for commands is\n"
<< " set|add|del <key> [[<type>] <value>].\n" << " set|add|del <key> [[<type>] <value>].\n"
@ -255,18 +255,18 @@ int Params::option(int opt, const std::string& optarg, int optopt)
case 'l': directory_ = optarg; break; case 'l': directory_ = optarg; break;
case 'S': suffix_ = optarg; break; case 'S': suffix_ = optarg; break;
case ':': case ':':
std::cerr << progname() << ": Option -" << static_cast<char>(optopt) std::cerr << progname() << ": Option -" << static_cast<char>(optopt)
<< " requires an argument\n"; << " requires an argument\n";
rc = 1; rc = 1;
break; break;
case '?': case '?':
std::cerr << progname() << ": Unrecognized option -" std::cerr << progname() << ": Unrecognized option -"
<< static_cast<char>(optopt) << "\n"; << static_cast<char>(optopt) << "\n";
rc = 1; rc = 1;
break; break;
default: default:
std::cerr << progname() std::cerr << progname()
<< ": getopt returned unexpected character code " << ": getopt returned unexpected character code "
<< std::hex << opt << "\n"; << std::hex << opt << "\n";
rc = 1; rc = 1;
break; break;
@ -280,14 +280,14 @@ int Params::evalRename(const std::string& optarg)
switch (action_) { switch (action_) {
case Action::none: case Action::none:
action_ = Action::rename; action_ = Action::rename;
format_ = optarg; format_ = optarg;
break; break;
case Action::rename: case Action::rename:
std::cerr << progname() std::cerr << progname()
<< ": Ignoring surplus option -r \"" << optarg << "\"\n"; << ": Ignoring surplus option -r \"" << optarg << "\"\n";
break; break;
default: default:
std::cerr << progname() std::cerr << progname()
<< ": Option -r is not compatible with a previous option\n"; << ": Option -r is not compatible with a previous option\n";
rc = 1; rc = 1;
break; break;
@ -303,17 +303,17 @@ int Params::evalAdjust(const std::string& optarg)
action_ = Action::adjust; action_ = Action::adjust;
adjust_ = parseTime(optarg, adjustment_); adjust_ = parseTime(optarg, adjustment_);
if (!adjust_) { if (!adjust_) {
std::cerr << progname() << ": Error parsing -a option argument `" std::cerr << progname() << ": Error parsing -a option argument `"
<< optarg << "'\n"; << optarg << "'\n";
rc = 1; rc = 1;
} }
break; break;
case Action::adjust: case Action::adjust:
std::cerr << progname() std::cerr << progname()
<< ": Ignoring surplus option -a " << optarg << "\n"; << ": Ignoring surplus option -a " << optarg << "\n";
break; break;
default: default:
std::cerr << progname() std::cerr << progname()
<< ": Option -a is not compatible with a previous option\n"; << ": Option -a is not compatible with a previous option\n";
rc = 1; rc = 1;
break; break;
@ -342,11 +342,11 @@ int Params::evalPrint(const std::string& optarg)
} }
break; break;
case Action::print: case Action::print:
std::cerr << progname() std::cerr << progname()
<< ": Ignoring surplus option -p" << optarg << "\n"; << ": Ignoring surplus option -p" << optarg << "\n";
break; break;
default: default:
std::cerr << progname() std::cerr << progname()
<< ": Option -p is not compatible with a previous option\n"; << ": Option -p is not compatible with a previous option\n";
rc = 1; rc = 1;
break; break;
@ -368,12 +368,12 @@ int Params::evalDelete(const std::string& optarg)
target_ |= rc; target_ |= rc;
rc = 0; rc = 0;
} }
else { else {
rc = 1; rc = 1;
} }
break; break;
default: default:
std::cerr << progname() std::cerr << progname()
<< ": Option -d is not compatible with a previous option\n"; << ": Option -d is not compatible with a previous option\n";
rc = 1; rc = 1;
break; break;
@ -395,12 +395,12 @@ int Params::evalExtract(const std::string& optarg)
target_ |= rc; target_ |= rc;
rc = 0; rc = 0;
} }
else { else {
rc = 1; rc = 1;
} }
break; break;
default: default:
std::cerr << progname() std::cerr << progname()
<< ": Option -e is not compatible with a previous option\n"; << ": Option -e is not compatible with a previous option\n";
rc = 1; rc = 1;
break; break;
@ -422,12 +422,12 @@ int Params::evalInsert(const std::string& optarg)
target_ |= rc; target_ |= rc;
rc = 0; rc = 0;
} }
else { else {
rc = 1; rc = 1;
} }
break; break;
default: default:
std::cerr << progname() std::cerr << progname()
<< ": Option -i is not compatible with a previous option\n"; << ": Option -i is not compatible with a previous option\n";
rc = 1; rc = 1;
break; break;
@ -447,7 +447,7 @@ int Params::evalModify(int opt, const std::string& optarg)
if (opt == 'M') cmdLines_.push_back(optarg); // parse the commands later if (opt == 'M') cmdLines_.push_back(optarg); // parse the commands later
break; break;
default: default:
std::cerr << progname() std::cerr << progname()
<< ": Option -" << (char)opt << ": Option -" << (char)opt
<< " is not compatible with a previous option\n"; << " is not compatible with a previous option\n";
rc = 1; rc = 1;
@ -538,7 +538,7 @@ int Params::nonoption(const std::string& argv)
} // Params::nonoption } // Params::nonoption
int Params::getopt(int argc, char* const argv[]) int Params::getopt(int argc, char* const argv[])
{ {
int rc = Util::Getopt::getopt(argc, argv, optstring_); int rc = Util::Getopt::getopt(argc, argv, optstring_);
// Further consistency checks // Further consistency checks
if (help_ || version_) return 0; if (help_ || version_) return 0;
@ -548,12 +548,12 @@ int Params::getopt(int argc, char* const argv[])
rc = 1; rc = 1;
} }
if (action_ == Action::adjust && !adjust_) { if (action_ == Action::adjust && !adjust_) {
std::cerr << progname() std::cerr << progname()
<< ": Adjust action requires option -a time\n"; << ": Adjust action requires option -a time\n";
rc = 1; rc = 1;
} }
if (action_ == Action::modify && cmdFiles_.empty() && cmdLines_.empty()) { if (action_ == Action::modify && cmdFiles_.empty() && cmdLines_.empty()) {
std::cerr << progname() std::cerr << progname()
<< ": Modify action requires at least one -m or -M option\n"; << ": Modify action requires at least one -m or -M option\n";
rc = 1; rc = 1;
} }
@ -564,7 +564,7 @@ int Params::getopt(int argc, char* const argv[])
if (rc == 0 && action_ == Action::modify) { if (rc == 0 && action_ == Action::modify) {
// Parse command files // Parse command files
if (!parseCmdFiles(modifyCmds_, cmdFiles_)) { if (!parseCmdFiles(modifyCmds_, cmdFiles_)) {
std::cerr << progname() << ": Error parsing -m option arguments\n"; std::cerr << progname() << ": Error parsing -m option arguments\n";
rc = 1; rc = 1;
} }
} }
@ -575,14 +575,14 @@ int Params::getopt(int argc, char* const argv[])
rc = 1; rc = 1;
} }
} }
if ( !directory_.empty() if ( !directory_.empty()
&& !(action_ == Action::insert || action_ == Action::extract)) { && !(action_ == Action::insert || action_ == Action::extract)) {
std::cerr << progname() std::cerr << progname()
<< ": -l option can only be used with extract or insert actions\n"; << ": -l option can only be used with extract or insert actions\n";
rc = 1; rc = 1;
} }
if (!suffix_.empty() && !(action_ == Action::insert)) { if (!suffix_.empty() && !(action_ == Action::insert)) {
std::cerr << progname() std::cerr << progname()
<< ": -S option can only be used with insert action\n"; << ": -S option can only be used with insert action\n";
rc = 1; rc = 1;
} }
@ -633,7 +633,7 @@ namespace {
return true; return true;
} // parseTime } // parseTime
int parseCommonTargets(const std::string& optarg, int parseCommonTargets(const std::string& optarg,
const std::string& action) const std::string& action)
{ {
int rc = 0; int rc = 0;
@ -644,11 +644,11 @@ namespace {
case 'i': target |= Params::ctIptc; break; case 'i': target |= Params::ctIptc; break;
case 'c': target |= Params::ctComment; break; case 'c': target |= Params::ctComment; break;
case 't': target |= Params::ctThumb; break; case 't': target |= Params::ctThumb; break;
case 'a': target |= Params::ctExif case 'a': target |= Params::ctExif
| Params::ctIptc | Params::ctIptc
| Params::ctComment; break; | Params::ctComment; break;
default: default:
std::cerr << Params::instance().progname() << ": Unrecognized " std::cerr << Params::instance().progname() << ": Unrecognized "
<< action << " target `" << optarg[i] << "'\n"; << action << " target `" << optarg[i] << "'\n";
rc = -1; rc = -1;
break; break;
@ -657,7 +657,7 @@ namespace {
return rc ? rc : target; return rc ? rc : target;
} // parseCommonTargets } // parseCommonTargets
bool parseCmdFiles(ModifyCmds& modifyCmds, bool parseCmdFiles(ModifyCmds& modifyCmds,
const Params::CmdFiles& cmdFiles) const Params::CmdFiles& cmdFiles)
{ {
Params::CmdFiles::const_iterator end = cmdFiles.end(); Params::CmdFiles::const_iterator end = cmdFiles.end();
@ -666,7 +666,7 @@ namespace {
try { try {
std::ifstream file(filename->c_str()); std::ifstream file(filename->c_str());
if (!file) { if (!file) {
std::cerr << *filename std::cerr << *filename
<< ": Failed to open command file for reading\n"; << ": Failed to open command file for reading\n";
return false; return false;
} }
@ -687,7 +687,7 @@ namespace {
return true; return true;
} // parseCmdFile } // parseCmdFile
bool parseCmdLines(ModifyCmds& modifyCmds, bool parseCmdLines(ModifyCmds& modifyCmds,
const Params::CmdLines& cmdLines) const Params::CmdLines& cmdLines)
{ {
try { try {
@ -716,21 +716,21 @@ namespace {
std::string::size_type cmdStart = line.find_first_not_of(delim); std::string::size_type cmdStart = line.find_first_not_of(delim);
if (cmdStart == std::string::npos || line[cmdStart] == '#') return false; if (cmdStart == std::string::npos || line[cmdStart] == '#') return false;
// Get command and key // Get command and key
std::string::size_type cmdEnd = line.find_first_of(delim, cmdStart+1); std::string::size_type cmdEnd = line.find_first_of(delim, cmdStart+1);
std::string::size_type keyStart = line.find_first_not_of(delim, cmdEnd+1); std::string::size_type keyStart = line.find_first_not_of(delim, cmdEnd+1);
std::string::size_type keyEnd = line.find_first_of(delim, keyStart+1); std::string::size_type keyEnd = line.find_first_of(delim, keyStart+1);
if ( cmdStart == std::string::npos if ( cmdStart == std::string::npos
|| cmdEnd == std::string::npos || cmdEnd == std::string::npos
|| keyStart == std::string::npos) { || keyStart == std::string::npos) {
throw Exiv2::Error(1, Exiv2::toString(num) throw Exiv2::Error(1, Exiv2::toString(num)
+ ": Invalid command line"); + ": Invalid command line");
} }
std::string cmd(line.substr(cmdStart, cmdEnd-cmdStart)); std::string cmd(line.substr(cmdStart, cmdEnd-cmdStart));
CmdId cmdId = commandId(cmd); CmdId cmdId = commandId(cmd);
if (cmdId == invalidCmdId) { if (cmdId == invalidCmdId) {
throw Exiv2::Error(1, Exiv2::toString(num) throw Exiv2::Error(1, Exiv2::toString(num)
+ ": Invalid command `" + cmd + "'"); + ": Invalid command `" + cmd + "'");
} }
@ -740,7 +740,7 @@ namespace {
try { try {
Exiv2::IptcKey iptcKey(key); Exiv2::IptcKey iptcKey(key);
metadataId = iptc; metadataId = iptc;
defaultType = Exiv2::IptcDataSets::dataSetType(iptcKey.tag(), defaultType = Exiv2::IptcDataSets::dataSetType(iptcKey.tag(),
iptcKey.record()); iptcKey.record());
} }
catch (const Exiv2::AnyError&) {} catch (const Exiv2::AnyError&) {}
@ -754,7 +754,7 @@ namespace {
catch (const Exiv2::AnyError&) {} catch (const Exiv2::AnyError&) {}
} }
if (metadataId == invalidMetadataId) { if (metadataId == invalidMetadataId) {
throw Exiv2::Error(1, Exiv2::toString(num) throw Exiv2::Error(1, Exiv2::toString(num)
+ ": Invalid key `" + key + "'"); + ": Invalid key `" + key + "'");
} }
@ -763,17 +763,17 @@ namespace {
bool explicitType = false; bool explicitType = false;
if (cmdId != del) { if (cmdId != del) {
// Get type and value // Get type and value
std::string::size_type typeStart std::string::size_type typeStart
= line.find_first_not_of(delim, keyEnd+1); = line.find_first_not_of(delim, keyEnd+1);
std::string::size_type typeEnd std::string::size_type typeEnd
= line.find_first_of(delim, typeStart+1); = line.find_first_of(delim, typeStart+1);
std::string::size_type valStart = typeStart; std::string::size_type valStart = typeStart;
std::string::size_type valEnd = line.find_last_not_of(delim); std::string::size_type valEnd = line.find_last_not_of(delim);
if ( keyEnd == std::string::npos if ( keyEnd == std::string::npos
|| typeStart == std::string::npos || typeStart == std::string::npos
|| valStart == std::string::npos) { || valStart == std::string::npos) {
throw Exiv2::Error(1, Exiv2::toString(num) throw Exiv2::Error(1, Exiv2::toString(num)
+ ": Invalid command line "); + ": Invalid command line ");
} }
@ -783,7 +783,7 @@ namespace {
if (tmpType != Exiv2::invalidTypeId) { if (tmpType != Exiv2::invalidTypeId) {
valStart = line.find_first_not_of(delim, typeEnd+1); valStart = line.find_first_not_of(delim, typeEnd+1);
if (valStart == std::string::npos) { if (valStart == std::string::npos) {
throw Exiv2::Error(1, Exiv2::toString(num) throw Exiv2::Error(1, Exiv2::toString(num)
+ ": Invalid command line "); + ": Invalid command line ");
} }
type = tmpType; type = tmpType;
@ -793,9 +793,9 @@ namespace {
value = line.substr(valStart, valEnd+1-valStart); value = line.substr(valStart, valEnd+1-valStart);
std::string::size_type last = value.length()-1; std::string::size_type last = value.length()-1;
if ( (value[0] == '"' || value[last] == '"') if ( (value[0] == '"' || value[last] == '"')
&& value[0] != value[last]) { && value[0] != value[last]) {
throw Exiv2::Error(1, Exiv2::toString(num) throw Exiv2::Error(1, Exiv2::toString(num)
+ ": Unbalanced quotes"); + ": Unbalanced quotes");
} }
if (value[0] == '"') { if (value[0] == '"') {

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -46,19 +46,19 @@
enum CmdId { invalidCmdId, add, set, del }; enum CmdId { invalidCmdId, add, set, del };
//! Metadata identifiers //! Metadata identifiers
enum MetadataId { invalidMetadataId, iptc, exif }; enum MetadataId { invalidMetadataId, iptc, exif };
//! Structure for one parsed modification command //! Structure for one parsed modification command
struct ModifyCmd { struct ModifyCmd {
//! C'tor //! C'tor
ModifyCmd() : ModifyCmd() :
cmdId_(invalidCmdId), metadataId_(invalidMetadataId), cmdId_(invalidCmdId), metadataId_(invalidMetadataId),
typeId_(Exiv2::invalidTypeId), explicitType_(false) {} typeId_(Exiv2::invalidTypeId), explicitType_(false) {}
CmdId cmdId_; //!< Command identifier CmdId cmdId_; //!< Command identifier
std::string key_; //!< Exiv2 key string std::string key_; //!< Exiv2 key string
MetadataId metadataId_; //!< Metadata identifier MetadataId metadataId_; //!< Metadata identifier
Exiv2::TypeId typeId_; //!< Exiv2 type identifier Exiv2::TypeId typeId_; //!< Exiv2 type identifier
//! Flag to indicate if the type was explicitely specified (true) //! Flag to indicate if the type was explicitely specified (true)
bool explicitType_; bool explicitType_;
std::string value_; //!< Data std::string value_; //!< Data
}; };
//! Container for modification commands //! Container for modification commands
typedef std::vector<ModifyCmd> ModifyCmds; typedef std::vector<ModifyCmd> ModifyCmds;
@ -69,7 +69,7 @@ struct CmdIdAndString {
}; };
/*! /*!
@brief Implements the command line handling for the program. @brief Implements the command line handling for the program.
Derives from Util::Getopt to use the command line argument parsing Derives from Util::Getopt to use the command line argument parsing
functionalty provided there. This class is implemented as a Singleton, functionalty provided there. This class is implemented as a Singleton,
@ -123,7 +123,7 @@ public:
void cleanup(); void cleanup();
//! Enumerates print modes //! Enumerates print modes
enum PrintMode { pmSummary, pmInterpreted, pmValues, pmHexdump, pmIptc, enum PrintMode { pmSummary, pmInterpreted, pmValues, pmHexdump, pmIptc,
pmComment }; pmComment };
//! Enumerates common targets, bitmap //! Enumerates common targets, bitmap
enum CommonTarget { ctExif = 1, ctIptc = 2, ctComment = 4, ctThumb = 8 }; enum CommonTarget { ctExif = 1, ctIptc = 2, ctComment = 4, ctThumb = 8 };
@ -133,10 +133,10 @@ public:
bool help_; //!< Help option flag. bool help_; //!< Help option flag.
bool version_; //!< Version option flag. bool version_; //!< Version option flag.
bool verbose_; //!< Verbose (talkative) option flag. bool verbose_; //!< Verbose (talkative) option flag.
bool force_; //!< Force overwrites flag. bool force_; //!< Force overwrites flag.
FileExistsPolicy fileExistsPolicy_; //!< What to do if file to rename exists. FileExistsPolicy fileExistsPolicy_; //!< What to do if file to rename exists.
bool adjust_; //!< Adjustment flag. bool adjust_; //!< Adjustment flag.
PrintMode printMode_; //!< Print mode. PrintMode printMode_; //!< Print mode.
//! %Action (integer rather than TaskType to avoid dependency). //! %Action (integer rather than TaskType to avoid dependency).
int action_; int action_;
int target_; //!< What common target to process. int target_; //!< What common target to process.
@ -156,10 +156,10 @@ private:
The c'tor is private to force instantiation through instance(). The c'tor is private to force instantiation through instance().
*/ */
Params() : optstring_(":hVvfFa:r:p:d:e:i:m:M:l:S:"), Params() : optstring_(":hVvfFa:r:p:d:e:i:m:M:l:S:"),
help_(false), help_(false),
version_(false), version_(false),
verbose_(false), verbose_(false),
force_(false), force_(false),
fileExistsPolicy_(askPolicy), fileExistsPolicy_(askPolicy),
adjust_(false), adjust_(false),
printMode_(pmSummary), printMode_(pmSummary),

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -25,7 +25,7 @@
History: 18-Feb-04, ahu: created History: 18-Feb-04, ahu: created
07-Mar-04, ahu: isolated as a separate component 07-Mar-04, ahu: isolated as a separate component
Credits: Fujifilm MakerNote implemented according to the specification Credits: Fujifilm MakerNote implemented according to the specification
in "Appendix 4: Makernote of Fujifilm" of the document in "Appendix 4: Makernote of Fujifilm" of the document
"Exif file format" by TsuruZoh Tachibanaya "Exif file format" by TsuruZoh Tachibanaya
<http://park2.wakwak.com/%7Etsuruzoh/Computer/Digicams/exif-e.html> <http://park2.wakwak.com/%7Etsuruzoh/Computer/Digicams/exif-e.html>
*/ */
@ -104,14 +104,14 @@ namespace Exiv2 {
} }
int FujiMakerNote::readHeader(const byte* buf, int FujiMakerNote::readHeader(const byte* buf,
long len, long len,
ByteOrder byteOrder) ByteOrder byteOrder)
{ {
if (len < 12) return 1; if (len < 12) return 1;
header_.alloc(12); header_.alloc(12);
memcpy(header_.pData_, buf, header_.size_); memcpy(header_.pData_, buf, header_.size_);
// Read offset to the IFD relative to the start of the makernote // Read offset to the IFD relative to the start of the makernote
// from the header. Note that we ignore the byteOrder paramter // from the header. Note that we ignore the byteOrder paramter
start_ = getUShort(header_.pData_ + 8, byteOrder_); start_ = getUShort(header_.pData_ + 8, byteOrder_);
return 0; return 0;
@ -122,7 +122,7 @@ namespace Exiv2 {
int rc = 0; int rc = 0;
// Check the FUJIFILM prefix // Check the FUJIFILM prefix
if ( header_.size_ < 12 if ( header_.size_ < 12
|| std::string(reinterpret_cast<char*>(header_.pData_), 8) || std::string(reinterpret_cast<char*>(header_.pData_), 8)
!= std::string("FUJIFILM", 8)) { != std::string("FUJIFILM", 8)) {
rc = 2; rc = 2;
} }
@ -134,7 +134,7 @@ namespace Exiv2 {
return AutoPtr(create_(alloc)); return AutoPtr(create_(alloc));
} }
FujiMakerNote* FujiMakerNote::create_(bool alloc) const FujiMakerNote* FujiMakerNote::create_(bool alloc) const
{ {
AutoPtr makerNote = AutoPtr(new FujiMakerNote(alloc)); AutoPtr makerNote = AutoPtr(new FujiMakerNote(alloc));
assert(makerNote.get() != 0); assert(makerNote.get() != 0);
@ -147,7 +147,7 @@ namespace Exiv2 {
return AutoPtr(clone_()); return AutoPtr(clone_());
} }
FujiMakerNote* FujiMakerNote::clone_() const FujiMakerNote* FujiMakerNote::clone_() const
{ {
return new FujiMakerNote(*this); return new FujiMakerNote(*this);
} }
@ -163,7 +163,7 @@ namespace Exiv2 {
return os; return os;
} }
std::ostream& FujiMakerNote::print0x1001(std::ostream& os, std::ostream& FujiMakerNote::print0x1001(std::ostream& os,
const Value& value) const Value& value)
{ {
switch (value.toLong()) { switch (value.toLong()) {
@ -173,7 +173,7 @@ namespace Exiv2 {
case 4: // fallthrough case 4: // fallthrough
case 5: os << "Hard"; break; case 5: os << "Hard"; break;
default: os << "(" << value << ")"; break; default: os << "(" << value << ")"; break;
} }
return os; return os;
} }
@ -206,7 +206,7 @@ namespace Exiv2 {
return os; return os;
} }
std::ostream& FujiMakerNote::print0x1004(std::ostream& os, std::ostream& FujiMakerNote::print0x1004(std::ostream& os,
const Value& value) const Value& value)
{ {
switch (value.toLong()) { switch (value.toLong()) {
@ -218,7 +218,7 @@ namespace Exiv2 {
return os; return os;
} }
std::ostream& FujiMakerNote::print0x1010(std::ostream& os, std::ostream& FujiMakerNote::print0x1010(std::ostream& os,
const Value& value) const Value& value)
{ {
switch (value.toLong()) { switch (value.toLong()) {
@ -264,9 +264,9 @@ namespace Exiv2 {
// free functions // free functions
MakerNote::AutoPtr createFujiMakerNote(bool alloc, MakerNote::AutoPtr createFujiMakerNote(bool alloc,
const byte* buf, const byte* buf,
long len, long len,
ByteOrder byteOrder, ByteOrder byteOrder,
long offset) long offset)
{ {
return MakerNote::AutoPtr(new FujiMakerNote(alloc)); return MakerNote::AutoPtr(new FujiMakerNote(alloc));

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -21,7 +21,7 @@
/*! /*!
@file fujimn.hpp @file fujimn.hpp
@brief Fujifilm MakerNote implemented according to the specification @brief Fujifilm MakerNote implemented according to the specification
in Appendix 4: Makernote of Fujifilm of the document in Appendix 4: Makernote of Fujifilm of the document
<a href="http://park2.wakwak.com/%7Etsuruzoh/Computer/Digicams/exif-e.html"> <a href="http://park2.wakwak.com/%7Etsuruzoh/Computer/Digicams/exif-e.html">
Exif file format</a> by TsuruZoh Tachibanaya Exif file format</a> by TsuruZoh Tachibanaya
@version $Rev$ @version $Rev$
@ -59,27 +59,27 @@ namespace Exiv2 {
initialized to operate in the memory management model indicated. initialized to operate in the memory management model indicated.
The caller owns this copy and the auto-pointer ensures that it The caller owns this copy and the auto-pointer ensures that it
will be deleted. will be deleted.
@param alloc Memory management model for the new MakerNote. Determines if @param alloc Memory management model for the new MakerNote. Determines if
memory required to store data should be allocated and deallocated memory required to store data should be allocated and deallocated
(true) or not (false). If false, only pointers to the buffer (true) or not (false). If false, only pointers to the buffer
provided to read() will be kept. See Ifd for more background on provided to read() will be kept. See Ifd for more background on
this concept. this concept.
@param buf Pointer to the makernote character buffer (not used). @param buf Pointer to the makernote character buffer (not used).
@param len Length of the makernote character buffer (not used). @param len Length of the makernote character buffer (not used).
@param byteOrder Byte order in which the Exif data (and possibly the @param byteOrder Byte order in which the Exif data (and possibly the
makernote) is encoded (not used). makernote) is encoded (not used).
@param offset Offset from the start of the TIFF header of the makernote @param offset Offset from the start of the TIFF header of the makernote
buffer (not used). buffer (not used).
@return An auto-pointer to a newly created empty MakerNote. The caller @return An auto-pointer to a newly created empty MakerNote. The caller
owns this copy and the auto-pointer ensures that it will be owns this copy and the auto-pointer ensures that it will be
deleted. deleted.
*/ */
MakerNote::AutoPtr createFujiMakerNote(bool alloc, MakerNote::AutoPtr createFujiMakerNote(bool alloc,
const byte* buf, const byte* buf,
long len, long len,
ByteOrder byteOrder, ByteOrder byteOrder,
long offset); long offset);
// ***************************************************************************** // *****************************************************************************
@ -105,8 +105,8 @@ namespace Exiv2 {
//@} //@}
//! @name Manipulators //! @name Manipulators
//@{ //@{
int readHeader(const byte* buf, int readHeader(const byte* buf,
long len, long len,
ByteOrder byteOrder); ByteOrder byteOrder);
//@} //@}
@ -118,7 +118,7 @@ namespace Exiv2 {
AutoPtr clone() const; AutoPtr clone() const;
//@} //@}
//! @name Print functions for Fujifilm %MakerNote tags //! @name Print functions for Fujifilm %MakerNote tags
//@{ //@{
//! Print Off or On status //! Print Off or On status
static std::ostream& printOffOn(std::ostream& os, const Value& value); static std::ostream& printOffOn(std::ostream& os, const Value& value);

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -70,14 +70,14 @@ namespace Exiv2 {
std::string strError() std::string strError()
{ {
int error = errno; int error = errno;
std::ostringstream os; std::ostringstream os;
#ifdef EXV_HAVE_STRERROR_R #ifdef EXV_HAVE_STRERROR_R
const size_t n = 1024; const size_t n = 1024;
char buf[n]; char buf[n];
strerror_r(error, buf, n); strerror_r(error, buf, n);
os << buf; os << buf;
#else #else
os << std::strerror(error); os << std::strerror(error);
#endif #endif
os << " (" << error << ")"; os << " (" << error << ")";
return os.str(); return os.str();

@ -1,19 +1,19 @@
// ********************************************************* -*- C++ -*- // ********************************************************* -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -44,19 +44,19 @@ namespace Exiv2 {
/*! /*!
@brief Test if a file exists. @brief Test if a file exists.
@param path Name of file to verify. @param path Name of file to verify.
@param ct Flag to check if <i>path</i> is a regular file. @param ct Flag to check if <i>path</i> is a regular file.
@return true if <i>path</i> exists and, if <i>ct</i> is set, @return true if <i>path</i> exists and, if <i>ct</i> is set,
is a regular file, else false. is a regular file, else false.
@note The function calls <b>stat()</b> test for <i>path</i> @note The function calls <b>stat()</b> test for <i>path</i>
and its type, see stat(2). <b>errno</b> is left unchanged and its type, see stat(2). <b>errno</b> is left unchanged
in case of an error. in case of an error.
*/ */
bool fileExists(const std::string& path, bool ct =false); bool fileExists(const std::string& path, bool ct =false);
/*! /*!
@brief Return a system error message and the error code (errno). @brief Return a system error message and the error code (errno).
See %strerror(3). See %strerror(3).
*/ */
std::string strError(); std::string strError();

@ -22,10 +22,10 @@ try {
std::cout << "Read standard Ifd from data buffer\n"; std::cout << "Read standard Ifd from data buffer\n";
const long len = 77; const long len = 77;
Exiv2::byte buf[] Exiv2::byte buf[]
= { 0xff, // Filler = { 0xff, // Filler
// No // No
0x00,0x04, 0x00,0x04,
// Tag Type Components Offset/Data // Tag Type Components Offset/Data
0x00,0x01, 0x00,0x02, 0x00,0x00,0x00,0x04, 'T', 'h', 'e', '\0', 0x00,0x01, 0x00,0x02, 0x00,0x00,0x00,0x04, 'T', 'h', 'e', '\0',
0x00,0x02, 0x00,0x02, 0x00,0x00,0x00,0x06, 0x00,0x00,0x00,0x37, 0x00,0x02, 0x00,0x02, 0x00,0x00,0x00,0x06, 0x00,0x00,0x00,0x37,
@ -53,31 +53,31 @@ try {
return 1; return 1;
} }
Exiv2::byte data[] = { 'T', 'H', 'R', 'E', 'E', '\0' }; Exiv2::byte data[] = { 'T', 'H', 'R', 'E', 'E', '\0' };
std::cout << "Setting value of entry 3...\n"; std::cout << "Setting value of entry 3...\n";
pos->setValue(2, 6, data, 6); pos->setValue(2, 6, data, 6);
Exiv2::DataBuf db(1024); Exiv2::DataBuf db(1024);
rc = ifd.copy(db.pData_ + 1, Exiv2::bigEndian); rc = ifd.copy(db.pData_ + 1, Exiv2::bigEndian);
std::cout << "Wrote " << rc << " characters to data buffer\n"; std::cout << "Wrote " << rc << " characters to data buffer\n";
rc = ifd.read(db.pData_, len, 1, Exiv2::bigEndian); rc = ifd.read(db.pData_, len, 1, Exiv2::bigEndian);
if (rc) { if (rc) {
std::cout << "Ifd::read (1a) failed, rc = " << rc << "\n"; std::cout << "Ifd::read (1a) failed, rc = " << rc << "\n";
return rc; return rc;
} }
ifd.print(std::cout); ifd.print(std::cout);
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
std::cout << "\nRead non-standard Ifd from data buffer\n"; std::cout << "\nRead non-standard Ifd from data buffer\n";
const long len2 = 76; const long len2 = 76;
Exiv2::byte buf2[] Exiv2::byte buf2[]
= { // Data = { // Data
'K', 'u', 'a', 'l', 'a', '\0', 'K', 'u', 'a', 'l', 'a', '\0',
'L', 'u', 'm', 'p', 'u', 'r', '\0', 'L', 'u', 'm', 'p', 'u', 'r', '\0',
'M', 'a', 'l', 'a', 'y', 's', 'i', 'a', '\0', 'M', 'a', 'l', 'a', 'y', 's', 'i', 'a', '\0',
// No // No
0x00,0x04, 0x00,0x04,
// Tag Type Components Offset/Data // Tag Type Components Offset/Data
0x00,0x01, 0x00,0x02, 0x00,0x00,0x00,0x04, 'T', 'h', 'e', '\0', 0x00,0x01, 0x00,0x02, 0x00,0x00,0x00,0x04, 'T', 'h', 'e', '\0',
0x00,0x02, 0x00,0x02, 0x00,0x00,0x00,0x06, 0x00,0x00,0x00,0x00, 0x00,0x02, 0x00,0x02, 0x00,0x00,0x00,0x06, 0x00,0x00,0x00,0x00,
@ -101,7 +101,7 @@ try {
return 1; return 1;
} }
Exiv2::byte data2[] = { 'T', 'H', 'R', 'E', 'E', '\0' }; Exiv2::byte data2[] = { 'T', 'H', 'R', 'E', 'E', '\0' };
std::cout << "Setting value of entry 3...\n"; std::cout << "Setting value of entry 3...\n";
pos->setValue(2, 6, data2, 6); pos->setValue(2, 6, data2, 6);

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -50,7 +50,7 @@ EXIV2_RCSID("@(#) $Id$");
namespace Exiv2 { namespace Exiv2 {
Entry::Entry(bool alloc) Entry::Entry(bool alloc)
: alloc_(alloc), ifdId_(ifdIdNotSet), idx_(0), : alloc_(alloc), ifdId_(ifdIdNotSet), idx_(0),
tag_(0), type_(0), count_(0), offset_(0), size_(0), pData_(0), tag_(0), type_(0), count_(0), offset_(0), size_(0), pData_(0),
sizeDataArea_(0), pDataArea_(0) sizeDataArea_(0), pDataArea_(0)
{ {
@ -66,7 +66,7 @@ namespace Exiv2 {
Entry::Entry(const Entry& rhs) Entry::Entry(const Entry& rhs)
: alloc_(rhs.alloc_), ifdId_(rhs.ifdId_), idx_(rhs.idx_), : alloc_(rhs.alloc_), ifdId_(rhs.ifdId_), idx_(rhs.idx_),
tag_(rhs.tag_), type_(rhs.type_), tag_(rhs.tag_), type_(rhs.type_),
count_(rhs.count_), offset_(rhs.offset_), size_(rhs.size_), pData_(0), count_(rhs.count_), offset_(rhs.offset_), size_(rhs.size_), pData_(0),
sizeDataArea_(rhs.sizeDataArea_), pDataArea_(0) sizeDataArea_(rhs.sizeDataArea_), pDataArea_(0)
{ {
@ -201,7 +201,7 @@ namespace Exiv2 {
break; break;
} }
case unsignedLong: { case unsignedLong: {
ul2Data(buf, getULong(buf, byteOrder) + offset, byteOrder); ul2Data(buf, getULong(buf, byteOrder) + offset, byteOrder);
break; break;
} }
case unsignedRational: { case unsignedRational: {
@ -253,7 +253,7 @@ namespace Exiv2 {
} // Entry::component } // Entry::component
Ifd::Ifd(IfdId ifdId) Ifd::Ifd(IfdId ifdId)
: alloc_(true), ifdId_(ifdId), pBase_(0), offset_(0), : alloc_(true), ifdId_(ifdId), pBase_(0), offset_(0),
dataOffset_(0), hasNext_(true), pNext_(0), next_(0) dataOffset_(0), hasNext_(true), pNext_(0), next_(0)
{ {
pNext_ = new byte[4]; pNext_ = new byte[4];
@ -261,7 +261,7 @@ namespace Exiv2 {
} }
Ifd::Ifd(IfdId ifdId, long offset) Ifd::Ifd(IfdId ifdId, long offset)
: alloc_(true), ifdId_(ifdId), pBase_(0), offset_(offset), : alloc_(true), ifdId_(ifdId), pBase_(0), offset_(offset),
dataOffset_(0), hasNext_(true), pNext_(0), next_(0) dataOffset_(0), hasNext_(true), pNext_(0), next_(0)
{ {
pNext_ = new byte[4]; pNext_ = new byte[4];
@ -269,7 +269,7 @@ namespace Exiv2 {
} }
Ifd::Ifd(IfdId ifdId, long offset, bool alloc, bool hasNext) Ifd::Ifd(IfdId ifdId, long offset, bool alloc, bool hasNext)
: alloc_(alloc), ifdId_(ifdId), pBase_(0), offset_(offset), : alloc_(alloc), ifdId_(ifdId), pBase_(0), offset_(offset),
dataOffset_(0), hasNext_(hasNext), pNext_(0), next_(0) dataOffset_(0), hasNext_(hasNext), pNext_(0), next_(0)
{ {
if (alloc_ && hasNext_) { if (alloc_ && hasNext_) {
@ -286,19 +286,19 @@ namespace Exiv2 {
Ifd::Ifd(const Ifd& rhs) Ifd::Ifd(const Ifd& rhs)
: alloc_(rhs.alloc_), entries_(rhs.entries_), ifdId_(rhs.ifdId_), : alloc_(rhs.alloc_), entries_(rhs.entries_), ifdId_(rhs.ifdId_),
pBase_(rhs.pBase_), offset_(rhs.offset_), dataOffset_(rhs.dataOffset_), pBase_(rhs.pBase_), offset_(rhs.offset_), dataOffset_(rhs.dataOffset_),
hasNext_(rhs.hasNext_), pNext_(rhs.pNext_), next_(rhs.next_) hasNext_(rhs.hasNext_), pNext_(rhs.pNext_), next_(rhs.next_)
{ {
if (alloc_ && hasNext_) { if (alloc_ && hasNext_) {
pNext_ = new byte[4]; pNext_ = new byte[4];
memset(pNext_, 0x0, 4); memset(pNext_, 0x0, 4);
if (rhs.pNext_) memcpy(pNext_, rhs.pNext_, 4); if (rhs.pNext_) memcpy(pNext_, rhs.pNext_, 4);
} }
} }
int Ifd::read(const byte* buf, int Ifd::read(const byte* buf,
long len, long len,
long start, long start,
ByteOrder byteOrder, ByteOrder byteOrder,
long shift) long shift)
{ {
@ -315,7 +315,7 @@ namespace Exiv2 {
for (int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
if (len < o + 12) { if (len < o + 12) {
#ifndef SUPPRESS_WARNINGS #ifndef SUPPRESS_WARNINGS
std::cerr << "Error: " << ExifTags::ifdName(ifdId_) std::cerr << "Error: " << ExifTags::ifdName(ifdId_)
<< " entry " << i << " entry " << i
<< " lies outside of the IFD memory buffer.\n"; << " lies outside of the IFD memory buffer.\n";
#endif #endif
@ -336,7 +336,7 @@ namespace Exiv2 {
if (rc == 0 && hasNext_) { if (rc == 0 && hasNext_) {
if (len < o + 4) { if (len < o + 4) {
#ifndef SUPPRESS_WARNINGS #ifndef SUPPRESS_WARNINGS
std::cerr << "Error: " << ExifTags::ifdName(ifdId_) std::cerr << "Error: " << ExifTags::ifdName(ifdId_)
<< " memory of the pointer to the next IFD" << " memory of the pointer to the next IFD"
<< " lies outside of the IFD memory buffer.\n"; << " lies outside of the IFD memory buffer.\n";
#endif #endif
@ -363,25 +363,25 @@ namespace Exiv2 {
// Set the offset of the first data entry outside of the IFD // Set the offset of the first data entry outside of the IFD
if (i->offset_ + shift < 0) { if (i->offset_ + shift < 0) {
#ifndef SUPPRESS_WARNINGS #ifndef SUPPRESS_WARNINGS
std::cerr << "Error: Offset of the 1st data entry of " std::cerr << "Error: Offset of the 1st data entry of "
<< ExifTags::ifdName(ifdId_) << ExifTags::ifdName(ifdId_)
<< " is out of bounds:\n" << " is out of bounds:\n"
<< " Offset = 0x" << std::setw(8) << " Offset = 0x" << std::setw(8)
<< std::setfill('0') << std::hex << std::setfill('0') << std::hex
<< i->offset_ - offset_ // relative to start of IFD << i->offset_ - offset_ // relative to start of IFD
<< ", is before start of buffer by " << ", is before start of buffer by "
<< std::dec << -1 * (i->offset_ + shift) << std::dec << -1 * (i->offset_ + shift)
<< " Bytes\n"; << " Bytes\n";
#endif #endif
rc = 6; rc = 6;
} }
else if (i->offset_ + shift + i->size_ > len) { else if (i->offset_ + shift + i->size_ > len) {
#ifndef SUPPRESS_WARNINGS #ifndef SUPPRESS_WARNINGS
std::cerr << "Error: Upper boundary of the 1st data entry of " std::cerr << "Error: Upper boundary of the 1st data entry of "
<< ExifTags::ifdName(ifdId_) << ExifTags::ifdName(ifdId_)
<< " is out of bounds:\n" << " is out of bounds:\n"
<< " Offset = 0x" << std::setw(8) << " Offset = 0x" << std::setw(8)
<< std::setfill('0') << std::hex << std::setfill('0') << std::hex
<< i->offset_ - offset_ // relative to start of IFD << i->offset_ - offset_ // relative to start of IFD
<< ", exceeds buffer size by " << ", exceeds buffer size by "
<< std::dec << i->offset_ + shift + i->size_ - len << std::dec << i->offset_ + shift + i->size_ - len
@ -411,14 +411,14 @@ namespace Exiv2 {
i->size_ > 4 ? i->offset_ : i->offsetLoc_; i->size_ > 4 ? i->offset_ : i->offsetLoc_;
if (tmpOffset + shift + i->size_ > len) { if (tmpOffset + shift + i->size_ > len) {
#ifndef SUPPRESS_WARNINGS #ifndef SUPPRESS_WARNINGS
std::cerr << "Warning: Upper boundary of data for " std::cerr << "Warning: Upper boundary of data for "
<< ExifTags::ifdName(ifdId_) << ExifTags::ifdName(ifdId_)
<< " entry " << static_cast<int>(i - begin) << " entry " << static_cast<int>(i - begin)
<< " is out of bounds:\n" << " is out of bounds:\n"
<< " Offset = 0x" << std::setw(8) << " Offset = 0x" << std::setw(8)
<< std::setfill('0') << std::hex << std::setfill('0') << std::hex
<< tmpOffset - offset_ // relative to start of IFD << tmpOffset - offset_ // relative to start of IFD
<< ", size = " << std::dec << i->size_ << ", size = " << std::dec << i->size_
<< ", exceeds buffer size by " << ", exceeds buffer size by "
<< tmpOffset + shift + i->size_ - len << tmpOffset + shift + i->size_ - len
<< " Bytes; Truncating the data.\n"; << " Bytes; Truncating the data.\n";
@ -431,7 +431,7 @@ namespace Exiv2 {
// Set the offset to the data, relative to start of IFD // Set the offset to the data, relative to start of IFD
e.setOffset(tmpOffset - offset_); e.setOffset(tmpOffset - offset_);
// Set the size to at least for bytes to accomodate offset-data // Set the size to at least for bytes to accomodate offset-data
e.setValue(i->type_, i->count_, buf + start + e.offset(), e.setValue(i->type_, i->count_, buf + start + e.offset(),
std::max(long(4), i->size_)); std::max(long(4), i->size_));
this->add(e); this->add(e);
} }
@ -442,7 +442,7 @@ namespace Exiv2 {
return rc; return rc;
} // Ifd::read } // Ifd::read
Ifd::const_iterator Ifd::findIdx(int idx) const Ifd::const_iterator Ifd::findIdx(int idx) const
{ {
return std::find_if(entries_.begin(), entries_.end(), return std::find_if(entries_.begin(), entries_.end(),
FindEntryByIdx(idx)); FindEntryByIdx(idx));
@ -454,7 +454,7 @@ namespace Exiv2 {
FindEntryByIdx(idx)); FindEntryByIdx(idx));
} }
Ifd::const_iterator Ifd::findTag(uint16_t tag) const Ifd::const_iterator Ifd::findTag(uint16_t tag) const
{ {
return std::find_if(entries_.begin(), entries_.end(), return std::find_if(entries_.begin(), entries_.end(),
FindEntryByTag(tag)); FindEntryByTag(tag));
@ -514,7 +514,7 @@ namespace Exiv2 {
us2Data(buf + o, i->tag(), byteOrder); us2Data(buf + o, i->tag(), byteOrder);
us2Data(buf + o + 2, i->type(), byteOrder); us2Data(buf + o + 2, i->type(), byteOrder);
ul2Data(buf + o + 4, i->count(), byteOrder); ul2Data(buf + o + 4, i->count(), byteOrder);
if (i->sizeDataArea() > 0) { if (i->sizeDataArea() > 0) {
long dataAreaOffset = offset_+size()+totalDataSize+dataAreaSize; long dataAreaOffset = offset_+size()+totalDataSize+dataAreaSize;
i->setDataAreaOffsets(dataAreaOffset, byteOrder); i->setDataAreaOffsets(dataAreaOffset, byteOrder);
dataAreaSize += i->sizeDataArea(); dataAreaSize += i->sizeDataArea();
@ -633,7 +633,7 @@ namespace Exiv2 {
long Ifd::size() const long Ifd::size() const
{ {
if (entries_.size() == 0 && next_ == 0) return 0; if (entries_.size() == 0 && next_ == 0) return 0;
return static_cast<long>(2 + 12 * entries_.size() + (hasNext_ ? 4 : 0)); return static_cast<long>(2 + 12 * entries_.size() + (hasNext_ ? 4 : 0));
} }
long Ifd::dataSize() const long Ifd::dataSize() const
@ -652,9 +652,9 @@ namespace Exiv2 {
if (entries_.size() == 0) return; if (entries_.size() == 0) return;
// Print a header // Print a header
os << prefix << "IFD Offset: 0x" os << prefix << "IFD Offset: 0x"
<< std::setw(8) << std::setfill('0') << std::hex << std::right << std::setw(8) << std::setfill('0') << std::hex << std::right
<< offset_ << offset_
<< ", IFD Entries: " << ", IFD Entries: "
<< std::setfill(' ') << std::dec << std::right << std::setfill(' ') << std::dec << std::right
<< static_cast<unsigned int>(entries_.size()) << "\n" << static_cast<unsigned int>(entries_.size()) << "\n"
<< prefix << "Entry Tag Format (Bytes each) Number Offset\n" << prefix << "Entry Tag Format (Bytes each) Number Offset\n"
@ -678,10 +678,10 @@ namespace Exiv2 {
} }
os << prefix << std::setw(5) << std::setfill(' ') << std::dec os << prefix << std::setw(5) << std::setfill(' ') << std::dec
<< std::right << static_cast<int>(i - b) << std::right << static_cast<int>(i - b)
<< " 0x" << std::setw(4) << std::setfill('0') << std::hex << " 0x" << std::setw(4) << std::setfill('0') << std::hex
<< std::right << i->tag() << std::right << i->tag()
<< " " << std::setw(17) << std::setfill(' ') << " " << std::setw(17) << std::setfill(' ')
<< std::left << i->typeName() << std::left << i->typeName()
<< " (" << std::dec << i->typeSize() << ")" << " (" << std::dec << i->typeSize() << ")"
<< " " << std::setw(6) << std::setfill(' ') << std::dec << " " << std::setw(6) << std::setfill(' ') << std::dec
<< std::right << i->count() << std::right << i->count()
@ -689,11 +689,11 @@ namespace Exiv2 {
<< "\n"; << "\n";
} }
if (hasNext_) { if (hasNext_) {
os << prefix << "Next IFD: 0x" os << prefix << "Next IFD: 0x"
<< std::setw(8) << std::setfill('0') << std::hex << std::setw(8) << std::setfill('0') << std::hex
<< std::right << next() << "\n"; << std::right << next() << "\n";
} }
// Print data of IFD entries // Print data of IFD entries
for (i = b; i != e; ++i) { for (i = b; i != e; ++i) {
if (i->size() > 4) { if (i->size() > 4) {
os << "Data of entry " << static_cast<int>(i - b) << ":\n"; os << "Data of entry " << static_cast<int>(i - b) << ":\n";

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -60,11 +60,11 @@ namespace Exiv2 {
//! @name Creators //! @name Creators
//@{ //@{
/*! /*!
@brief Default constructor. The entry allocates memory for its @brief Default constructor. The entry allocates memory for its
data if alloc is true (the default), otherwise it remembers data if alloc is true (the default), otherwise it remembers
just the pointers into a read and writeable data buffer which just the pointers into a read and writeable data buffer which
it doesn't allocate or delete. it doesn't allocate or delete.
*/ */
explicit Entry(bool alloc =true); explicit Entry(bool alloc =true);
//! Destructor //! Destructor
~Entry(); ~Entry();
@ -87,13 +87,13 @@ namespace Exiv2 {
/*! /*!
@brief Set the value of the entry to a single unsigned long component, @brief Set the value of the entry to a single unsigned long component,
i.e., set the type of the entry to unsigned long, number of i.e., set the type of the entry to unsigned long, number of
components to one and the value according to the data provided. components to one and the value according to the data provided.
The size of the data buffer is set to at least four bytes, but is left The size of the data buffer is set to at least four bytes, but is left
unchanged if it can accomodate the pointer. This method can be used unchanged if it can accomodate the pointer. This method can be used
to set the value of a tag which contains a pointer (offset) to a to set the value of a tag which contains a pointer (offset) to a
location in the Exif data (like e.g., ExifTag, 0x8769 in IFD0, which location in the Exif data (like e.g., ExifTag, 0x8769 in IFD0, which
contains a pointer to the Exif IFD). contains a pointer to the Exif IFD).
<BR>This method cannot be used to set the value of a newly created <BR>This method cannot be used to set the value of a newly created
%Entry in non-alloc mode. %Entry in non-alloc mode.
@ -110,9 +110,9 @@ namespace Exiv2 {
copied, i.e., the buffer must remain valid throughout the life of the copied, i.e., the buffer must remain valid throughout the life of the
%Entry. Subsequent calls in non-alloc mode will overwrite the data %Entry. Subsequent calls in non-alloc mode will overwrite the data
pointed to by this pointer with the data provided, i.e., the buffer pointed to by this pointer with the data provided, i.e., the buffer
provided in subsequent calls can be deleted after the call. provided in subsequent calls can be deleted after the call.
<BR>In either memory allocation mode, the data buffer provided must be <BR>In either memory allocation mode, the data buffer provided must be
large enough to hold count components of type. The size of the buffer large enough to hold count components of type. The size of the buffer
will be as indicated in the size argument. I.e., it is possible to will be as indicated in the size argument. I.e., it is possible to
allocate (set) a data buffer larger than required to hold count allocate (set) a data buffer larger than required to hold count
components of the given type. components of the given type.
@ -121,14 +121,14 @@ namespace Exiv2 {
@param count Number of components in the buffer. @param count Number of components in the buffer.
@param data Pointer to the data buffer. @param data Pointer to the data buffer.
@param size Size of the desired data buffer in bytes. @param size Size of the desired data buffer in bytes.
@throw Error if no memory allocation is allowed @throw Error if no memory allocation is allowed
and the size of the data buffer is larger than the existing and the size of the data buffer is larger than the existing
data buffer of the entry or if size is not large enough to hold data buffer of the entry or if size is not large enough to hold
count components of the given type. count components of the given type.
*/ */
void setValue(uint16_t type, uint32_t count, const byte* data, long size); void setValue(uint16_t type, uint32_t count, const byte* data, long size);
/*! /*!
@brief Set the data area. Memory management as for @brief Set the data area. Memory management as for
setValue(uint16_t, uint32_t, const byte*, long) setValue(uint16_t, uint32_t, const byte*, long)
For certain tags the regular value of an IFD entry is an offset to a For certain tags the regular value of an IFD entry is an offset to a
@ -136,36 +136,36 @@ namespace Exiv2 {
(Exif.Image.ExifTag) or tag 0x0201 in IFD1 (Exif.Image.ExifTag) or tag 0x0201 in IFD1
(Exif.Thumbnail.JPEGInterchangeFormat). The offset of ExifTag points (Exif.Thumbnail.JPEGInterchangeFormat). The offset of ExifTag points
to a data area containing the Exif IFD. That of JPEGInterchangeFormat to a data area containing the Exif IFD. That of JPEGInterchangeFormat
contains the JPEG thumbnail image. contains the JPEG thumbnail image.
This method sets the data area of a tag in accordance with the memory This method sets the data area of a tag in accordance with the memory
allocation mode. allocation mode.
@param buf Pointer to the data area. @param buf Pointer to the data area.
@param len Size of the data area. @param len Size of the data area.
@throw Error in non-alloc mode, if there already is a dataarea but the @throw Error in non-alloc mode, if there already is a dataarea but the
size of the existing dataarea is not large enough for the size of the existing dataarea is not large enough for the
new buffer. new buffer.
*/ */
void setDataArea(const byte* buf, long len); void setDataArea(const byte* buf, long len);
/*! /*!
@brief Set the offset(s) to the data area of an entry. @brief Set the offset(s) to the data area of an entry.
Add @em offset to each data component of the entry. This is used by Add @em offset to each data component of the entry. This is used by
Ifd::copy to convert the data components of an entry containing Ifd::copy to convert the data components of an entry containing
offsets relative to the data area to become offsets from the start of offsets relative to the data area to become offsets from the start of
the TIFF header. Usually, entries with a data area have exactly one the TIFF header. Usually, entries with a data area have exactly one
unsigned long data component, which is 0. unsigned long data component, which is 0.
@param offset Offset @param offset Offset
@param byteOrder Byte order @param byteOrder Byte order
@throw Error if the offset is out of range for the data type of the @throw Error if the offset is out of range for the data type of the
tag or the data type is not supported. tag or the data type is not supported.
*/ */
void setDataAreaOffsets(uint32_t offset, ByteOrder byteOrder); void setDataAreaOffsets(uint32_t offset, ByteOrder byteOrder);
/*! /*!
@brief Update the base pointer of the Entry from \em pOldBase @brief Update the base pointer of the Entry from \em pOldBase
to \em pNewBase. to \em pNewBase.
Allows to re-locate the underlying data buffer to a new location Allows to re-locate the underlying data buffer to a new location
@ -184,7 +184,7 @@ namespace Exiv2 {
//! Return the type id. //! Return the type id.
uint16_t type() const { return type_; } uint16_t type() const { return type_; }
//! Return the name of the type //! Return the name of the type
const char* typeName() const const char* typeName() const
{ return TypeInfo::typeName(TypeId(type_)); } { return TypeInfo::typeName(TypeId(type_)); }
//! Return the size in bytes of one element of this type //! Return the size in bytes of one element of this type
long typeSize() const long typeSize() const
@ -209,7 +209,7 @@ namespace Exiv2 {
*/ */
const byte* data() const { return pData_; } const byte* data() const { return pData_; }
/*! /*!
@brief Return a pointer to the n-th component, 0 if there is no @brief Return a pointer to the n-th component, 0 if there is no
n-th component. Do not attempt to write to this pointer. n-th component. Do not attempt to write to this pointer.
*/ */
const byte* component(uint32_t n) const; const byte* component(uint32_t n) const;
@ -227,7 +227,7 @@ namespace Exiv2 {
(Exif.Thumbnail.JPEGInterchangeFormat). The offset of ExifTag points (Exif.Thumbnail.JPEGInterchangeFormat). The offset of ExifTag points
to a data area containing the Exif IFD. That of JPEGInterchangeFormat to a data area containing the Exif IFD. That of JPEGInterchangeFormat
contains the JPEG thumbnail image. contains the JPEG thumbnail image.
Use this method to access (read-only) the data area of a tag. Use Use this method to access (read-only) the data area of a tag. Use
setDataArea() to write to the data area. setDataArea() to write to the data area.
@return Return a pointer to the data area. @return Return a pointer to the data area.
@ -255,7 +255,7 @@ namespace Exiv2 {
//! Offset from the start of the IFD to the data //! Offset from the start of the IFD to the data
long offset_; long offset_;
/*! /*!
Size of the data buffer holding the value in bytes, there is Size of the data buffer holding the value in bytes, there is
no minimum size. no minimum size.
*/ */
long size_; long size_;
@ -302,13 +302,13 @@ namespace Exiv2 {
private: private:
uint16_t tag_; uint16_t tag_;
}; // class FindEntryByTag }; // class FindEntryByTag
/*! /*!
@brief Models an IFD (%Image File Directory) @brief Models an IFD (%Image File Directory)
This class models an IFD as described in the TIFF 6.0 specification. This class models an IFD as described in the TIFF 6.0 specification.
An instance of class %Ifd can operate in two modes, one that allocates and An instance of class %Ifd can operate in two modes, one that allocates and
deallocates the memory required to store data, and one that doesn't deallocates the memory required to store data, and one that doesn't
@ -322,8 +322,8 @@ namespace Exiv2 {
that tag data, which the Exif reader may not understand (e.g., the that tag data, which the Exif reader may not understand (e.g., the
Makernote) remains valid. A "non-intrusive write operation" is the Makernote) remains valid. A "non-intrusive write operation" is the
modification of tag data without increasing the data size. modification of tag data without increasing the data size.
@note Use the mode with memory management (the default) if you are unsure @note Use the mode with memory management (the default) if you are unsure
or if these memory management considerations are of no concern to you. or if these memory management considerations are of no concern to you.
@note The two different modes imply completely different copy and @note The two different modes imply completely different copy and
@ -375,8 +375,8 @@ namespace Exiv2 {
/*! /*!
@brief Read a complete IFD and its data from a data buffer @brief Read a complete IFD and its data from a data buffer
@param buf Pointer to the Exif data buffer that contains the IFD to @param buf Pointer to the Exif data buffer that contains the IFD to
decode. Usually, the buffer will contain all Exif data decode. Usually, the buffer will contain all Exif data
starting from the TIFF header. starting from the TIFF header.
@param len Number of bytes in the Exif data buffer. @param len Number of bytes in the Exif data buffer.
@param start IFD starts at buf + start. @param start IFD starts at buf + start.
@ -384,13 +384,13 @@ namespace Exiv2 {
@param shift IFD offsets are relative to buf + shift. @param shift IFD offsets are relative to buf + shift.
@return 0 if successful;<BR> @return 0 if successful;<BR>
6 if the data buffer is too small, e.g., if an offset points 6 if the data buffer is too small, e.g., if an offset points
beyond the provided buffer. The IFD is cleared in this beyond the provided buffer. The IFD is cleared in this
case. case.
*/ */
int read(const byte* buf, int read(const byte* buf,
long len, long len,
long start, long start,
ByteOrder byteOrder, ByteOrder byteOrder,
long shift =0); long shift =0);
/*! /*!
@ -440,7 +440,7 @@ namespace Exiv2 {
*/ */
void add(const Entry& entry); void add(const Entry& entry);
/*! /*!
@brief Delete the directory entry with the given tag. Return the index @brief Delete the directory entry with the given tag. Return the index
of the deleted entry or 0 if no entry with tag was found. of the deleted entry or 0 if no entry with tag was found.
*/ */
int erase(uint16_t tag); int erase(uint16_t tag);
@ -477,22 +477,22 @@ namespace Exiv2 {
//! @name Accessors //! @name Accessors
//@{ //@{
/*! /*!
@brief Read a sub-IFD from the location pointed to by the directory entry @brief Read a sub-IFD from the location pointed to by the directory entry
with the given tag. with the given tag.
@param dest References the destination IFD. @param dest References the destination IFD.
@param buf The data buffer to read from. The buffer must contain all Exif @param buf The data buffer to read from. The buffer must contain all Exif
data starting from the TIFF header. data starting from the TIFF header.
@param len Number of bytes in the data buffer @param len Number of bytes in the data buffer
@param byteOrder Applicable byte order (little or big endian). @param byteOrder Applicable byte order (little or big endian).
@param tag Tag to look for. @param tag Tag to look for.
@return 0 if successful;<BR> @return 0 if successful;<BR>
6 if reading the sub-IFD failed (see read() above) or 6 if reading the sub-IFD failed (see read() above) or
the location pointed to by the directory entry with the the location pointed to by the directory entry with the
given tag is outside of the data buffer. given tag is outside of the data buffer.
@note It is not considered an error if the tag cannot be found in the @note It is not considered an error if the tag cannot be found in the
IFD. 0 is returned and no action is taken in this case. IFD. 0 is returned and no action is taken in this case.
*/ */
int readSubIfd( int readSubIfd(
@ -514,7 +514,7 @@ namespace Exiv2 {
long offset() const { return offset_; } long offset() const { return offset_; }
/*! /*!
@brief Get the offset of the first data entry outside of the IFD from @brief Get the offset of the first data entry outside of the IFD from
the start of the TIFF header, return 0 if there is none. The the start of the TIFF header, return 0 if there is none. The
data offset is determined when the IFD is read. data offset is determined when the IFD is read.
*/ */
long dataOffset() const { return dataOffset_; } long dataOffset() const { return dataOffset_; }
@ -542,7 +542,7 @@ namespace Exiv2 {
//! Helper structure to build IFD entries //! Helper structure to build IFD entries
struct PreEntry { struct PreEntry {
uint16_t tag_; uint16_t tag_;
uint16_t type_; uint16_t type_;
uint32_t count_; uint32_t count_;
long size_; long size_;
long offsetLoc_; long offsetLoc_;
@ -551,7 +551,7 @@ namespace Exiv2 {
//! cmpPreEntriesByOffset needs to know about PreEntry, that's all. //! cmpPreEntriesByOffset needs to know about PreEntry, that's all.
friend bool cmpPreEntriesByOffset(const PreEntry&, const PreEntry&); friend bool cmpPreEntriesByOffset(const PreEntry&, const PreEntry&);
//! Container for 'pre-entries' //! Container for 'pre-entries'
typedef std::vector<PreEntry> PreEntries; typedef std::vector<PreEntry> PreEntries;
@ -576,7 +576,7 @@ namespace Exiv2 {
//! Pointer to the offset of next IFD //! Pointer to the offset of next IFD
byte* pNext_; byte* pNext_;
/*! /*!
The offset of the next IFD from the start of the TIFF header as data The offset of the next IFD from the start of the TIFF header as data
value (always in sync with *pNext_) value (always in sync with *pNext_)
*/ */
uint32_t next_; uint32_t next_;
@ -600,7 +600,7 @@ namespace Exiv2 {
than those with an offset. than those with an offset.
*/ */
bool cmpPreEntriesByOffset(const Ifd::PreEntry& lhs, const Ifd::PreEntry& rhs); bool cmpPreEntriesByOffset(const Ifd::PreEntry& lhs, const Ifd::PreEntry& rhs);
} // namespace Exiv2 } // namespace Exiv2
#endif // #ifndef IFD_HPP_ #endif // #ifndef IFD_HPP_

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -70,8 +70,8 @@ namespace Exiv2 {
return 0; return 0;
} }
void ImageFactory::registerImage(int type, void ImageFactory::registerImage(int type,
NewInstanceFct newInst, NewInstanceFct newInst,
IsThisTypeFct isType) IsThisTypeFct isType)
{ {
unsigned int i = 0; unsigned int i = 0;
@ -98,7 +98,7 @@ namespace Exiv2 {
int ImageFactory::getType(BasicIo& io) int ImageFactory::getType(BasicIo& io)
{ {
if (io.open() != 0) return ImageType::none; if (io.open() != 0) return ImageType::none;
IoCloser closer(io); IoCloser closer(io);
for (unsigned int i = 0; registry_[i].imageType_ != ImageType::none; ++i) { for (unsigned int i = 0; registry_[i].imageType_ != ImageType::none; ++i) {
if (registry_[i].isThisType_(io, false)) { if (registry_[i].isThisType_(io, false)) {
@ -137,7 +137,7 @@ namespace Exiv2 {
return Image::AutoPtr(); return Image::AutoPtr();
} // ImageFactory::open } // ImageFactory::open
Image::AutoPtr ImageFactory::create(int type, Image::AutoPtr ImageFactory::create(int type,
const std::string& path) const std::string& path)
{ {
std::auto_ptr<FileIo> fileIo(new FileIo(path)); std::auto_ptr<FileIo> fileIo(new FileIo(path));
@ -160,7 +160,7 @@ namespace Exiv2 {
return image; return image;
} }
Image::AutoPtr ImageFactory::create(int type, Image::AutoPtr ImageFactory::create(int type,
BasicIo::AutoPtr io) BasicIo::AutoPtr io)
{ {
// BasicIo instance does not need to be open // BasicIo instance does not need to be open
@ -171,7 +171,7 @@ namespace Exiv2 {
return Image::AutoPtr(); return Image::AutoPtr();
} // ImageFactory::create } // ImageFactory::create
TiffHeader::TiffHeader(ByteOrder byteOrder) TiffHeader::TiffHeader(ByteOrder byteOrder)
: byteOrder_(byteOrder), tag_(0x002a), offset_(0x00000008) : byteOrder_(byteOrder), tag_(0x002a), offset_(0x00000008)
{ {
} }

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -24,7 +24,7 @@
@version $Rev$ @version $Rev$
@author Andreas Huggel (ahu) @author Andreas Huggel (ahu)
<a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a> <a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a>
@author Brad Schick (brad) @author Brad Schick (brad)
<a href="mailto:brad@robotbattle.com">brad@robotbattle.com</a> <a href="mailto:brad@robotbattle.com">brad@robotbattle.com</a>
@date 09-Jan-04, ahu: created<BR> @date 09-Jan-04, ahu: created<BR>
11-Feb-04, ahu: isolated as a component<BR> 11-Feb-04, ahu: isolated as a component<BR>
@ -56,7 +56,7 @@ namespace Exiv2 {
// class definitions // class definitions
//! Supported image formats //! Supported image formats
namespace ImageType { namespace ImageType {
const int none = 0; //!< Not an image const int none = 0; //!< Not an image
} }
@ -66,10 +66,10 @@ namespace Exiv2 {
Most client apps will obtain an Image instance by calling a static Most client apps will obtain an Image instance by calling a static
ImageFactory method. The Image class can then be used to to ImageFactory method. The Image class can then be used to to
read, write, and save metadata. read, write, and save metadata.
*/ */
class Image { class Image {
public: public:
//! Image auto_ptr type //! Image auto_ptr type
typedef std::auto_ptr<Image> AutoPtr; typedef std::auto_ptr<Image> AutoPtr;
@ -85,7 +85,7 @@ namespace Exiv2 {
@brief Read all metadata supported by a specific image format from the @brief Read all metadata supported by a specific image format from the
image. Before this method is called, the various metadata types image. Before this method is called, the various metadata types
will be empty. will be empty.
This method returns success even if no metadata is found in the This method returns success even if no metadata is found in the
image. Callers must therefore check the size of individual metadata image. Callers must therefore check the size of individual metadata
types before accessing the data. types before accessing the data.
@ -96,7 +96,7 @@ namespace Exiv2 {
*/ */
virtual void readMetadata() =0; virtual void readMetadata() =0;
/*! /*!
@brief Write metadata back to the image. @brief Write metadata back to the image.
All existing metadata sections in the image are either created, All existing metadata sections in the image are either created,
replaced, or erased. If values for a given metadata type have been replaced, or erased. If values for a given metadata type have been
@ -104,7 +104,7 @@ namespace Exiv2 {
replaced. If no values have been assigned to a given metadata type, replaced. If no values have been assigned to a given metadata type,
any exists section for that metadata type will be removed from the any exists section for that metadata type will be removed from the
image. image.
@throw Error if the operation fails @throw Error if the operation fails
*/ */
virtual void writeMetadata() =0; virtual void writeMetadata() =0;
@ -158,7 +158,7 @@ namespace Exiv2 {
//! @name Accessors //! @name Accessors
//@{ //@{
/*! /*!
@brief Check if the Image instance is valid. Use after object @brief Check if the Image instance is valid. Use after object
construction. construction.
@return true if the Image is in a valid state. @return true if the Image is in a valid state.
*/ */
@ -171,7 +171,7 @@ namespace Exiv2 {
a previous call to readMetadata() or added directly. The Exif a previous call to readMetadata() or added directly. The Exif
data in the returned instance will be written to the image when data in the returned instance will be written to the image when
writeMetadata() is called. writeMetadata() is called.
@return read only ExifData instance containing Exif values @return read only ExifData instance containing Exif values
*/ */
virtual const ExifData& exifData() const =0; virtual const ExifData& exifData() const =0;
@ -183,7 +183,7 @@ namespace Exiv2 {
a previous call to readMetadata() or added directly. The Exif a previous call to readMetadata() or added directly. The Exif
data in the returned instance will be written to the image when data in the returned instance will be written to the image when
writeMetadata() is called. writeMetadata() is called.
@return modifiable ExifData instance containing Exif values @return modifiable ExifData instance containing Exif values
*/ */
virtual ExifData& exifData() =0; virtual ExifData& exifData() =0;
@ -195,7 +195,7 @@ namespace Exiv2 {
a previous call to readMetadata() or added directly. The Iptc a previous call to readMetadata() or added directly. The Iptc
data in the returned instance will be written to the image when data in the returned instance will be written to the image when
writeMetadata() is called. writeMetadata() is called.
@return modifiable IptcData instance containing Iptc values @return modifiable IptcData instance containing Iptc values
*/ */
virtual const IptcData& iptcData() const =0; virtual const IptcData& iptcData() const =0;
@ -207,7 +207,7 @@ namespace Exiv2 {
a previous call to readMetadata() or added directly. The Iptc a previous call to readMetadata() or added directly. The Iptc
data in the returned instance will be written to the image when data in the returned instance will be written to the image when
writeMetadata() is called. writeMetadata() is called.
@return modifiable IptcData instance containing Iptc values @return modifiable IptcData instance containing Iptc values
*/ */
virtual IptcData& iptcData() =0; virtual IptcData& iptcData() =0;
@ -217,12 +217,12 @@ namespace Exiv2 {
virtual std::string comment() const =0; virtual std::string comment() const =0;
/*! /*!
@brief Return a reference to the BasicIo instance being used for Io. @brief Return a reference to the BasicIo instance being used for Io.
This refence is particularly useful to reading the results of This refence is particularly useful to reading the results of
operations on a MemIo instance. For example after metadata has operations on a MemIo instance. For example after metadata has
been modified and the writeMetadata() method has been called, been modified and the writeMetadata() method has been called,
this method can be used to get access to the modified image. this method can be used to get access to the modified image.
@return BasicIo instance that can be used to read or write image @return BasicIo instance that can be used to read or write image
data directly. data directly.
@note If the returned BasicIo is used to write to the image, the @note If the returned BasicIo is used to write to the image, the
@ -277,8 +277,8 @@ namespace Exiv2 {
@param newInst Function pointer for creating image instances. @param newInst Function pointer for creating image instances.
@param isType Function pointer to test for matching image types. @param isType Function pointer to test for matching image types.
*/ */
static void registerImage(int type, static void registerImage(int type,
NewInstanceFct newInst, NewInstanceFct newInst,
IsThisTypeFct isType); IsThisTypeFct isType);
//@} //@}
@ -287,11 +287,11 @@ namespace Exiv2 {
/*! /*!
@brief Create an Image subclass of the appropriate type by reading @brief Create an Image subclass of the appropriate type by reading
the specified file. %Image type is derived from the file the specified file. %Image type is derived from the file
contents. contents.
@param path %Image file. The contents of the file are tested to @param path %Image file. The contents of the file are tested to
determine the image type. File extension is ignored. determine the image type. File extension is ignored.
@return An auto-pointer that owns an Image instance whose type @return An auto-pointer that owns an Image instance whose type
matches that of the file. matches that of the file.
@throw Error If opening the file fails or it contains data of an @throw Error If opening the file fails or it contains data of an
unknown image type. unknown image type.
*/ */
@ -299,11 +299,11 @@ namespace Exiv2 {
/*! /*!
@brief Create an Image subclass of the appropriate type by reading @brief Create an Image subclass of the appropriate type by reading
the provided memory. %Image type is derived from the memory the provided memory. %Image type is derived from the memory
contents. contents.
@param data Pointer to a data buffer containing an image. The contents @param data Pointer to a data buffer containing an image. The contents
of the memory are tested to determine the image type. of the memory are tested to determine the image type.
@param size Number of bytes pointed to by \em data. @param size Number of bytes pointed to by \em data.
@return An auto-pointer that owns an Image instance whose type @return An auto-pointer that owns an Image instance whose type
matches that of the data buffer. matches that of the data buffer.
@throw Error If the memory contains data of an unknown image type. @throw Error If the memory contains data of an unknown image type.
*/ */
@ -312,15 +312,15 @@ namespace Exiv2 {
@brief Create an Image subclass of the appropriate type by reading @brief Create an Image subclass of the appropriate type by reading
the provided BasicIo instance. %Image type is derived from the the provided BasicIo instance. %Image type is derived from the
data provided by \em io. The passed in \em io instance is data provided by \em io. The passed in \em io instance is
(re)opened by this method. (re)opened by this method.
@param io An auto-pointer that owns a BasicIo instance that provides @param io An auto-pointer that owns a BasicIo instance that provides
image data. The contents of the image data are tested to determine image data. The contents of the image data are tested to determine
the type. the type.
@note This method takes ownership of the passed @note This method takes ownership of the passed
in BasicIo instance through the auto-pointer. Callers should not in BasicIo instance through the auto-pointer. Callers should not
continue to use the BasicIo instance after it is passed to this method. continue to use the BasicIo instance after it is passed to this method.
Use the Image::io() method to get a temporary reference. Use the Image::io() method to get a temporary reference.
@return An auto-pointer that owns an Image instance whose type @return An auto-pointer that owns an Image instance whose type
matches that of the \em io data. If no image type could be matches that of the \em io data. If no image type could be
determined, the pointer is 0. determined, the pointer is 0.
@throw Error If opening the BasicIo fails @throw Error If opening the BasicIo fails
@ -332,7 +332,7 @@ namespace Exiv2 {
@param type Type of the image to be created. @param type Type of the image to be created.
@param path %Image file to create. File extension is ignored. @param path %Image file to create. File extension is ignored.
@return An auto-pointer that owns an Image instance of the requested @return An auto-pointer that owns an Image instance of the requested
type. type.
@throw Error If the image type is not supported. @throw Error If the image type is not supported.
*/ */
static Image::AutoPtr create(int type, const std::string& path); static Image::AutoPtr create(int type, const std::string& path);
@ -341,7 +341,7 @@ namespace Exiv2 {
new image in memory. new image in memory.
@param type Type of the image to be created. @param type Type of the image to be created.
@return An auto-pointer that owns an Image instance of the requested @return An auto-pointer that owns an Image instance of the requested
type. type.
@throw Error If the image type is not supported @throw Error If the image type is not supported
*/ */
static Image::AutoPtr create(int type); static Image::AutoPtr create(int type);
@ -351,24 +351,24 @@ namespace Exiv2 {
contains data, it will be overwritten. contains data, it will be overwritten.
@param type Type of the image to be created. @param type Type of the image to be created.
@param io An auto-pointer that owns a BasicIo instance that will @param io An auto-pointer that owns a BasicIo instance that will
be written to when creating a new image. be written to when creating a new image.
@note This method takes ownership of the passed in BasicIo instance @note This method takes ownership of the passed in BasicIo instance
through the auto-pointer. Callers should not continue to use the through the auto-pointer. Callers should not continue to use the
BasicIo instance after it is passed to this method. Use the BasicIo instance after it is passed to this method. Use the
Image::io() method to get a temporary reference. Image::io() method to get a temporary reference.
@return An auto-pointer that owns an Image instance of the requested @return An auto-pointer that owns an Image instance of the requested
type. If the image type is not supported, the pointer is 0. type. If the image type is not supported, the pointer is 0.
*/ */
static Image::AutoPtr create(int type, BasicIo::AutoPtr io); static Image::AutoPtr create(int type, BasicIo::AutoPtr io);
/*! /*!
@brief Returns the image type of the provided file. @brief Returns the image type of the provided file.
@param path %Image file. The contents of the file are tested to @param path %Image file. The contents of the file are tested to
determine the image type. File extension is ignored. determine the image type. File extension is ignored.
@return %Image type or Image::none if the type is not recognized. @return %Image type or Image::none if the type is not recognized.
*/ */
static int getType(const std::string& path); static int getType(const std::string& path);
/*! /*!
@brief Returns the image type of the provided data buffer. @brief Returns the image type of the provided data buffer.
@param data Pointer to a data buffer containing an image. The contents @param data Pointer to a data buffer containing an image. The contents
of the memory are tested to determine the image type. of the memory are tested to determine the image type.
@param size Number of bytes pointed to by \em data. @param size Number of bytes pointed to by \em data.
@ -405,11 +405,11 @@ namespace Exiv2 {
{} {}
//! Constructor //! Constructor
Registry(int imageType, Registry(int imageType,
NewInstanceFct newInstance, NewInstanceFct newInstance,
IsThisTypeFct isThisType) IsThisTypeFct isThisType)
: imageType_(imageType), : imageType_(imageType),
newInstance_(newInstance), newInstance_(newInstance),
isThisType_(isThisType) isThisType_(isThisType)
{} {}
int imageType_; int imageType_;
NewInstanceFct newInstance_; NewInstanceFct newInstance_;
@ -431,7 +431,7 @@ namespace Exiv2 {
//! @name Creators //! @name Creators
//@{ //@{
/*! /*!
@brief Default constructor. Optionally sets the byte order @brief Default constructor. Optionally sets the byte order
(default: little endian). (default: little endian).
*/ */
explicit TiffHeader(ByteOrder byteOrder =littleEndian); explicit TiffHeader(ByteOrder byteOrder =littleEndian);
@ -445,7 +445,7 @@ namespace Exiv2 {
//! @name Accessors //! @name Accessors
//@{ //@{
/*! /*!
@brief Write a standard TIFF header into buf as a data string, return @brief Write a standard TIFF header into buf as a data string, return
number of bytes copied. number of bytes copied.
@ -466,7 +466,7 @@ namespace Exiv2 {
uint16_t tag() const { return tag_; } uint16_t tag() const { return tag_; }
/*! /*!
@brief Return the offset to IFD0 from the start of the TIFF header. @brief Return the offset to IFD0 from the start of the TIFF header.
The offset is 0x00000008 if IFD0 begins immediately after the The offset is 0x00000008 if IFD0 begins immediately after the
TIFF header. TIFF header.
*/ */
uint32_t offset() const { return offset_; } uint32_t offset() const { return offset_; }
@ -477,7 +477,7 @@ namespace Exiv2 {
uint16_t tag_; uint16_t tag_;
uint32_t offset_; uint32_t offset_;
}; // class TiffHeader }; // class TiffHeader
} // namespace Exiv2 } // namespace Exiv2

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -23,7 +23,7 @@
Version: $Rev$ Version: $Rev$
Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net> Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
History: 19-Sep-05, ahu: created History: 19-Sep-05, ahu: created
*/ */
// ***************************************************************************** // *****************************************************************************
#include "rcsid.hpp" #include "rcsid.hpp"

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -75,7 +75,7 @@ try {
// Make sure they are all the same size // Make sure they are all the same size
if(fileIn.size() != memIo1.size() || memIo1.size() != fileOut1.size()) { if(fileIn.size() != memIo1.size() || memIo1.size() != fileOut1.size()) {
std::cerr << argv[0] << std::cerr << argv[0] <<
": Sizes do not match\n"; ": Sizes do not match\n";
return 1; return 1;
} }
@ -95,7 +95,7 @@ try {
fileTest.close(); fileTest.close();
rc = WriteReadSeek(fileTest); rc = WriteReadSeek(fileTest);
if (rc != 0) return rc; if (rc != 0) return rc;
// Another test of reading and writing // Another test of reading and writing
fileOut1.seek(0, BasicIo::beg); fileOut1.seek(0, BasicIo::beg);
memIo2.seek(0, BasicIo::beg); memIo2.seek(0, BasicIo::beg);
@ -108,12 +108,12 @@ try {
byte buf[32]; byte buf[32];
while ((readCount=fileOut1.read(buf, sizeof(buf)))) { while ((readCount=fileOut1.read(buf, sizeof(buf)))) {
if (memIo2.write(buf, readCount) != readCount) { if (memIo2.write(buf, readCount) != readCount) {
std::cerr << argv[0] << std::cerr << argv[0] <<
": MemIo bad write 2\n"; ": MemIo bad write 2\n";
return 13; return 13;
} }
if (fileOut2.write(buf, readCount) != readCount) { if (fileOut2.write(buf, readCount) != readCount) {
std::cerr << argv[0] << std::cerr << argv[0] <<
": FileIo bad write 2\n"; ": FileIo bad write 2\n";
return 14; return 14;
} }
@ -146,7 +146,7 @@ int WriteReadSeek(BasicIo &io)
std::cerr << ": WRS initial write failed\n"; std::cerr << ": WRS initial write failed\n";
return 2; return 2;
} }
if (io.size() != len1) { if (io.size() != len1) {
std::cerr << ": WRS size is not " << len1 << "\n"; std::cerr << ": WRS size is not " << len1 << "\n";
return 2; return 2;
@ -176,7 +176,7 @@ int WriteReadSeek(BasicIo &io)
std::cerr << ": WRS bad getb o\n"; std::cerr << ": WRS bad getb o\n";
return 5; return 5;
} }
io.seek(-2, BasicIo::cur); io.seek(-2, BasicIo::cur);
if (io.getb() != 'I') { if (io.getb() != 'I') {
std::cerr << ": WRS bad getb I\n"; std::cerr << ": WRS bad getb I\n";
@ -187,7 +187,7 @@ int WriteReadSeek(BasicIo &io)
std::cerr << ": WRS bad putb\n"; std::cerr << ": WRS bad putb\n";
return 7; return 7;
} }
io.seek(-1, BasicIo::cur); io.seek(-1, BasicIo::cur);
if (io.getb() != 'O') { if (io.getb() != 'O') {
std::cerr << ": WRS bad getb O\n"; std::cerr << ": WRS bad getb O\n";
@ -209,7 +209,7 @@ int WriteReadSeek(BasicIo &io)
std::cerr << ": WRS something went wrong\n"; std::cerr << ": WRS something went wrong\n";
return 10; return 10;
} }
// Make sure we got the null back // Make sure we got the null back
if(buf[insert + len2 - 1] != 0) { if(buf[insert + len2 - 1] != 0) {
std::cerr << ": WRS missing null terminator 2\n"; std::cerr << ": WRS missing null terminator 2\n";

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -45,7 +45,7 @@ EXIV2_RCSID("@(#) $Id$");
// class member definitions // class member definitions
namespace Exiv2 { namespace Exiv2 {
Iptcdatum::Iptcdatum(const IptcKey& key, Iptcdatum::Iptcdatum(const IptcKey& key,
const Value* pValue) const Value* pValue)
: key_(key.clone()) : key_(key.clone())
{ {
@ -66,7 +66,7 @@ namespace Exiv2 {
const Value& Iptcdatum::value() const const Value& Iptcdatum::value() const
{ {
if (value_.get() == 0) throw Error(8); if (value_.get() == 0) throw Error(8);
return *value_; return *value_;
} }
Iptcdatum& Iptcdatum::operator=(const Iptcdatum& rhs) Iptcdatum& Iptcdatum::operator=(const Iptcdatum& rhs)
@ -82,7 +82,7 @@ namespace Exiv2 {
return *this; return *this;
} // Iptcdatum::operator= } // Iptcdatum::operator=
Iptcdatum& Iptcdatum::operator=(const uint16_t& value) Iptcdatum& Iptcdatum::operator=(const uint16_t& value)
{ {
UShortValue::AutoPtr v = UShortValue::AutoPtr(new UShortValue); UShortValue::AutoPtr v = UShortValue::AutoPtr(new UShortValue);
@ -174,7 +174,7 @@ namespace Exiv2 {
return rc; return rc;
} // IptcData::read } // IptcData::read
int IptcData::readData(uint16_t dataSet, uint16_t record, int IptcData::readData(uint16_t dataSet, uint16_t record,
const byte* data, uint32_t sizeData) const byte* data, uint32_t sizeData)
{ {
Value::AutoPtr value; Value::AutoPtr value;
@ -246,7 +246,7 @@ namespace Exiv2 {
int IptcData::add(const Iptcdatum& iptcDatum) int IptcData::add(const Iptcdatum& iptcDatum)
{ {
if (!IptcDataSets::dataSetRepeatable( if (!IptcDataSets::dataSetRepeatable(
iptcDatum.tag(), iptcDatum.record()) && iptcDatum.tag(), iptcDatum.record()) &&
findId(iptcDatum.tag(), iptcDatum.record()) != end()) { findId(iptcDatum.tag(), iptcDatum.record()) != end()) {
return 6; return 6;
} }

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -22,7 +22,7 @@
@file iptc.hpp @file iptc.hpp
@brief Encoding and decoding of Iptc data @brief Encoding and decoding of Iptc data
@version $Rev$ @version $Rev$
@author Brad Schick (brad) @author Brad Schick (brad)
<a href="mailto:brad@robotbattle.com">brad@robotbattle.com</a> <a href="mailto:brad@robotbattle.com">brad@robotbattle.com</a>
@date 31-Jul-04, brad: created @date 31-Jul-04, brad: created
*/ */
@ -49,7 +49,7 @@ namespace Exiv2 {
// class definitions // class definitions
/*! /*!
@brief Information related to one Iptc dataset. An Iptc metadatum consists @brief Information related to one Iptc dataset. An Iptc metadatum consists
of an IptcKey and a Value and provides methods to manipulate these. of an IptcKey and a Value and provides methods to manipulate these.
*/ */
class Iptcdatum : public Metadatum { class Iptcdatum : public Metadatum {
@ -68,7 +68,7 @@ namespace Exiv2 {
@throw Error if the key cannot be parsed and converted @throw Error if the key cannot be parsed and converted
to a tag number and record id. to a tag number and record id.
*/ */
explicit Iptcdatum(const IptcKey& key, explicit Iptcdatum(const IptcKey& key,
const Value* pValue =0); const Value* pValue =0);
//! Copy constructor //! Copy constructor
Iptcdatum(const Iptcdatum& rhs); Iptcdatum(const Iptcdatum& rhs);
@ -86,7 +86,7 @@ namespace Exiv2 {
*/ */
Iptcdatum& operator=(const uint16_t& value); Iptcdatum& operator=(const uint16_t& value);
/*! /*!
@brief Assign \em value to the %Iptcdatum. @brief Assign \em value to the %Iptcdatum.
Calls setValue(const std::string&). Calls setValue(const std::string&).
*/ */
Iptcdatum& operator=(const std::string& value); Iptcdatum& operator=(const std::string& value);
@ -101,11 +101,11 @@ namespace Exiv2 {
*/ */
void setValue(const Value* pValue); void setValue(const Value* pValue);
/*! /*!
@brief Set the value to the string \em value, using @brief Set the value to the string \em value, using
Value::read(const std::string&). Value::read(const std::string&).
If the %Iptcdatum does not have a Value yet, then a %Value of If the %Iptcdatum does not have a Value yet, then a %Value of
the correct type for this %Iptcdatum is created. If that the correct type for this %Iptcdatum is created. If that
fails (because of an unknown dataset), a StringValue is fails (because of an unknown dataset), a StringValue is
created. created.
*/ */
void setValue(const std::string& value); void setValue(const std::string& value);
@ -124,7 +124,7 @@ namespace Exiv2 {
@param byteOrder Applicable byte order (little or big endian). @param byteOrder Applicable byte order (little or big endian).
@return Number of characters written. @return Number of characters written.
*/ */
long copy(byte* buf, ByteOrder byteOrder) const long copy(byte* buf, ByteOrder byteOrder) const
{ return value_.get() == 0 ? 0 : value_->copy(buf, byteOrder); } { return value_.get() == 0 ? 0 : value_->copy(buf, byteOrder); }
/*! /*!
@brief Return the key of the Iptcdatum. The key is of the form @brief Return the key of the Iptcdatum. The key is of the form
@ -140,10 +140,10 @@ namespace Exiv2 {
std::string recordName() const std::string recordName() const
{ return key_.get() == 0 ? "" : key_->recordName(); } { return key_.get() == 0 ? "" : key_->recordName(); }
/*! /*!
@brief Return the record id @brief Return the record id
@return record id @return record id
*/ */
uint16_t record() const uint16_t record() const
{ return key_.get() == 0 ? 0 : key_->record(); } { return key_.get() == 0 ? 0 : key_->record(); }
/*! /*!
@brief Return the name of the tag (aka dataset) @brief Return the name of the tag (aka dataset)
@ -155,7 +155,7 @@ namespace Exiv2 {
uint16_t tag() const uint16_t tag() const
{ return key_.get() == 0 ? 0 : key_->tag(); } { return key_.get() == 0 ? 0 : key_->tag(); }
//! Return the type id of the value //! Return the type id of the value
TypeId typeId() const TypeId typeId() const
{ return value_.get() == 0 ? invalidTypeId : value_->typeId(); } { return value_.get() == 0 ? invalidTypeId : value_->typeId(); }
//! Return the name of the type //! Return the name of the type
const char* typeName() const { return TypeInfo::typeName(typeId()); } const char* typeName() const { return TypeInfo::typeName(typeId()); }
@ -166,7 +166,7 @@ namespace Exiv2 {
//! Return the size of the value in bytes //! Return the size of the value in bytes
long size() const { return value_.get() == 0 ? 0 : value_->size(); } long size() const { return value_.get() == 0 ? 0 : value_->size(); }
//! Return the value as a string. //! Return the value as a string.
std::string toString() const std::string toString() const
{ return value_.get() == 0 ? "" : value_->toString(); } { return value_.get() == 0 ? "" : value_->toString(); }
/*! /*!
@brief Return the n-th component of the value converted to long. The @brief Return the n-th component of the value converted to long. The
@ -174,7 +174,7 @@ namespace Exiv2 {
the behaviour of the method is undefined if there is no n-th the behaviour of the method is undefined if there is no n-th
component. component.
*/ */
long toLong(long n =0) const long toLong(long n =0) const
{ return value_.get() == 0 ? -1 : value_->toLong(n); } { return value_.get() == 0 ? -1 : value_->toLong(n); }
/*! /*!
@brief Return the n-th component of the value converted to float. The @brief Return the n-th component of the value converted to float. The
@ -182,7 +182,7 @@ namespace Exiv2 {
the behaviour of the method is undefined if there is no n-th the behaviour of the method is undefined if there is no n-th
component. component.
*/ */
float toFloat(long n =0) const float toFloat(long n =0) const
{ return value_.get() == 0 ? -1 : value_->toFloat(n); } { return value_.get() == 0 ? -1 : value_->toFloat(n); }
/*! /*!
@brief Return the n-th component of the value converted to @brief Return the n-th component of the value converted to
@ -190,30 +190,30 @@ namespace Exiv2 {
Iptcdatum is not set and the behaviour of the method is Iptcdatum is not set and the behaviour of the method is
undefined if there is no n-th component. undefined if there is no n-th component.
*/ */
Rational toRational(long n =0) const Rational toRational(long n =0) const
{ return value_.get() == 0 ? Rational(-1, 1) : value_->toRational(n); } { return value_.get() == 0 ? Rational(-1, 1) : value_->toRational(n); }
/*! /*!
@brief Return an auto-pointer to a copy (clone) of the value. The @brief Return an auto-pointer to a copy (clone) of the value. The
caller owns this copy and the auto-pointer ensures that it will caller owns this copy and the auto-pointer ensures that it will
be deleted. be deleted.
This method is provided for users who need full control over the This method is provided for users who need full control over the
value. A caller may, e.g., downcast the pointer to the appropriate value. A caller may, e.g., downcast the pointer to the appropriate
subclass of Value to make use of the interface of the subclass to set subclass of Value to make use of the interface of the subclass to set
or modify its contents. or modify its contents.
@return An auto-pointer to a copy (clone) of the value, 0 if the value @return An auto-pointer to a copy (clone) of the value, 0 if the value
is not set. is not set.
*/ */
Value::AutoPtr getValue() const Value::AutoPtr getValue() const
{ return value_.get() == 0 ? Value::AutoPtr(0) : value_->clone(); } { return value_.get() == 0 ? Value::AutoPtr(0) : value_->clone(); }
/*! /*!
@brief Return a constant reference to the value. @brief Return a constant reference to the value.
This method is provided mostly for convenient and versatile output of This method is provided mostly for convenient and versatile output of
the value which can (to some extent) be formatted through standard the value which can (to some extent) be formatted through standard
stream manipulators. Do not attempt to write to the value through stream manipulators. Do not attempt to write to the value through
this reference. this reference.
<b>Example:</b> <br> <b>Example:</b> <br>
@code @code
@ -261,17 +261,17 @@ namespace Exiv2 {
private: private:
uint16_t dataset_; uint16_t dataset_;
uint16_t record_; uint16_t record_;
}; // class FindMetadatumById }; // class FindMetadatumById
/*! /*!
@brief A container for Iptc data. This is a top-level class of @brief A container for Iptc data. This is a top-level class of
the %Exiv2 library. the %Exiv2 library.
Provide high-level access to the Iptc data of an image: Provide high-level access to the Iptc data of an image:
- read Iptc information from JPEG files - read Iptc information from JPEG files
- access metadata through keys and standard C++ iterators - access metadata through keys and standard C++ iterators
- add, modify and delete metadata - add, modify and delete metadata
- write Iptc data to JPEG files - write Iptc data to JPEG files
- extract Iptc metadata to files, insert from these files - extract Iptc metadata to files, insert from these files
*/ */
@ -290,7 +290,7 @@ namespace Exiv2 {
@brief Load the Iptc data from a byte buffer. The format must follow @brief Load the Iptc data from a byte buffer. The format must follow
the IPTC IIM4 standard. the IPTC IIM4 standard.
@param buf Pointer to the data buffer to read from @param buf Pointer to the data buffer to read from
@param len Number of bytes in the data buffer @param len Number of bytes in the data buffer
@return 0 if successful;<BR> @return 0 if successful;<BR>
5 if Iptc data is invalid or corrupt;<BR> 5 if Iptc data is invalid or corrupt;<BR>
*/ */
@ -319,7 +319,7 @@ namespace Exiv2 {
6 if the dataset already exists and is not repeatable 6 if the dataset already exists and is not repeatable
*/ */
int add(const IptcKey& key, Value* value); int add(const IptcKey& key, Value* value);
/*! /*!
@brief Add a copy of the Iptcdatum to the Iptc metadata. A check @brief Add a copy of the Iptcdatum to the Iptc metadata. A check
for non-repeatable datasets is performed. for non-repeatable datasets is performed.
@return 0 if successful;<BR> @return 0 if successful;<BR>
@ -327,9 +327,9 @@ namespace Exiv2 {
*/ */
int add(const Iptcdatum& iptcdatum); int add(const Iptcdatum& iptcdatum);
/*! /*!
@brief Delete the Iptcdatum at iterator position pos, return the @brief Delete the Iptcdatum at iterator position pos, return the
position of the next Iptcdatum. Note that iterators into position of the next Iptcdatum. Note that iterators into
the metadata, including pos, are potentially invalidated the metadata, including pos, are potentially invalidated
by this call. by this call.
*/ */
iterator erase(iterator pos); iterator erase(iterator pos);
@ -347,17 +347,17 @@ namespace Exiv2 {
iterator end() { return iptcMetadata_.end(); } iterator end() { return iptcMetadata_.end(); }
/*! /*!
@brief Find a Iptcdatum with the given key, return an iterator to it. @brief Find a Iptcdatum with the given key, return an iterator to it.
If multiple entries with the same key exist, it is undefined If multiple entries with the same key exist, it is undefined
which of the matching metadata is found. which of the matching metadata is found.
*/ */
iterator findKey(const IptcKey& key); iterator findKey(const IptcKey& key);
/*! /*!
@brief Find a Iptcdatum with the given record and dataset it, @brief Find a Iptcdatum with the given record and dataset it,
return a const iterator to it. If multiple entries with the return a const iterator to it. If multiple entries with the
same Ids exists, it is undefined which of the matching same Ids exists, it is undefined which of the matching
metadata is found. metadata is found.
*/ */
iterator findId(uint16_t dataset, iterator findId(uint16_t dataset,
uint16_t record = IptcDataSets::application2); uint16_t record = IptcDataSets::application2);
//@} //@}
@ -374,12 +374,12 @@ namespace Exiv2 {
*/ */
const_iterator findKey(const IptcKey& key) const; const_iterator findKey(const IptcKey& key) const;
/*! /*!
@brief Find a Iptcdatum with the given record and dataset number, @brief Find a Iptcdatum with the given record and dataset number,
return a const iterator to it. If multiple metadata with the return a const iterator to it. If multiple metadata with the
same Ids exist it is undefined which of the matching same Ids exist it is undefined which of the matching
metadata is found. metadata is found.
*/ */
const_iterator findId(uint16_t dataset, const_iterator findId(uint16_t dataset,
uint16_t record = IptcDataSets::application2) const; uint16_t record = IptcDataSets::application2) const;
//! Return true if there is no Iptc metadata //! Return true if there is no Iptc metadata
bool empty() const { return count() == 0; } bool empty() const { return count() == 0; }
@ -400,12 +400,12 @@ namespace Exiv2 {
@param sizeData Length in bytes of dataset payload @param sizeData Length in bytes of dataset payload
@return 0 if successful. @return 0 if successful.
*/ */
int readData(uint16_t dataSet, uint16_t record, int readData(uint16_t dataSet, uint16_t record,
const byte* data, uint32_t sizeData); const byte* data, uint32_t sizeData);
// Constant data // Constant data
static const byte marker_; // Dataset marker static const byte marker_; // Dataset marker
// DATA // DATA
IptcMetadata iptcMetadata_; IptcMetadata iptcMetadata_;
}; // class IptcData }; // class IptcData

@ -32,13 +32,13 @@ try {
std::cout << std::setw(44) << std::setfill(' ') << std::left std::cout << std::setw(44) << std::setfill(' ') << std::left
<< md->key() << " " << md->key() << " "
<< "0x" << std::setw(4) << std::setfill('0') << std::right << "0x" << std::setw(4) << std::setfill('0') << std::right
<< std::hex << md->tag() << " " << std::hex << md->tag() << " "
<< std::setw(9) << std::setfill(' ') << std::left << std::setw(9) << std::setfill(' ') << std::left
<< md->typeName() << " " << md->typeName() << " "
<< std::dec << std::setw(3) << std::dec << std::setw(3)
<< std::setfill(' ') << std::right << std::setfill(' ') << std::right
<< md->count() << " " << md->count() << " "
<< std::dec << md->value() << std::dec << md->value()
<< std::endl; << std::endl;
} }

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -24,7 +24,7 @@
Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net> Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
Brad Schick (brad) <brad@robotbattle.com> Brad Schick (brad) <brad@robotbattle.com>
History: 15-Jan-05, brad: split out from image.cpp History: 15-Jan-05, brad: split out from image.cpp
*/ */
// ***************************************************************************** // *****************************************************************************
#include "rcsid.hpp" #include "rcsid.hpp"
@ -49,7 +49,7 @@ EXIV2_RCSID("@(#) $Id$");
// ***************************************************************************** // *****************************************************************************
// class member definitions // class member definitions
namespace Exiv2 { namespace Exiv2 {
const byte JpegBase::sos_ = 0xda; const byte JpegBase::sos_ = 0xda;
const byte JpegBase::eoi_ = 0xd9; const byte JpegBase::eoi_ = 0xd9;
const byte JpegBase::app0_ = 0xe0; const byte JpegBase::app0_ = 0xe0;
@ -62,8 +62,8 @@ namespace Exiv2 {
const char JpegBase::ps3Id_[] = "Photoshop 3.0\0"; const char JpegBase::ps3Id_[] = "Photoshop 3.0\0";
const char JpegBase::bimId_[] = "8BIM"; const char JpegBase::bimId_[] = "8BIM";
JpegBase::JpegBase(BasicIo::AutoPtr io, bool create, JpegBase::JpegBase(BasicIo::AutoPtr io, bool create,
const byte initData[], long dataSize) const byte initData[], long dataSize)
: io_(io) : io_(io)
{ {
if (create) { if (create) {
@ -96,7 +96,7 @@ namespace Exiv2 {
clearExifData(); clearExifData();
clearComment(); clearComment();
} }
void JpegBase::clearIptcData() void JpegBase::clearIptcData()
{ {
iptcData_.clear(); iptcData_.clear();
@ -123,8 +123,8 @@ namespace Exiv2 {
} }
void JpegBase::setComment(const std::string& comment) void JpegBase::setComment(const std::string& comment)
{ {
comment_ = comment; comment_ = comment;
} }
void JpegBase::setMetadata(const Image& image) void JpegBase::setMetadata(const Image& image)
@ -141,7 +141,7 @@ namespace Exiv2 {
while ((c=io_->getb()) != 0xff) { while ((c=io_->getb()) != 0xff) {
if (c == EOF) return -1; if (c == EOF) return -1;
} }
// Markers can start with any number of 0xff // Markers can start with any number of 0xff
while ((c=io_->getb()) == 0xff) { while ((c=io_->getb()) == 0xff) {
if (c == EOF) return -1; if (c == EOF) return -1;
@ -169,7 +169,7 @@ namespace Exiv2 {
// Read section marker // Read section marker
int marker = advanceToMarker(); int marker = advanceToMarker();
if (marker < 0) throw Error(15); if (marker < 0) throw Error(15);
while (marker != sos_ && marker != eoi_ && search > 0) { while (marker != sos_ && marker != eoi_ && search > 0) {
// Read size and signature (ok if this hits EOF) // Read size and signature (ok if this hits EOF)
bufRead = io_->read(buf.pData_, bufMinSize); bufRead = io_->read(buf.pData_, bufMinSize);
@ -179,7 +179,7 @@ namespace Exiv2 {
if (marker == app1_ && memcmp(buf.pData_ + 2, exifId_, 6) == 0) { if (marker == app1_ && memcmp(buf.pData_ + 2, exifId_, 6) == 0) {
if (size < 8) throw Error(15); if (size < 8) throw Error(15);
// Seek to begining and read the Exif data // Seek to begining and read the Exif data
io_->seek(8-bufRead, BasicIo::cur); io_->seek(8-bufRead, BasicIo::cur);
long sizeExifData = size - 8; long sizeExifData = size - 8;
DataBuf rawExif(sizeExifData); DataBuf rawExif(sizeExifData);
io_->read(rawExif.pData_, sizeExifData); io_->read(rawExif.pData_, sizeExifData);
@ -235,9 +235,9 @@ namespace Exiv2 {
// Operates on raw data (rather than file streams) to simplify reuse // Operates on raw data (rather than file streams) to simplify reuse
int JpegBase::locateIptcData(const byte *pPsData, int JpegBase::locateIptcData(const byte *pPsData,
long sizePsData, long sizePsData,
const byte **record, const byte **record,
uint16_t *const sizeHdr, uint16_t *const sizeHdr,
uint16_t *const sizeIptc) const uint16_t *const sizeIptc) const
{ {
@ -254,7 +254,7 @@ namespace Exiv2 {
position += 4; position += 4;
uint16_t type = getUShort(pPsData+ position, bigEndian); uint16_t type = getUShort(pPsData+ position, bigEndian);
position += 2; position += 2;
// Pascal string is padded to have an even size (including size byte) // Pascal string is padded to have an even size (including size byte)
byte psSize = pPsData[position] + 1; byte psSize = pPsData[position] + 1;
psSize += (psSize & 1); psSize += (psSize & 1);
@ -265,7 +265,7 @@ namespace Exiv2 {
long dataSize = getULong(pPsData + position, bigEndian); long dataSize = getULong(pPsData + position, bigEndian);
position += 4; position += 4;
if (dataSize > sizePsData - position) return -2; if (dataSize > sizePsData - position) return -2;
if (type == iptc_) { if (type == iptc_) {
*sizeIptc = static_cast<uint16_t>(dataSize); *sizeIptc = static_cast<uint16_t>(dataSize);
*sizeHdr = psSize + 10; *sizeHdr = psSize + 10;
@ -301,7 +301,7 @@ namespace Exiv2 {
if (io_->error() || io_->eof()) throw Error(20); if (io_->error() || io_->eof()) throw Error(20);
throw Error(22); throw Error(22);
} }
const long bufMinSize = 16; const long bufMinSize = 16;
long bufRead = 0; long bufRead = 0;
DataBuf buf(bufMinSize); DataBuf buf(bufMinSize);
@ -320,7 +320,7 @@ namespace Exiv2 {
// Read section marker // Read section marker
int marker = advanceToMarker(); int marker = advanceToMarker();
if (marker < 0) throw Error(22); if (marker < 0) throw Error(22);
// First find segments of interest. Normally app0 is first and we want // First find segments of interest. Normally app0 is first and we want
// to insert after it. But if app0 comes after com, app1 and app13 then // to insert after it. But if app0 comes after com, app1 and app13 then
// don't bother. // don't bother.
@ -376,7 +376,7 @@ namespace Exiv2 {
count = 0; count = 0;
marker = advanceToMarker(); marker = advanceToMarker();
if (marker < 0) throw Error(22); if (marker < 0) throw Error(22);
// To simplify this a bit, new segments are inserts at either the start // To simplify this a bit, new segments are inserts at either the start
// or right after app0. This is standard in most jpegs, but has the // or right after app0. This is standard in most jpegs, but has the
// potential to change segment ordering (which is allowed). // potential to change segment ordering (which is allowed).
@ -395,7 +395,7 @@ namespace Exiv2 {
// Write COM marker, size of comment, and string // Write COM marker, size of comment, and string
tmpBuf[0] = 0xff; tmpBuf[0] = 0xff;
tmpBuf[1] = com_; tmpBuf[1] = com_;
us2Data(tmpBuf + 2, us2Data(tmpBuf + 2,
static_cast<uint16_t>(comment_.length()+3), bigEndian); static_cast<uint16_t>(comment_.length()+3), bigEndian);
if (outIo.write(tmpBuf, 4) != 4) throw Error(21); if (outIo.write(tmpBuf, 4) != 4) throw Error(21);
if (outIo.write((byte*)comment_.data(), (long)comment_.length()) if (outIo.write((byte*)comment_.data(), (long)comment_.length())
@ -409,17 +409,17 @@ namespace Exiv2 {
DataBuf rawExif(exifData_.copy()); DataBuf rawExif(exifData_.copy());
tmpBuf[0] = 0xff; tmpBuf[0] = 0xff;
tmpBuf[1] = app1_; tmpBuf[1] = app1_;
us2Data(tmpBuf + 2, us2Data(tmpBuf + 2,
static_cast<uint16_t>(rawExif.size_+8), static_cast<uint16_t>(rawExif.size_+8),
bigEndian); bigEndian);
memcpy(tmpBuf + 4, exifId_, 6); memcpy(tmpBuf + 4, exifId_, 6);
if (outIo.write(tmpBuf, 10) != 10) throw Error(21); if (outIo.write(tmpBuf, 10) != 10) throw Error(21);
if (outIo.write(rawExif.pData_, rawExif.size_) if (outIo.write(rawExif.pData_, rawExif.size_)
!= rawExif.size_) throw Error(21); != rawExif.size_) throw Error(21);
if (outIo.error()) throw Error(21); if (outIo.error()) throw Error(21);
--search; --search;
} }
const byte *record = psData.pData_; const byte *record = psData.pData_;
uint16_t sizeIptc = 0; uint16_t sizeIptc = 0;
uint16_t sizeHdr = 0; uint16_t sizeHdr = 0;
@ -434,9 +434,9 @@ namespace Exiv2 {
// write app13 marker, new size, and ps3Id // write app13 marker, new size, and ps3Id
tmpBuf[0] = 0xff; tmpBuf[0] = 0xff;
tmpBuf[1] = app13_; tmpBuf[1] = app13_;
const int sizeNewData = rawIptc.size_ ? const int sizeNewData = rawIptc.size_ ?
rawIptc.size_ + (rawIptc.size_ & 1) + 12 : 0; rawIptc.size_ + (rawIptc.size_ & 1) + 12 : 0;
us2Data(tmpBuf + 2, us2Data(tmpBuf + 2,
static_cast<uint16_t>(psData.size_-sizeOldData+sizeNewData+16), static_cast<uint16_t>(psData.size_-sizeOldData+sizeNewData+16),
bigEndian); bigEndian);
memcpy(tmpBuf + 4, ps3Id_, 14); memcpy(tmpBuf + 4, ps3Id_, 14);
@ -456,7 +456,7 @@ namespace Exiv2 {
tmpBuf[7] = 0; tmpBuf[7] = 0;
ul2Data(tmpBuf + 8, rawIptc.size_, bigEndian); ul2Data(tmpBuf + 8, rawIptc.size_, bigEndian);
if (outIo.write(tmpBuf, 12) != 12) throw Error(21); if (outIo.write(tmpBuf, 12) != 12) throw Error(21);
if (outIo.write(rawIptc.pData_, rawIptc.size_) if (outIo.write(rawIptc.pData_, rawIptc.size_)
!= rawIptc.size_) throw Error(21); != rawIptc.size_) throw Error(21);
// data is padded to be even (but not included in size) // data is padded to be even (but not included in size)
if (rawIptc.size_ & 1) { if (rawIptc.size_ & 1) {
@ -465,9 +465,9 @@ namespace Exiv2 {
if (outIo.error()) throw Error(21); if (outIo.error()) throw Error(21);
--search; --search;
} }
// write existing stuff after record // write existing stuff after record
if (outIo.write(record+sizeOldData, sizeEnd) if (outIo.write(record+sizeOldData, sizeEnd)
!= sizeEnd) throw Error(21); != sizeEnd) throw Error(21);
if (outIo.error()) throw Error(21); if (outIo.error()) throw Error(21);
} }
@ -526,11 +526,11 @@ namespace Exiv2 {
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xDA,0x00,0x0C,0x03,0x01,0x00,0x02, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xDA,0x00,0x0C,0x03,0x01,0x00,0x02,
0x11,0x03,0x11,0x00,0x3F,0x00,0xA0,0x00,0x0F,0xFF,0xD9 }; 0x11,0x03,0x11,0x00,0x3F,0x00,0xA0,0x00,0x0F,0xFF,0xD9 };
JpegImage::JpegImage(BasicIo::AutoPtr io, bool create) JpegImage::JpegImage(BasicIo::AutoPtr io, bool create)
: JpegBase(io, create, blank_, sizeof(blank_)) : JpegBase(io, create, blank_, sizeof(blank_))
{ {
} }
int JpegImage::writeHeader(BasicIo& outIo) const int JpegImage::writeHeader(BasicIo& outIo) const
{ {
// Jpeg header // Jpeg header
@ -569,11 +569,11 @@ namespace Exiv2 {
if (!advance || !result ) iIo.seek(-2, BasicIo::cur); if (!advance || !result ) iIo.seek(-2, BasicIo::cur);
return result; return result;
} }
const char ExvImage::exiv2Id_[] = "Exiv2"; const char ExvImage::exiv2Id_[] = "Exiv2";
const byte ExvImage::blank_[] = { 0xff,0x01,'E','x','i','v','2',0xff,0xd9 }; const byte ExvImage::blank_[] = { 0xff,0x01,'E','x','i','v','2',0xff,0xd9 };
ExvImage::ExvImage(BasicIo::AutoPtr io, bool create) ExvImage::ExvImage(BasicIo::AutoPtr io, bool create)
: JpegBase(io, create, blank_, sizeof(blank_)) : JpegBase(io, create, blank_, sizeof(blank_))
{ {
} }
@ -615,7 +615,7 @@ namespace Exiv2 {
iIo.read(tmpBuf, 7); iIo.read(tmpBuf, 7);
if (iIo.error() || iIo.eof()) return false; if (iIo.error() || iIo.eof()) return false;
if ( 0xff != tmpBuf[0] || 0x01 != tmpBuf[1] if ( 0xff != tmpBuf[0] || 0x01 != tmpBuf[1]
|| memcmp(tmpBuf + 2, ExvImage::exiv2Id_, 5) != 0) { || memcmp(tmpBuf + 2, ExvImage::exiv2Id_, 5) != 0) {
result = false; result = false;
} }

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -24,7 +24,7 @@
@version $Rev$ @version $Rev$
@author Andreas Huggel (ahu) @author Andreas Huggel (ahu)
<a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a> <a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a>
@author Brad Schick (brad) @author Brad Schick (brad)
<a href="mailto:brad@robotbattle.com">brad@robotbattle.com</a> <a href="mailto:brad@robotbattle.com">brad@robotbattle.com</a>
@date 15-Jan-05, brad: split out from image.cpp @date 15-Jan-05, brad: split out from image.cpp
*/ */
@ -51,12 +51,12 @@ namespace Exiv2 {
// class definitions // class definitions
// Supported jpeg image formats // Supported jpeg image formats
namespace ImageType { namespace ImageType {
const int jpeg = 1; //!< Jpeg image type (see class JpegImage) const int jpeg = 1; //!< Jpeg image type (see class JpegImage)
const int exv = 2; //!< Exv image type (see class ExvImage) const int exv = 2; //!< Exv image type (see class ExvImage)
} }
/*! /*!
@brief Abstract helper base class to access JPEG images. @brief Abstract helper base class to access JPEG images.
*/ */
class JpegBase : public Image { class JpegBase : public Image {
@ -89,11 +89,11 @@ namespace Exiv2 {
IptcData& iptcData() { return iptcData_; } IptcData& iptcData() { return iptcData_; }
std::string comment() const { return comment_; } std::string comment() const { return comment_; }
BasicIo& io() const { return *io_; } BasicIo& io() const { return *io_; }
//@} //@}
protected: protected:
//! @name Creators //! @name Creators
//@{ //@{
/*! /*!
@brief Constructor that can either open an existing image or create @brief Constructor that can either open an existing image or create
a new image from scratch. If a new image is to be created, any a new image from scratch. If a new image is to be created, any
existing data is overwritten. existing data is overwritten.
@ -133,9 +133,9 @@ namespace Exiv2 {
moved (see below). This applies only if the type matches and the moved (see below). This applies only if the type matches and the
function returns true. If the type does not match, the stream function returns true. If the type does not match, the stream
position is not changed. However, if reading from the stream fails, position is not changed. However, if reading from the stream fails,
the stream position is undefined. Consult the stream state to obtain the stream position is undefined. Consult the stream state to obtain
more information in this case. more information in this case.
@param iIo BasicIo instance to read from. @param iIo BasicIo instance to read from.
@param advance Flag indicating whether the position of the io @param advance Flag indicating whether the position of the io
should be advanced by the number of characters read to should be advanced by the number of characters read to
@ -180,7 +180,7 @@ namespace Exiv2 {
/*! /*!
@brief Locates Photoshop formated Iptc data in a memory buffer. @brief Locates Photoshop formated Iptc data in a memory buffer.
Operates on raw data to simplify reuse. Operates on raw data to simplify reuse.
@param pPsData Pointer to buffer containing entire payload of @param pPsData Pointer to buffer containing entire payload of
Photoshop formated APP13 Jpeg segment. Photoshop formated APP13 Jpeg segment.
@param sizePsData Size in bytes of pPsData. @param sizePsData Size in bytes of pPsData.
@param record Output value that is set to the start of the Iptc @param record Output value that is set to the start of the Iptc
@ -195,9 +195,9 @@ namespace Exiv2 {
3 if no Iptc data was found in pPsData;<BR> 3 if no Iptc data was found in pPsData;<BR>
-2 if the pPsData buffer does not contain valid data. -2 if the pPsData buffer does not contain valid data.
*/ */
int locateIptcData(const byte *pPsData, int locateIptcData(const byte *pPsData,
long sizePsData, long sizePsData,
const byte **record, const byte **record,
uint16_t *const sizeHdr, uint16_t *const sizeHdr,
uint16_t *const sizeIptc) const; uint16_t *const sizeIptc) const;
/*! /*!
@ -209,8 +209,8 @@ namespace Exiv2 {
*/ */
int initImage(const byte initData[], long dataSize); int initImage(const byte initData[], long dataSize);
/*! /*!
@brief Provides the main implementation of writeMetadata() by @brief Provides the main implementation of writeMetadata() by
writing all buffered metadata to the provided BasicIo. writing all buffered metadata to the provided BasicIo.
@param oIo BasicIo instance to write to (a temporary location). @param oIo BasicIo instance to write to (a temporary location).
@return 4 if opening or writing to the associated BasicIo fails @return 4 if opening or writing to the associated BasicIo fails
@ -226,7 +226,7 @@ namespace Exiv2 {
JpegBase& operator=(const JpegBase& rhs); JpegBase& operator=(const JpegBase& rhs);
}; // class JpegBase }; // class JpegBase
/*! /*!
@brief Class to access JPEG images @brief Class to access JPEG images
*/ */
class JpegImage : public JpegBase { class JpegImage : public JpegBase {
@ -234,7 +234,7 @@ namespace Exiv2 {
public: public:
//! @name Creators //! @name Creators
//@{ //@{
/*! /*!
@brief Constructor that can either open an existing Jpeg image or create @brief Constructor that can either open an existing Jpeg image or create
a new image from scratch. If a new image is to be created, any a new image from scratch. If a new image is to be created, any
existing data is overwritten. Since the constructor can not return existing data is overwritten. Since the constructor can not return
@ -290,7 +290,7 @@ namespace Exiv2 {
public: public:
//! @name Creators //! @name Creators
//@{ //@{
/*! /*!
@brief Constructor that can either open an existing Exv image or create @brief Constructor that can either open an existing Exv image or create
a new image from scratch. If a new image is to be created, any a new image from scratch. If a new image is to be created, any
existing data is overwritten. Since the constructor can not return existing data is overwritten. Since the constructor can not return
@ -335,19 +335,19 @@ namespace Exiv2 {
// ***************************************************************************** // *****************************************************************************
// template, inline and free functions // template, inline and free functions
// These could be static private functions on Image subclasses but then // These could be static private functions on Image subclasses but then
// ImageFactory needs to be made a friend. // ImageFactory needs to be made a friend.
/*! /*!
@brief Create a new JpegImage instance and return an auto-pointer to it. @brief Create a new JpegImage instance and return an auto-pointer to it.
Caller owns the returned object and the auto-pointer ensures that Caller owns the returned object and the auto-pointer ensures that
it will be deleted. it will be deleted.
*/ */
Image::AutoPtr newJpegInstance(BasicIo::AutoPtr io, bool create); Image::AutoPtr newJpegInstance(BasicIo::AutoPtr io, bool create);
//! Check if the file iIo is a JPEG image. //! Check if the file iIo is a JPEG image.
bool isJpegType(BasicIo& iIo, bool advance); bool isJpegType(BasicIo& iIo, bool advance);
/*! /*!
@brief Create a new ExvImage instance and return an auto-pointer to it. @brief Create a new ExvImage instance and return an auto-pointer to it.
Caller owns the returned object and the auto-pointer ensures that Caller owns the returned object and the auto-pointer ensures that
it will be deleted. it will be deleted.
*/ */
Image::AutoPtr newExvInstance(BasicIo::AutoPtr io, bool create); Image::AutoPtr newExvInstance(BasicIo::AutoPtr io, bool create);

@ -1,6 +1,6 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
Abstract : Key unit tests Abstract : Key unit tests
File : key-test.cpp File : key-test.cpp
Version : $Rev$ Version : $Rev$
@ -31,43 +31,43 @@ int main()
os << ek; os << ek;
if (os.str() != key) { if (os.str() != key) {
std::cout << "Testcase failed (operator<<)" << std::endl; std::cout << "Testcase failed (operator<<)" << std::endl;
rc += 1; rc += 1;
} }
// familyName // familyName
tc += 1; tc += 1;
if (std::string(ek.familyName()) != "Exif") { if (std::string(ek.familyName()) != "Exif") {
std::cout << "Testcase failed (familyName)" << std::endl; std::cout << "Testcase failed (familyName)" << std::endl;
rc += 1; rc += 1;
} }
// groupName // groupName
tc += 1; tc += 1;
if (ek.groupName() != "Iop") { if (ek.groupName() != "Iop") {
std::cout << "Testcase failed (groupName)" << std::endl; std::cout << "Testcase failed (groupName)" << std::endl;
rc += 1; rc += 1;
} }
// tagName // tagName
tc += 1; tc += 1;
if (ek.tagName() != "InteroperabilityVersion") { if (ek.tagName() != "InteroperabilityVersion") {
std::cout << "Testcase failed (tagName)" << std::endl; std::cout << "Testcase failed (tagName)" << std::endl;
rc += 1; rc += 1;
} }
// tagName // tagName
tc += 1; tc += 1;
if (ek.tag() != 0x0002) { if (ek.tag() != 0x0002) {
std::cout << "Testcase failed (tag)" << std::endl; std::cout << "Testcase failed (tag)" << std::endl;
rc += 1; rc += 1;
} }
// ifdName // ifdName
tc += 1; tc += 1;
if (std::string(ek.ifdName()) != "Iop") { if (std::string(ek.ifdName()) != "Iop") {
std::cout << "Testcase failed (ifdName: " << std::endl; std::cout << "Testcase failed (ifdName: " << std::endl;
rc += 1; rc += 1;
} }
// sectionName // sectionName
tc += 1; tc += 1;
if (ek.sectionName() != "Interoperability") { if (ek.sectionName() != "Interoperability") {
std::cout << "Testcase failed (sectionName)" << std::endl; std::cout << "Testcase failed (sectionName)" << std::endl;
rc += 1; rc += 1;
} }
// ----- // -----
@ -81,51 +81,51 @@ int main()
os2 << ek2; os2 << ek2;
if (os2.str() != key) { if (os2.str() != key) {
std::cout << "Testcase failed (operator<<)" << std::endl; std::cout << "Testcase failed (operator<<)" << std::endl;
rc += 1; rc += 1;
} }
// familyName // familyName
tc += 1; tc += 1;
if (std::string(ek2.familyName()) != "Exif") { if (std::string(ek2.familyName()) != "Exif") {
std::cout << "Testcase failed (familyName)" << std::endl; std::cout << "Testcase failed (familyName)" << std::endl;
rc += 1; rc += 1;
} }
// groupName // groupName
tc += 1; tc += 1;
if (ek2.groupName() != "Iop") { if (ek2.groupName() != "Iop") {
std::cout << "Testcase failed (groupName)" << std::endl; std::cout << "Testcase failed (groupName)" << std::endl;
rc += 1; rc += 1;
} }
// tagName // tagName
tc += 1; tc += 1;
if (ek2.tagName() != "InteroperabilityVersion") { if (ek2.tagName() != "InteroperabilityVersion") {
std::cout << "Testcase failed (tagName)" << std::endl; std::cout << "Testcase failed (tagName)" << std::endl;
rc += 1; rc += 1;
} }
// tagName // tagName
tc += 1; tc += 1;
if (ek2.tag() != 0x0002) { if (ek2.tag() != 0x0002) {
std::cout << "Testcase failed (tag)" << std::endl; std::cout << "Testcase failed (tag)" << std::endl;
rc += 1; rc += 1;
} }
// ifdName // ifdName
tc += 1; tc += 1;
if (std::string(ek2.ifdName()) != "Iop") { if (std::string(ek2.ifdName()) != "Iop") {
std::cout << "Testcase failed (ifdName: " << std::endl; std::cout << "Testcase failed (ifdName: " << std::endl;
rc += 1; rc += 1;
} }
// sectionName // sectionName
tc += 1; tc += 1;
if (ek2.sectionName() != "Interoperability") { if (ek2.sectionName() != "Interoperability") {
std::cout << "Testcase failed (sectionName)" << std::endl; std::cout << "Testcase failed (sectionName)" << std::endl;
rc += 1; rc += 1;
} }
// ----- // -----
long len = 76; long len = 76;
byte buf[] byte buf[]
= { // No = { // No
0x00,0x04, 0x00,0x04,
// Tag Type Components Offset/Data // Tag Type Components Offset/Data
0x00,0x01, 0x00,0x02, 0x00,0x00,0x00,0x04, 'T', 'h', 'e', '\0', 0x00,0x01, 0x00,0x02, 0x00,0x00,0x00,0x04, 'T', 'h', 'e', '\0',
0x00,0x02, 0x00,0x02, 0x00,0x00,0x00,0x06, 0x00,0x00,0x00,0x37, 0x00,0x02, 0x00,0x02, 0x00,0x00,0x00,0x06, 0x00,0x00,0x00,0x37,
@ -159,43 +159,43 @@ int main()
os2 << ek3; os2 << ek3;
if (os2.str() != key) { if (os2.str() != key) {
std::cout << "Testcase failed (operator<<)" << std::endl; std::cout << "Testcase failed (operator<<)" << std::endl;
rc += 1; rc += 1;
} }
// familyName // familyName
tc += 1; tc += 1;
if (std::string(ek3.familyName()) != "Exif") { if (std::string(ek3.familyName()) != "Exif") {
std::cout << "Testcase failed (familyName)" << std::endl; std::cout << "Testcase failed (familyName)" << std::endl;
rc += 1; rc += 1;
} }
// groupName // groupName
tc += 1; tc += 1;
if (ek3.groupName() != "Iop") { if (ek3.groupName() != "Iop") {
std::cout << "Testcase failed (groupName)" << std::endl; std::cout << "Testcase failed (groupName)" << std::endl;
rc += 1; rc += 1;
} }
// tagName // tagName
tc += 1; tc += 1;
if (ek3.tagName() != "InteroperabilityVersion") { if (ek3.tagName() != "InteroperabilityVersion") {
std::cout << "Testcase failed (tagName)" << std::endl; std::cout << "Testcase failed (tagName)" << std::endl;
rc += 1; rc += 1;
} }
// tagName // tagName
tc += 1; tc += 1;
if (ek3.tag() != 0x0002) { if (ek3.tag() != 0x0002) {
std::cout << "Testcase failed (tag)" << std::endl; std::cout << "Testcase failed (tag)" << std::endl;
rc += 1; rc += 1;
} }
// ifdName // ifdName
tc += 1; tc += 1;
if (std::string(ek3.ifdName()) != "Iop") { if (std::string(ek3.ifdName()) != "Iop") {
std::cout << "Testcase failed (ifdName: " << std::endl; std::cout << "Testcase failed (ifdName: " << std::endl;
rc += 1; rc += 1;
} }
// sectionName // sectionName
tc += 1; tc += 1;
if (ek3.sectionName() != "Interoperability") { if (ek3.sectionName() != "Interoperability") {
std::cout << "Testcase failed (sectionName)" << std::endl; std::cout << "Testcase failed (sectionName)" << std::endl;
rc += 1; rc += 1;
} }
} }
@ -206,12 +206,12 @@ int main()
tc += 1; tc += 1;
if (ek4.key() != "Exif.Image.Model") { if (ek4.key() != "Exif.Image.Model") {
std::cout << "Testcase failed (converted key)" << std::endl; std::cout << "Testcase failed (converted key)" << std::endl;
rc += 1; rc += 1;
} }
tc += 1; tc += 1;
if (ek4.tagName() != "Model") { if (ek4.tagName() != "Model") {
std::cout << "Testcase failed (converted tagName)" << std::endl; std::cout << "Testcase failed (converted tagName)" << std::endl;
rc += 1; rc += 1;
} }
// ----- // -----
@ -220,12 +220,12 @@ int main()
tc += 1; tc += 1;
if (ek5.key() != "Exif.Nikon3.Focus") { if (ek5.key() != "Exif.Nikon3.Focus") {
std::cout << "Testcase failed (converted key)" << std::endl; std::cout << "Testcase failed (converted key)" << std::endl;
rc += 1; rc += 1;
} }
tc += 1; tc += 1;
if (ek5.tagName() != "Focus") { if (ek5.tagName() != "Focus") {
std::cout << "Testcase failed (converted tagName)" << std::endl; std::cout << "Testcase failed (converted tagName)" << std::endl;
rc += 1; rc += 1;
} }
// ----- // -----
@ -234,17 +234,17 @@ int main()
tc += 1; tc += 1;
if (ik1.key() != "Iptc.Envelope.Destination") { if (ik1.key() != "Iptc.Envelope.Destination") {
std::cout << "Testcase failed (converted Iptc key)" << std::endl; std::cout << "Testcase failed (converted Iptc key)" << std::endl;
rc += 1; rc += 1;
} }
tc += 1; tc += 1;
if (ik1.tagName() != "Destination") { if (ik1.tagName() != "Destination") {
std::cout << "Testcase failed (converted tagName)" << std::endl; std::cout << "Testcase failed (converted tagName)" << std::endl;
rc += 1; rc += 1;
} }
tc += 1; tc += 1;
if (ik1.recordName() != "Envelope") { if (ik1.recordName() != "Envelope") {
std::cout << "Testcase failed (converted recordName)" << std::endl; std::cout << "Testcase failed (converted recordName)" << std::endl;
rc += 1; rc += 1;
} }
// ----- // -----
@ -253,17 +253,17 @@ int main()
tc += 1; tc += 1;
if (ik2.key() != "Iptc.0x1234.0xabcd") { if (ik2.key() != "Iptc.0x1234.0xabcd") {
std::cout << "Testcase failed (unknown Iptc key)" << std::endl; std::cout << "Testcase failed (unknown Iptc key)" << std::endl;
rc += 1; rc += 1;
} }
tc += 1; tc += 1;
if (ik2.tagName() != "0xabcd") { if (ik2.tagName() != "0xabcd") {
std::cout << "Testcase failed (converted tagName)" << std::endl; std::cout << "Testcase failed (converted tagName)" << std::endl;
rc += 1; rc += 1;
} }
tc += 1; tc += 1;
if (ik2.recordName() != "0x1234") { if (ik2.recordName() != "0x1234") {
std::cout << "Testcase failed (converted recordName)" << std::endl; std::cout << "Testcase failed (converted recordName)" << std::endl;
rc += 1; rc += 1;
} }
// ----- // -----

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -29,7 +29,7 @@
EXIV2_RCSID("@(#) $Id$"); EXIV2_RCSID("@(#) $Id$");
// Define DEBUG_* to output debug information to std::cerr, e.g, by calling // Define DEBUG_* to output debug information to std::cerr, e.g, by calling
// make like this: make DEFS=-DDEBUG_MAKERNOTE makernote.o // make like this: make DEFS=-DDEBUG_MAKERNOTE makernote.o
//#define DEBUG_MAKERNOTE //#define DEBUG_MAKERNOTE
//#define DEBUG_REGISTRY //#define DEBUG_REGISTRY
@ -49,7 +49,7 @@ EXIV2_RCSID("@(#) $Id$");
// class member definitions // class member definitions
namespace Exiv2 { namespace Exiv2 {
MakerNote::MakerNote(bool alloc) MakerNote::MakerNote(bool alloc)
: alloc_(alloc), offset_(0), byteOrder_(invalidByteOrder) : alloc_(alloc), offset_(0), byteOrder_(invalidByteOrder)
{ {
} }
@ -65,7 +65,7 @@ namespace Exiv2 {
} }
IfdMakerNote::IfdMakerNote(IfdId ifdId, bool alloc, bool hasNext) IfdMakerNote::IfdMakerNote(IfdId ifdId, bool alloc, bool hasNext)
: MakerNote(alloc), : MakerNote(alloc),
absShift_(true), shift_(0), start_(0), ifd_(ifdId, 0, alloc, hasNext) absShift_(true), shift_(0), start_(0), ifd_(ifdId, 0, alloc, hasNext)
{ {
} }
@ -78,8 +78,8 @@ namespace Exiv2 {
} }
int IfdMakerNote::read(const byte* buf, int IfdMakerNote::read(const byte* buf,
long len, long len,
long start, long start,
ByteOrder byteOrder, ByteOrder byteOrder,
long shift) long shift)
{ {
@ -132,7 +132,7 @@ namespace Exiv2 {
return len; return len;
} // IfdMakerNote::copy } // IfdMakerNote::copy
int IfdMakerNote::readHeader(const byte* buf, int IfdMakerNote::readHeader(const byte* buf,
long len, long len,
ByteOrder byteOrder) ByteOrder byteOrder)
{ {
@ -141,7 +141,7 @@ namespace Exiv2 {
} }
void IfdMakerNote::updateBase(byte* pNewBase) void IfdMakerNote::updateBase(byte* pNewBase)
{ {
if (absShift_) { if (absShift_) {
ifd_.updateBase(pNewBase); ifd_.updateBase(pNewBase);
} }
@ -164,9 +164,9 @@ namespace Exiv2 {
return header_.size_; return header_.size_;
} }
Entries::const_iterator IfdMakerNote::findIdx(int idx) const Entries::const_iterator IfdMakerNote::findIdx(int idx) const
{ {
return ifd_.findIdx(idx); return ifd_.findIdx(idx);
} }
long IfdMakerNote::size() const long IfdMakerNote::size() const
@ -253,12 +253,12 @@ namespace Exiv2 {
return i->second->create(alloc); return i->second->create(alloc);
} // MakerNoteFactory::create } // MakerNoteFactory::create
void MakerNoteFactory::registerMakerNote(const std::string& make, void MakerNoteFactory::registerMakerNote(const std::string& make,
const std::string& model, const std::string& model,
CreateFct createMakerNote) CreateFct createMakerNote)
{ {
#ifdef DEBUG_REGISTRY #ifdef DEBUG_REGISTRY
std::cerr << "Registering MakerNote create function for \"" std::cerr << "Registering MakerNote create function for \""
<< make << "\" and \"" << model << "\".\n"; << make << "\" and \"" << model << "\".\n";
#endif #endif
init(); init();
@ -293,16 +293,16 @@ namespace Exiv2 {
} }
} // MakerNoteFactory::registerMakerNote } // MakerNoteFactory::registerMakerNote
MakerNote::AutoPtr MakerNoteFactory::create(const std::string& make, MakerNote::AutoPtr MakerNoteFactory::create(const std::string& make,
const std::string& model, const std::string& model,
bool alloc, bool alloc,
const byte* buf, const byte* buf,
long len, long len,
ByteOrder byteOrder, ByteOrder byteOrder,
long offset) long offset)
{ {
#ifdef DEBUG_REGISTRY #ifdef DEBUG_REGISTRY
std::cerr << "Entering MakerNoteFactory::create(\"" std::cerr << "Entering MakerNoteFactory::create(\""
<< make << "\", \"" << model << "\", " << make << "\", \"" << model << "\", "
<< (alloc == true ? "true" : "false") << ")\n"; << (alloc == true ? "true" : "false") << ")\n";
#endif #endif
@ -311,7 +311,7 @@ namespace Exiv2 {
ModelRegistry* pModelRegistry = 0; ModelRegistry* pModelRegistry = 0;
#ifdef DEBUG_REGISTRY #ifdef DEBUG_REGISTRY
std::string makeMatch; std::string makeMatch;
std::cerr << "Searching make registry...\n"; std::cerr << "Searching make registry...\n";
#endif #endif
assert(pRegistry_ != 0); assert(pRegistry_ != 0);
Registry::const_iterator end1 = pRegistry_->end(); Registry::const_iterator end1 = pRegistry_->end();
@ -362,7 +362,7 @@ namespace Exiv2 {
const std::string& key) const std::string& key)
{ {
#ifdef DEBUG_REGISTRY #ifdef DEBUG_REGISTRY
std::cerr << " Matching registry entry \"" << regEntry << "\" (" std::cerr << " Matching registry entry \"" << regEntry << "\" ("
<< (int)regEntry.size() << ") with key \"" << key << "\" (" << (int)regEntry.size() << ") with key \"" << key << "\" ("
<< (int)key.size() << "): "; << (int)key.size() << "): ";
#endif #endif
@ -398,11 +398,11 @@ namespace Exiv2 {
} }
bool found = false; bool found = false;
// Find the substr ss in the key starting from index ki. // Find the substr ss in the key starting from index ki.
// Take care of the special cases // Take care of the special cases
// + where the substr must match the key from beg to end, // + where the substr must match the key from beg to end,
// + from beg, // + from beg,
// + to end // + to end
// + and where it can be anywhere in the key. // + and where it can be anywhere in the key.
// If found, ki is adjusted to the position in the key after ss. // If found, ki is adjusted to the position in the key after ss.
if (ei == 0 && pos == std::string::npos) { // ei == 0 => ki == 0 if (ei == 0 && pos == std::string::npos) { // ei == 0 => ki == 0
@ -418,7 +418,7 @@ namespace Exiv2 {
} }
} }
else if (pos == std::string::npos) { else if (pos == std::string::npos) {
if ( ss.size() <= uKey.size() if ( ss.size() <= uKey.size()
&& ki <= uKey.size() - ss.size()) { && ki <= uKey.size() - ss.size()) {
if (0 == uKey.compare( if (0 == uKey.compare(
uKey.size() - ss.size(), ss.size(), ss)) { uKey.size() - ss.size(), ss.size(), ss)) {
@ -428,7 +428,7 @@ namespace Exiv2 {
} }
} }
else { else {
std::string::size_type idx = uKey.find(ss, ki); std::string::size_type idx = uKey.find(ss, ki);
if (idx != std::string::npos) { if (idx != std::string::npos) {
found = true; found = true;
ki = idx + ss.size(); ki = idx + ss.size();
@ -454,7 +454,7 @@ namespace Exiv2 {
std::cerr << "Match (score: " << count + 1 << ")\n"; std::cerr << "Match (score: " << count + 1 << ")\n";
#endif #endif
return count + 1; return count + 1;
} // MakerNoteFactory::match } // MakerNoteFactory::match
} // namespace Exiv2 } // namespace Exiv2

@ -1,26 +1,26 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
/*! /*!
@file makernote.hpp @file makernote.hpp
@brief Contains the Exif %MakerNote interface, IFD %MakerNote and a @brief Contains the Exif %MakerNote interface, IFD %MakerNote and a
MakerNote factory MakerNote factory
@version $Rev$ @version $Rev$
@author Andreas Huggel (ahu) @author Andreas Huggel (ahu)
@ -68,7 +68,7 @@ namespace Exiv2 {
MakerNote holds methods and functionality to MakerNote holds methods and functionality to
- read the makernote from a character buffer - read the makernote from a character buffer
- copy the makernote to a character buffer - copy the makernote to a character buffer
- maintain a list of makernote entries (similar to IFD entries) - maintain a list of makernote entries (similar to IFD entries)
- interpret (print) the values of makernote tags - interpret (print) the values of makernote tags
Makernotes can be added to the system by subclassing %MakerNote and Makernotes can be added to the system by subclassing %MakerNote and
@ -78,18 +78,18 @@ namespace Exiv2 {
subclass IfdMakerNote is provided. It contains an IFD container and subclass IfdMakerNote is provided. It contains an IFD container and
implements all interface methods related to the makernote entries. <BR> implements all interface methods related to the makernote entries. <BR>
To implement a new IFD makernote, all that you need to do is To implement a new IFD makernote, all that you need to do is
- subclass %IfdMakerNote, - subclass %IfdMakerNote,
- implement methods to read and check the header (if any) as well as - implement methods to read and check the header (if any) as well as
clone and create functions, clone and create functions,
- add a list of tag descriptions and appropriate print functions and - add a list of tag descriptions and appropriate print functions and
- register the camera make/model and create function in the makernote factory. - register the camera make/model and create function in the makernote factory.
. .
See existing makernote implementations for examples, e.g., CanonMakerNote See existing makernote implementations for examples, e.g., CanonMakerNote
or FujiMakerNote. or FujiMakerNote.
Finally, the header file which defines the static variable Finally, the header file which defines the static variable
\em register*MakerNote needs to be included from mn.hpp, to ensure that \em register*MakerNote needs to be included from mn.hpp, to ensure that
the makernote is automatically registered in the factory. the makernote is automatically registered in the factory.
*/ */
class MakerNote { class MakerNote {
@ -106,7 +106,7 @@ namespace Exiv2 {
//! @name Creators //! @name Creators
//@{ //@{
/*! /*!
@brief Constructor. Allows to choose whether or not memory management @brief Constructor. Allows to choose whether or not memory management
is required for the Entries. is required for the Entries.
*/ */
explicit MakerNote(bool alloc =true); explicit MakerNote(bool alloc =true);
@ -117,11 +117,11 @@ namespace Exiv2 {
//! @name Manipulators //! @name Manipulators
//@{ //@{
/*! /*!
@brief Read the makernote, including the makernote header, from the @brief Read the makernote, including the makernote header, from the
Exif data buffer. Exif data buffer.
@param buf Pointer to the Exif data buffer that contains the @param buf Pointer to the Exif data buffer that contains the
MakerNote to decode. The buffer should contain all Exif MakerNote to decode. The buffer should contain all Exif
data starting from the TIFF header. data starting from the TIFF header.
@param len Number of bytes in the Exif data buffer @param len Number of bytes in the Exif data buffer
@param start MakerNote starts at buf + start. @param start MakerNote starts at buf + start.
@ -130,13 +130,13 @@ namespace Exiv2 {
@return 0 if successful. @return 0 if successful.
*/ */
virtual int read(const byte* buf, virtual int read(const byte* buf,
long len, long len,
long start, long start,
ByteOrder byteOrder, ByteOrder byteOrder,
long shift =0) =0; long shift =0) =0;
/*! /*!
@brief Copy (write) the makerNote to the character buffer buf at @brief Copy (write) the makerNote to the character buffer buf at
position offset (from the start of the TIFF header), encoded position offset (from the start of the TIFF header), encoded
in byte order byteOrder. Update internal offsets if necessary. in byte order byteOrder. Update internal offsets if necessary.
Return the number of bytes written. Return the number of bytes written.
@ -145,7 +145,7 @@ namespace Exiv2 {
/*! /*!
@brief Add the entry to the makernote. No duplicate-check is performed, @brief Add the entry to the makernote. No duplicate-check is performed,
i.e., it is possible to add multiple entries with the same tag. i.e., it is possible to add multiple entries with the same tag.
The memory allocation mode of the entry to be added must be the The memory allocation mode of the entry to be added must be the
same as that of the makernote and the IFD id of the entry must same as that of the makernote and the IFD id of the entry must
be set to 'makerIfd'. be set to 'makerIfd'.
*/ */
@ -155,7 +155,7 @@ namespace Exiv2 {
//! End of the makernote entries //! End of the makernote entries
virtual Entries::iterator end() =0; virtual Entries::iterator end() =0;
/*! /*!
@brief Update the base pointer of the %MakerNote and all its entries @brief Update the base pointer of the %MakerNote and all its entries
to \em pNewBase. to \em pNewBase.
Allows to re-locate the underlying data buffer to a new location Allows to re-locate the underlying data buffer to a new location
@ -176,7 +176,7 @@ namespace Exiv2 {
copied. The caller owns the new object and the auto-pointer copied. The caller owns the new object and the auto-pointer
ensures that it will be deleted. ensures that it will be deleted.
@param alloc Memory management model for the newly created object. @param alloc Memory management model for the newly created object.
Indicates if memory required to store data should be allocated Indicates if memory required to store data should be allocated
and deallocated (true) or not (false). If false, only pointers and deallocated (true) or not (false). If false, only pointers
to the buffer provided to read() will be kept. See Ifd for more to the buffer provided to read() will be kept. See Ifd for more
@ -188,8 +188,8 @@ namespace Exiv2 {
owns the new object and the auto-pointer ensures that it will owns the new object and the auto-pointer ensures that it will
be deleted. be deleted.
@note In non-alloc mode the clone potentially contains pointers to @note In non-alloc mode the clone potentially contains pointers to
the same data buffer as the original. the same data buffer as the original.
Use updateBase(byte* pNewBase) to adjust them. Use updateBase(byte* pNewBase) to adjust them.
*/ */
AutoPtr clone() const; AutoPtr clone() const;
@ -210,9 +210,9 @@ namespace Exiv2 {
True: requires memory allocation and deallocation, <BR> True: requires memory allocation and deallocation, <BR>
False: no memory management needed. False: no memory management needed.
*/ */
const bool alloc_; const bool alloc_;
/*! /*!
@brief Offset of the makernote from the start of the TIFF header @brief Offset of the makernote from the start of the TIFF header
(for offset()). (for offset()).
*/ */
long offset_; long offset_;
@ -248,9 +248,9 @@ namespace Exiv2 {
typedef std::auto_ptr<IfdMakerNote> AutoPtr; typedef std::auto_ptr<IfdMakerNote> AutoPtr;
//! @name Creators //! @name Creators
//@{ //@{
/*! /*!
@brief Constructor. Requires an %Ifd id and allows to choose whether @brief Constructor. Requires an %Ifd id and allows to choose whether
or not memory management is needed for the Entries and whether or not memory management is needed for the Entries and whether
the IFD has a next pointer. the IFD has a next pointer.
*/ */
@ -263,20 +263,20 @@ namespace Exiv2 {
//! @name Manipulators //! @name Manipulators
//@{ //@{
virtual int read(const byte* buf, virtual int read(const byte* buf,
long len, long len,
long start, long start,
ByteOrder byteOrder, ByteOrder byteOrder,
long shift); long shift);
/*! /*!
@brief Read the makernote header from the makernote databuffer. This @brief Read the makernote header from the makernote databuffer. This
method must set the offset to the start of the IFD (start_), if method must set the offset to the start of the IFD (start_), if
needed (assuming that the required information is in the header). needed (assuming that the required information is in the header).
Return 0 if successful. Return 0 if successful.
@note The default implementation does nothing, assuming there is no @note The default implementation does nothing, assuming there is no
header header
*/ */
virtual int readHeader(const byte* buf, virtual int readHeader(const byte* buf,
long len, long len,
ByteOrder byteOrder); ByteOrder byteOrder);
virtual long copy(byte* buf, ByteOrder byteOrder, long offset); virtual long copy(byte* buf, ByteOrder byteOrder, long offset);
@ -303,14 +303,14 @@ namespace Exiv2 {
*/ */
virtual int checkHeader() const; virtual int checkHeader() const;
/*! /*!
@brief Write the makernote header to a character buffer, return the @brief Write the makernote header to a character buffer, return the
number of characters written. number of characters written.
@note The default implementation copies the header_ buffer. @note The default implementation copies the header_ buffer.
*/ */
virtual long copyHeader(byte* buf) const; virtual long copyHeader(byte* buf) const;
/*! /*!
@brief Return the size of the makernote header in bytes. @brief Return the size of the makernote header in bytes.
@note The default implementation returns the size of the header_ @note The default implementation returns the size of the header_
buffer. buffer.
*/ */
virtual long headerSize() const; virtual long headerSize() const;
@ -322,7 +322,7 @@ namespace Exiv2 {
@brief True: IFD offsets are relative to the start of the TIFF @brief True: IFD offsets are relative to the start of the TIFF
header (i.e., the start of the Exif data section) header (i.e., the start of the Exif data section)
+ shift_ + shift_
False: IFD offsets are relative to the start of the False: IFD offsets are relative to the start of the
makernote + shift_ makernote + shift_
*/ */
bool absShift_; bool absShift_;
@ -373,13 +373,13 @@ namespace Exiv2 {
make tag.) make tag.)
@param model Camera model. (Typically the string from the Exif @param model Camera model. (Typically the string from the Exif
model tag.) model tag.)
@param createMakerNote Pointer to a function to create a new @param createMakerNote Pointer to a function to create a new
%MakerNote of a particular type. %MakerNote of a particular type.
*/ */
static void registerMakerNote(const std::string& make, static void registerMakerNote(const std::string& make,
const std::string& model, const std::string& model,
CreateFct createMakerNote); CreateFct createMakerNote);
//! Register a %MakerNote prototype in the IFD id registry. //! Register a %MakerNote prototype in the IFD id registry.
static void registerMakerNote(IfdId ifdId, MakerNote::AutoPtr makerNote); static void registerMakerNote(IfdId ifdId, MakerNote::AutoPtr makerNote);
@ -415,24 +415,24 @@ namespace Exiv2 {
if memory required to store data should be allocated and if memory required to store data should be allocated and
deallocated (true) or not (false). If false, only pointers to deallocated (true) or not (false). If false, only pointers to
the buffer provided to read() will be kept. See Ifd for more the buffer provided to read() will be kept. See Ifd for more
background on this concept. background on this concept.
@param buf Pointer to the makernote character buffer. @param buf Pointer to the makernote character buffer.
@param len Length of the makernote character buffer. @param len Length of the makernote character buffer.
@param byteOrder Byte order in which the Exif data (and possibly the @param byteOrder Byte order in which the Exif data (and possibly the
makernote) is encoded. makernote) is encoded.
@param offset Offset from the start of the TIFF header of the makernote @param offset Offset from the start of the TIFF header of the makernote
buffer. buffer.
@return An auto-pointer that owns a %MakerNote for the camera model. @return An auto-pointer that owns a %MakerNote for the camera model.
If the camera is not supported, the pointer is 0. If the camera is not supported, the pointer is 0.
*/ */
static MakerNote::AutoPtr create(const std::string& make, static MakerNote::AutoPtr create(const std::string& make,
const std::string& model, const std::string& model,
bool alloc, bool alloc,
const byte* buf, const byte* buf,
long len, long len,
ByteOrder byteOrder, ByteOrder byteOrder,
long offset); long offset);
//! Create a %MakerNote for an IFD id. //! Create a %MakerNote for an IFD id.
static MakerNote::AutoPtr create(IfdId ifdId, bool alloc =true); static MakerNote::AutoPtr create(IfdId ifdId, bool alloc =true);
@ -444,20 +444,20 @@ namespace Exiv2 {
registry entry are supported. The best match is an exact match, then registry entry are supported. The best match is an exact match, then
a match is rated according to the number of matching characters. a match is rated according to the number of matching characters.
@return A score value indicating how good the key and registry entry @return A score value indicating how good the key and registry entry
match. 0 means no match, values greater than 0 indicate a match. 0 means no match, values greater than 0 indicate a
match, larger values are better matches:<BR> match, larger values are better matches:<BR>
0: key and registry entry do not match<BR> 0: key and registry entry do not match<BR>
1: a pure wildcard match, i.e., the registry entry is just 1: a pure wildcard match, i.e., the registry entry is just
a wildcard.<BR> a wildcard.<BR>
Score values greater than 1 are computed by adding 1 to the Score values greater than 1 are computed by adding 1 to the
number of matching characters, except for an exact match, number of matching characters, except for an exact match,
which scores 2 plus the number of matching characters. which scores 2 plus the number of matching characters.
*/ */
static int match(const std::string& regEntry, const std::string& key); static int match(const std::string& regEntry, const std::string& key);
/*! /*!
@brief Class Init is used to execute initialisation and termination @brief Class Init is used to execute initialisation and termination
code exactly once, at the begin and end of the program. code exactly once, at the begin and end of the program.
See Bjarne Stroustrup, 'The C++ Programming Language 3rd See Bjarne Stroustrup, 'The C++ Programming Language 3rd
@ -467,7 +467,7 @@ namespace Exiv2 {
static int count; //!< Counts calls to constructor static int count; //!< Counts calls to constructor
public: public:
//! @name Creators //! @name Creators
//@{ //@{
//! Perform one-time initialisations. //! Perform one-time initialisations.
Init(); Init();
//! Perform one-time cleanup operations. //! Perform one-time cleanup operations.
@ -477,7 +477,7 @@ namespace Exiv2 {
private: private:
//! @name Creators //! @name Creators
//@{ //@{
//! Prevent construction: not implemented. //! Prevent construction: not implemented.
MakerNoteFactory() {} MakerNoteFactory() {}
//! Prevent copy construction: not implemented. //! Prevent copy construction: not implemented.
@ -501,7 +501,7 @@ namespace Exiv2 {
static IfdIdRegistry* pIfdIdRegistry_; static IfdIdRegistry* pIfdIdRegistry_;
}; // class MakerNoteFactory }; // class MakerNoteFactory
} // namespace Exiv2 } // namespace Exiv2
namespace { namespace {

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -57,7 +57,7 @@ try {
Exiv2::BasicIo::AutoPtr fileIo(new Exiv2::FileIo(params.read_)); Exiv2::BasicIo::AutoPtr fileIo(new Exiv2::FileIo(params.read_));
Exiv2::BasicIo::AutoPtr memIo(new Exiv2::MemIo); Exiv2::BasicIo::AutoPtr memIo(new Exiv2::MemIo);
memIo->transfer(*fileIo); memIo->transfer(*fileIo);
Exiv2::Image::AutoPtr readImg = Exiv2::ImageFactory::open(memIo); Exiv2::Image::AutoPtr readImg = Exiv2::ImageFactory::open(memIo);
assert(readImg.get() != 0); assert(readImg.get() != 0);
readImg->readMetadata(); readImg->readMetadata();
@ -79,7 +79,7 @@ try {
writeImg->writeMetadata(); writeImg->writeMetadata();
} }
catch (const Exiv2::AnyError&) { catch (const Exiv2::AnyError&) {
std::cerr << params.progname() << std::cerr << params.progname() <<
": Could not write metadata to (" << params.write_ << ")\n"; ": Could not write metadata to (" << params.write_ << ")\n";
return 8; return 8;
} }
@ -101,31 +101,31 @@ int Params::option(int opt, const std::string& optarg, int optopt)
case 'e': exif_ = true; break; case 'e': exif_ = true; break;
case 'c': comment_ = true; break; case 'c': comment_ = true; break;
case 'p': preserve_ = true; break; case 'p': preserve_ = true; break;
case 'a': case 'a':
iptc_ =true; iptc_ =true;
exif_ =true; exif_ =true;
comment_ =true; comment_ =true;
break; break;
case ':': case ':':
std::cerr << progname() << ": Option -" << static_cast<char>(optopt) std::cerr << progname() << ": Option -" << static_cast<char>(optopt)
<< " requires an argument\n"; << " requires an argument\n";
rc = 1; rc = 1;
break; break;
case '?': case '?':
std::cerr << progname() << ": Unrecognized option -" std::cerr << progname() << ": Unrecognized option -"
<< static_cast<char>(optopt) << "\n"; << static_cast<char>(optopt) << "\n";
rc = 1; rc = 1;
break; break;
default: default:
std::cerr << progname() std::cerr << progname()
<< ": getopt returned unexpected character code " << ": getopt returned unexpected character code "
<< std::hex << opt << "\n"; << std::hex << opt << "\n";
rc = 1; rc = 1;
break; break;
} }
return rc; return rc;
} }
int Params::nonoption(const std::string& argv) int Params::nonoption(const std::string& argv)
{ {
@ -137,10 +137,10 @@ int Params::nonoption(const std::string& argv)
else write_ = argv; else write_ = argv;
first_ = false; first_ = false;
return 0; return 0;
} }
int Params::getopt(int argc, char* const argv[]) int Params::getopt(int argc, char* const argv[])
{ {
int rc = Util::Getopt::getopt(argc, argv, optstring_); int rc = Util::Getopt::getopt(argc, argv, optstring_);
// Further consistency checks // Further consistency checks
if (help_==false) { if (help_==false) {
@ -164,7 +164,7 @@ int Params::getopt(int argc, char* const argv[])
void Params::usage(std::ostream& os) const void Params::usage(std::ostream& os) const
{ {
os << "\nReads and writes raw metadata. Use -h option for help.\n" os << "\nReads and writes raw metadata. Use -h option for help.\n"
<< "Usage: " << progname() << "Usage: " << progname()
<< " [-iecaph] readfile writefile\n"; << " [-iecaph] readfile writefile\n";
} }

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -50,7 +50,7 @@ public:
*/ */
Params() : optstring_(":iecaph"), Params() : optstring_(":iecaph"),
first_(true), first_(true),
help_(false), help_(false),
iptc_(false), iptc_(false),
exif_(false), exif_(false),
comment_(false), comment_(false),

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -42,43 +42,43 @@ EXIV2_RCSID("@(#) $Id$");
// ***************************************************************************** // *****************************************************************************
// class member definitions // class member definitions
namespace Exiv2 { namespace Exiv2 {
Key::AutoPtr Key::clone() const Key::AutoPtr Key::clone() const
{ {
return AutoPtr(clone_()); return AutoPtr(clone_());
} }
Key& Key::operator=(const Key& /*rhs*/) Key& Key::operator=(const Key& /*rhs*/)
{ {
return *this; return *this;
} }
Metadatum::Metadatum() Metadatum::Metadatum()
{ {
} }
Metadatum::Metadatum(const Metadatum& /*rhs*/) Metadatum::Metadatum(const Metadatum& /*rhs*/)
{ {
} }
Metadatum::~Metadatum() Metadatum::~Metadatum()
{ {
} }
Metadatum& Metadatum::operator=(const Metadatum& /*rhs*/) Metadatum& Metadatum::operator=(const Metadatum& /*rhs*/)
{ {
return *this; return *this;
} }
std::ostream& operator<<(std::ostream& os, const Metadatum& md) std::ostream& operator<<(std::ostream& os, const Metadatum& md)
{ {
os << "0x" << std::setw(4) << std::setfill('0') << std::right os << "0x" << std::setw(4) << std::setfill('0') << std::right
<< std::hex << md.tag() << " " << std::hex << md.tag() << " "
<< std::setw(40) << std::setfill(' ') << std::left << std::setw(40) << std::setfill(' ') << std::left
<< md.key() << " " << md.key() << " "
<< std::setw(9) << std::setfill(' ') << std::left << std::setw(9) << std::setfill(' ') << std::left
<< md.typeName() << " " << md.typeName() << " "
<< std::dec << md.value() << std::dec << md.value()
<< "\n"; << "\n";
return os; return os;
} }

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -24,7 +24,7 @@
@version $Rev$ @version $Rev$
@author Andreas Huggel (ahu) @author Andreas Huggel (ahu)
<a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a> <a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a>
@author Brad Schick (brad) @author Brad Schick (brad)
<a href="mailto:brad@robotbattle.com">brad@robotbattle.com</a> <a href="mailto:brad@robotbattle.com">brad@robotbattle.com</a>
@date 09-Jan-04, ahu: created<BR> @date 09-Jan-04, ahu: created<BR>
31-Jul-04, brad: isolated as a component<BR> 31-Jul-04, brad: isolated as a component<BR>
@ -87,10 +87,10 @@ namespace Exiv2 {
will be deleted. will be deleted.
*/ */
AutoPtr clone() const; AutoPtr clone() const;
/*! /*!
@brief Write the key to an output stream. You do not usually have @brief Write the key to an output stream. You do not usually have
to use this function; it is used for the implementation of to use this function; it is used for the implementation of
the output operator for %Key, the output operator for %Key,
operator<<(std::ostream &os, const Key &key). operator<<(std::ostream &os, const Key &key).
*/ */
std::ostream& write(std::ostream& os) const { return os << key(); } std::ostream& write(std::ostream& os) const { return os << key(); }
@ -142,7 +142,7 @@ namespace Exiv2 {
*/ */
virtual void setValue(const Value* pValue) =0; virtual void setValue(const Value* pValue) =0;
/*! /*!
@brief Set the value to the string buf. @brief Set the value to the string buf.
Uses Value::read(const std::string& buf). If the metadatum does Uses Value::read(const std::string& buf). If the metadatum does
not have a value yet, then an AsciiValue is created. not have a value yet, then an AsciiValue is created.
*/ */
@ -212,22 +212,22 @@ namespace Exiv2 {
caller owns this copy and the auto-poiner ensures that it will caller owns this copy and the auto-poiner ensures that it will
be deleted. be deleted.
This method is provided for users who need full control over the This method is provided for users who need full control over the
value. A caller may, e.g., downcast the pointer to the appropriate value. A caller may, e.g., downcast the pointer to the appropriate
subclass of Value to make use of the interface of the subclass to set subclass of Value to make use of the interface of the subclass to set
or modify its contents. or modify its contents.
@return An auto-pointer containing a pointer to a copy (clone) of the @return An auto-pointer containing a pointer to a copy (clone) of the
value, 0 if the value is not set. value, 0 if the value is not set.
*/ */
virtual Value::AutoPtr getValue() const =0; virtual Value::AutoPtr getValue() const =0;
/*! /*!
@brief Return a constant reference to the value. @brief Return a constant reference to the value.
This method is provided mostly for convenient and versatile output of This method is provided mostly for convenient and versatile output of
the value which can (to some extent) be formatted through standard the value which can (to some extent) be formatted through standard
stream manipulators. Do not attempt to write to the value through stream manipulators. Do not attempt to write to the value through
this reference. this reference.
<b>Example:</b> <br> <b>Example:</b> <br>
@code @code
@ -269,7 +269,7 @@ namespace Exiv2 {
private: private:
std::string key_; std::string key_;
}; // class FindMetadatumByTag }; // class FindMetadatumByTag

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

@ -2,21 +2,21 @@
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* Lens database to decode Exif.Nikon3.LensData * Lens database to decode Exif.Nikon3.LensData
* Copyright (C) 2005 Robert Rottmerhusen <email@rottmerhusen.com> * Copyright (C) 2005 Robert Rottmerhusen <email@rottmerhusen.com>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -103,7 +103,7 @@ namespace Exiv2 {
return AutoPtr(create_(alloc)); return AutoPtr(create_(alloc));
} }
Nikon1MakerNote* Nikon1MakerNote::create_(bool alloc) const Nikon1MakerNote* Nikon1MakerNote::create_(bool alloc) const
{ {
return new Nikon1MakerNote(alloc); return new Nikon1MakerNote(alloc);
} }
@ -113,7 +113,7 @@ namespace Exiv2 {
return AutoPtr(clone_()); return AutoPtr(clone_());
} }
Nikon1MakerNote* Nikon1MakerNote::clone_() const Nikon1MakerNote* Nikon1MakerNote::clone_() const
{ {
return new Nikon1MakerNote(*this); return new Nikon1MakerNote(*this);
} }
@ -125,7 +125,7 @@ namespace Exiv2 {
os << value.toLong(1); os << value.toLong(1);
} }
else { else {
os << "(" << value << ")"; os << "(" << value << ")";
} }
return os; return os;
} }
@ -133,7 +133,7 @@ namespace Exiv2 {
std::ostream& Nikon1MakerNote::print0x0007(std::ostream& os, std::ostream& Nikon1MakerNote::print0x0007(std::ostream& os,
const Value& value) const Value& value)
{ {
std::string focus = value.toString(); std::string focus = value.toString();
if (focus == "AF-C ") os << "Continuous autofocus"; if (focus == "AF-C ") os << "Continuous autofocus";
else if (focus == "AF-S ") os << "Single autofocus"; else if (focus == "AF-S ") os << "Single autofocus";
else os << "(" << value << ")"; else os << "(" << value << ")";
@ -196,7 +196,7 @@ namespace Exiv2 {
} }
} }
else { else {
os << "(" << value << ")"; os << "(" << value << ")";
} }
return os; return os;
} }
@ -243,7 +243,7 @@ namespace Exiv2 {
} }
int Nikon2MakerNote::readHeader(const byte* buf, int Nikon2MakerNote::readHeader(const byte* buf,
long len, long len,
ByteOrder byteOrder) ByteOrder byteOrder)
{ {
if (len < 8) return 1; if (len < 8) return 1;
@ -259,7 +259,7 @@ namespace Exiv2 {
int rc = 0; int rc = 0;
// Check the Nikon prefix // Check the Nikon prefix
if ( header_.size_ < 8 if ( header_.size_ < 8
|| std::string(reinterpret_cast<char*>(header_.pData_), 6) || std::string(reinterpret_cast<char*>(header_.pData_), 6)
!= std::string("Nikon\0", 6)) { != std::string("Nikon\0", 6)) {
rc = 2; rc = 2;
} }
@ -271,9 +271,9 @@ namespace Exiv2 {
return AutoPtr(create_(alloc)); return AutoPtr(create_(alloc));
} }
Nikon2MakerNote* Nikon2MakerNote::create_(bool alloc) const Nikon2MakerNote* Nikon2MakerNote::create_(bool alloc) const
{ {
AutoPtr makerNote(new Nikon2MakerNote(alloc)); AutoPtr makerNote(new Nikon2MakerNote(alloc));
assert(makerNote.get() != 0); assert(makerNote.get() != 0);
makerNote->readHeader(header_.pData_, header_.size_, byteOrder_); makerNote->readHeader(header_.pData_, header_.size_, byteOrder_);
return makerNote.release(); return makerNote.release();
@ -284,7 +284,7 @@ namespace Exiv2 {
return AutoPtr(clone_()); return AutoPtr(clone_());
} }
Nikon2MakerNote* Nikon2MakerNote::clone_() const Nikon2MakerNote* Nikon2MakerNote::clone_() const
{ {
return new Nikon2MakerNote(*this); return new Nikon2MakerNote(*this);
} }
@ -465,7 +465,7 @@ namespace Exiv2 {
{ {
absShift_ = false; absShift_ = false;
byte buf[] = { byte buf[] = {
'N', 'i', 'k', 'o', 'n', '\0', 'N', 'i', 'k', 'o', 'n', '\0',
0x02, 0x10, 0x00, 0x00, 0x4d, 0x4d, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x08 0x02, 0x10, 0x00, 0x00, 0x4d, 0x4d, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x08
}; };
readHeader(buf, 18, byteOrder_); readHeader(buf, 18, byteOrder_);
@ -477,7 +477,7 @@ namespace Exiv2 {
} }
int Nikon3MakerNote::readHeader(const byte* buf, int Nikon3MakerNote::readHeader(const byte* buf,
long len, long len,
ByteOrder byteOrder) ByteOrder byteOrder)
{ {
if (len < 18) return 1; if (len < 18) return 1;
@ -497,7 +497,7 @@ namespace Exiv2 {
int rc = 0; int rc = 0;
// Check the Nikon prefix // Check the Nikon prefix
if ( header_.size_ < 18 if ( header_.size_ < 18
|| std::string(reinterpret_cast<char*>(header_.pData_), 6) || std::string(reinterpret_cast<char*>(header_.pData_), 6)
!= std::string("Nikon\0", 6)) { != std::string("Nikon\0", 6)) {
rc = 2; rc = 2;
} }
@ -509,9 +509,9 @@ namespace Exiv2 {
return AutoPtr(create_(alloc)); return AutoPtr(create_(alloc));
} }
Nikon3MakerNote* Nikon3MakerNote::create_(bool alloc) const Nikon3MakerNote* Nikon3MakerNote::create_(bool alloc) const
{ {
AutoPtr makerNote(new Nikon3MakerNote(alloc)); AutoPtr makerNote(new Nikon3MakerNote(alloc));
assert(makerNote.get() != 0); assert(makerNote.get() != 0);
makerNote->readHeader(header_.pData_, header_.size_, byteOrder_); makerNote->readHeader(header_.pData_, header_.size_, byteOrder_);
return makerNote.release(); return makerNote.release();
@ -522,7 +522,7 @@ namespace Exiv2 {
return AutoPtr(clone_()); return AutoPtr(clone_());
} }
Nikon3MakerNote* Nikon3MakerNote::clone_() const Nikon3MakerNote* Nikon3MakerNote::clone_() const
{ {
return new Nikon3MakerNote(*this); return new Nikon3MakerNote(*this);
} }
@ -534,12 +534,12 @@ namespace Exiv2 {
os << value.toLong(1); os << value.toLong(1);
} }
else { else {
os << "(" << value << ")"; os << "(" << value << ")";
} }
return os; return os;
} }
std::ostream& Nikon3MakerNote::print0x0012(std::ostream& os, std::ostream& Nikon3MakerNote::print0x0012(std::ostream& os,
const Value& value) const Value& value)
{ {
// From the PHP JPEG Metadata Toolkit // From the PHP JPEG Metadata Toolkit
@ -579,13 +579,13 @@ namespace Exiv2 {
if (len2 != len1) { if (len2 != len1) {
os << "-" << len2; os << "-" << len2;
} }
os << "mm "; os << "mm ";
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
os << "F" << std::setprecision(2) os << "F" << std::setprecision(2)
<< static_cast<float>(fno1.first) / fno1.second; << static_cast<float>(fno1.first) / fno1.second;
if (fno2 != fno1) { if (fno2 != fno1) {
os << "-" << std::setprecision(2) os << "-" << std::setprecision(2)
<< static_cast<float>(fno2.first) / fno2.second; << static_cast<float>(fno2.first) / fno2.second;
} }
os.copyfmt(oss); os.copyfmt(oss);
@ -613,7 +613,7 @@ namespace Exiv2 {
std::ostream& Nikon3MakerNote::print0x0088(std::ostream& os, std::ostream& Nikon3MakerNote::print0x0088(std::ostream& os,
const Value& value) const Value& value)
{ {
// Mappings taken from Exiftool // Mappings taken from Exiftool
long afpos = value.toLong(); long afpos = value.toLong();
switch (afpos) { switch (afpos) {
case 0x0000: os << "Center"; break; case 0x0000: os << "Center"; break;
@ -621,7 +621,7 @@ namespace Exiv2 {
case 0x0200: os << "Bottom"; break; case 0x0200: os << "Bottom"; break;
case 0x0300: os << "Left"; break; case 0x0300: os << "Left"; break;
case 0x0400: os << "Right"; break; case 0x0400: os << "Right"; break;
// D70 // D70
case 0x00001: os << "Single area, center"; break; case 0x00001: os << "Single area, center"; break;
case 0x10002: os << "Single area, top"; break; case 0x10002: os << "Single area, top"; break;
@ -849,7 +849,7 @@ namespace Exiv2 {
idx = 6; idx = 6;
} }
else if (0 == memcmp(lens.pData_, "0101", 4)) { else if (0 == memcmp(lens.pData_, "0101", 4)) {
idx = 11; idx = 11;
} }
else if (0 == memcmp(lens.pData_, "0201", 4)) { else if (0 == memcmp(lens.pData_, "0201", 4)) {
// Here we should decrypt(lens.pData_ + 4, lens.size_ - 4); // Here we should decrypt(lens.pData_ + 4, lens.size_ - 4);
@ -875,7 +875,7 @@ namespace Exiv2 {
} }
// Lens not found in database // Lens not found in database
return os << value; return os << value;
#else #else
return os << value; return os << value;
#endif // EXV_HAVE_LENSDATA #endif // EXV_HAVE_LENSDATA
} }
@ -884,25 +884,25 @@ namespace Exiv2 {
// free functions // free functions
MakerNote::AutoPtr createNikonMakerNote(bool alloc, MakerNote::AutoPtr createNikonMakerNote(bool alloc,
const byte* buf, const byte* buf,
long len, long len,
ByteOrder byteOrder, ByteOrder byteOrder,
long offset) long offset)
{ {
// If there is no "Nikon" string it must be Nikon1 format // If there is no "Nikon" string it must be Nikon1 format
if (len < 6 || std::string(reinterpret_cast<const char*>(buf), 6) if (len < 6 || std::string(reinterpret_cast<const char*>(buf), 6)
!= std::string("Nikon\0", 6)) { != std::string("Nikon\0", 6)) {
return MakerNote::AutoPtr(new Nikon1MakerNote(alloc)); return MakerNote::AutoPtr(new Nikon1MakerNote(alloc));
} }
// If the "Nikon" string is not followed by a TIFF header, we assume // If the "Nikon" string is not followed by a TIFF header, we assume
// Nikon2 format // Nikon2 format
TiffHeader tiffHeader; TiffHeader tiffHeader;
if ( len < 18 if ( len < 18
|| tiffHeader.read(buf + 10) != 0 || tiffHeader.tag() != 0x002a) { || tiffHeader.read(buf + 10) != 0 || tiffHeader.tag() != 0x002a) {
return MakerNote::AutoPtr(new Nikon2MakerNote(alloc)); return MakerNote::AutoPtr(new Nikon2MakerNote(alloc));
} }
// Else we have a Nikon3 makernote // Else we have a Nikon3 makernote
return MakerNote::AutoPtr(new Nikon3MakerNote(alloc)); return MakerNote::AutoPtr(new Nikon3MakerNote(alloc));
} }
} // namespace Exiv2 } // namespace Exiv2

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -23,16 +23,16 @@
@brief Nikon MakerNote formats. @brief Nikon MakerNote formats.
The Nikon MakerNote formats are implemented according to the following references<BR> The Nikon MakerNote formats are implemented according to the following references<BR>
Format 1: Format 1:
<ul> <ul>
<li><a href="http://www.tawbaware.com/990exif.htm">MakerNote EXIF Tag of the Nikon 990</a> by Max Lyons</li></ul> <li><a href="http://www.tawbaware.com/990exif.htm">MakerNote EXIF Tag of the Nikon 990</a> by Max Lyons</li></ul>
Format 2: Format 2:
<ul><li>"Appendix 2: Makernote of Nikon" of the document <ul><li>"Appendix 2: Makernote of Nikon" of the document
<a href="http://park2.wakwak.com/%7Etsuruzoh/Computer/Digicams/exif-e.html"> <a href="http://park2.wakwak.com/%7Etsuruzoh/Computer/Digicams/exif-e.html">
Exif file format</a> by TsuruZoh Tachibanaya</li></ul> Exif file format</a> by TsuruZoh Tachibanaya</li></ul>
Format 3: Format 3:
<ul><li>"EXIFutils Field Reference Guide"</li> <ul><li>"EXIFutils Field Reference Guide"</li>
<li><a href="http://www.ozhiker.com/electronics/pjmt/jpeg_info/nikon_mn.html#Nikon_Type_3_Tags">Nikon Type 3 Makernote Tags Definition</a> <li><a href="http://www.ozhiker.com/electronics/pjmt/jpeg_info/nikon_mn.html#Nikon_Type_3_Tags">Nikon Type 3 Makernote Tags Definition</a>
of the PHP JPEG Metadata Toolkit by Evan Hunter</li> of the PHP JPEG Metadata Toolkit by Evan Hunter</li>
<li>Nikon tag information from <a href="http://www.sno.phy.queensu.ca/~phil/exiftool/">ExifTool</a> by Phil Harvey</li> <li>Nikon tag information from <a href="http://www.sno.phy.queensu.ca/~phil/exiftool/">ExifTool</a> by Phil Harvey</li>
<li>Email communication with <a href="http://www.rottmerhusen.com">Robert Rottmerhusen</a></li> <li>Email communication with <a href="http://www.rottmerhusen.com">Robert Rottmerhusen</a></li>
@ -74,27 +74,27 @@ namespace Exiv2 {
initialized to operate in the memory management model indicated. initialized to operate in the memory management model indicated.
The caller owns this copy and the auto-pointer ensures that it The caller owns this copy and the auto-pointer ensures that it
will be deleted. will be deleted.
@param alloc Memory management model for the new MakerNote. Determines if @param alloc Memory management model for the new MakerNote. Determines if
memory required to store data should be allocated and deallocated memory required to store data should be allocated and deallocated
(true) or not (false). If false, only pointers to the buffer (true) or not (false). If false, only pointers to the buffer
provided to read() will be kept. See Ifd for more background on provided to read() will be kept. See Ifd for more background on
this concept. this concept.
@param buf Pointer to the makernote character buffer (not used). @param buf Pointer to the makernote character buffer (not used).
@param len Length of the makernote character buffer (not used). @param len Length of the makernote character buffer (not used).
@param byteOrder Byte order in which the Exif data (and possibly the @param byteOrder Byte order in which the Exif data (and possibly the
makernote) is encoded (not used). makernote) is encoded (not used).
@param offset Offset from the start of the TIFF header of the makernote @param offset Offset from the start of the TIFF header of the makernote
buffer (not used). buffer (not used).
@return An auto-pointer to a newly created empty MakerNote. The caller @return An auto-pointer to a newly created empty MakerNote. The caller
owns this copy and the auto-pointer ensures that it will be owns this copy and the auto-pointer ensures that it will be
deleted. deleted.
*/ */
MakerNote::AutoPtr createNikonMakerNote(bool alloc, MakerNote::AutoPtr createNikonMakerNote(bool alloc,
const byte* buf, const byte* buf,
long len, long len,
ByteOrder byteOrder, ByteOrder byteOrder,
long offset); long offset);
// ***************************************************************************** // *****************************************************************************
@ -125,7 +125,7 @@ namespace Exiv2 {
AutoPtr clone() const; AutoPtr clone() const;
//@} //@}
//! @name Print functions for Nikon1 %MakerNote tags //! @name Print functions for Nikon1 %MakerNote tags
//@{ //@{
//! Print ISO setting //! Print ISO setting
static std::ostream& print0x0002(std::ostream& os, const Value& value); static std::ostream& print0x0002(std::ostream& os, const Value& value);
@ -160,9 +160,9 @@ namespace Exiv2 {
static Nikon1MakerNote::RegisterMn registerNikon1MakerNote; static Nikon1MakerNote::RegisterMn registerNikon1MakerNote;
/*! /*!
@brief A second MakerNote format used by Nikon cameras, including the @brief A second MakerNote format used by Nikon cameras, including the
E700, E800, E900, E900S, E910, E950 E700, E800, E900, E900S, E910, E950
*/ */
class Nikon2MakerNote : public IfdMakerNote { class Nikon2MakerNote : public IfdMakerNote {
public: public:
//! Shortcut for a %Nikon2MakerNote auto pointer. //! Shortcut for a %Nikon2MakerNote auto pointer.
@ -182,8 +182,8 @@ namespace Exiv2 {
//@} //@}
//! @name Manipulators //! @name Manipulators
//@{ //@{
int readHeader(const byte* buf, int readHeader(const byte* buf,
long len, long len,
ByteOrder byteOrder); ByteOrder byteOrder);
//@} //@}
@ -195,7 +195,7 @@ namespace Exiv2 {
AutoPtr clone() const; AutoPtr clone() const;
//@} //@}
//! @name Print functions for Nikon2 %MakerNote tags //! @name Print functions for Nikon2 %MakerNote tags
//@{ //@{
//! Print quality setting //! Print quality setting
static std::ostream& print0x0003(std::ostream& os, const Value& value); static std::ostream& print0x0003(std::ostream& os, const Value& value);
@ -252,7 +252,7 @@ namespace Exiv2 {
//! @name Manipulators //! @name Manipulators
//@{ //@{
int readHeader(const byte* buf, int readHeader(const byte* buf,
long len, long len,
ByteOrder byteOrder); ByteOrder byteOrder);
//@} //@}
@ -264,7 +264,7 @@ namespace Exiv2 {
AutoPtr clone() const; AutoPtr clone() const;
//@} //@}
//! @name Print functions for Nikon3 %MakerNote tags //! @name Print functions for Nikon3 %MakerNote tags
//@{ //@{
//! Print ISO setting //! Print ISO setting
static std::ostream& print0x0002(std::ostream& os, const Value& value); static std::ostream& print0x0002(std::ostream& os, const Value& value);

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -52,7 +52,7 @@ namespace Exiv2 {
OlympusMakerNote::RegisterMn::RegisterMn() OlympusMakerNote::RegisterMn::RegisterMn()
{ {
MakerNoteFactory::registerMakerNote( MakerNoteFactory::registerMakerNote(
"OLYMPUS*", "*", createOlympusMakerNote); "OLYMPUS*", "*", createOlympusMakerNote);
MakerNoteFactory::registerMakerNote( MakerNoteFactory::registerMakerNote(
olympusIfdId, MakerNote::AutoPtr(new OlympusMakerNote)); olympusIfdId, MakerNote::AutoPtr(new OlympusMakerNote));
@ -149,11 +149,11 @@ namespace Exiv2 {
} }
int OlympusMakerNote::readHeader(const byte* buf, int OlympusMakerNote::readHeader(const byte* buf,
long len, long len,
ByteOrder byteOrder) ByteOrder byteOrder)
{ {
if (len < 8) return 1; if (len < 8) return 1;
// Copy the header // Copy the header
header_.alloc(8); header_.alloc(8);
memcpy(header_.pData_, buf, header_.size_); memcpy(header_.pData_, buf, header_.size_);
@ -167,7 +167,7 @@ namespace Exiv2 {
int rc = 0; int rc = 0;
// Check the OLYMPUS prefix // Check the OLYMPUS prefix
if ( header_.size_ < 8 if ( header_.size_ < 8
|| std::string(reinterpret_cast<char*>(header_.pData_), 5) || std::string(reinterpret_cast<char*>(header_.pData_), 5)
!= std::string("OLYMP", 5)) { != std::string("OLYMP", 5)) {
rc = 2; rc = 2;
} }
@ -192,12 +192,12 @@ namespace Exiv2 {
return AutoPtr(clone_()); return AutoPtr(clone_());
} }
OlympusMakerNote* OlympusMakerNote::clone_() const OlympusMakerNote* OlympusMakerNote::clone_() const
{ {
return new OlympusMakerNote(*this); return new OlympusMakerNote(*this);
} }
std::ostream& OlympusMakerNote::print0x0200(std::ostream& os, std::ostream& OlympusMakerNote::print0x0200(std::ostream& os,
const Value& value) const Value& value)
{ {
if (value.count() != 3 || value.typeId() != unsignedLong) { if (value.count() != 3 || value.typeId() != unsignedLong) {
@ -239,7 +239,7 @@ namespace Exiv2 {
{ 0, "(end)" } { 0, "(end)" }
}; };
std::ostream& OlympusMakerNote::print0x0201(std::ostream& os, std::ostream& OlympusMakerNote::print0x0201(std::ostream& os,
const Value& value) const Value& value)
{ {
return TagTranslator(quality).print(os, value); return TagTranslator(quality).print(os, value);
@ -254,13 +254,13 @@ namespace Exiv2 {
{ -1, "(end)" } { -1, "(end)" }
}; };
std::ostream& OlympusMakerNote::print0x0202(std::ostream& os, std::ostream& OlympusMakerNote::print0x0202(std::ostream& os,
const Value& value) const Value& value)
{ {
return TagTranslator(macro).print(os, value); return TagTranslator(macro).print(os, value);
} // OlympusMakerNote::print0x0202 } // OlympusMakerNote::print0x0202
std::ostream& OlympusMakerNote::print0x0204(std::ostream& os, std::ostream& OlympusMakerNote::print0x0204(std::ostream& os,
const Value& value) const Value& value)
{ {
float f = value.toFloat(); float f = value.toFloat();
@ -281,7 +281,7 @@ namespace Exiv2 {
{ -1, "(end)" } { -1, "(end)" }
}; };
std::ostream& OlympusMakerNote::print0x0302(std::ostream& os, std::ostream& OlympusMakerNote::print0x0302(std::ostream& os,
const Value& value) const Value& value)
{ {
return TagTranslator(oneTouchWb).print(os, value); return TagTranslator(oneTouchWb).print(os, value);
@ -297,7 +297,7 @@ namespace Exiv2 {
{ -1, "(end)" } { -1, "(end)" }
}; };
std::ostream& OlympusMakerNote::print0x1005(std::ostream& os, std::ostream& OlympusMakerNote::print0x1005(std::ostream& os,
const Value& value) const Value& value)
{ {
return TagTranslator(flashDevice).print(os, value); return TagTranslator(flashDevice).print(os, value);
@ -307,9 +307,9 @@ namespace Exiv2 {
// free functions // free functions
MakerNote::AutoPtr createOlympusMakerNote(bool alloc, MakerNote::AutoPtr createOlympusMakerNote(bool alloc,
const byte* buf, const byte* buf,
long len, long len,
ByteOrder byteOrder, ByteOrder byteOrder,
long offset) long offset)
{ {
return MakerNote::AutoPtr(new OlympusMakerNote(alloc)); return MakerNote::AutoPtr(new OlympusMakerNote(alloc));

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -21,9 +21,9 @@
/*! /*!
@file olympusmn.hpp @file olympusmn.hpp
@brief Olympus MakerNote implemented using the following references: @brief Olympus MakerNote implemented using the following references:
<a href="http://park2.wakwak.com/%7Etsuruzoh/Computer/Digicams/exif-e.html#APP1">Exif file format, Appendix 1: MakerNote of Olympus Digicams</a> by TsuruZoh Tachibanaya, <a href="http://park2.wakwak.com/%7Etsuruzoh/Computer/Digicams/exif-e.html#APP1">Exif file format, Appendix 1: MakerNote of Olympus Digicams</a> by TsuruZoh Tachibanaya,
Olympus.pm of <a href="http://www.sno.phy.queensu.ca/~phil/exiftool/">ExifTool</a> by Phil Harvey, Olympus.pm of <a href="http://www.sno.phy.queensu.ca/~phil/exiftool/">ExifTool</a> by Phil Harvey,
<a href="http://www.ozhiker.com/electronics/pjmt/jpeg_info/olympus_mn.html">Olympus Makernote Format Specification</a> by Evan Hunter, <a href="http://www.ozhiker.com/electronics/pjmt/jpeg_info/olympus_mn.html">Olympus Makernote Format Specification</a> by Evan Hunter,
email communication with <a href="mailto:wstokes@gmail.com">Will Stokes</a> email communication with <a href="mailto:wstokes@gmail.com">Will Stokes</a>
@version $Rev$ @version $Rev$
@author Andreas Huggel (ahu) @author Andreas Huggel (ahu)
@ -62,27 +62,27 @@ namespace Exiv2 {
initialized to operate in the memory management model indicated. initialized to operate in the memory management model indicated.
The caller owns this copy and the auto-pointer ensures that it The caller owns this copy and the auto-pointer ensures that it
will be deleted. will be deleted.
@param alloc Memory management model for the new MakerNote. Determines if @param alloc Memory management model for the new MakerNote. Determines if
memory required to store data should be allocated and deallocated memory required to store data should be allocated and deallocated
(true) or not (false). If false, only pointers to the buffer (true) or not (false). If false, only pointers to the buffer
provided to read() will be kept. See Ifd for more background on provided to read() will be kept. See Ifd for more background on
this concept. this concept.
@param buf Pointer to the makernote character buffer (not used). @param buf Pointer to the makernote character buffer (not used).
@param len Length of the makernote character buffer (not used). @param len Length of the makernote character buffer (not used).
@param byteOrder Byte order in which the Exif data (and possibly the @param byteOrder Byte order in which the Exif data (and possibly the
makernote) is encoded (not used). makernote) is encoded (not used).
@param offset Offset from the start of the TIFF header of the makernote @param offset Offset from the start of the TIFF header of the makernote
buffer (not used). buffer (not used).
@return An auto-pointer to a newly created empty MakerNote. The caller @return An auto-pointer to a newly created empty MakerNote. The caller
owns this copy and the auto-pointer ensures that it will be owns this copy and the auto-pointer ensures that it will be
deleted. deleted.
*/ */
MakerNote::AutoPtr createOlympusMakerNote(bool alloc, MakerNote::AutoPtr createOlympusMakerNote(bool alloc,
const byte* buf, const byte* buf,
long len, long len,
ByteOrder byteOrder, ByteOrder byteOrder,
long offset); long offset);
// ***************************************************************************** // *****************************************************************************
@ -108,8 +108,8 @@ namespace Exiv2 {
//@} //@}
//! @name Manipulators //! @name Manipulators
//@{ //@{
int readHeader(const byte* buf, int readHeader(const byte* buf,
long len, long len,
ByteOrder byteOrder); ByteOrder byteOrder);
//@} //@}
@ -121,7 +121,7 @@ namespace Exiv2 {
AutoPtr clone() const; AutoPtr clone() const;
//@} //@}
//! @name Print functions for Olympus %MakerNote tags //! @name Print functions for Olympus %MakerNote tags
//@{ //@{
//! Print 'Special Mode' //! Print 'Special Mode'
static std::ostream& print0x0200(std::ostream& os, const Value& value); static std::ostream& print0x0200(std::ostream& os, const Value& value);

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -107,7 +107,7 @@ namespace Exiv2 {
} }
int PanasonicMakerNote::readHeader(const byte* buf, int PanasonicMakerNote::readHeader(const byte* buf,
long len, long len,
ByteOrder byteOrder) ByteOrder byteOrder)
{ {
if (len < 12) return 1; if (len < 12) return 1;
@ -124,7 +124,7 @@ namespace Exiv2 {
int rc = 0; int rc = 0;
// Check the Panasonic prefix // Check the Panasonic prefix
if ( header_.size_ < 12 if ( header_.size_ < 12
|| std::string(reinterpret_cast<char*>(header_.pData_), 9) || std::string(reinterpret_cast<char*>(header_.pData_), 9)
!= std::string("Panasonic", 9)) { != std::string("Panasonic", 9)) {
rc = 2; rc = 2;
} }
@ -136,7 +136,7 @@ namespace Exiv2 {
return AutoPtr(create_(alloc)); return AutoPtr(create_(alloc));
} }
PanasonicMakerNote* PanasonicMakerNote::create_(bool alloc) const PanasonicMakerNote* PanasonicMakerNote::create_(bool alloc) const
{ {
AutoPtr makerNote = AutoPtr(new PanasonicMakerNote(alloc)); AutoPtr makerNote = AutoPtr(new PanasonicMakerNote(alloc));
assert(makerNote.get() != 0); assert(makerNote.get() != 0);
@ -149,7 +149,7 @@ namespace Exiv2 {
return AutoPtr(clone_()); return AutoPtr(clone_());
} }
PanasonicMakerNote* PanasonicMakerNote::clone_() const PanasonicMakerNote* PanasonicMakerNote::clone_() const
{ {
return new PanasonicMakerNote(*this); return new PanasonicMakerNote(*this);
} }
@ -164,7 +164,7 @@ namespace Exiv2 {
{ 0, "(end)" } { 0, "(end)" }
}; };
std::ostream& PanasonicMakerNote::print0x0001(std::ostream& os, std::ostream& PanasonicMakerNote::print0x0001(std::ostream& os,
const Value& value) const Value& value)
{ {
return TagTranslator(quality).print(os, value); return TagTranslator(quality).print(os, value);
@ -183,7 +183,7 @@ namespace Exiv2 {
{ 0, "(end)" } { 0, "(end)" }
}; };
std::ostream& PanasonicMakerNote::print0x0003(std::ostream& os, std::ostream& PanasonicMakerNote::print0x0003(std::ostream& os,
const Value& value) const Value& value)
{ {
return TagTranslator(whiteBalance).print(os, value); return TagTranslator(whiteBalance).print(os, value);
@ -197,13 +197,13 @@ namespace Exiv2 {
{ 0, "(end)" } { 0, "(end)" }
}; };
std::ostream& PanasonicMakerNote::print0x0007(std::ostream& os, std::ostream& PanasonicMakerNote::print0x0007(std::ostream& os,
const Value& value) const Value& value)
{ {
return TagTranslator(focusMode).print(os, value); return TagTranslator(focusMode).print(os, value);
} // PanasonicMakerNote::print0x0007 } // PanasonicMakerNote::print0x0007
std::ostream& PanasonicMakerNote::print0x000f(std::ostream& os, std::ostream& PanasonicMakerNote::print0x000f(std::ostream& os,
const Value& value) const Value& value)
{ {
if (value.count() < 2 || value.typeId() != unsignedByte) { if (value.count() < 2 || value.typeId() != unsignedByte) {
@ -225,7 +225,7 @@ namespace Exiv2 {
{ 0, "(end)" } { 0, "(end)" }
}; };
std::ostream& PanasonicMakerNote::print0x001a(std::ostream& os, std::ostream& PanasonicMakerNote::print0x001a(std::ostream& os,
const Value& value) const Value& value)
{ {
return TagTranslator(imageStabilizer).print(os, value); return TagTranslator(imageStabilizer).print(os, value);
@ -239,7 +239,7 @@ namespace Exiv2 {
{ 0, "(end)" } { 0, "(end)" }
}; };
std::ostream& PanasonicMakerNote::print0x001c(std::ostream& os, std::ostream& PanasonicMakerNote::print0x001c(std::ostream& os,
const Value& value) const Value& value)
{ {
return TagTranslator(macro).print(os, value); return TagTranslator(macro).print(os, value);
@ -266,7 +266,7 @@ namespace Exiv2 {
{ 0, "(end)" } { 0, "(end)" }
}; };
std::ostream& PanasonicMakerNote::print0x001f(std::ostream& os, std::ostream& PanasonicMakerNote::print0x001f(std::ostream& os,
const Value& value) const Value& value)
{ {
return TagTranslator(shootingMode).print(os, value); return TagTranslator(shootingMode).print(os, value);
@ -280,18 +280,18 @@ namespace Exiv2 {
{ 0, "(end)" } { 0, "(end)" }
}; };
std::ostream& PanasonicMakerNote::print0x0020(std::ostream& os, std::ostream& PanasonicMakerNote::print0x0020(std::ostream& os,
const Value& value) const Value& value)
{ {
return TagTranslator(Audio).print(os, value); return TagTranslator(Audio).print(os, value);
} // PanasonicMakerNote::print0x0020 } // PanasonicMakerNote::print0x0020
std::ostream& PanasonicMakerNote::print0x0023(std::ostream& os, std::ostream& PanasonicMakerNote::print0x0023(std::ostream& os,
const Value& value) const Value& value)
{ {
std::ostringstream oss; std::ostringstream oss;
oss.copyfmt(os); oss.copyfmt(os);
os << std::fixed << std::setprecision(1) os << std::fixed << std::setprecision(1)
<< value.toLong() / 3 << " EV"; << value.toLong() / 3 << " EV";
os.copyfmt(oss); os.copyfmt(oss);
@ -310,7 +310,7 @@ namespace Exiv2 {
{ 0, "(end)" } { 0, "(end)" }
}; };
std::ostream& PanasonicMakerNote::print0x0028(std::ostream& os, std::ostream& PanasonicMakerNote::print0x0028(std::ostream& os,
const Value& value) const Value& value)
{ {
return TagTranslator(colorEffect).print(os, value); return TagTranslator(colorEffect).print(os, value);
@ -328,7 +328,7 @@ namespace Exiv2 {
{ -1, "(end)" } { -1, "(end)" }
}; };
std::ostream& PanasonicMakerNote::print0x002c(std::ostream& os, std::ostream& PanasonicMakerNote::print0x002c(std::ostream& os,
const Value& value) const Value& value)
{ {
return TagTranslator(contrast).print(os, value); return TagTranslator(contrast).print(os, value);
@ -343,7 +343,7 @@ namespace Exiv2 {
{ -1, "(end)" } { -1, "(end)" }
}; };
std::ostream& PanasonicMakerNote::print0x002d(std::ostream& os, std::ostream& PanasonicMakerNote::print0x002d(std::ostream& os,
const Value& value) const Value& value)
{ {
return TagTranslator(noiseReduction).print(os, value); return TagTranslator(noiseReduction).print(os, value);
@ -353,9 +353,9 @@ namespace Exiv2 {
// free functions // free functions
MakerNote::AutoPtr createPanasonicMakerNote(bool alloc, MakerNote::AutoPtr createPanasonicMakerNote(bool alloc,
const byte* buf, const byte* buf,
long len, long len,
ByteOrder byteOrder, ByteOrder byteOrder,
long offset) long offset)
{ {
return MakerNote::AutoPtr(new PanasonicMakerNote(alloc)); return MakerNote::AutoPtr(new PanasonicMakerNote(alloc));

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -21,8 +21,8 @@
/*! /*!
@file panasonicmn.hpp @file panasonicmn.hpp
@brief Panasonic MakerNote implemented using the following references: @brief Panasonic MakerNote implemented using the following references:
<a href="http://www.compton.nu/panasonic.html">Panasonic MakerNote Information</a> by Tom Hughes, <a href="http://www.compton.nu/panasonic.html">Panasonic MakerNote Information</a> by Tom Hughes,
Panasonic.pm of <a href="http://www.sno.phy.queensu.ca/~phil/exiftool/">ExifTool</a> by Phil Harvey, Panasonic.pm of <a href="http://www.sno.phy.queensu.ca/~phil/exiftool/">ExifTool</a> by Phil Harvey,
<a href="http://www.ozhiker.com/electronics/pjmt/jpeg_info/panasonic_mn.html">Panasonic Makernote Format Specification</a> by Evan Hunter. <a href="http://www.ozhiker.com/electronics/pjmt/jpeg_info/panasonic_mn.html">Panasonic Makernote Format Specification</a> by Evan Hunter.
@version $Rev$ @version $Rev$
@author Andreas Huggel (ahu) @author Andreas Huggel (ahu)
@ -59,27 +59,27 @@ namespace Exiv2 {
initialized to operate in the memory management model indicated. initialized to operate in the memory management model indicated.
The caller owns this copy and the auto-pointer ensures that it The caller owns this copy and the auto-pointer ensures that it
will be deleted. will be deleted.
@param alloc Memory management model for the new MakerNote. Determines if @param alloc Memory management model for the new MakerNote. Determines if
memory required to store data should be allocated and deallocated memory required to store data should be allocated and deallocated
(true) or not (false). If false, only pointers to the buffer (true) or not (false). If false, only pointers to the buffer
provided to read() will be kept. See Ifd for more background on provided to read() will be kept. See Ifd for more background on
this concept. this concept.
@param buf Pointer to the makernote character buffer (not used). @param buf Pointer to the makernote character buffer (not used).
@param len Length of the makernote character buffer (not used). @param len Length of the makernote character buffer (not used).
@param byteOrder Byte order in which the Exif data (and possibly the @param byteOrder Byte order in which the Exif data (and possibly the
makernote) is encoded (not used). makernote) is encoded (not used).
@param offset Offset from the start of the TIFF header of the makernote @param offset Offset from the start of the TIFF header of the makernote
buffer (not used). buffer (not used).
@return An auto-pointer to a newly created empty MakerNote. The caller @return An auto-pointer to a newly created empty MakerNote. The caller
owns this copy and the auto-pointer ensures that it will be owns this copy and the auto-pointer ensures that it will be
deleted. deleted.
*/ */
MakerNote::AutoPtr createPanasonicMakerNote(bool alloc, MakerNote::AutoPtr createPanasonicMakerNote(bool alloc,
const byte* buf, const byte* buf,
long len, long len,
ByteOrder byteOrder, ByteOrder byteOrder,
long offset); long offset);
// ***************************************************************************** // *****************************************************************************
@ -105,8 +105,8 @@ namespace Exiv2 {
//@} //@}
//! @name Manipulators //! @name Manipulators
//@{ //@{
int readHeader(const byte* buf, int readHeader(const byte* buf,
long len, long len,
ByteOrder byteOrder); ByteOrder byteOrder);
//@} //@}
@ -118,7 +118,7 @@ namespace Exiv2 {
AutoPtr clone() const; AutoPtr clone() const;
//@} //@}
//! @name Print functions for Panasonic %MakerNote tags //! @name Print functions for Panasonic %MakerNote tags
//@{ //@{
//! Print Quality //! Print Quality
static std::ostream& print0x0001(std::ostream& os, const Value& value); static std::ostream& print0x0001(std::ostream& os, const Value& value);

@ -12,7 +12,7 @@ int main(int argc, char* const argv[])
if (argc != 2) { if (argc != 2) {
std::cout << "Usage: " << argv[0] << " file\n"; std::cout << "Usage: " << argv[0] << " file\n";
return 1; return 1;
} }
std::ifstream file(argv[1]); std::ifstream file(argv[1]);
if (!file) { if (!file) {
std::cerr << *argv[1] << ": Failed to open file for reading\n"; std::cerr << *argv[1] << ": Failed to open file for reading\n";
@ -27,7 +27,7 @@ int main(int argc, char* const argv[])
std::string b = Util::basename(path); std::string b = Util::basename(path);
if (d != dir || b != base) { if (d != dir || b != base) {
std::cout << path << "\t'" << d << "'\t '" << b std::cout << path << "\t'" << d << "'\t '" << b
<< "'\t ==> Testcase failed\n"; << "'\t ==> Testcase failed\n";
} }
} }

@ -1,29 +1,29 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
/*! /*!
@file rcsid.hpp @file rcsid.hpp
@brief Define an RCS id string in every object file compiled from a source @brief Define an RCS id string in every object file compiled from a source
file that includes rcsid.hpp. file that includes rcsid.hpp.
This is a simplified version of the ACE_RCSID macro that is used in the This is a simplified version of the ACE_RCSID macro that is used in the
<a href="http://www.cs.wustl.edu/~schmidt/ACE.html">ACE(TM)</a> distribution. <a href="http://www.cs.wustl.edu/~schmidt/ACE.html">ACE(TM)</a> distribution.
@version $Rev$ @version $Rev$
@ -36,7 +36,7 @@
#if !defined (EXIV2_RCSID) #if !defined (EXIV2_RCSID)
/*! /*!
@brief Macro to store version information in each object file. @brief Macro to store version information in each object file.
Use this macro by including the following two lines at the beginning of Use this macro by including the following two lines at the beginning of
each *.cpp file. See the ident(1) manual pages for more information. each *.cpp file. See the ident(1) manual pages for more information.

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -51,7 +51,7 @@ namespace Exiv2 {
//! @cond IGNORE //! @cond IGNORE
SigmaMakerNote::RegisterMn::RegisterMn() SigmaMakerNote::RegisterMn::RegisterMn()
{ {
MakerNoteFactory::registerMakerNote("SIGMA", "*", createSigmaMakerNote); MakerNoteFactory::registerMakerNote("SIGMA", "*", createSigmaMakerNote);
MakerNoteFactory::registerMakerNote("FOVEON", "*", createSigmaMakerNote); MakerNoteFactory::registerMakerNote("FOVEON", "*", createSigmaMakerNote);
MakerNoteFactory::registerMakerNote( MakerNoteFactory::registerMakerNote(
sigmaIfdId, MakerNote::AutoPtr(new SigmaMakerNote)); sigmaIfdId, MakerNote::AutoPtr(new SigmaMakerNote));
@ -104,7 +104,7 @@ namespace Exiv2 {
} }
int SigmaMakerNote::readHeader(const byte* buf, int SigmaMakerNote::readHeader(const byte* buf,
long len, long len,
ByteOrder byteOrder) ByteOrder byteOrder)
{ {
if (len < 10) return 1; if (len < 10) return 1;
@ -124,9 +124,9 @@ namespace Exiv2 {
int rc = 0; int rc = 0;
// Check the SIGMA or FOVEON prefix // Check the SIGMA or FOVEON prefix
if ( header_.size_ < 10 if ( header_.size_ < 10
|| std::string(reinterpret_cast<char*>(header_.pData_), 8) || std::string(reinterpret_cast<char*>(header_.pData_), 8)
!= std::string("SIGMA\0\0\0", 8) != std::string("SIGMA\0\0\0", 8)
&& std::string(reinterpret_cast<char*>(header_.pData_), 8) && std::string(reinterpret_cast<char*>(header_.pData_), 8)
!= std::string("FOVEON\0\0", 8)) { != std::string("FOVEON\0\0", 8)) {
rc = 2; rc = 2;
} }
@ -197,9 +197,9 @@ namespace Exiv2 {
// free functions // free functions
MakerNote::AutoPtr createSigmaMakerNote(bool alloc, MakerNote::AutoPtr createSigmaMakerNote(bool alloc,
const byte* buf, const byte* buf,
long len, long len,
ByteOrder byteOrder, ByteOrder byteOrder,
long offset) long offset)
{ {
return MakerNote::AutoPtr(new SigmaMakerNote(alloc)); return MakerNote::AutoPtr(new SigmaMakerNote(alloc));

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -22,7 +22,7 @@
@file sigmamn.hpp @file sigmamn.hpp
@brief Sigma and Foveon MakerNote implemented according to the specification @brief Sigma and Foveon MakerNote implemented according to the specification
<a href="http://www.x3f.info/technotes/FileDocs/MakerNoteDoc.html"> <a href="http://www.x3f.info/technotes/FileDocs/MakerNoteDoc.html">
SIGMA and FOVEON EXIF MakerNote Documentation</a> by Foveon. SIGMA and FOVEON EXIF MakerNote Documentation</a> by Foveon.
@version $Rev$ @version $Rev$
@author Andreas Huggel (ahu) @author Andreas Huggel (ahu)
<a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a> <a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a>
@ -58,27 +58,27 @@ namespace Exiv2 {
initialized to operate in the memory management model indicated. initialized to operate in the memory management model indicated.
The caller owns this copy and the auto-pointer ensures that it The caller owns this copy and the auto-pointer ensures that it
will be deleted. will be deleted.
@param alloc Memory management model for the new MakerNote. Determines if @param alloc Memory management model for the new MakerNote. Determines if
memory required to store data should be allocated and deallocated memory required to store data should be allocated and deallocated
(true) or not (false). If false, only pointers to the buffer (true) or not (false). If false, only pointers to the buffer
provided to read() will be kept. See Ifd for more background on provided to read() will be kept. See Ifd for more background on
this concept. this concept.
@param buf Pointer to the makernote character buffer (not used). @param buf Pointer to the makernote character buffer (not used).
@param len Length of the makernote character buffer (not used). @param len Length of the makernote character buffer (not used).
@param byteOrder Byte order in which the Exif data (and possibly the @param byteOrder Byte order in which the Exif data (and possibly the
makernote) is encoded (not used). makernote) is encoded (not used).
@param offset Offset from the start of the TIFF header of the makernote @param offset Offset from the start of the TIFF header of the makernote
buffer (not used). buffer (not used).
@return An auto-pointer to a newly created empty MakerNote. The caller @return An auto-pointer to a newly created empty MakerNote. The caller
owns this copy and the auto-pointer ensures that it will be owns this copy and the auto-pointer ensures that it will be
deleted. deleted.
*/ */
MakerNote::AutoPtr createSigmaMakerNote(bool alloc, MakerNote::AutoPtr createSigmaMakerNote(bool alloc,
const byte* buf, const byte* buf,
long len, long len,
ByteOrder byteOrder, ByteOrder byteOrder,
long offset); long offset);
// ***************************************************************************** // *****************************************************************************
@ -104,8 +104,8 @@ namespace Exiv2 {
//@} //@}
//! @name Manipulators //! @name Manipulators
//@{ //@{
int readHeader(const byte* buf, int readHeader(const byte* buf,
long len, long len,
ByteOrder byteOrder); ByteOrder byteOrder);
//@} //@}
@ -117,7 +117,7 @@ namespace Exiv2 {
AutoPtr clone() const; AutoPtr clone() const;
//@} //@}
//! @name Print functions for Sigma (Foveon) %MakerNote tags //! @name Print functions for Sigma (Foveon) %MakerNote tags
//@{ //@{
//! Strip the label from the value and print the remainder //! Strip the label from the value and print the remainder
static std::ostream& printStripLabel(std::ostream& os, const Value& value); static std::ostream& printStripLabel(std::ostream& os, const Value& value);

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -48,10 +48,10 @@ namespace Exiv2 {
//! @cond IGNORE //! @cond IGNORE
SonyMakerNote::RegisterMn::RegisterMn() SonyMakerNote::RegisterMn::RegisterMn()
{ {
MakerNoteFactory::registerMakerNote("SONY", "*", createSonyMakerNote); MakerNoteFactory::registerMakerNote("SONY", "*", createSonyMakerNote);
MakerNoteFactory::registerMakerNote( MakerNoteFactory::registerMakerNote(
sonyIfdId, MakerNote::AutoPtr(new SonyMakerNote)); sonyIfdId, MakerNote::AutoPtr(new SonyMakerNote));
ExifTags::registerMakerTagInfo(sonyIfdId, tagInfo_); ExifTags::registerMakerTagInfo(sonyIfdId, tagInfo_);
} }
//! @endcond //! @endcond
@ -86,7 +86,7 @@ namespace Exiv2 {
} }
int SonyMakerNote::readHeader(const byte* buf, int SonyMakerNote::readHeader(const byte* buf,
long len, long len,
ByteOrder byteOrder) ByteOrder byteOrder)
{ {
if (len < 12) return 1; if (len < 12) return 1;
@ -102,7 +102,7 @@ namespace Exiv2 {
int rc = 0; int rc = 0;
// Check the SONY prefix // Check the SONY prefix
if ( header_.size_ < 12 if ( header_.size_ < 12
|| std::string(reinterpret_cast<char*>(header_.pData_), 12) || std::string(reinterpret_cast<char*>(header_.pData_), 12)
!= std::string("SONY DSC \0\0\0", 12)) { != std::string("SONY DSC \0\0\0", 12)) {
rc = 2; rc = 2;
} }
@ -136,9 +136,9 @@ namespace Exiv2 {
// free functions // free functions
MakerNote::AutoPtr createSonyMakerNote(bool alloc, MakerNote::AutoPtr createSonyMakerNote(bool alloc,
const byte* buf, const byte* buf,
long len, long len,
ByteOrder byteOrder, ByteOrder byteOrder,
long offset) long offset)
{ {
return MakerNote::AutoPtr(new SonyMakerNote(alloc)); return MakerNote::AutoPtr(new SonyMakerNote(alloc));

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -56,27 +56,27 @@ namespace Exiv2 {
initialized to operate in the memory management model indicated. initialized to operate in the memory management model indicated.
The caller owns this copy and the auto-pointer ensures that it The caller owns this copy and the auto-pointer ensures that it
will be deleted. will be deleted.
@param alloc Memory management model for the new MakerNote. Determines if @param alloc Memory management model for the new MakerNote. Determines if
memory required to store data should be allocated and deallocated memory required to store data should be allocated and deallocated
(true) or not (false). If false, only pointers to the buffer (true) or not (false). If false, only pointers to the buffer
provided to read() will be kept. See Ifd for more background on provided to read() will be kept. See Ifd for more background on
this concept. this concept.
@param buf Pointer to the makernote character buffer (not used). @param buf Pointer to the makernote character buffer (not used).
@param len Length of the makernote character buffer (not used). @param len Length of the makernote character buffer (not used).
@param byteOrder Byte order in which the Exif data (and possibly the @param byteOrder Byte order in which the Exif data (and possibly the
makernote) is encoded (not used). makernote) is encoded (not used).
@param offset Offset from the start of the TIFF header of the makernote @param offset Offset from the start of the TIFF header of the makernote
buffer (not used). buffer (not used).
@return An auto-pointer to a newly created empty MakerNote. The caller @return An auto-pointer to a newly created empty MakerNote. The caller
owns this copy and the auto-pointer ensures that it will be owns this copy and the auto-pointer ensures that it will be
deleted. deleted.
*/ */
MakerNote::AutoPtr createSonyMakerNote(bool alloc, MakerNote::AutoPtr createSonyMakerNote(bool alloc,
const byte* buf, const byte* buf,
long len, long len,
ByteOrder byteOrder, ByteOrder byteOrder,
long offset); long offset);
// ***************************************************************************** // *****************************************************************************
@ -102,8 +102,8 @@ namespace Exiv2 {
//@} //@}
//! @name Manipulators //! @name Manipulators
//@{ //@{
int readHeader(const byte* buf, int readHeader(const byte* buf,
long len, long len,
ByteOrder byteOrder); ByteOrder byteOrder);
//@} //@}

@ -57,7 +57,7 @@ try {
break; break;
} }
if (rc) { if (rc) {
std::cout << "Usage: " << argv[0] std::cout << "Usage: " << argv[0]
<< " [Exif|Canon|CanonCs1|CanonCs2|CanonCf|Fujifilm|Nikon1|Nikon2|Nikon3|Olympus|Sigma|Sony|Iptc]\n" << " [Exif|Canon|CanonCs1|CanonCs2|CanonCf|Fujifilm|Nikon1|Nikon2|Nikon3|Olympus|Sigma|Sony|Iptc]\n"
<< "Print Exif tags, MakerNote tags, or Iptc datasets\n"; << "Print Exif tags, MakerNote tags, or Iptc datasets\n";
} }

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -109,14 +109,14 @@ namespace Exiv2 {
}; };
TagInfo::TagInfo( TagInfo::TagInfo(
uint16_t tag, uint16_t tag,
const char* name, const char* name,
const char* title, const char* title,
const char* desc, const char* desc,
IfdId ifdId, IfdId ifdId,
SectionId sectionId, SectionId sectionId,
TypeId typeId, TypeId typeId,
PrintFct printFct PrintFct printFct
) )
: tag_(tag), name_(name), title_(title), desc_(desc), ifdId_(ifdId), : tag_(tag), name_(name), title_(title), desc_(desc), ifdId_(ifdId),
sectionId_(sectionId), typeId_(typeId), printFct_(printFct) sectionId_(sectionId), typeId_(typeId), printFct_(printFct)
@ -274,7 +274,7 @@ namespace Exiv2 {
// End of list marker // End of list marker
TagInfo(0xffff, "(UnknownGpsTag)", "Unknown GPSInfo tag", "Unknown GPSInfo tag", ifdIdNotSet, sectionIdNotSet, invalidTypeId, printValue) TagInfo(0xffff, "(UnknownGpsTag)", "Unknown GPSInfo tag", "Unknown GPSInfo tag", ifdIdNotSet, sectionIdNotSet, invalidTypeId, printValue)
}; };
// Exif Interoperability IFD Tags // Exif Interoperability IFD Tags
static const TagInfo iopTagInfo[] = { static const TagInfo iopTagInfo[] = {
TagInfo(0x0001, "InteroperabilityIndex", "InteroperabilityIndex", "Interoperability Identification", iopIfdId, iopTags, asciiString, printValue), TagInfo(0x0001, "InteroperabilityIndex", "InteroperabilityIndex", "Interoperability Identification", iopIfdId, iopTags, asciiString, printValue),
@ -311,8 +311,8 @@ namespace Exiv2 {
// this is an array with pointers to one list per IFD. The IfdId is used as the // this is an array with pointers to one list per IFD. The IfdId is used as the
// index into the array. // index into the array.
const TagInfo* ExifTags::tagInfos_[] = { const TagInfo* ExifTags::tagInfos_[] = {
0, 0,
ifdTagInfo, exifTagInfo, gpsTagInfo, iopTagInfo, ifdTagInfo, ifdTagInfo, exifTagInfo, gpsTagInfo, iopTagInfo, ifdTagInfo,
0 0
}; };
@ -364,7 +364,7 @@ namespace Exiv2 {
return 0; return 0;
} // ExifTags::makerTagInfo } // ExifTags::makerTagInfo
const TagInfo* ExifTags::makerTagInfo(const std::string& tagName, const TagInfo* ExifTags::makerTagInfo(const std::string& tagName,
IfdId ifdId) IfdId ifdId)
{ {
int i = 0; int i = 0;
@ -533,13 +533,13 @@ namespace Exiv2 {
} }
std::ostream& ExifTags::printTag(std::ostream& os, std::ostream& ExifTags::printTag(std::ostream& os,
uint16_t tag, uint16_t tag,
IfdId ifdId, IfdId ifdId,
const Value& value) const Value& value)
{ {
if (value.count() == 0) return os; if (value.count() == 0) return os;
PrintFct fct = printValue; PrintFct fct = printValue;
if (isExifIfd(ifdId)) { if (isExifIfd(ifdId)) {
int idx = tagInfoIdx(tag, ifdId); int idx = tagInfoIdx(tag, ifdId);
if (idx != -1) { if (idx != -1) {
fct = tagInfos_[ifdId][idx].printFct_; fct = tagInfos_[ifdId][idx].printFct_;
@ -605,7 +605,7 @@ namespace Exiv2 {
} }
ExifKey::ExifKey(const Entry& e) ExifKey::ExifKey(const Entry& e)
: tag_(e.tag()), ifdId_(e.ifdId()), : tag_(e.tag()), ifdId_(e.ifdId()),
ifdItem_(ExifTags::ifdItem(e.ifdId())), ifdItem_(ExifTags::ifdItem(e.ifdId())),
idx_(e.idx()), key_("") idx_(e.idx()), key_("")
{ {
@ -636,9 +636,9 @@ namespace Exiv2 {
std::string ExifKey::tagName() const std::string ExifKey::tagName() const
{ {
return ExifTags::tagName(tag_, ifdId_); return ExifTags::tagName(tag_, ifdId_);
} }
ExifKey::AutoPtr ExifKey::clone() const ExifKey::AutoPtr ExifKey::clone() const
{ {
return AutoPtr(clone_()); return AutoPtr(clone_());
@ -649,9 +649,9 @@ namespace Exiv2 {
return new ExifKey(*this); return new ExifKey(*this);
} }
std::string ExifKey::sectionName() const std::string ExifKey::sectionName() const
{ {
return ExifTags::sectionName(tag(), ifdId()); return ExifTags::sectionName(tag(), ifdId());
} }
void ExifKey::decomposeKey() void ExifKey::decomposeKey()
@ -680,7 +680,7 @@ namespace Exiv2 {
} }
// Convert tag // Convert tag
uint16_t tag = ExifTags::tag(tagName, ifdId); uint16_t tag = ExifTags::tag(tagName, ifdId);
// Translate hex tag name (0xabcd) to a real tag name if there is one // Translate hex tag name (0xabcd) to a real tag name if there is one
tagName = ExifTags::tagName(tag, ifdId); tagName = ExifTags::tagName(tag, ifdId);
@ -692,11 +692,11 @@ namespace Exiv2 {
void ExifKey::makeKey() void ExifKey::makeKey()
{ {
key_ = std::string(familyName_) key_ = std::string(familyName_)
+ "." + ifdItem_ + "." + ifdItem_
+ "." + ExifTags::tagName(tag_, ifdId_); + "." + ExifTags::tagName(tag_, ifdId_);
} }
// ************************************************************************* // *************************************************************************
// free functions // free functions
@ -714,46 +714,46 @@ namespace Exiv2 {
return rc; return rc;
} // isExifIfd } // isExifIfd
std::ostream& operator<<(std::ostream& os, const TagInfo& ti) std::ostream& operator<<(std::ostream& os, const TagInfo& ti)
{ {
ExifKey exifKey(ti.tag_, ExifTags::ifdItem(ti.ifdId_)); ExifKey exifKey(ti.tag_, ExifTags::ifdItem(ti.ifdId_));
return os << ExifTags::tagName(ti.tag_, ti.ifdId_) << ", " return os << ExifTags::tagName(ti.tag_, ti.ifdId_) << ", "
<< std::dec << ti.tag_ << ", " << std::dec << ti.tag_ << ", "
<< "0x" << std::setw(4) << std::setfill('0') << "0x" << std::setw(4) << std::setfill('0')
<< std::right << std::hex << ti.tag_ << ", " << std::right << std::hex << ti.tag_ << ", "
<< ExifTags::ifdName(ti.ifdId_) << ", " << ExifTags::ifdName(ti.ifdId_) << ", "
<< exifKey.key() << ", " << exifKey.key() << ", "
<< TypeInfo::typeName( << TypeInfo::typeName(
ExifTags::tagType(ti.tag_, ti.ifdId_)) << ", " ExifTags::tagType(ti.tag_, ti.ifdId_)) << ", "
<< ExifTags::tagDesc(ti.tag_, ti.ifdId_); << ExifTags::tagDesc(ti.tag_, ti.ifdId_);
} }
std::ostream& operator<<(std::ostream& os, const Rational& r) std::ostream& operator<<(std::ostream& os, const Rational& r)
{ {
return os << r.first << "/" << r.second; return os << r.first << "/" << r.second;
} }
std::istream& operator>>(std::istream& is, Rational& r) std::istream& operator>>(std::istream& is, Rational& r)
{ {
int32_t nominator; int32_t nominator;
int32_t denominator; int32_t denominator;
char c; char c;
is >> nominator >> c >> denominator; is >> nominator >> c >> denominator;
if (is && c == '/') r = std::make_pair(nominator, denominator); if (is && c == '/') r = std::make_pair(nominator, denominator);
return is; return is;
} }
std::ostream& operator<<(std::ostream& os, const URational& r) std::ostream& operator<<(std::ostream& os, const URational& r)
{ {
return os << r.first << "/" << r.second; return os << r.first << "/" << r.second;
} }
std::istream& operator>>(std::istream& is, URational& r) std::istream& operator>>(std::istream& is, URational& r)
{ {
uint32_t nominator; uint32_t nominator;
uint32_t denominator; uint32_t denominator;
char c; char c;
is >> nominator >> c >> denominator; is >> nominator >> c >> denominator;
if (is && c == '/') r = std::make_pair(nominator, denominator); if (is && c == '/') r = std::make_pair(nominator, denominator);
return is; return is;
} }
@ -998,7 +998,7 @@ namespace Exiv2 {
else { else {
os << "(" << value << ")"; os << "(" << value << ")";
} }
return os; return os;
} }
std::ostream& print0x9207(std::ostream& os, const Value& value) std::ostream& print0x9207(std::ostream& os, const Value& value)

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -60,8 +60,8 @@ namespace Exiv2 {
@brief Section identifiers to logically group tags. A section consists @brief Section identifiers to logically group tags. A section consists
of nothing more than a name, based on the Exif standard. of nothing more than a name, based on the Exif standard.
*/ */
enum SectionId { sectionIdNotSet, enum SectionId { sectionIdNotSet,
imgStruct, recOffset, imgCharacter, otherTags, exifFormat, imgStruct, recOffset, imgCharacter, otherTags, exifFormat,
exifVersion, imgConfig, userInfo, relatedFile, dateTime, exifVersion, imgConfig, userInfo, relatedFile, dateTime,
captureCond, gpsTags, iopTags, makerTags, captureCond, gpsTags, iopTags, makerTags,
lastSectionId }; lastSectionId };
@ -76,7 +76,7 @@ namespace Exiv2 {
IfdId ifdId_; //!< IFD id IfdId ifdId_; //!< IFD id
const char* name_; //!< IFD name const char* name_; //!< IFD name
//! Related IFD item. This is also an IFD name, unique for each IFD. //! Related IFD item. This is also an IFD name, unique for each IFD.
const char* item_; const char* item_;
}; };
//! Contains information pertaining to one section //! Contains information pertaining to one section
@ -92,10 +92,10 @@ namespace Exiv2 {
struct TagInfo { struct TagInfo {
//! Constructor //! Constructor
TagInfo( TagInfo(
uint16_t tag, uint16_t tag,
const char* name, const char* name,
const char* title, const char* title,
const char* desc, const char* desc,
IfdId ifdId, IfdId ifdId,
SectionId sectionId, SectionId sectionId,
TypeId typeId, TypeId typeId,
@ -112,7 +112,7 @@ namespace Exiv2 {
}; // struct TagInfo }; // struct TagInfo
/*! /*!
@brief Helper structure for lookup tables for translations of numeric @brief Helper structure for lookup tables for translations of numeric
tag values to human readable labels. tag values to human readable labels.
*/ */
struct TagDetails { struct TagDetails {
@ -154,14 +154,14 @@ namespace Exiv2 {
public: public:
/*! /*!
@brief Return the name of the tag or a string with the hexadecimal @brief Return the name of the tag or a string with the hexadecimal
value of the tag in the form "0x01ff", if the tag is not value of the tag in the form "0x01ff", if the tag is not
a known Exif tag. a known Exif tag.
@param tag The tag @param tag The tag
@param ifdId IFD id @param ifdId IFD id
@return The name of the tag or a string containing the hexadecimal @return The name of the tag or a string containing the hexadecimal
value of the tag in the form "0x01ff", if this is an unknown value of the tag in the form "0x01ff", if this is an unknown
tag. tag.
*/ */
static std::string tagName(uint16_t tag, IfdId ifdId); static std::string tagName(uint16_t tag, IfdId ifdId);
@ -178,12 +178,12 @@ namespace Exiv2 {
@param tag The tag @param tag The tag
@param ifdId IFD id @param ifdId IFD id
@return The description of the tag or a string indicating that @return The description of the tag or a string indicating that
the tag is unknown. the tag is unknown.
*/ */
static const char* tagDesc(uint16_t tag, IfdId ifdId); static const char* tagDesc(uint16_t tag, IfdId ifdId);
/*! /*!
@brief Return the tag for one combination of IFD id and tagName. @brief Return the tag for one combination of IFD id and tagName.
If the tagName is not known, it expects tag names in the If the tagName is not known, it expects tag names in the
form "0x01ff" and converts them to unsigned integer. form "0x01ff" and converts them to unsigned integer.
@throw Error if the tagname or ifdId is invalid @throw Error if the tagname or ifdId is invalid
@ -198,21 +198,21 @@ namespace Exiv2 {
//! Return the name of the section //! Return the name of the section
static const char* sectionName(SectionId sectionId); static const char* sectionName(SectionId sectionId);
/*! /*!
@brief Return the name of the section for a combination of @brief Return the name of the section for a combination of
tag and IFD id. tag and IFD id.
@param tag The tag @param tag The tag
@param ifdId IFD id @param ifdId IFD id
@return The name of the section or a string indicating that the @return The name of the section or a string indicating that the
section or the tag is unknown. section or the tag is unknown.
*/ */
static const char* sectionName(uint16_t tag, IfdId ifdId); static const char* sectionName(uint16_t tag, IfdId ifdId);
/*! /*!
@brief Return the description of the section for a combination of @brief Return the description of the section for a combination of
tag and IFD id. tag and IFD id.
@param tag The tag @param tag The tag
@param ifdId IFD id @param ifdId IFD id
@return The description of the section or a string indicating that @return The description of the section or a string indicating that
the section or the tag is unknown. the section or the tag is unknown.
*/ */
static const char* sectionDesc(uint16_t tag, IfdId ifdId); static const char* sectionDesc(uint16_t tag, IfdId ifdId);
//! Return the section id for a section name //! Return the section id for a section name
@ -221,7 +221,7 @@ namespace Exiv2 {
static TypeId tagType(uint16_t tag, IfdId ifdId); static TypeId tagType(uint16_t tag, IfdId ifdId);
//! Interpret and print the value of an Exif tag //! Interpret and print the value of an Exif tag
static std::ostream& printTag(std::ostream& os, static std::ostream& printTag(std::ostream& os,
uint16_t tag, uint16_t tag,
IfdId ifdId, IfdId ifdId,
const Value& value); const Value& value);
//! Print a list of all standard Exif tags to output stream //! Print a list of all standard Exif tags to output stream
@ -238,7 +238,7 @@ namespace Exiv2 {
static void registerMakerTagInfo(IfdId ifdId, const TagInfo* tagInfo); static void registerMakerTagInfo(IfdId ifdId, const TagInfo* tagInfo);
/*! /*!
@brief Return true if \em ifdId is an %Ifd Id which is registered @brief Return true if \em ifdId is an %Ifd Id which is registered
as a makernote %Ifd id. Note: Calling this function with as a makernote %Ifd id. Note: Calling this function with
makerIfd returns false. makerIfd returns false.
*/ */
static bool isMakerIfd(IfdId ifdId); static bool isMakerIfd(IfdId ifdId);
@ -246,7 +246,7 @@ namespace Exiv2 {
private: private:
static int tagInfoIdx(uint16_t tag, IfdId ifdId); static int tagInfoIdx(uint16_t tag, IfdId ifdId);
static const TagInfo* makerTagInfo(uint16_t tag, IfdId ifdId); static const TagInfo* makerTagInfo(uint16_t tag, IfdId ifdId);
static const TagInfo* makerTagInfo(const std::string& tagName, static const TagInfo* makerTagInfo(const std::string& tagName,
IfdId ifdId); IfdId ifdId);
static const IfdInfo ifdInfo_[]; static const IfdInfo ifdInfo_[];
@ -276,14 +276,14 @@ namespace Exiv2 {
@param key The key string. @param key The key string.
@throw Error if the first part of the key is not '<b>Exif</b>' or @throw Error if the first part of the key is not '<b>Exif</b>' or
the remainin parts of the key cannot be parsed and the remainin parts of the key cannot be parsed and
converted to an ifd-item and tag name. converted to an ifd-item and tag name.
*/ */
explicit ExifKey(const std::string& key); explicit ExifKey(const std::string& key);
/*! /*!
@brief Constructor to create an Exif key from a tag and IFD item @brief Constructor to create an Exif key from a tag and IFD item
string. string.
@param tag The tag value @param tag The tag value
@param ifdItem The IFD string. For MakerNote tags, this must be the @param ifdItem The IFD string. For MakerNote tags, this must be the
IFD item of the specific MakerNote. "MakerNote" is not allowed. IFD item of the specific MakerNote. "MakerNote" is not allowed.
@throw Error if the key cannot be constructed from the tag and IFD @throw Error if the key cannot be constructed from the tag and IFD
item parameters. item parameters.
@ -311,7 +311,7 @@ namespace Exiv2 {
/*! /*!
@brief Return the name of the group (the second part of the key). @brief Return the name of the group (the second part of the key).
For Exif keys, the group name is the IFD item. For Exif keys, the group name is the IFD item.
*/ */
virtual std::string groupName() const { return ifdItem(); } virtual std::string groupName() const { return ifdItem(); }
virtual std::string tagName() const; virtual std::string tagName() const;
virtual uint16_t tag() const { return tag_; } virtual uint16_t tag() const { return tag_; }
@ -323,7 +323,7 @@ namespace Exiv2 {
const char* ifdName() const { return ExifTags::ifdName(ifdId()); } const char* ifdName() const { return ExifTags::ifdName(ifdId()); }
//! Return the related image item //! Return the related image item
std::string ifdItem() const { return ifdItem_; } std::string ifdItem() const { return ifdItem_; }
//! Return the name of the Exif section (deprecated) //! Return the name of the Exif section (deprecated)
std::string sectionName() const; std::string sectionName() const;
//! Return the index (unique id of this key within the original IFD) //! Return the index (unique id of this key within the original IFD)
int idx() const { return idx_; } int idx() const { return idx_; }
@ -333,12 +333,12 @@ namespace Exiv2 {
//! @name Manipulators //! @name Manipulators
//@{ //@{
/*! /*!
@brief Set the key corresponding to the tag and IFD id. @brief Set the key corresponding to the tag and IFD id.
The key is of the form '<b>Exif</b>.ifdItem.tagName'. The key is of the form '<b>Exif</b>.ifdItem.tagName'.
*/ */
void makeKey(); void makeKey();
/*! /*!
@brief Parse and convert the key string into tag and IFD Id. @brief Parse and convert the key string into tag and IFD Id.
Updates data members if the string can be decomposed, Updates data members if the string can be decomposed,
or throws \em Error . or throws \em Error .
@ -348,7 +348,7 @@ namespace Exiv2 {
//@} //@}
private: private:
//! Internal virtual copy constructor. //! Internal virtual copy constructor.
virtual ExifKey* clone_() const; virtual ExifKey* clone_() const;
// DATA // DATA
@ -356,7 +356,7 @@ namespace Exiv2 {
uint16_t tag_; //!< Tag value uint16_t tag_; //!< Tag value
IfdId ifdId_; //!< The IFD associated with this tag IfdId ifdId_; //!< The IFD associated with this tag
std::string ifdItem_; //!< The IFD item std::string ifdItem_; //!< The IFD item
int idx_; //!< Unique id of an entry within one IFD int idx_; //!< Unique id of an entry within one IFD
std::string key_; //!< Key std::string key_; //!< Key
}; // class ExifKey }; // class ExifKey
@ -394,7 +394,7 @@ namespace Exiv2 {
std::ostream& print0x0112(std::ostream& os, const Value& value); std::ostream& print0x0112(std::ostream& os, const Value& value);
//! Print the YCbCrPositioning //! Print the YCbCrPositioning
std::ostream& print0x0213(std::ostream& os, const Value& value); std::ostream& print0x0213(std::ostream& os, const Value& value);
//! Print the copyright //! Print the copyright
std::ostream& print0x8298(std::ostream& os, const Value& value); std::ostream& print0x8298(std::ostream& os, const Value& value);
//! Print the exposure time //! Print the exposure time
std::ostream& print0x829a(std::ostream& os, const Value& value); std::ostream& print0x829a(std::ostream& os, const Value& value);
@ -438,7 +438,7 @@ namespace Exiv2 {
std::ostream& print0xa403(std::ostream& os, const Value& value); std::ostream& print0xa403(std::ostream& os, const Value& value);
//! Print digital zoom ratio //! Print digital zoom ratio
std::ostream& print0xa404(std::ostream& os, const Value& value); std::ostream& print0xa404(std::ostream& os, const Value& value);
//! Print 35mm equivalent focal length //! Print 35mm equivalent focal length
std::ostream& print0xa405(std::ostream& os, const Value& value); std::ostream& print0xa405(std::ostream& os, const Value& value);
//! Print scene capture type //! Print scene capture type
std::ostream& print0xa406(std::ostream& os, const Value& value); std::ostream& print0xa406(std::ostream& os, const Value& value);

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -90,14 +90,14 @@ namespace Exiv2 {
{ {
return typeInfoTable_[ typeId < lastTypeId ? typeId : 0 ].size_; return typeInfoTable_[ typeId < lastTypeId ? typeId : 0 ].size_;
} }
DataBuf::DataBuf(DataBuf& rhs) DataBuf::DataBuf(DataBuf& rhs)
: pData_(rhs.pData_), size_(rhs.size_) : pData_(rhs.pData_), size_(rhs.size_)
{ {
rhs.release(); rhs.release();
} }
DataBuf::DataBuf(byte* pData, long size) DataBuf::DataBuf(byte* pData, long size)
: pData_(0), size_(0) : pData_(0), size_(0)
{ {
if (size > 0) { if (size > 0) {
@ -115,12 +115,12 @@ namespace Exiv2 {
} }
void DataBuf::alloc(long size) void DataBuf::alloc(long size)
{ {
if (size > size_) { if (size > size_) {
delete[] pData_; delete[] pData_;
size_ = size; size_ = size;
pData_ = new byte[size]; pData_ = new byte[size];
} }
} }
std::pair<byte*, long> DataBuf::release() std::pair<byte*, long> DataBuf::release()
@ -156,11 +156,11 @@ namespace Exiv2 {
uint32_t getULong(const byte* buf, ByteOrder byteOrder) uint32_t getULong(const byte* buf, ByteOrder byteOrder)
{ {
if (byteOrder == littleEndian) { if (byteOrder == littleEndian) {
return (byte)buf[3] << 24 | (byte)buf[2] << 16 return (byte)buf[3] << 24 | (byte)buf[2] << 16
| (byte)buf[1] << 8 | (byte)buf[0]; | (byte)buf[1] << 8 | (byte)buf[0];
} }
else { else {
return (byte)buf[0] << 24 | (byte)buf[1] << 16 return (byte)buf[0] << 24 | (byte)buf[1] << 16
| (byte)buf[2] << 8 | (byte)buf[3]; | (byte)buf[2] << 8 | (byte)buf[3];
} }
} }
@ -185,11 +185,11 @@ namespace Exiv2 {
int32_t getLong(const byte* buf, ByteOrder byteOrder) int32_t getLong(const byte* buf, ByteOrder byteOrder)
{ {
if (byteOrder == littleEndian) { if (byteOrder == littleEndian) {
return (byte)buf[3] << 24 | (byte)buf[2] << 16 return (byte)buf[3] << 24 | (byte)buf[2] << 16
| (byte)buf[1] << 8 | (byte)buf[0]; | (byte)buf[1] << 8 | (byte)buf[0];
} }
else { else {
return (byte)buf[0] << 24 | (byte)buf[1] << 16 return (byte)buf[0] << 24 | (byte)buf[1] << 16
| (byte)buf[2] << 8 | (byte)buf[3]; | (byte)buf[2] << 8 | (byte)buf[3];
} }
} }
@ -277,13 +277,13 @@ namespace Exiv2 {
void hexdump(std::ostream& os, const byte* buf, long len, long offset) void hexdump(std::ostream& os, const byte* buf, long len, long offset)
{ {
const std::string::size_type pos = 8 + 16 * 3 + 2; const std::string::size_type pos = 8 + 16 * 3 + 2;
const std::string align(pos, ' '); const std::string align(pos, ' ');
long i = 0; long i = 0;
while (i < len) { while (i < len) {
os << " " os << " "
<< std::setw(4) << std::setfill('0') << std::hex << std::setw(4) << std::setfill('0') << std::hex
<< i + offset << " "; << i + offset << " ";
std::ostringstream ss; std::ostringstream ss;
do { do {
@ -300,11 +300,11 @@ namespace Exiv2 {
bool isHex(const std::string& str, size_t size, const std::string& prefix) bool isHex(const std::string& str, size_t size, const std::string& prefix)
{ {
if ( str.size() <= prefix.size() if ( str.size() <= prefix.size()
|| str.substr(0, prefix.size()) != prefix) return false; || str.substr(0, prefix.size()) != prefix) return false;
if ( size > 0 if ( size > 0
&& str.size() != size + prefix.size()) return false; && str.size() != size + prefix.size()) return false;
for (size_t i = prefix.size(); i < str.size(); ++i) { for (size_t i = prefix.size(); i < str.size(); ++i) {
if (!isxdigit(str[i])) return false; if (!isxdigit(str[i])) return false;
} }

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -77,25 +77,25 @@ namespace Exiv2 {
enum ByteOrder { invalidByteOrder, littleEndian, bigEndian }; enum ByteOrder { invalidByteOrder, littleEndian, bigEndian };
//! Type identifiers for IFD format types //! Type identifiers for IFD format types
enum TypeId { invalidTypeId, unsignedByte, asciiString, unsignedShort, enum TypeId { invalidTypeId, unsignedByte, asciiString, unsignedShort,
unsignedLong, unsignedRational, invalid6, undefined, unsignedLong, unsignedRational, invalid6, undefined,
signedShort, signedLong, signedRational, signedShort, signedLong, signedRational,
string, date, time, string, date, time,
comment, comment,
directory, directory,
lastTypeId }; lastTypeId };
// Todo: decentralize IfdId, so that new ids can be defined elsewhere // Todo: decentralize IfdId, so that new ids can be defined elsewhere
//! Type to specify the IFD to which a metadata belongs //! Type to specify the IFD to which a metadata belongs
enum IfdId { ifdIdNotSet, enum IfdId { ifdIdNotSet,
ifd0Id, exifIfdId, gpsIfdId, iopIfdId, ifd1Id, ifd0Id, exifIfdId, gpsIfdId, iopIfdId, ifd1Id,
canonIfdId, canonCs1IfdId, canonCs2IfdId, canonCfIfdId, canonIfdId, canonCs1IfdId, canonCs2IfdId, canonCfIfdId,
fujiIfdId, nikon1IfdId, nikon2IfdId, nikon3IfdId, fujiIfdId, nikon1IfdId, nikon2IfdId, nikon3IfdId,
olympusIfdId, panasonicIfdId, sigmaIfdId, sonyIfdId, olympusIfdId, panasonicIfdId, sigmaIfdId, sonyIfdId,
lastIfdId }; lastIfdId };
//! Type to identify where the data is stored in a directory //! Type to identify where the data is stored in a directory
enum DataLocId { invalidDataLocId, enum DataLocId { invalidDataLocId,
valueData, directoryData, valueData, directoryData,
lastDataLocId }; lastDataLocId };
@ -108,7 +108,7 @@ namespace Exiv2 {
TypeInfoTable(TypeId typeId, const char* name, long size); TypeInfoTable(TypeId typeId, const char* name, long size);
TypeId typeId_; //!< Type id TypeId typeId_; //!< Type id
const char* name_; //!< Name of the type const char* name_; //!< Name of the type
long size_; //!< Bytes per data entry long size_; //!< Bytes per data entry
}; // struct TypeInfoTable }; // struct TypeInfoTable
//! Type information lookup functions. Implemented as a static class. //! Type information lookup functions. Implemented as a static class.
@ -157,12 +157,12 @@ namespace Exiv2 {
//@{ //@{
//! Default constructor //! Default constructor
DataBuf() : pData_(0), size_(0) {} DataBuf() : pData_(0), size_(0) {}
//! Constructor with an initial buffer size //! Constructor with an initial buffer size
explicit DataBuf(long size) : pData_(new byte[size]), size_(size) {} explicit DataBuf(long size) : pData_(new byte[size]), size_(size) {}
//! Constructor, copies an existing buffer //! Constructor, copies an existing buffer
DataBuf(byte* pData, long size); DataBuf(byte* pData, long size);
/*! /*!
@brief Copy constructor. Transfers the buffer to the newly created @brief Copy constructor. Transfers the buffer to the newly created
object similar to std::auto_ptr, i.e., the original object is object similar to std::auto_ptr, i.e., the original object is
modified. modified.
*/ */
@ -175,14 +175,14 @@ namespace Exiv2 {
//@{ //@{
/*! /*!
@brief Assignment operator. Transfers the buffer and releases the @brief Assignment operator. Transfers the buffer and releases the
buffer at the original object similar to std::auto_ptr, i.e., buffer at the original object similar to std::auto_ptr, i.e.,
the original object is modified. the original object is modified.
*/ */
DataBuf& operator=(DataBuf& rhs); DataBuf& operator=(DataBuf& rhs);
//! Allocate a data buffer of the given size //! Allocate a data buffer of the given size
void alloc(long size); void alloc(long size);
/*! /*!
@brief Release ownership of the buffer to the caller. Returns the @brief Release ownership of the buffer to the caller. Returns the
buffer as a data pointer and size pair, resets the internal buffer as a data pointer and size pair, resets the internal
buffer. buffer.
*/ */
@ -194,7 +194,7 @@ namespace Exiv2 {
/*! /*!
@name Conversions @name Conversions
Special conversions with auxiliary type to enable copies Special conversions with auxiliary type to enable copies
and assignments, similar to those used for std::auto_ptr. and assignments, similar to those used for std::auto_ptr.
See http://www.josuttis.com/libbook/auto_ptr.html for a discussion. See http://www.josuttis.com/libbook/auto_ptr.html for a discussion.
*/ */
@ -208,7 +208,7 @@ namespace Exiv2 {
//! Pointer to the buffer, 0 if none has been allocated //! Pointer to the buffer, 0 if none has been allocated
byte* pData_; byte* pData_;
//! The current size of the buffer //! The current size of the buffer
long size_; long size_;
}; // class DataBuf }; // class DataBuf
@ -238,7 +238,7 @@ namespace Exiv2 {
std::istream& operator>>(std::istream& is, URational& r); std::istream& operator>>(std::istream& is, URational& r);
/*! /*!
@brief Convert an unsigned short to data, write the data to the buffer, @brief Convert an unsigned short to data, write the data to the buffer,
return number of bytes written. return number of bytes written.
*/ */
long us2Data(byte* buf, uint16_t s, ByteOrder byteOrder); long us2Data(byte* buf, uint16_t s, ByteOrder byteOrder);
@ -253,7 +253,7 @@ namespace Exiv2 {
*/ */
long ur2Data(byte* buf, URational l, ByteOrder byteOrder); long ur2Data(byte* buf, URational l, ByteOrder byteOrder);
/*! /*!
@brief Convert a signed short to data, write the data to the buffer, @brief Convert a signed short to data, write the data to the buffer,
return number of bytes written. return number of bytes written.
*/ */
long s2Data(byte* buf, int16_t s, ByteOrder byteOrder); long s2Data(byte* buf, int16_t s, ByteOrder byteOrder);
@ -277,10 +277,10 @@ namespace Exiv2 {
/*! /*!
@brief Return true if str is a hex number starting with prefix followed @brief Return true if str is a hex number starting with prefix followed
by size hex digits, false otherwise. If size is 0, any number of by size hex digits, false otherwise. If size is 0, any number of
digits is allowed and all are checked. digits is allowed and all are checked.
*/ */
bool isHex(const std::string& str, bool isHex(const std::string& str,
size_t size =0, size_t size =0,
const std::string& prefix =""); const std::string& prefix ="");
@ -288,7 +288,7 @@ namespace Exiv2 {
// template and inline definitions // template and inline definitions
//! Utility function to convert the argument of any type to a string //! Utility function to convert the argument of any type to a string
template<typename T> template<typename T>
std::string toString(const T& arg) std::string toString(const T& arg)
{ {
std::ostringstream os; std::ostringstream os;
@ -300,8 +300,8 @@ namespace Exiv2 {
@brief Return the greatest common denominator of n and m. @brief Return the greatest common denominator of n and m.
(implementation from Boost rational.hpp) (implementation from Boost rational.hpp)
@note We use n and m as temporaries in this function, so there is no @note We use n and m as temporaries in this function, so there is no
value in using const IntType& as we would only need to make a copy value in using const IntType& as we would only need to make a copy
anyway... anyway...
*/ */
template <typename IntType> template <typename IntType>
@ -309,7 +309,7 @@ namespace Exiv2 {
{ {
// Avoid repeated construction // Avoid repeated construction
IntType zero(0); IntType zero(0);
// This is abs() - given the existence of broken compilers with Koenig // This is abs() - given the existence of broken compilers with Koenig
// lookup issues and other problems, I code this explicitly. (Remember, // lookup issues and other problems, I code this explicitly. (Remember,
// IntType may be a user-defined type). // IntType may be a user-defined type).

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -72,12 +72,12 @@ namespace Util {
for (int i = ::optind; i < argc; i++) { for (int i = ::optind; i < argc; i++) {
errcnt_ += nonoption(argv[i]); errcnt_ += nonoption(argv[i]);
} }
return errcnt_; return errcnt_;
} }
int Getopt::nonoption(const std::string& /*argv*/) int Getopt::nonoption(const std::string& /*argv*/)
{ {
return 0; return 0;
} }
// ***************************************************************************** // *****************************************************************************
@ -88,7 +88,7 @@ namespace Util {
if (path == "") return "."; if (path == "") return ".";
// Strip trailing slashes or backslashes // Strip trailing slashes or backslashes
std::string p = path; std::string p = path;
while ( p.length() > 1 while ( p.length() > 1
&& (p[p.length()-1] == '\\' || p[p.length()-1] == '/')) { && (p[p.length()-1] == '\\' || p[p.length()-1] == '/')) {
p = p.substr(0, p.length()-1); p = p.substr(0, p.length()-1);
} }
@ -98,7 +98,7 @@ namespace Util {
if (idx == std::string::npos) return "."; if (idx == std::string::npos) return ".";
if (idx == 1 && p[0] == '\\' && p[1] == '\\') return p; // For Windows paths if (idx == 1 && p[0] == '\\' && p[1] == '\\') return p; // For Windows paths
p = p.substr(0, idx == 0 ? 1 : idx); p = p.substr(0, idx == 0 ? 1 : idx);
while ( p.length() > 1 while ( p.length() > 1
&& (p[p.length()-1] == '\\' || p[p.length()-1] == '/')) { && (p[p.length()-1] == '\\' || p[p.length()-1] == '/')) {
p = p.substr(0, p.length()-1); p = p.substr(0, p.length()-1);
} }
@ -110,7 +110,7 @@ namespace Util {
if (path == "") return "."; if (path == "") return ".";
// Strip trailing slashes or backslashes // Strip trailing slashes or backslashes
std::string p = path; std::string p = path;
while ( p.length() > 1 while ( p.length() > 1
&& (p[p.length()-1] == '\\' || p[p.length()-1] == '/')) { && (p[p.length()-1] == '\\' || p[p.length()-1] == '/')) {
p = p.substr(0, p.length()-1); p = p.substr(0, p.length()-1);
} }
@ -124,7 +124,7 @@ namespace Util {
std::string suffix(const std::string& path) std::string suffix(const std::string& path)
{ {
std::string b = basename(path); std::string b = basename(path);
std::string::size_type idx = b.rfind('.'); std::string::size_type idx = b.rfind('.');
if (idx == std::string::npos || idx == 0 || idx == b.length()-1) { if (idx == std::string::npos || idx == 0 || idx == b.length()-1) {
return ""; return "";

@ -1,19 +1,19 @@
// ********************************************************* -*- C++ -*- // ********************************************************* -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -37,8 +37,8 @@
// ********************************************************************* // *********************************************************************
// namespace extensions // namespace extensions
/*! /*!
@brief Contains utility classes and functions. Most of these are @brief Contains utility classes and functions. Most of these are
wrappers for common C functions that do not require pointers wrappers for common C functions that do not require pointers
and memory considerations. and memory considerations.
*/ */
namespace Util { namespace Util {
@ -77,13 +77,13 @@ public:
@param argv Argument array as passed to main() on program invocation. @param argv Argument array as passed to main() on program invocation.
@param optstring String containing the legitimate option characters. @param optstring String containing the legitimate option characters.
@return Number of errors (the sum of the return values from option() @return Number of errors (the sum of the return values from option()
and nonoption()). and nonoption()).
*/ */
int getopt(int argc, char* const argv[], const std::string& optstring); int getopt(int argc, char* const argv[], const std::string& optstring);
/*! /*!
@brief Callback used by getopt() to pass on each option and its @brief Callback used by getopt() to pass on each option and its
argument (if any). argument (if any).
Implement this method in a derived class to handle the options as Implement this method in a derived class to handle the options as
@ -128,32 +128,32 @@ private:
// free functions // free functions
/*! /*!
@brief Get the directory component from the \em path string. @brief Get the directory component from the \em path string.
See %dirname(3). See %dirname(3).
This function can handle Windows paths to some extent: c:\\bar should This function can handle Windows paths to some extent: c:\\bar should
be fine, \\\\bigsrv\\foo also, but \\\\bigsrv alone doesn't work. be fine, \\\\bigsrv\\foo also, but \\\\bigsrv alone doesn't work.
*/ */
std::string dirname(const std::string& path); std::string dirname(const std::string& path);
/*! /*!
@brief Get the filename component from the \em path string. @brief Get the filename component from the \em path string.
See %basename(3). If the \em delsuffix parameter is true, See %basename(3). If the \em delsuffix parameter is true,
the suffix will be removed. the suffix will be removed.
This function can handle Windows paths to some extent: c:\\bar should This function can handle Windows paths to some extent: c:\\bar should
be fine, \\\\bigsrv\\foo also, but \\\\bigsrv alone doesn't work. be fine, \\\\bigsrv\\foo also, but \\\\bigsrv alone doesn't work.
*/ */
std::string basename(const std::string& path, bool delsuffix =false); std::string basename(const std::string& path, bool delsuffix =false);
/*! /*!
@brief Get the suffix from the path string. Normally, the suffix @brief Get the suffix from the path string. Normally, the suffix
is the substring of the basename of path from the last '.' is the substring of the basename of path from the last '.'
to the end of the string. to the end of the string.
*/ */
std::string suffix(const std::string& path); std::string suffix(const std::string& path);
/*! /*!
@brief Convert a C string to a long value, which is returned in n. @brief Convert a C string to a long value, which is returned in n.
Returns true if the conversion is successful, else false. Returns true if the conversion is successful, else false.
n is not modified if the conversion is unsuccessful. See strtol(2). n is not modified if the conversion is unsuccessful. See strtol(2).

@ -86,8 +86,8 @@ void testPaths()
void testPath(const std::string& path) void testPath(const std::string& path)
{ {
std::cout << std::setw(15) << path << " " std::cout << std::setw(15) << path << " "
<< std::setw(15) << Util::dirname(path) << " " << std::setw(15) << Util::dirname(path) << " "
<< std::setw(15) << Util::basename(path) << " " << std::setw(15) << Util::basename(path) << " "
<< std::setw(15) << Util::suffix(path) << "\n"; << std::setw(15) << Util::suffix(path) << "\n";
} }

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -110,9 +110,9 @@ namespace Exiv2 {
return value; return value;
} // Value::create } // Value::create
int Value::setDataArea(const byte* /*buf*/, long /*len*/) int Value::setDataArea(const byte* /*buf*/, long /*len*/)
{ {
return -1; return -1;
} }
std::string Value::toString() const std::string Value::toString() const
@ -188,7 +188,7 @@ namespace Exiv2 {
void StringValueBase::read(const byte* buf, long len, ByteOrder byteOrder) void StringValueBase::read(const byte* buf, long len, ByteOrder byteOrder)
{ {
// byteOrder not needed // byteOrder not needed
value_ = std::string(reinterpret_cast<const char*>(buf), len); value_ = std::string(reinterpret_cast<const char*>(buf), len);
} }
@ -248,7 +248,7 @@ namespace Exiv2 {
} }
CommentValue::CharsetTable::CharsetTable(CharsetId charsetId, CommentValue::CharsetTable::CharsetTable(CharsetId charsetId,
const char* name, const char* name,
const char* code) const char* code)
: charsetId_(charsetId), name_(name), code_(code) : charsetId_(charsetId), name_(name), code_(code)
{ {
@ -348,15 +348,15 @@ namespace Exiv2 {
const std::string code = value_.substr(0, 8); const std::string code = value_.substr(0, 8);
charsetId = CharsetInfo::charsetIdByCode(code); charsetId = CharsetInfo::charsetIdByCode(code);
} }
return charsetId; return charsetId;
} }
CommentValue* CommentValue::clone_() const CommentValue* CommentValue::clone_() const
{ {
return new CommentValue(*this); return new CommentValue(*this);
} }
DateValue::DateValue(int year, int month, int day) DateValue::DateValue(int year, int month, int day)
: Value(date) : Value(date)
{ {
date_.year = year; date_.year = year;
@ -376,22 +376,22 @@ namespace Exiv2 {
void DateValue::read(const byte* buf, long len, ByteOrder byteOrder) void DateValue::read(const byte* buf, long len, ByteOrder byteOrder)
{ {
// byteOrder not needed // byteOrder not needed
// Hard coded to read Iptc style dates // Hard coded to read Iptc style dates
if (len != 8) throw Error(29); if (len != 8) throw Error(29);
int scanned = sscanf(reinterpret_cast<const char*>(buf), int scanned = sscanf(reinterpret_cast<const char*>(buf),
"%4d%2d%2d", "%4d%2d%2d",
&date_.year, &date_.month, &date_.day); &date_.year, &date_.month, &date_.day);
if (scanned != 3) throw Error(29); if (scanned != 3) throw Error(29);
} }
void DateValue::read(const std::string& buf) void DateValue::read(const std::string& buf)
{ {
// byteOrder not needed // byteOrder not needed
// Hard coded to read Iptc style dates // Hard coded to read Iptc style dates
if (buf.length() < 8) throw Error(29); if (buf.length() < 8) throw Error(29);
int scanned = sscanf(buf.data(), int scanned = sscanf(buf.data(),
"%4d-%d-%d", "%4d-%d-%d",
&date_.year, &date_.month, &date_.day); &date_.year, &date_.month, &date_.day);
if (scanned != 3) throw Error(29); if (scanned != 3) throw Error(29);
} }
@ -402,14 +402,14 @@ namespace Exiv2 {
date_.month = src.month; date_.month = src.month;
date_.day = src.day; date_.day = src.day;
} }
long DateValue::copy(byte* buf, ByteOrder byteOrder) const long DateValue::copy(byte* buf, ByteOrder byteOrder) const
{ {
// byteOrder not needed // byteOrder not needed
// sprintf wants to add the null terminator, so use oversized buffer // sprintf wants to add the null terminator, so use oversized buffer
char temp[9]; char temp[9];
int wrote = sprintf( temp, "%04d%02d%02d", int wrote = sprintf( temp, "%04d%02d%02d",
date_.year, date_.month, date_.day); date_.year, date_.month, date_.day);
assert(wrote == 8); assert(wrote == 8);
memcpy(buf, temp, 8); memcpy(buf, temp, 8);
@ -433,7 +433,7 @@ namespace Exiv2 {
<< std::setw(2) << std::setfill('0') << date_.day; << std::setw(2) << std::setfill('0') << date_.day;
} }
long DateValue::toLong(long n) const long DateValue::toLong(long n) const
{ {
// Range of tm struct is limited to about 1970 to 2038 // Range of tm struct is limited to about 1970 to 2038
// This will return -1 if outside that range // This will return -1 if outside that range
@ -445,8 +445,8 @@ namespace Exiv2 {
return static_cast<long>(std::mktime(&tms)); return static_cast<long>(std::mktime(&tms));
} }
TimeValue::TimeValue(int hour, int minute, TimeValue::TimeValue(int hour, int minute,
int second, int tzHour, int second, int tzHour,
int tzMinute) int tzMinute)
: Value(date) : Value(date)
{ {
@ -467,13 +467,13 @@ namespace Exiv2 {
void TimeValue::read(const byte* buf, long len, ByteOrder byteOrder) void TimeValue::read(const byte* buf, long len, ByteOrder byteOrder)
{ {
// byteOrder not needed // byteOrder not needed
// Hard coded to read Iptc style times // Hard coded to read Iptc style times
if (len != 11) throw Error(30); if (len != 11) throw Error(30);
char plusMinus; char plusMinus;
int scanned = sscanf(reinterpret_cast<const char*>(buf), int scanned = sscanf(reinterpret_cast<const char*>(buf),
"%2d%2d%2d%1c%2d%2d", "%2d%2d%2d%1c%2d%2d",
&time_.hour, &time_.minute, &time_.second, &time_.hour, &time_.minute, &time_.second,
&plusMinus, &time_.tzHour, &time_.tzMinute ); &plusMinus, &time_.tzHour, &time_.tzMinute );
if (scanned != 6) throw Error(30); if (scanned != 6) throw Error(30);
@ -485,13 +485,13 @@ namespace Exiv2 {
void TimeValue::read(const std::string& buf) void TimeValue::read(const std::string& buf)
{ {
// byteOrder not needed // byteOrder not needed
// Hard coded to read Iptc style times // Hard coded to read Iptc style times
if (buf.length() < 9) throw Error(30); if (buf.length() < 9) throw Error(30);
char plusMinus; char plusMinus;
int scanned = sscanf(buf.data(), int scanned = sscanf(buf.data(),
"%d:%d:%d%1c%d:%d", "%d:%d:%d%1c%d:%d",
&time_.hour, &time_.minute, &time_.second, &time_.hour, &time_.minute, &time_.second,
&plusMinus, &time_.tzHour, &time_.tzMinute ); &plusMinus, &time_.tzHour, &time_.tzMinute );
if (scanned != 6) throw Error(30); if (scanned != 6) throw Error(30);
@ -505,7 +505,7 @@ namespace Exiv2 {
{ {
memcpy(&time_, &src, sizeof(time_)); memcpy(&time_, &src, sizeof(time_));
} }
long TimeValue::copy(byte* buf, ByteOrder byteOrder) const long TimeValue::copy(byte* buf, ByteOrder byteOrder) const
{ {
// byteOrder not needed // byteOrder not needed
@ -514,9 +514,9 @@ namespace Exiv2 {
char plusMinus = '+'; char plusMinus = '+';
if (time_.tzHour < 0 || time_.tzMinute < 0) plusMinus = '-'; if (time_.tzHour < 0 || time_.tzMinute < 0) plusMinus = '-';
int wrote = sprintf(temp, int wrote = sprintf(temp,
"%02d%02d%02d%1c%02d%02d", "%02d%02d%02d%1c%02d%02d",
time_.hour, time_.minute, time_.second, time_.hour, time_.minute, time_.second,
plusMinus, abs(time_.tzHour), abs(time_.tzMinute)); plusMinus, abs(time_.tzHour), abs(time_.tzMinute));
assert(wrote == 11); assert(wrote == 11);
@ -538,7 +538,7 @@ namespace Exiv2 {
{ {
char plusMinus = '+'; char plusMinus = '+';
if (time_.tzHour < 0 || time_.tzMinute < 0) plusMinus = '-'; if (time_.tzHour < 0 || time_.tzMinute < 0) plusMinus = '-';
return os << std::right return os << std::right
<< std::setw(2) << std::setfill('0') << time_.hour << ':' << std::setw(2) << std::setfill('0') << time_.hour << ':'
<< std::setw(2) << std::setfill('0') << time_.minute << ':' << std::setw(2) << std::setfill('0') << time_.minute << ':'
@ -547,9 +547,9 @@ namespace Exiv2 {
<< std::setw(2) << std::setfill('0') << abs(time_.tzMinute); << std::setw(2) << std::setfill('0') << abs(time_.tzMinute);
} }
long TimeValue::toLong(long n) const long TimeValue::toLong(long n) const
{ {
// Returns number of seconds in the day in UTC. // Returns number of seconds in the day in UTC.
long result = (time_.hour - time_.tzHour) * 60 * 60; long result = (time_.hour - time_.tzHour) * 60 * 60;
result += (time_.minute - time_.tzMinute) * 60; result += (time_.minute - time_.tzMinute) * 60;
result += time_.second; result += time_.second;

@ -1,19 +1,19 @@
// ***************************************************************** -*- C++ -*- // ***************************************************************** -*- C++ -*-
/* /*
* Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net> * Copyright (C) 2004, 2005 Andreas Huggel <ahuggel@gmx.net>
* *
* This program is part of the Exiv2 distribution. * This program is part of the Exiv2 distribution.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@ -50,7 +50,7 @@ namespace Exiv2 {
// class definitions // class definitions
/*! /*!
@brief Common interface for all types of values used with metadata. @brief Common interface for all types of values used with metadata.
The interface provides a uniform way to access values independent from The interface provides a uniform way to access values independent from
their actual C++ type for simple tasks like reading the values from a their actual C++ type for simple tasks like reading the values from a
@ -66,7 +66,7 @@ namespace Exiv2 {
//! @name Creators //! @name Creators
//@{ //@{
//! Constructor, taking a type id to initialize the base class with //! Constructor, taking a type id to initialize the base class with
explicit Value(TypeId typeId) explicit Value(TypeId typeId)
: type_(typeId) {} : type_(typeId) {}
//! Copy constructor //! Copy constructor
Value(const Value& rhs) Value(const Value& rhs)
@ -81,14 +81,14 @@ namespace Exiv2 {
@brief Read the value from a character buffer. @brief Read the value from a character buffer.
@param buf Pointer to the data buffer to read from @param buf Pointer to the data buffer to read from
@param len Number of bytes in the data buffer @param len Number of bytes in the data buffer
@param byteOrder Applicable byte order (little or big endian). @param byteOrder Applicable byte order (little or big endian).
*/ */
virtual void read(const byte* buf, long len, ByteOrder byteOrder) =0; virtual void read(const byte* buf, long len, ByteOrder byteOrder) =0;
/*! /*!
@brief Set the value from a string buffer. The format of the string @brief Set the value from a string buffer. The format of the string
corresponds to that of the write() method, i.e., a string corresponds to that of the write() method, i.e., a string
obtained through the write() method can be read by this obtained through the write() method can be read by this
function. function.
@param buf The string to read from. @param buf The string to read from.
@ -115,12 +115,12 @@ namespace Exiv2 {
TypeId typeId() const { return type_; } TypeId typeId() const { return type_; }
/*! /*!
@brief Return the value as a string. Implemented in terms of @brief Return the value as a string. Implemented in terms of
write(std::ostream& os) const of the concrete class. write(std::ostream& os) const of the concrete class.
*/ */
std::string toString() const; std::string toString() const;
/*! /*!
@brief Return an auto-pointer to a copy of itself (deep copy). @brief Return an auto-pointer to a copy of itself (deep copy).
The caller owns this copy and the auto-pointer ensures that The caller owns this copy and the auto-pointer ensures that
it will be deleted. it will be deleted.
*/ */
AutoPtr clone() const { return AutoPtr(clone_()); } AutoPtr clone() const { return AutoPtr(clone_()); }
@ -139,10 +139,10 @@ namespace Exiv2 {
virtual long count() const =0; virtual long count() const =0;
//! Return the size of the value in bytes //! Return the size of the value in bytes
virtual long size() const =0; virtual long size() const =0;
/*! /*!
@brief Write the value to an output stream. You do not usually have @brief Write the value to an output stream. You do not usually have
to use this function; it is used for the implementation of to use this function; it is used for the implementation of
the output operator for %Value, the output operator for %Value,
operator<<(std::ostream &os, const Value &value). operator<<(std::ostream &os, const Value &value).
*/ */
virtual std::ostream& write(std::ostream& os) const =0; virtual std::ostream& write(std::ostream& os) const =0;
@ -151,7 +151,7 @@ namespace Exiv2 {
behaviour of this method may be undefined if there is no behaviour of this method may be undefined if there is no
n-th component. n-th component.
@return The converted value. @return The converted value.
*/ */
virtual long toLong(long n =0) const =0; virtual long toLong(long n =0) const =0;
/*! /*!
@ -159,7 +159,7 @@ namespace Exiv2 {
behaviour of this method may be undefined if there is no behaviour of this method may be undefined if there is no
n-th component. n-th component.
@return The converted value. @return The converted value.
*/ */
virtual float toFloat(long n =0) const =0; virtual float toFloat(long n =0) const =0;
/*! /*!
@ -167,7 +167,7 @@ namespace Exiv2 {
behaviour of this method may be undefined if there is no behaviour of this method may be undefined if there is no
n-th component. n-th component.
@return The converted value. @return The converted value.
*/ */
virtual Rational toRational(long n =0) const =0; virtual Rational toRational(long n =0) const =0;
//! Return the size of the data area, 0 if there is none. //! Return the size of the data area, 0 if there is none.
@ -175,7 +175,7 @@ namespace Exiv2 {
/*! /*!
@brief Return a copy of the data area if the value has one. The @brief Return a copy of the data area if the value has one. The
caller owns this copy and DataBuf ensures that it will be caller owns this copy and DataBuf ensures that it will be
deleted. deleted.
Values may have a data area, which can contain additional Values may have a data area, which can contain additional
information besides the actual value. This method is used to access information besides the actual value. This method is used to access
@ -251,7 +251,7 @@ namespace Exiv2 {
//! Constructor //! Constructor
DataValue(const byte* buf, DataValue(const byte* buf,
long len, ByteOrder byteOrder =invalidByteOrder, long len, ByteOrder byteOrder =invalidByteOrder,
TypeId typeId =undefined) TypeId typeId =undefined)
: Value(typeId) { read(buf, len, byteOrder); } : Value(typeId) { read(buf, len, byteOrder); }
//! Virtual destructor. //! Virtual destructor.
virtual ~DataValue() {} virtual ~DataValue() {}
@ -262,17 +262,17 @@ namespace Exiv2 {
//! Assignment operator. //! Assignment operator.
DataValue& operator=(const DataValue& rhs); DataValue& operator=(const DataValue& rhs);
/*! /*!
@brief Read the value from a character buffer. @brief Read the value from a character buffer.
@note The byte order is required by the interface but not @note The byte order is required by the interface but not
used by this method, so just use the default. used by this method, so just use the default.
@param buf Pointer to the data buffer to read from @param buf Pointer to the data buffer to read from
@param len Number of bytes in the data buffer @param len Number of bytes in the data buffer
@param byteOrder Byte order. Not needed. @param byteOrder Byte order. Not needed.
*/ */
virtual void read(const byte* buf, virtual void read(const byte* buf,
long len, long len,
ByteOrder byteOrder =invalidByteOrder); ByteOrder byteOrder =invalidByteOrder);
//! Set the data from a string of integer values (e.g., "0 1 2 3") //! Set the data from a string of integer values (e.g., "0 1 2 3")
virtual void read(const std::string& buf); virtual void read(const std::string& buf);
@ -282,7 +282,7 @@ namespace Exiv2 {
//@{ //@{
AutoPtr clone() const { return AutoPtr(clone_()); } AutoPtr clone() const { return AutoPtr(clone_()); }
/*! /*!
@brief Write value to a character data buffer. @brief Write value to a character data buffer.
@note The byte order is required by the interface but not used by this @note The byte order is required by the interface but not used by this
method, so just use the default. method, so just use the default.
@ -313,9 +313,9 @@ namespace Exiv2 {
}; // class DataValue }; // class DataValue
/*! /*!
@brief Abstract base class for a string based %Value type. @brief Abstract base class for a string based %Value type.
Uses a std::string to store the value and implements defaults for Uses a std::string to store the value and implements defaults for
most operations. most operations.
*/ */
class StringValueBase : public Value { class StringValueBase : public Value {
@ -334,7 +334,7 @@ namespace Exiv2 {
//! Copy constructor //! Copy constructor
StringValueBase(const StringValueBase& rhs) StringValueBase(const StringValueBase& rhs)
: Value(rhs), value_(rhs.value_) {} : Value(rhs), value_(rhs.value_) {}
//! Virtual destructor. //! Virtual destructor.
virtual ~StringValueBase() {} virtual ~StringValueBase() {}
//@} //@}
@ -352,11 +352,11 @@ namespace Exiv2 {
method, so just use the default. method, so just use the default.
@param buf Pointer to the data buffer to read from @param buf Pointer to the data buffer to read from
@param len Number of bytes in the data buffer @param len Number of bytes in the data buffer
@param byteOrder Byte order. Not needed. @param byteOrder Byte order. Not needed.
*/ */
virtual void read(const byte* buf, virtual void read(const byte* buf,
long len, long len,
ByteOrder byteOrder =invalidByteOrder); ByteOrder byteOrder =invalidByteOrder);
//@} //@}
@ -390,7 +390,7 @@ namespace Exiv2 {
//! Internal virtual copy constructor. //! Internal virtual copy constructor.
virtual StringValueBase* clone_() const =0; virtual StringValueBase* clone_() const =0;
// DATA // DATA
std::string value_; //!< Stores the string value. std::string value_; //!< Stores the string value.
}; // class StringValueBase }; // class StringValueBase
@ -409,12 +409,12 @@ namespace Exiv2 {
//! @name Creators //! @name Creators
//@{ //@{
//! Default constructor. //! Default constructor.
StringValue() StringValue()
: StringValueBase(string) {} : StringValueBase(string) {}
//! Constructor //! Constructor
StringValue(const std::string& buf) StringValue(const std::string& buf)
: StringValueBase(string, buf) {} : StringValueBase(string, buf) {}
//! Copy constructor //! Copy constructor
StringValue(const StringValue& rhs) StringValue(const StringValue& rhs)
: StringValueBase(rhs) {} : StringValueBase(rhs) {}
//! Virtual destructor. //! Virtual destructor.
@ -438,9 +438,9 @@ namespace Exiv2 {
}; // class StringValue }; // class StringValue
/*! /*!
@brief %Value for an Ascii string type. @brief %Value for an Ascii string type.
This class is for null terminated single byte Ascii strings. This class is for null terminated single byte Ascii strings.
This class also ensures that the string is null terminated. This class also ensures that the string is null terminated.
*/ */
class AsciiValue : public StringValueBase { class AsciiValue : public StringValueBase {
@ -451,10 +451,10 @@ namespace Exiv2 {
//! @name Creators //! @name Creators
//@{ //@{
//! Default constructor. //! Default constructor.
AsciiValue() AsciiValue()
: StringValueBase(asciiString) {} : StringValueBase(asciiString) {}
//! Constructor //! Constructor
AsciiValue(const std::string &buf) AsciiValue(const std::string &buf)
: StringValueBase(asciiString, buf) {} : StringValueBase(asciiString, buf) {}
//! Copy constructor //! Copy constructor
AsciiValue(const AsciiValue& rhs) AsciiValue(const AsciiValue& rhs)
@ -478,7 +478,7 @@ namespace Exiv2 {
//! @name Accessors //! @name Accessors
//@{ //@{
AutoPtr clone() const { return AutoPtr(clone_()); } AutoPtr clone() const { return AutoPtr(clone_()); }
/*! /*!
@brief Write the value to an output stream. Any trailing '\\0' @brief Write the value to an output stream. Any trailing '\\0'
characters of the ASCII value are stripped and not written to characters of the ASCII value are stripped and not written to
the output stream. the output stream.
@ -508,12 +508,12 @@ namespace Exiv2 {
//! Information pertaining to the defined character sets //! Information pertaining to the defined character sets
struct CharsetTable { struct CharsetTable {
//! Constructor //! Constructor
CharsetTable(CharsetId charsetId, CharsetTable(CharsetId charsetId,
const char* name, const char* name,
const char* code); const char* code);
CharsetId charsetId_; //!< Charset id CharsetId charsetId_; //!< Charset id
const char* name_; //!< Name of the charset const char* name_; //!< Name of the charset
const char* code_; //!< Code of the charset const char* code_; //!< Code of the charset
}; // struct CharsetTable }; // struct CharsetTable
//! Charset information lookup functions. Implemented as a static class. //! Charset information lookup functions. Implemented as a static class.
class CharsetInfo { class CharsetInfo {
@ -523,7 +523,7 @@ namespace Exiv2 {
CharsetInfo(const CharsetInfo&); CharsetInfo(const CharsetInfo&);
//! Prevent assignment: not implemented. //! Prevent assignment: not implemented.
CharsetInfo& operator=(const CharsetInfo&); CharsetInfo& operator=(const CharsetInfo&);
public: public:
//! Return the name for a charset id //! Return the name for a charset id
static const char* name(CharsetId charsetId); static const char* name(CharsetId charsetId);
@ -533,7 +533,7 @@ namespace Exiv2 {
static CharsetId charsetIdByName(const std::string& name); static CharsetId charsetIdByName(const std::string& name);
//! Return the charset id for a code //! Return the charset id for a code
static CharsetId charsetIdByCode(const std::string& code); static CharsetId charsetIdByCode(const std::string& code);
private: private:
static const CharsetTable charsetTable_[]; static const CharsetTable charsetTable_[];
}; // class CharsetInfo }; // class CharsetInfo
@ -548,7 +548,7 @@ namespace Exiv2 {
: StringValueBase(Exiv2::undefined) {} : StringValueBase(Exiv2::undefined) {}
//! Constructor, uses read(const std::string& comment) //! Constructor, uses read(const std::string& comment)
CommentValue(const std::string& comment); CommentValue(const std::string& comment);
//! Copy constructor //! Copy constructor
CommentValue(const CommentValue& rhs) CommentValue(const CommentValue& rhs)
: StringValueBase(rhs) {} : StringValueBase(rhs) {}
//! Virtual destructor. //! Virtual destructor.
@ -561,10 +561,10 @@ namespace Exiv2 {
CommentValue& operator=(const CommentValue& rhs); CommentValue& operator=(const CommentValue& rhs);
/*! /*!
@brief Read the value from a comment @brief Read the value from a comment
The format of \em comment is: The format of \em comment is:
<BR> <BR>
<CODE>[charset=["]Ascii|Jis|Unicode|Undefined["] ]comment</CODE> <CODE>[charset=["]Ascii|Jis|Unicode|Undefined["] ]comment</CODE>
<BR> <BR>
The default charset is Undefined. The default charset is Undefined.
@ -577,7 +577,7 @@ namespace Exiv2 {
//@{ //@{
AutoPtr clone() const { return AutoPtr(clone_()); } AutoPtr clone() const { return AutoPtr(clone_()); }
/*! /*!
@brief Write the comment in a format which can be read by @brief Write the comment in a format which can be read by
read(const std::string& comment). read(const std::string& comment).
*/ */
std::ostream& write(std::ostream& os) const; std::ostream& write(std::ostream& os) const;
@ -593,7 +593,7 @@ namespace Exiv2 {
}; // class CommentValue }; // class CommentValue
/*! /*!
@brief %Value for simple ISO 8601 dates @brief %Value for simple ISO 8601 dates
This class is limited to parsing simple date strings in the ISO 8601 This class is limited to parsing simple date strings in the ISO 8601
@ -615,7 +615,7 @@ namespace Exiv2 {
//@} //@}
//! Simple Date helper structure //! Simple Date helper structure
struct Date struct Date
{ {
int year; //!< Year int year; //!< Year
int month; //!< Month int month; //!< Month
@ -633,16 +633,16 @@ namespace Exiv2 {
method, so just use the default. method, so just use the default.
@param buf Pointer to the data buffer to read from @param buf Pointer to the data buffer to read from
@param len Number of bytes in the data buffer @param len Number of bytes in the data buffer
@param byteOrder Byte order. Not needed. @param byteOrder Byte order. Not needed.
@throw Error in case of an unsupported date format @throw Error in case of an unsupported date format
*/ */
virtual void read(const byte* buf, virtual void read(const byte* buf,
long len, long len,
ByteOrder byteOrder =invalidByteOrder); ByteOrder byteOrder =invalidByteOrder);
/*! /*!
@brief Set the value to that of the string buf. @brief Set the value to that of the string buf.
@param buf String containing the date @param buf String containing the date
@ -674,12 +674,12 @@ namespace Exiv2 {
virtual const Date& getDate() const { return date_; } virtual const Date& getDate() const { return date_; }
virtual long count() const { return size(); } virtual long count() const { return size(); }
virtual long size() const; virtual long size() const;
/*! /*!
@brief Write the value to an output stream. . @brief Write the value to an output stream. .
*/ */
virtual std::ostream& write(std::ostream& os) const; virtual std::ostream& write(std::ostream& os) const;
virtual long toLong(long n =0) const; virtual long toLong(long n =0) const;
virtual float toFloat(long n =0) const virtual float toFloat(long n =0) const
{ return static_cast<float>(toLong(n)); } { return static_cast<float>(toLong(n)); }
virtual Rational toRational(long n =0) const virtual Rational toRational(long n =0) const
{ return Rational(toLong(n), 1); } { return Rational(toLong(n), 1); }
@ -691,7 +691,7 @@ namespace Exiv2 {
// DATA // DATA
Date date_; Date date_;
}; // class DateValue }; // class DateValue
/*! /*!
@brief %Value for simple ISO 8601 times. @brief %Value for simple ISO 8601 times.
@ -711,7 +711,7 @@ namespace Exiv2 {
//! Default constructor. //! Default constructor.
TimeValue() : Value(time) { memset(&time_, 0, sizeof(time_)); } TimeValue() : Value(time) { memset(&time_, 0, sizeof(time_)); }
//! Constructor //! Constructor
TimeValue(int hour, int minute, int second =0, TimeValue(int hour, int minute, int second =0,
int tzHour =0, int tzMinute =0); int tzHour =0, int tzMinute =0);
//! Virtual destructor. //! Virtual destructor.
@ -719,7 +719,7 @@ namespace Exiv2 {
//@} //@}
//! Simple Time helper structure //! Simple Time helper structure
struct Time struct Time
{ {
int hour; //!< Hour int hour; //!< Hour
int minute; //!< Minute int minute; //!< Minute
@ -739,16 +739,16 @@ namespace Exiv2 {
method, so just use the default. method, so just use the default.
@param buf Pointer to the data buffer to read from @param buf Pointer to the data buffer to read from
@param len Number of bytes in the data buffer @param len Number of bytes in the data buffer
@param byteOrder Byte order. Not needed. @param byteOrder Byte order. Not needed.
@throw Error in case of an unsupported time format @throw Error in case of an unsupported time format
*/ */
virtual void read(const byte* buf, virtual void read(const byte* buf,
long len, long len,
ByteOrder byteOrder =invalidByteOrder); ByteOrder byteOrder =invalidByteOrder);
/*! /*!
@brief Set the value to that of the string buf. @brief Set the value to that of the string buf.
@param buf String containing the time. @param buf String containing the time.
@ -780,12 +780,12 @@ namespace Exiv2 {
virtual const Time& getTime() const { return time_; } virtual const Time& getTime() const { return time_; }
virtual long count() const { return size(); } virtual long count() const { return size(); }
virtual long size() const; virtual long size() const;
/*! /*!
@brief Write the value to an output stream. . @brief Write the value to an output stream. .
*/ */
virtual std::ostream& write(std::ostream& os) const; virtual std::ostream& write(std::ostream& os) const;
virtual long toLong(long n =0) const; virtual long toLong(long n =0) const;
virtual float toFloat(long n =0) const virtual float toFloat(long n =0) const
{ return static_cast<float>(toLong(n)); } { return static_cast<float>(toLong(n)); }
virtual Rational toRational(long n =0) const virtual Rational toRational(long n =0) const
{ return Rational(toLong(n), 1); } { return Rational(toLong(n), 1); }
@ -797,7 +797,7 @@ namespace Exiv2 {
// DATA // DATA
Time time_; Time time_;
}; // class TimeValue }; // class TimeValue
//! Template to determine the TypeId for a type T //! Template to determine the TypeId for a type T
template<typename T> TypeId getType(); template<typename T> TypeId getType();
@ -818,9 +818,9 @@ namespace Exiv2 {
// template<typename T> inline TypeId getType() { return invalid; } // template<typename T> inline TypeId getType() { return invalid; }
/*! /*!
@brief Template for a %Value of a basic type. This is used for unsigned @brief Template for a %Value of a basic type. This is used for unsigned
and signed short, long and rationals. and signed short, long and rationals.
*/ */
template<typename T> template<typename T>
class ValueType : public Value { class ValueType : public Value {
public: public:
@ -847,9 +847,9 @@ namespace Exiv2 {
ValueType<T>& operator=(const ValueType<T>& rhs); ValueType<T>& operator=(const ValueType<T>& rhs);
virtual void read(const byte* buf, long len, ByteOrder byteOrder); virtual void read(const byte* buf, long len, ByteOrder byteOrder);
/*! /*!
@brief Set the data from a string of values of type T (e.g., @brief Set the data from a string of values of type T (e.g.,
"0 1 2 3" or "1/2 1/3 1/4" depending on what T is). "0 1 2 3" or "1/2 1/3 1/4" depending on what T is).
Generally, the accepted input format is the same as that Generally, the accepted input format is the same as that
produced by the write() method. produced by the write() method.
*/ */
virtual void read(const std::string& buf); virtual void read(const std::string& buf);
@ -879,7 +879,7 @@ namespace Exiv2 {
virtual DataBuf dataArea() const; virtual DataBuf dataArea() const;
//@} //@}
//! Container for values //! Container for values
typedef std::vector<T> ValueList; typedef std::vector<T> ValueList;
//! Iterator type defined for convenience. //! Iterator type defined for convenience.
typedef typename std::vector<T>::iterator iterator; typedef typename std::vector<T>::iterator iterator;
@ -888,9 +888,9 @@ namespace Exiv2 {
// DATA // DATA
/*! /*!
@brief The container for all values. In your application, if you know @brief The container for all values. In your application, if you know
what subclass of Value you're dealing with (and possibly the T) what subclass of Value you're dealing with (and possibly the T)
then you can access this STL container through the usual then you can access this STL container through the usual
standard library functions. standard library functions.
*/ */
ValueList value_; ValueList value_;
@ -903,7 +903,7 @@ namespace Exiv2 {
//! Pointer to the buffer, 0 if none has been allocated //! Pointer to the buffer, 0 if none has been allocated
byte* pDataArea_; byte* pDataArea_;
//! The current size of the buffer //! The current size of the buffer
long sizeDataArea_; long sizeDataArea_;
}; // class ValueType }; // class ValueType
//! Unsigned short value type //! Unsigned short value type
@ -925,7 +925,7 @@ namespace Exiv2 {
/*! /*!
@brief Read a value of type T from the data buffer. @brief Read a value of type T from the data buffer.
We need this template function for the ValueType template classes. We need this template function for the ValueType template classes.
There are only specializations of this function available; no default There are only specializations of this function available; no default
implementation is provided. implementation is provided.
@ -935,37 +935,37 @@ namespace Exiv2 {
*/ */
template<typename T> T getValue(const byte* buf, ByteOrder byteOrder); template<typename T> T getValue(const byte* buf, ByteOrder byteOrder);
// Specialization for a 2 byte unsigned short value. // Specialization for a 2 byte unsigned short value.
template<> template<>
inline uint16_t getValue(const byte* buf, ByteOrder byteOrder) inline uint16_t getValue(const byte* buf, ByteOrder byteOrder)
{ {
return getUShort(buf, byteOrder); return getUShort(buf, byteOrder);
} }
// Specialization for a 4 byte unsigned long value. // Specialization for a 4 byte unsigned long value.
template<> template<>
inline uint32_t getValue(const byte* buf, ByteOrder byteOrder) inline uint32_t getValue(const byte* buf, ByteOrder byteOrder)
{ {
return getULong(buf, byteOrder); return getULong(buf, byteOrder);
} }
// Specialization for an 8 byte unsigned rational value. // Specialization for an 8 byte unsigned rational value.
template<> template<>
inline URational getValue(const byte* buf, ByteOrder byteOrder) inline URational getValue(const byte* buf, ByteOrder byteOrder)
{ {
return getURational(buf, byteOrder); return getURational(buf, byteOrder);
} }
// Specialization for a 2 byte signed short value. // Specialization for a 2 byte signed short value.
template<> template<>
inline int16_t getValue(const byte* buf, ByteOrder byteOrder) inline int16_t getValue(const byte* buf, ByteOrder byteOrder)
{ {
return getShort(buf, byteOrder); return getShort(buf, byteOrder);
} }
// Specialization for a 4 byte signed long value. // Specialization for a 4 byte signed long value.
template<> template<>
inline int32_t getValue(const byte* buf, ByteOrder byteOrder) inline int32_t getValue(const byte* buf, ByteOrder byteOrder)
{ {
return getLong(buf, byteOrder); return getLong(buf, byteOrder);
} }
// Specialization for an 8 byte signed rational value. // Specialization for an 8 byte signed rational value.
template<> template<>
inline Rational getValue(const byte* buf, ByteOrder byteOrder) inline Rational getValue(const byte* buf, ByteOrder byteOrder)
{ {
return getRational(buf, byteOrder); return getRational(buf, byteOrder);
@ -974,7 +974,7 @@ namespace Exiv2 {
/*! /*!
@brief Convert a value of type T to data, write the data to the data buffer. @brief Convert a value of type T to data, write the data to the data buffer.
We need this template function for the ValueType template classes. We need this template function for the ValueType template classes.
There are only specializations of this function available; no default There are only specializations of this function available; no default
implementation is provided. implementation is provided.
@ -984,20 +984,20 @@ namespace Exiv2 {
@return The number of bytes written to the buffer. @return The number of bytes written to the buffer.
*/ */
template<typename T> long toData(byte* buf, T t, ByteOrder byteOrder); template<typename T> long toData(byte* buf, T t, ByteOrder byteOrder);
/*! /*!
@brief Specialization to write an unsigned short to the data buffer. @brief Specialization to write an unsigned short to the data buffer.
Return the number of bytes written. Return the number of bytes written.
*/ */
template<> template<>
inline long toData(byte* buf, uint16_t t, ByteOrder byteOrder) inline long toData(byte* buf, uint16_t t, ByteOrder byteOrder)
{ {
return us2Data(buf, t, byteOrder); return us2Data(buf, t, byteOrder);
} }
/*! /*!
@brief Specialization to write an unsigned long to the data buffer. @brief Specialization to write an unsigned long to the data buffer.
Return the number of bytes written. Return the number of bytes written.
*/ */
template<> template<>
inline long toData(byte* buf, uint32_t t, ByteOrder byteOrder) inline long toData(byte* buf, uint32_t t, ByteOrder byteOrder)
{ {
return ul2Data(buf, t, byteOrder); return ul2Data(buf, t, byteOrder);
@ -1006,25 +1006,25 @@ namespace Exiv2 {
@brief Specialization to write an unsigned rational to the data buffer. @brief Specialization to write an unsigned rational to the data buffer.
Return the number of bytes written. Return the number of bytes written.
*/ */
template<> template<>
inline long toData(byte* buf, URational t, ByteOrder byteOrder) inline long toData(byte* buf, URational t, ByteOrder byteOrder)
{ {
return ur2Data(buf, t, byteOrder); return ur2Data(buf, t, byteOrder);
} }
/*! /*!
@brief Specialization to write a signed short to the data buffer. @brief Specialization to write a signed short to the data buffer.
Return the number of bytes written. Return the number of bytes written.
*/ */
template<> template<>
inline long toData(byte* buf, int16_t t, ByteOrder byteOrder) inline long toData(byte* buf, int16_t t, ByteOrder byteOrder)
{ {
return s2Data(buf, t, byteOrder); return s2Data(buf, t, byteOrder);
} }
/*! /*!
@brief Specialization to write a signed long to the data buffer. @brief Specialization to write a signed long to the data buffer.
Return the number of bytes written. Return the number of bytes written.
*/ */
template<> template<>
inline long toData(byte* buf, int32_t t, ByteOrder byteOrder) inline long toData(byte* buf, int32_t t, ByteOrder byteOrder)
{ {
return l2Data(buf, t, byteOrder); return l2Data(buf, t, byteOrder);
@ -1033,14 +1033,14 @@ namespace Exiv2 {
@brief Specialization to write a signed rational to the data buffer. @brief Specialization to write a signed rational to the data buffer.
Return the number of bytes written. Return the number of bytes written.
*/ */
template<> template<>
inline long toData(byte* buf, Rational t, ByteOrder byteOrder) inline long toData(byte* buf, Rational t, ByteOrder byteOrder)
{ {
return r2Data(buf, t, byteOrder); return r2Data(buf, t, byteOrder);
} }
template<typename T> template<typename T>
ValueType<T>::ValueType(const byte* buf, long len, ByteOrder byteOrder) ValueType<T>::ValueType(const byte* buf, long len, ByteOrder byteOrder)
: Value(getType<T>()), pDataArea_(0), sizeDataArea_(0) : Value(getType<T>()), pDataArea_(0), sizeDataArea_(0)
{ {
read(buf, len, byteOrder); read(buf, len, byteOrder);
@ -1048,11 +1048,11 @@ namespace Exiv2 {
template<typename T> template<typename T>
ValueType<T>::ValueType(const T& val, ByteOrder byteOrder) ValueType<T>::ValueType(const T& val, ByteOrder byteOrder)
: Value(getType<T>()), pDataArea_(0), sizeDataArea_(0) : Value(getType<T>()), pDataArea_(0), sizeDataArea_(0)
{ {
read(reinterpret_cast<const byte*>(&val), read(reinterpret_cast<const byte*>(&val),
TypeInfo::typeSize(typeId()), TypeInfo::typeSize(typeId()),
byteOrder); byteOrder);
} }
template<typename T> template<typename T>
@ -1061,8 +1061,8 @@ namespace Exiv2 {
{ {
if (rhs.sizeDataArea_ > 0) { if (rhs.sizeDataArea_ > 0) {
pDataArea_ = new byte[rhs.sizeDataArea_]; pDataArea_ = new byte[rhs.sizeDataArea_];
memcpy(pDataArea_, rhs.pDataArea_, rhs.sizeDataArea_); memcpy(pDataArea_, rhs.pDataArea_, rhs.sizeDataArea_);
sizeDataArea_ = rhs.sizeDataArea_; sizeDataArea_ = rhs.sizeDataArea_;
} }
} }
@ -1082,7 +1082,7 @@ namespace Exiv2 {
byte* tmp = 0; byte* tmp = 0;
if (rhs.sizeDataArea_ > 0) { if (rhs.sizeDataArea_ > 0) {
tmp = new byte[rhs.sizeDataArea_]; tmp = new byte[rhs.sizeDataArea_];
memcpy(tmp, rhs.pDataArea_, rhs.sizeDataArea_); memcpy(tmp, rhs.pDataArea_, rhs.sizeDataArea_);
} }
delete[] pDataArea_; delete[] pDataArea_;
pDataArea_ = tmp; pDataArea_ = tmp;
@ -1148,38 +1148,38 @@ namespace Exiv2 {
// Default implementation // Default implementation
template<typename T> template<typename T>
inline long ValueType<T>::toLong(long n) const inline long ValueType<T>::toLong(long n) const
{ {
return value_[n]; return value_[n];
} }
// Specialization for rational // Specialization for rational
template<> template<>
inline long ValueType<Rational>::toLong(long n) const inline long ValueType<Rational>::toLong(long n) const
{ {
return value_[n].first / value_[n].second; return value_[n].first / value_[n].second;
} }
// Specialization for unsigned rational // Specialization for unsigned rational
template<> template<>
inline long ValueType<URational>::toLong(long n) const inline long ValueType<URational>::toLong(long n) const
{ {
return value_[n].first / value_[n].second; return value_[n].first / value_[n].second;
} }
// Default implementation // Default implementation
template<typename T> template<typename T>
inline float ValueType<T>::toFloat(long n) const inline float ValueType<T>::toFloat(long n) const
{ {
return static_cast<float>(value_[n]); return static_cast<float>(value_[n]);
} }
// Specialization for rational // Specialization for rational
template<> template<>
inline float ValueType<Rational>::toFloat(long n) const inline float ValueType<Rational>::toFloat(long n) const
{ {
return static_cast<float>(value_[n].first) / value_[n].second; return static_cast<float>(value_[n].first) / value_[n].second;
} }
// Specialization for unsigned rational // Specialization for unsigned rational
template<> template<>
inline float ValueType<URational>::toFloat(long n) const inline float ValueType<URational>::toFloat(long n) const
{ {
return static_cast<float>(value_[n].first) / value_[n].second; return static_cast<float>(value_[n].first) / value_[n].second;
} }
// Default implementation // Default implementation
template<typename T> template<typename T>
@ -1189,13 +1189,13 @@ namespace Exiv2 {
} }
// Specialization for rational // Specialization for rational
template<> template<>
inline Rational ValueType<Rational>::toRational(long n) const inline Rational ValueType<Rational>::toRational(long n) const
{ {
return Rational(value_[n].first, value_[n].second); return Rational(value_[n].first, value_[n].second);
} }
// Specialization for unsigned rational // Specialization for unsigned rational
template<> template<>
inline Rational ValueType<URational>::toRational(long n) const inline Rational ValueType<URational>::toRational(long n) const
{ {
return Rational(value_[n].first, value_[n].second); return Rational(value_[n].first, value_[n].second);
} }

@ -5,11 +5,11 @@
Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net> Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
Version : $Rev$ Version : $Rev$
Test procedure: Test procedure:
$ rm -f test.jpg thumb.jpg iii ttt; $ rm -f test.jpg thumb.jpg iii ttt;
$ ./exifprint ../test/img_1771.jpg > iii; $ ./exifprint ../test/img_1771.jpg > iii;
$ cp ../test/img_1771.jpg ./test.jpg; $ cp ../test/img_1771.jpg ./test.jpg;
$ ./makernote-test2 ../test/img_1771.jpg > ttt; $ ./makernote-test2 ../test/img_1771.jpg > ttt;
$ diff iii ttt $ diff iii ttt
*/ */
@ -60,8 +60,8 @@ try {
case 1: case 1:
std::cerr << "Case 1: "; std::cerr << "Case 1: ";
std::cerr << "Non-intrusive change to the standard Exif metadata\n"; std::cerr << "Non-intrusive change to the standard Exif metadata\n";
testCase(testFile, "test1.jpg", "thumb1", testCase(testFile, "test1.jpg", "thumb1",
"Exif.Photo.DateTimeOriginal", "Exif.Photo.DateTimeOriginal",
"1999:11:22 00:11:22"); "1999:11:22 00:11:22");
break; break;
case 2: case 2:
@ -75,14 +75,14 @@ try {
std::cerr << "Case 3: "; std::cerr << "Case 3: ";
std::cerr << "Non-intrusive change to the Exif metadata (w/o makernote)\n"; std::cerr << "Non-intrusive change to the Exif metadata (w/o makernote)\n";
testCase(testFile, "test3.jpg", "thumb3", testCase(testFile, "test3.jpg", "thumb3",
"Exif.Photo.DateTimeOriginal", "Exif.Photo.DateTimeOriginal",
"1999:11:22 00:11:22"); "1999:11:22 00:11:22");
break; break;
case 4: case 4:
std::cerr << "Case 4: "; std::cerr << "Case 4: ";
std::cerr << "Intrusive change to the standard Exif metadata\n"; std::cerr << "Intrusive change to the standard Exif metadata\n";
testCase(testFile, "test4.jpg", "thumb4", testCase(testFile, "test4.jpg", "thumb4",
"Exif.Photo.DateTimeOriginal", "Exif.Photo.DateTimeOriginal",
"1999:11:22 00:11:22 and twenty seconds"); "1999:11:22 00:11:22 and twenty seconds");
break; break;
case 5: case 5:
@ -96,7 +96,7 @@ try {
std::cerr << "Case 6: "; std::cerr << "Case 6: ";
std::cerr << "Intrusive change to the Exif metadata (w/o makernote)\n"; std::cerr << "Intrusive change to the Exif metadata (w/o makernote)\n";
testCase(testFile, "test6.jpg", "thumb6", testCase(testFile, "test6.jpg", "thumb6",
"Exif.Photo.DateTimeOriginal", "Exif.Photo.DateTimeOriginal",
"1999:11:22 00:11:22 and twenty seconds"); "1999:11:22 00:11:22 and twenty seconds");
break; break;
case 7: case 7:
@ -207,8 +207,8 @@ void exifPrint(const ExifData& exifData)
std::cout << std::setw(53) << std::setfill(' ') << std::left std::cout << std::setw(53) << std::setfill(' ') << std::left
<< i->key() << " " << i->key() << " "
<< "0x" << std::setw(4) << std::setfill('0') << std::right << "0x" << std::setw(4) << std::setfill('0') << std::right
<< std::hex << i->tag() << " " << std::hex << i->tag() << " "
<< std::dec << i->value() << std::dec << i->value()
<< "\n"; << "\n";
} }
} }

@ -209,15 +209,15 @@ void print(const std::string& file)
std::cout << std::setw(45) << std::setfill(' ') << std::left std::cout << std::setw(45) << std::setfill(' ') << std::left
<< i->key() << " " << i->key() << " "
<< "0x" << std::setw(4) << std::setfill('0') << std::right << "0x" << std::setw(4) << std::setfill('0') << std::right
<< std::hex << i->tag() << " " << std::hex << i->tag() << " "
<< std::setw(12) << std::setfill(' ') << std::left << std::setw(12) << std::setfill(' ') << std::left
<< i->ifdName() << " " << i->ifdName() << " "
<< std::setw(9) << std::setfill(' ') << std::left << std::setw(9) << std::setfill(' ') << std::left
<< i->typeName() << " " << i->typeName() << " "
<< std::dec << std::setw(3) << std::dec << std::setw(3)
<< std::setfill(' ') << std::right << std::setfill(' ') << std::right
<< i->count() << " " << i->count() << " "
<< std::dec << i->value() << std::dec << i->value()
<< "\n"; << "\n";
} }

Loading…
Cancel
Save