#719: Removed standard Exif tag definitions and pretty-print functions from the API. Fixed warnings in the code for Float and Double values (added for #711).

This commit is contained in:
Andreas Huggel
2010-08-16 13:38:06 +00:00
parent d182528d56
commit 248cfb33c5
16 changed files with 933 additions and 844 deletions
+1
View File
@@ -45,6 +45,7 @@ SET( LIBEXIV2_PRIVATE_HDR canonmn_int.hpp
rw2image_int.hpp
sigmamn_int.hpp
sonymn_int.hpp
tags_int.hpp
tiffcomposite_int.hpp
tifffwd_int.hpp
tiffimage_int.hpp
+1
View File
@@ -33,6 +33,7 @@ EXIV2_RCSID("@(#) $Id$")
// included header files
#include "types.hpp"
#include "canonmn_int.hpp"
#include "tags_int.hpp"
#include "value.hpp"
#include "exif.hpp"
#include "i18n.h" // NLS support.
+1
View File
@@ -47,6 +47,7 @@ EXIV2_RCSID("@(#) $Id$")
#include "futils.hpp"
#include "value.hpp"
#include "tags.hpp"
#include "tags_int.hpp"
#include "canonmn_int.hpp"
#include "i18n.h" // NLS support.
+1
View File
@@ -35,6 +35,7 @@ EXIV2_RCSID("@(#) $Id$")
// included header files
#include "types.hpp"
#include "fujimn_int.hpp"
#include "tags_int.hpp"
#include "value.hpp"
#include "i18n.h" // NLS support.
+1
View File
@@ -34,6 +34,7 @@ EXIV2_RCSID("@(#) $Id$")
// *****************************************************************************
// included header files
#include "minoltamn_int.hpp"
#include "tags_int.hpp"
#include "value.hpp"
#include "i18n.h" // NLS support.
+1 -1
View File
@@ -40,7 +40,7 @@ EXIV2_RCSID("@(#) $Id$")
#include "nikonmn_int.hpp"
#include "value.hpp"
#include "image.hpp"
#include "tags.hpp"
#include "tags_int.hpp"
#include "error.hpp"
#include "i18n.h" // NLS support.
+1 -1
View File
@@ -39,7 +39,7 @@ EXIV2_RCSID("@(#) $Id$")
#include "olympusmn_int.hpp"
#include "value.hpp"
#include "image.hpp"
#include "tags.hpp"
#include "tags_int.hpp"
#include "i18n.h" // NLS support.
// + standard includes
+1
View File
@@ -34,6 +34,7 @@ EXIV2_RCSID("@(#) $Id$")
// included header files
#include "types.hpp"
#include "panasonicmn_int.hpp"
#include "tags_int.hpp"
#include "value.hpp"
#include "i18n.h" // NLS support.
+1
View File
@@ -35,6 +35,7 @@
// *****************************************************************************
// included header files
#include "tags.hpp"
#include "tags_int.hpp"
#include "types.hpp"
// + standard includes
+3 -1
View File
@@ -32,7 +32,7 @@ EXIV2_RCSID("@(#) $Id$")
// *****************************************************************************
// included header files
#include "properties.hpp"
#include "tags.hpp"
#include "tags_int.hpp"
#include "error.hpp"
#include "types.hpp"
#include "value.hpp"
@@ -67,6 +67,8 @@ namespace {
// class member definitions
namespace Exiv2 {
using namespace Internal;
//! @cond IGNORE
extern const XmpPropertyInfo xmpDcInfo[];
extern const XmpPropertyInfo xmpDigikamInfo[];
+1
View File
@@ -35,6 +35,7 @@ EXIV2_RCSID("@(#) $Id$")
// included header files
#include "types.hpp"
#include "sigmamn_int.hpp"
#include "tags_int.hpp"
#include "value.hpp"
#include "i18n.h" // NLS support.
+1
View File
@@ -33,6 +33,7 @@ EXIV2_RCSID("@(#) $Id$")
#include "types.hpp"
#include "minoltamn_int.hpp"
#include "sonymn_int.hpp"
#include "tags_int.hpp"
#include "value.hpp"
#include "i18n.h" // NLS support.
+552 -579
View File
File diff suppressed because it is too large Load Diff
+1 -223
View File
@@ -34,12 +34,10 @@
// included header files
#include "metadatum.hpp"
#include "types.hpp"
#include "value.hpp"
// + standard includes
#include <string>
#include <utility> // for std::pair
#include <iostream>
#include <iosfwd>
#include <memory>
// *****************************************************************************
@@ -120,118 +118,6 @@ namespace Exiv2 {
PrintFct printFct_; //!< Pointer to tag print function
}; // struct TagInfo
/*!
@brief Helper structure for lookup tables for translations of numeric
tag values to human readable labels.
*/
struct EXIV2API TagDetails {
long val_; //!< Tag value
const char* label_; //!< Translation of the tag value
//! Comparison operator for use with the find template
bool operator==(long key) const { return val_ == key; }
}; // struct TagDetails
/*!
@brief Helper structure for lookup tables for translations of bitmask
values to human readable labels.
*/
struct EXIV2API TagDetailsBitmask {
uint32_t mask_; //!< Bitmask value
const char* label_; //!< Description of the tag value
}; // struct TagDetailsBitmask
/*!
@brief Helper structure for lookup tables for translations of controlled
vocabulary strings to their descriptions.
*/
struct EXIV2API TagVocabulary {
const char* voc_; //!< Vocabulary string
const char* label_; //!< Description of the vocabulary string
/*!
@brief Comparison operator for use with the find template
Compare vocabulary strings like "PR-NON" with keys like
"http://ns.useplus.org/ldf/vocab/PR-NON" and return true if the vocabulary
string matches the end of the key.
*/
bool operator==(const std::string& key) const;
}; // struct TagDetails
/*!
@brief Generic pretty-print function to translate a long value to a description
by looking up a reference table.
*/
template <int N, const TagDetails (&array)[N]>
std::ostream& printTag(std::ostream& os, const Value& value, const ExifData*)
{
const TagDetails* td = find(array, value.toLong());
if (td) {
os << exvGettext(td->label_);
}
else {
os << "(" << value << ")";
}
return os;
}
//! Shortcut for the printTag template which requires typing the array name only once.
#define EXV_PRINT_TAG(array) printTag<EXV_COUNTOF(array), array>
/*!
@brief Generic print function to translate a long value to a description
by looking up bitmasks in a reference table.
*/
template <int N, const TagDetailsBitmask (&array)[N]>
std::ostream& printTagBitmask(std::ostream& os, const Value& value, const ExifData*)
{
const uint32_t val = static_cast<uint32_t>(value.toLong());
if (val == 0 && N > 0) {
const TagDetailsBitmask* td = *(&array);
if (td->mask_ == 0) return os << exvGettext(td->label_);
}
bool sep = false;
for (int i = 0; i < N; ++i) {
// *& acrobatics is a workaround for a MSVC 7.1 bug
const TagDetailsBitmask* td = *(&array) + i;
if (val & td->mask_) {
if (sep) {
os << ", " << exvGettext(td->label_);
}
else {
os << exvGettext(td->label_);
sep = true;
}
}
}
return os;
}
//! Shortcut for the printTagBitmask template which requires typing the array name only once.
#define EXV_PRINT_TAG_BITMASK(array) printTagBitmask<EXV_COUNTOF(array), array>
/*!
@brief Generic pretty-print function to translate a controlled vocabulary value (string)
to a description by looking up a reference table.
*/
template <int N, const TagVocabulary (&array)[N]>
std::ostream& printTagVocabulary(std::ostream& os, const Value& value, const ExifData*)
{
const TagVocabulary* td = find(array, value.toString());
if (td) {
os << exvGettext(td->label_);
}
else {
os << "(" << value << ")";
}
return os;
}
//! Shortcut for the printTagVocabulary template which requires typing the array name only once.
#define EXV_PRINT_VOCABULARY(array) printTagVocabulary<EXV_COUNTOF(array), array>
//! Exif tag reference, implemented as a static class.
class EXIV2API ExifTags {
//! Prevent construction: not implemented.
@@ -471,114 +357,6 @@ namespace Exiv2 {
//! Output operator for TagInfo
EXIV2API std::ostream& operator<<(std::ostream& os, const TagInfo& ti);
//! @name Functions printing interpreted tag values
//@{
//! Default print function, using the Value output operator
EXIV2API std::ostream& printValue(std::ostream& os, const Value& value, const ExifData*);
//! Print the value converted to a long
EXIV2API std::ostream& printLong(std::ostream& os, const Value& value, const ExifData*);
//! Print a Rational or URational value in floating point format
EXIV2API std::ostream& printFloat(std::ostream& os, const Value& value, const ExifData*);
//! Print a longitude or latitude value
EXIV2API std::ostream& printDegrees(std::ostream& os, const Value& value, const ExifData*);
//! Print function converting from UCS-2LE to UTF-8
EXIV2API std::ostream& printUcs2(std::ostream& os, const Value& value, const ExifData*);
//! Print function for Exif units
EXIV2API std::ostream& printExifUnit(std::ostream& os, const Value& value, const ExifData*);
//! Print GPS version
EXIV2API std::ostream& print0x0000(std::ostream& os, const Value& value, const ExifData*);
//! Print GPS altitude ref
EXIV2API std::ostream& print0x0005(std::ostream& os, const Value& value, const ExifData*);
//! Print GPS altitude
EXIV2API std::ostream& print0x0006(std::ostream& os, const Value& value, const ExifData*);
//! Print GPS timestamp
EXIV2API std::ostream& print0x0007(std::ostream& os, const Value& value, const ExifData*);
//! Print GPS status
EXIV2API std::ostream& print0x0009(std::ostream& os, const Value& value, const ExifData*);
//! Print GPS measurement mode
EXIV2API std::ostream& print0x000a(std::ostream& os, const Value& value, const ExifData*);
//! Print GPS speed ref
EXIV2API std::ostream& print0x000c(std::ostream& os, const Value& value, const ExifData*);
//! Print GPS destination distance ref
EXIV2API std::ostream& print0x0019(std::ostream& os, const Value& value, const ExifData*);
//! Print GPS differential correction
EXIV2API std::ostream& print0x001e(std::ostream& os, const Value& value, const ExifData*);
//! Print orientation
EXIV2API std::ostream& print0x0112(std::ostream& os, const Value& value, const ExifData*);
//! Print YCbCrPositioning
EXIV2API std::ostream& print0x0213(std::ostream& os, const Value& value, const ExifData*);
//! Print the copyright
EXIV2API std::ostream& print0x8298(std::ostream& os, const Value& value, const ExifData*);
//! Print the exposure time
EXIV2API std::ostream& print0x829a(std::ostream& os, const Value& value, const ExifData*);
//! Print the f-number
EXIV2API std::ostream& print0x829d(std::ostream& os, const Value& value, const ExifData*);
//! Print exposure program
EXIV2API std::ostream& print0x8822(std::ostream& os, const Value& value, const ExifData*);
//! Print ISO speed ratings
EXIV2API std::ostream& print0x8827(std::ostream& os, const Value& value, const ExifData*);
//! Print components configuration specific to compressed data
EXIV2API std::ostream& print0x9101(std::ostream& os, const Value& value, const ExifData*);
//! Print exposure time converted from APEX shutter speed value
EXIV2API std::ostream& print0x9201(std::ostream& os, const Value& value, const ExifData*);
//! Print f-number converted from APEX aperture value
EXIV2API std::ostream& print0x9202(std::ostream& os, const Value& value, const ExifData*);
//! Print the exposure bias value
EXIV2API std::ostream& print0x9204(std::ostream& os, const Value& value, const ExifData*);
//! Print the subject distance
EXIV2API std::ostream& print0x9206(std::ostream& os, const Value& value, const ExifData*);
//! Print metering mode
EXIV2API std::ostream& print0x9207(std::ostream& os, const Value& value, const ExifData*);
//! Print light source
EXIV2API std::ostream& print0x9208(std::ostream& os, const Value& value, const ExifData*);
//! Print the actual focal length of the lens
EXIV2API std::ostream& print0x920a(std::ostream& os, const Value& value, const ExifData*);
//! Print the user comment
EXIV2API std::ostream& print0x9286(std::ostream& os, const Value& value, const ExifData*);
//! Print color space
EXIV2API std::ostream& print0xa001(std::ostream& os, const Value& value, const ExifData*);
//! Print sensing method
EXIV2API std::ostream& print0xa217(std::ostream& os, const Value& value, const ExifData*);
//! Print file source
EXIV2API std::ostream& print0xa300(std::ostream& os, const Value& value, const ExifData*);
//! Print scene type
EXIV2API std::ostream& print0xa301(std::ostream& os, const Value& value, const ExifData*);
//! Print custom rendered
EXIV2API std::ostream& print0xa401(std::ostream& os, const Value& value, const ExifData*);
//! Print exposure mode
EXIV2API std::ostream& print0xa402(std::ostream& os, const Value& value, const ExifData*);
//! Print white balance
EXIV2API std::ostream& print0xa403(std::ostream& os, const Value& value, const ExifData*);
//! Print digital zoom ratio
EXIV2API std::ostream& print0xa404(std::ostream& os, const Value& value, const ExifData*);
//! Print 35mm equivalent focal length
EXIV2API std::ostream& print0xa405(std::ostream& os, const Value& value, const ExifData*);
//! Print scene capture type
EXIV2API std::ostream& print0xa406(std::ostream& os, const Value& value, const ExifData*);
//! Print gain control
EXIV2API std::ostream& print0xa407(std::ostream& os, const Value& value, const ExifData*);
//! Print saturation
EXIV2API std::ostream& print0xa409(std::ostream& os, const Value& value, const ExifData*);
//! Print subject distance range
EXIV2API std::ostream& print0xa40c(std::ostream& os, const Value& value, const ExifData*);
//! Print GPS direction ref
EXIV2API std::ostream& printGPSDirRef(std::ostream& os, const Value& value, const ExifData*);
//! Print contrast, sharpness (normal, soft, hard)
EXIV2API std::ostream& printNormalSoftHard(std::ostream& os, const Value& value, const ExifData*);
//! Print any version packed in 4 Bytes format : major major minor minor
EXIV2API std::ostream& printExifVersion(std::ostream& os, const Value& value, const ExifData*);
//! Print any version encoded in the ASCII string majormajorminorminor
EXIV2API std::ostream& printXmpVersion(std::ostream& os, const Value& value, const ExifData*);
//! Print a date following the format YYYY-MM-DDTHH:MM:SSZ
EXIV2API std::ostream& printXmpDate(std::ostream& os, const Value& value, const ExifData*);
//@}
//! Calculate F number from an APEX aperture value
EXIV2API float fnumber(float apertureValue);
//! Calculate the exposure time from an APEX shutter speed value
EXIV2API URational exposureTime(float shutterSpeedValue);
} // namespace Exiv2
#endif // #ifndef TAGS_HPP_
+278
View File
@@ -0,0 +1,278 @@
// ***************************************************************** -*- C++ -*-
/*
* Copyright (C) 2004-2010 Andreas Huggel <ahuggel@gmx.net>
*
* This program is part of the Exiv2 distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
*/
/*!
@file tags_int.hpp
@brief Internal Exif tag and type information
@version $Rev$
@author Andreas Huggel (ahu)
<a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a>
@date 15-Jan-04, ahu: created<BR>
11-Feb-04, ahu: isolated as a component
*/
#ifndef TAGS_INT_HPP_
#define TAGS_INT_HPP_
// *****************************************************************************
// included header files
#include "types.hpp"
#include "value.hpp"
// + standard includes
#include <string>
#include <iostream>
#include <memory>
// *****************************************************************************
// namespace extensions
namespace Exiv2 {
class ExifData;
namespace Internal {
// *****************************************************************************
// class definitions
/*!
@brief Helper structure for lookup tables for translations of numeric
tag values to human readable labels.
*/
struct TagDetails {
long val_; //!< Tag value
const char* label_; //!< Translation of the tag value
//! Comparison operator for use with the find template
bool operator==(long key) const { return val_ == key; }
}; // struct TagDetails
/*!
@brief Helper structure for lookup tables for translations of bitmask
values to human readable labels.
*/
struct TagDetailsBitmask {
uint32_t mask_; //!< Bitmask value
const char* label_; //!< Description of the tag value
}; // struct TagDetailsBitmask
/*!
@brief Helper structure for lookup tables for translations of controlled
vocabulary strings to their descriptions.
*/
struct TagVocabulary {
const char* voc_; //!< Vocabulary string
const char* label_; //!< Description of the vocabulary string
/*!
@brief Comparison operator for use with the find template
Compare vocabulary strings like "PR-NON" with keys like
"http://ns.useplus.org/ldf/vocab/PR-NON" and return true if the vocabulary
string matches the end of the key.
*/
bool operator==(const std::string& key) const;
}; // struct TagDetails
/*!
@brief Generic pretty-print function to translate a long value to a description
by looking up a reference table.
*/
template <int N, const TagDetails (&array)[N]>
std::ostream& printTag(std::ostream& os, const Value& value, const ExifData*)
{
const TagDetails* td = find(array, value.toLong());
if (td) {
os << exvGettext(td->label_);
}
else {
os << "(" << value << ")";
}
return os;
}
//! Shortcut for the printTag template which requires typing the array name only once.
#define EXV_PRINT_TAG(array) printTag<EXV_COUNTOF(array), array>
/*!
@brief Generic print function to translate a long value to a description
by looking up bitmasks in a reference table.
*/
template <int N, const TagDetailsBitmask (&array)[N]>
std::ostream& printTagBitmask(std::ostream& os, const Value& value, const ExifData*)
{
const uint32_t val = static_cast<uint32_t>(value.toLong());
if (val == 0 && N > 0) {
const TagDetailsBitmask* td = *(&array);
if (td->mask_ == 0) return os << exvGettext(td->label_);
}
bool sep = false;
for (int i = 0; i < N; ++i) {
// *& acrobatics is a workaround for a MSVC 7.1 bug
const TagDetailsBitmask* td = *(&array) + i;
if (val & td->mask_) {
if (sep) {
os << ", " << exvGettext(td->label_);
}
else {
os << exvGettext(td->label_);
sep = true;
}
}
}
return os;
}
//! Shortcut for the printTagBitmask template which requires typing the array name only once.
#define EXV_PRINT_TAG_BITMASK(array) printTagBitmask<EXV_COUNTOF(array), array>
/*!
@brief Generic pretty-print function to translate a controlled vocabulary value (string)
to a description by looking up a reference table.
*/
template <int N, const TagVocabulary (&array)[N]>
std::ostream& printTagVocabulary(std::ostream& os, const Value& value, const ExifData*)
{
const TagVocabulary* td = find(array, value.toString());
if (td) {
os << exvGettext(td->label_);
}
else {
os << "(" << value << ")";
}
return os;
}
//! Shortcut for the printTagVocabulary template which requires typing the array name only once.
#define EXV_PRINT_VOCABULARY(array) printTagVocabulary<EXV_COUNTOF(array), array>
// *****************************************************************************
// free functions
//! @name Functions printing interpreted tag values
//@{
//! Default print function, using the Value output operator
std::ostream& printValue(std::ostream& os, const Value& value, const ExifData*);
//! Print the value converted to a long
std::ostream& printLong(std::ostream& os, const Value& value, const ExifData*);
//! Print a Rational or URational value in floating point format
std::ostream& printFloat(std::ostream& os, const Value& value, const ExifData*);
//! Print a longitude or latitude value
std::ostream& printDegrees(std::ostream& os, const Value& value, const ExifData*);
//! Print function converting from UCS-2LE to UTF-8
std::ostream& printUcs2(std::ostream& os, const Value& value, const ExifData*);
//! Print function for Exif units
std::ostream& printExifUnit(std::ostream& os, const Value& value, const ExifData*);
//! Print GPS version
std::ostream& print0x0000(std::ostream& os, const Value& value, const ExifData*);
//! Print GPS altitude ref
std::ostream& print0x0005(std::ostream& os, const Value& value, const ExifData*);
//! Print GPS altitude
std::ostream& print0x0006(std::ostream& os, const Value& value, const ExifData*);
//! Print GPS timestamp
std::ostream& print0x0007(std::ostream& os, const Value& value, const ExifData*);
//! Print GPS status
std::ostream& print0x0009(std::ostream& os, const Value& value, const ExifData*);
//! Print GPS measurement mode
std::ostream& print0x000a(std::ostream& os, const Value& value, const ExifData*);
//! Print GPS speed ref
std::ostream& print0x000c(std::ostream& os, const Value& value, const ExifData*);
//! Print GPS destination distance ref
std::ostream& print0x0019(std::ostream& os, const Value& value, const ExifData*);
//! Print GPS differential correction
std::ostream& print0x001e(std::ostream& os, const Value& value, const ExifData*);
//! Print orientation
std::ostream& print0x0112(std::ostream& os, const Value& value, const ExifData*);
//! Print YCbCrPositioning
std::ostream& print0x0213(std::ostream& os, const Value& value, const ExifData*);
//! Print the copyright
std::ostream& print0x8298(std::ostream& os, const Value& value, const ExifData*);
//! Print the exposure time
std::ostream& print0x829a(std::ostream& os, const Value& value, const ExifData*);
//! Print the f-number
std::ostream& print0x829d(std::ostream& os, const Value& value, const ExifData*);
//! Print exposure program
std::ostream& print0x8822(std::ostream& os, const Value& value, const ExifData*);
//! Print ISO speed ratings
std::ostream& print0x8827(std::ostream& os, const Value& value, const ExifData*);
//! Print components configuration specific to compressed data
std::ostream& print0x9101(std::ostream& os, const Value& value, const ExifData*);
//! Print exposure time converted from APEX shutter speed value
std::ostream& print0x9201(std::ostream& os, const Value& value, const ExifData*);
//! Print f-number converted from APEX aperture value
std::ostream& print0x9202(std::ostream& os, const Value& value, const ExifData*);
//! Print the exposure bias value
std::ostream& print0x9204(std::ostream& os, const Value& value, const ExifData*);
//! Print the subject distance
std::ostream& print0x9206(std::ostream& os, const Value& value, const ExifData*);
//! Print metering mode
std::ostream& print0x9207(std::ostream& os, const Value& value, const ExifData*);
//! Print light source
std::ostream& print0x9208(std::ostream& os, const Value& value, const ExifData*);
//! Print the actual focal length of the lens
std::ostream& print0x920a(std::ostream& os, const Value& value, const ExifData*);
//! Print the user comment
std::ostream& print0x9286(std::ostream& os, const Value& value, const ExifData*);
//! Print color space
std::ostream& print0xa001(std::ostream& os, const Value& value, const ExifData*);
//! Print sensing method
std::ostream& print0xa217(std::ostream& os, const Value& value, const ExifData*);
//! Print file source
std::ostream& print0xa300(std::ostream& os, const Value& value, const ExifData*);
//! Print scene type
std::ostream& print0xa301(std::ostream& os, const Value& value, const ExifData*);
//! Print custom rendered
std::ostream& print0xa401(std::ostream& os, const Value& value, const ExifData*);
//! Print exposure mode
std::ostream& print0xa402(std::ostream& os, const Value& value, const ExifData*);
//! Print white balance
std::ostream& print0xa403(std::ostream& os, const Value& value, const ExifData*);
//! Print digital zoom ratio
std::ostream& print0xa404(std::ostream& os, const Value& value, const ExifData*);
//! Print 35mm equivalent focal length
std::ostream& print0xa405(std::ostream& os, const Value& value, const ExifData*);
//! Print scene capture type
std::ostream& print0xa406(std::ostream& os, const Value& value, const ExifData*);
//! Print gain control
std::ostream& print0xa407(std::ostream& os, const Value& value, const ExifData*);
//! Print saturation
std::ostream& print0xa409(std::ostream& os, const Value& value, const ExifData*);
//! Print subject distance range
std::ostream& print0xa40c(std::ostream& os, const Value& value, const ExifData*);
//! Print GPS direction ref
std::ostream& printGPSDirRef(std::ostream& os, const Value& value, const ExifData*);
//! Print contrast, sharpness (normal, soft, hard)
std::ostream& printNormalSoftHard(std::ostream& os, const Value& value, const ExifData*);
//! Print any version packed in 4 Bytes format : major major minor minor
std::ostream& printExifVersion(std::ostream& os, const Value& value, const ExifData*);
//! Print any version encoded in the ASCII string majormajorminorminor
std::ostream& printXmpVersion(std::ostream& os, const Value& value, const ExifData*);
//! Print a date following the format YYYY-MM-DDTHH:MM:SSZ
std::ostream& printXmpDate(std::ostream& os, const Value& value, const ExifData*);
//@}
//! Calculate F number from an APEX aperture value
float fnumber(float apertureValue);
//! Calculate the exposure time from an APEX shutter speed value
URational exposureTime(float shutterSpeedValue);
}} // namespace Internal, Exiv2
#endif // #ifndef TAGS_INT_HPP_
+88 -39
View File
@@ -177,6 +177,38 @@ namespace Exiv2 {
// *************************************************************************
// free functions
std::ostream& operator<<(std::ostream& os, const Rational& r)
{
return os << r.first << "/" << r.second;
}
std::istream& operator>>(std::istream& is, Rational& r)
{
int32_t nominator;
int32_t denominator;
char c('\0');
is >> nominator >> c >> denominator;
if (c != '/') is.setstate(std::ios::failbit);
if (is) r = std::make_pair(nominator, denominator);
return is;
}
std::ostream& operator<<(std::ostream& os, const URational& r)
{
return os << r.first << "/" << r.second;
}
std::istream& operator>>(std::istream& is, URational& r)
{
uint32_t nominator;
uint32_t denominator;
char c('\0');
is >> nominator >> c >> denominator;
if (c != '/') is.setstate(std::ios::failbit);
if (is) r = std::make_pair(nominator, denominator);
return is;
}
uint16_t getUShort(const byte* buf, ByteOrder byteOrder)
{
if (byteOrder == littleEndian) {
@@ -241,8 +273,12 @@ namespace Exiv2 {
// type is the 4-byte IEEE 754 binary32 format, which is common but not
// required by the C++ standard.
assert(sizeof(float) == 4);
uint32_t ul = getULong(buf, byteOrder);
return *reinterpret_cast<float*>(&ul);
union {
uint32_t ul_;
float f_;
} u;
u.ul_ = getULong(buf, byteOrder);
return u.f_;
}
double getDouble(const byte* buf, ByteOrder byteOrder)
@@ -251,28 +287,32 @@ namespace Exiv2 {
// type is the 8-byte IEEE 754 binary64 format, which is common but not
// required by the C++ standard.
assert(sizeof(double) == 8);
uint64_t ull = 0;
union {
uint64_t ull_;
double d_;
} u;
u.ull_ = 0;
if (byteOrder == littleEndian) {
ull = static_cast<uint64_t>(buf[7]) << 56
| static_cast<uint64_t>(buf[6]) << 48
| static_cast<uint64_t>(buf[5]) << 40
| static_cast<uint64_t>(buf[4]) << 32
| static_cast<uint64_t>(buf[3]) << 24
| static_cast<uint64_t>(buf[2]) << 16
| static_cast<uint64_t>(buf[1]) << 8
| static_cast<uint64_t>(buf[0]);
u.ull_ = static_cast<uint64_t>(buf[7]) << 56
| static_cast<uint64_t>(buf[6]) << 48
| static_cast<uint64_t>(buf[5]) << 40
| static_cast<uint64_t>(buf[4]) << 32
| static_cast<uint64_t>(buf[3]) << 24
| static_cast<uint64_t>(buf[2]) << 16
| static_cast<uint64_t>(buf[1]) << 8
| static_cast<uint64_t>(buf[0]);
}
else {
ull = static_cast<uint64_t>(buf[0]) << 56
| static_cast<uint64_t>(buf[1]) << 48
| static_cast<uint64_t>(buf[2]) << 40
| static_cast<uint64_t>(buf[3]) << 32
| static_cast<uint64_t>(buf[4]) << 24
| static_cast<uint64_t>(buf[5]) << 16
| static_cast<uint64_t>(buf[6]) << 8
| static_cast<uint64_t>(buf[7]);
u.ull_ = static_cast<uint64_t>(buf[0]) << 56
| static_cast<uint64_t>(buf[1]) << 48
| static_cast<uint64_t>(buf[2]) << 40
| static_cast<uint64_t>(buf[3]) << 32
| static_cast<uint64_t>(buf[4]) << 24
| static_cast<uint64_t>(buf[5]) << 16
| static_cast<uint64_t>(buf[6]) << 8
| static_cast<uint64_t>(buf[7]);
}
return *reinterpret_cast<double*>(&ull);
return u.d_;
}
long us2Data(byte* buf, uint16_t s, ByteOrder byteOrder)
@@ -355,8 +395,12 @@ namespace Exiv2 {
// type is the 4-byte IEEE 754 binary32 format, which is common but not
// required by the C++ standard.
assert(sizeof(float) == 4);
uint32_t ul = *reinterpret_cast<uint32_t*>(&f);
return ul2Data(buf, ul, byteOrder);
union {
uint32_t ul_;
float f_;
} u;
u.f_ = f;
return ul2Data(buf, u.ul_, byteOrder);
}
long d2Data(byte* buf, double d, ByteOrder byteOrder)
@@ -365,26 +409,31 @@ namespace Exiv2 {
// type is the 8-byte IEEE 754 binary64 format, which is common but not
// required by the C++ standard.
assert(sizeof(double) == 8);
uint64_t ull = *reinterpret_cast<uint64_t*>(&d);
union {
uint64_t ull_;
double d_;
} u;
u.d_ = d;
uint64_t m = 0xff;
if (byteOrder == littleEndian) {
buf[0] = (byte)(ull & 0x00000000000000ff);
buf[1] = (byte)((ull & 0x000000000000ff00) >> 8);
buf[2] = (byte)((ull & 0x0000000000ff0000) >> 16);
buf[3] = (byte)((ull & 0x00000000ff000000) >> 24);
buf[4] = (byte)((ull & 0x000000ff00000000) >> 32);
buf[5] = (byte)((ull & 0x0000ff0000000000) >> 40);
buf[6] = (byte)((ull & 0x00ff000000000000) >> 48);
buf[7] = (byte)((ull & 0xff00000000000000) >> 56);
buf[0] = (byte)(u.ull_ & m);
buf[1] = (byte)((u.ull_ & (m << 8)) >> 8);
buf[2] = (byte)((u.ull_ & (m << 16)) >> 16);
buf[3] = (byte)((u.ull_ & (m << 24)) >> 24);
buf[4] = (byte)((u.ull_ & (m << 32)) >> 32);
buf[5] = (byte)((u.ull_ & (m << 40)) >> 40);
buf[6] = (byte)((u.ull_ & (m << 48)) >> 48);
buf[7] = (byte)((u.ull_ & (m << 56)) >> 56);
}
else {
buf[0] = (byte)((ull & 0xff00000000000000) >> 56);
buf[1] = (byte)((ull & 0x00ff000000000000) >> 48);
buf[2] = (byte)((ull & 0x0000ff0000000000) >> 40);
buf[3] = (byte)((ull & 0x000000ff00000000) >> 32);
buf[4] = (byte)((ull & 0x00000000ff000000) >> 24);
buf[5] = (byte)((ull & 0x0000000000ff0000) >> 16);
buf[6] = (byte)((ull & 0x000000000000ff00) >> 8);
buf[7] = (byte)(ull & 0x00000000000000ff);
buf[0] = (byte)((u.ull_ & (m << 56)) >> 56);
buf[1] = (byte)((u.ull_ & (m << 48)) >> 48);
buf[2] = (byte)((u.ull_ & (m << 40)) >> 40);
buf[3] = (byte)((u.ull_ & (m << 32)) >> 32);
buf[4] = (byte)((u.ull_ & (m << 24)) >> 24);
buf[5] = (byte)((u.ull_ & (m << 16)) >> 16);
buf[6] = (byte)((u.ull_ & (m << 8)) >> 8);
buf[7] = (byte)(u.ull_ & m);
}
return 8;
}