Added generic printTag template function (and the COUNTOF macro) and the first two Minolta lookup tables and print functions which make use of it.

This commit is contained in:
Andreas Huggel 2006-05-06 17:31:28 +00:00
parent 59187208cd
commit 516bc73153
3 changed files with 48 additions and 3 deletions

View File

@ -37,6 +37,7 @@ EXIV2_RCSID("@(#) $Id$");
#include "minoltamn.hpp"
#include "makernote.hpp"
#include "value.hpp"
#include "tags.hpp"
// + standard includes
#include <string>
@ -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<COUNTOF(minoltaColorMode), minoltaColorMode>),
TagInfo(0x0102, "ImageQuality", "Image Quality", "Image quality", minoltaIfdId, makerTags, unsignedLong, printTag<COUNTOF(minoltaImageQuality), minoltaImageQuality>),
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)

View File

@ -34,11 +34,12 @@
// included header files
#include "metadatum.hpp"
#include "types.hpp"
#include "value.hpp"
// + standard includes
#include <string>
#include <utility> // for std::pair
#include <iosfwd>
#include <iostream>
#include <memory>
// *****************************************************************************
@ -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 <int N, const TagDetails (&array)[N]>
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

View File

@ -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 <typename T, int N> 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<typename T>
std::string toString(const T& arg)