From 516bc731530def8d6763ec79b87e80c3164e0916 Mon Sep 17 00:00:00 2001 From: Andreas Huggel Date: Sat, 6 May 2006 17:31:28 +0000 Subject: [PATCH] Added generic printTag template function (and the COUNTOF macro) and the first two Minolta lookup tables and print functions which make use of it. --- src/minoltamn.cpp | 23 +++++++++++++++++++++-- src/tags.hpp | 23 ++++++++++++++++++++++- src/types.hpp | 5 +++++ 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/minoltamn.cpp b/src/minoltamn.cpp index bbfa4252..e1222854 100644 --- a/src/minoltamn.cpp +++ b/src/minoltamn.cpp @@ -37,6 +37,7 @@ EXIV2_RCSID("@(#) $Id$"); #include "minoltamn.hpp" #include "makernote.hpp" #include "value.hpp" +#include "tags.hpp" // + standard includes #include @@ -48,6 +49,24 @@ EXIV2_RCSID("@(#) $Id$"); // class member definitions namespace Exiv2 { + //! Lookup table to translate Minolta color mode values to readable labels + extern const TagDetails minoltaColorMode[] = { + { 0, "Natural Color" }, + { 1, "Black & White" }, + { 2, "Vivid Color" }, + { 3, "Solarization" }, + { 4, "AdobeRGB" } + }; + + //! Lookup table to translate Minolta image quality values to readable labels + extern const TagDetails minoltaImageQuality[] = { + { 0, "Raw" }, + { 1, "Superfine" }, + { 2, "Fine" }, + { 3, "Standard" }, + { 5, "Extrafine" } + }; + //! @cond IGNORE MinoltaMakerNote::RegisterMn::RegisterMn() { @@ -69,8 +88,8 @@ namespace Exiv2 { TagInfo(0x0081, "Thumbnail", "Thumbnail", "Jpeg thumbnail 640x480 pixels", minoltaIfdId, makerTags, undefined, printValue), TagInfo(0x0088, "ThumbnailOffset", "Thumbnail Offset", "Offset of the thumbnail", minoltaIfdId, makerTags, unsignedLong, printValue), TagInfo(0x0089, "ThumbnailLength", "Thumbnail Length", "Size of the thumbnail", minoltaIfdId, makerTags, unsignedLong, printValue), - TagInfo(0x0101, "ColorMode", "Color Mode", "Color mode", minoltaIfdId, makerTags, unsignedLong, printValue), - TagInfo(0x0102, "ImageQuality", "Image Quality", "Image quality", minoltaIfdId, makerTags, unsignedLong, printValue), + TagInfo(0x0101, "ColorMode", "Color Mode", "Color mode", minoltaIfdId, makerTags, unsignedLong, printTag), + TagInfo(0x0102, "ImageQuality", "Image Quality", "Image quality", minoltaIfdId, makerTags, unsignedLong, printTag), TagInfo(0x0e00, "PIM_IFD", "PIM IFD", "PIM information", minoltaIfdId, makerTags, undefined, printValue), // End of list marker TagInfo(0xffff, "(UnknownMinoltaMakerNoteTag)", "(UnknownMinoltaMakerNoteTag)", "Unknown MinoltaMakerNote tag", minoltaIfdId, makerTags, invalidTypeId, printValue) diff --git a/src/tags.hpp b/src/tags.hpp index fbb5d0f3..30e94828 100644 --- a/src/tags.hpp +++ b/src/tags.hpp @@ -34,11 +34,12 @@ // included header files #include "metadatum.hpp" #include "types.hpp" +#include "value.hpp" // + standard includes #include #include // for std::pair -#include +#include #include // ***************************************************************************** @@ -118,8 +119,28 @@ namespace Exiv2 { struct TagDetails { long val_; //!< Tag value 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 Generic print function to translate a long value to a description + by looking up a reference table. + */ + template + std::ostream& printTag(std::ostream& os, const Value& value) + { + const TagDetails* td = find(array, value.toLong()); + if (td) { + os << td->label_; + } + else { + os << "(" << value << ")"; + } + return os; + } + /*! @brief Translation from numeric values from a lookup list to human readable labels diff --git a/src/types.hpp b/src/types.hpp index 836b80ca..289d7ab3 100644 --- a/src/types.hpp +++ b/src/types.hpp @@ -352,6 +352,11 @@ namespace Exiv2 { return rc == src + N ? 0 : rc; } + //! Template used in the COUNTOF macro to determine the size of an array + template char (&sizer(T (&)[N]))[N]; +//! Macro to determine the size of an array +#define COUNTOF(a) (sizeof(sizer(a))) + //! Utility function to convert the argument of any type to a string template std::string toString(const T& arg)