Exiv2
properties.hpp
Go to the documentation of this file.
1 // ***************************************************************** -*- C++ -*-
2 /*
3  * Copyright (C) 2004-2018 Exiv2 authors
4  * This program is part of the Exiv2 distribution.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
19  */
31 #ifndef PROPERTIES_HPP_
32 #define PROPERTIES_HPP_
33 
34 // *****************************************************************************
35 #include "exiv2lib_export.h"
36 
37 // included header files
38 #include "datasets.hpp"
39 #include "rwlock.hpp"
40 
41 // *****************************************************************************
42 // namespace extensions
43 namespace Exiv2 {
44 
45 // *****************************************************************************
46 // class declarations
47  class XmpKey;
48 
49 // *****************************************************************************
50 // class definitions
51 
53  enum XmpCategory { xmpInternal, xmpExternal };
54 
56  struct EXIV2API XmpPropertyInfo {
58  bool operator==(const std::string& name) const;
59 
60  const char* name_;
61  const char* title_;
62  const char* xmpValueType_;
65  const char* desc_;
66  };
67 
69  struct EXIV2API XmpNsInfo {
71  struct Prefix {
73  explicit Prefix(const std::string& prefix);
76  };
78  struct Ns {
80  explicit Ns(const std::string& ns);
83  };
85  bool operator==(const Ns& ns) const;
87  bool operator==(const Prefix& prefix) const;
88 
89  const char* ns_;
90  const char* prefix_;
92  const char* desc_;
93  };
94 
96  class EXIV2API XmpProperties {
98  XmpProperties();
100  XmpProperties(const XmpProperties& rhs);
102  XmpProperties& operator=(const XmpProperties& rhs);
103 
104  private:
105  static const XmpNsInfo* nsInfoUnsafe(const std::string& prefix);
106  static void unregisterNsUnsafe(const std::string& ns);
107  static const XmpNsInfo* lookupNsRegistryUnsafe(const XmpNsInfo::Prefix& prefix);
108 
109  public:
116  static const char* propertyTitle(const XmpKey& key);
123  static const char* propertyDesc(const XmpKey& key);
130  static TypeId propertyType(const XmpKey& key);
142  static const XmpPropertyInfo* propertyInfo(const XmpKey& key);
150  static std::string ns(const std::string& prefix);
158  static const char* nsDesc(const std::string& prefix);
166  static const XmpPropertyInfo* propertyList(const std::string& prefix);
174  static const XmpNsInfo* nsInfo(const std::string& prefix);
175 
182  static std::string prefix(const std::string& ns);
184  static void printProperties(std::ostream& os, const std::string& prefix);
185 
187  static std::ostream& printProperty(std::ostream& os,
188  const std::string& key,
189  const Value& value);
198  static void registerNs(const std::string& ns, const std::string& prefix);
207  static void unregisterNs(const std::string& ns);
208 
211 
220  static void unregisterNs();
222  typedef std::map<std::string, XmpNsInfo> NsRegistry;
226  static const XmpNsInfo* lookupNsRegistry(const XmpNsInfo::Prefix& prefix);
227 
228  // DATA
230 
234  static void registeredNamespaces(Exiv2::Dictionary& nsDict);
235 
236  }; // class XmpProperties
237 
241  class EXIV2API XmpKey : public Key
242  {
243  public:
245  typedef std::auto_ptr<XmpKey> AutoPtr;
246 
248 
249 
257  explicit XmpKey(const std::string& key);
267  XmpKey(const std::string& prefix, const std::string& property);
269  XmpKey(const XmpKey& rhs);
271  virtual ~XmpKey();
273 
275 
276  XmpKey& operator=(const XmpKey& rhs);
279 
281 
282  virtual std::string key() const;
283  virtual const char* familyName() const;
288  virtual std::string groupName() const;
289  virtual std::string tagName() const;
290  virtual std::string tagLabel() const;
292  virtual uint16_t tag() const;
293 
294  AutoPtr clone() const;
295 
296  // Todo: Should this be removed? What about tagLabel then?
298  std::string ns() const;
300 
301  private:
303  virtual XmpKey* clone_() const;
304 
305  private:
306  // Pimpl idiom
307  struct Impl;
308  std::auto_ptr<Impl> p_;
309 
310  }; // class XmpKey
311 
312  // *****************************************************************************
313  // free functions
314 
316  EXIV2API std::ostream& operator<<(std::ostream& os, const XmpPropertyInfo& propertyInfo);
317 
318 } // namespace Exiv2
319 
320 #endif // #ifndef PROPERTIES_HPP_
Exiv2::XmpPropertyInfo::operator==
bool operator==(const std::string &name) const
Comparison operator for name.
Exiv2::XmpPropertyInfo::xmpValueType_
const char * xmpValueType_
XMP value type (for info only)
Definition: properties.hpp:62
Exiv2::Key::operator=
Key & operator=(const Key &rhs)
Assignment operator. Protected so that it can only be used by subclasses but not directly.
Definition: metadatum.cpp:49
Exiv2::XmpKey::tagName
virtual std::string tagName() const
Return the name of the tag (which is also the third part of the key)
Exiv2::XmpProperties::propertyType
static TypeId propertyType(const XmpKey &key)
Return the type for property key. The default for unknown keys is xmpText.
Exiv2::XmpKey::groupName
virtual std::string groupName() const
Return the name of the group (the second part of the key). For XMP keys, the group name is the schema...
Exiv2::Internal::print0x0009
std::ostream & print0x0009(std::ostream &os, const Value &value, const ExifData *metadata)
Print GPS status.
Definition: tags_int.cpp:2348
Exiv2::Internal::printXmpVersion
std::ostream & printXmpVersion(std::ostream &os, const Value &value, const ExifData *)
Print any version encoded in the ASCII string majormajorminorminor.
Definition: tags_int.cpp:2849
Exiv2::XmpNsInfo::prefix_
const char * prefix_
(Preferred) prefix
Definition: properties.hpp:90
Exiv2::XmpProperties::propertyTitle
static const char * propertyTitle(const XmpKey &key)
Return the title (label) of the property.
Exiv2::XmpNsInfo::Prefix::prefix_
std::string prefix_
The prefix string.
Definition: properties.hpp:75
Exiv2::Internal::print0x9208
std::ostream & print0x9208(std::ostream &os, const Value &value, const ExifData *metadata)
Print light source.
Definition: tags_int.cpp:2607
Exiv2::XmpPropertyInfo::title_
const char * title_
Property title or label.
Definition: properties.hpp:61
Exiv2::XmpKey::ns
std::string ns() const
Return the schema namespace for the prefix of the key.
Exiv2::Value
Common interface for all types of values used with metadata.
Definition: value.hpp:60
metadatum.hpp
Provides abstract base classes Metadatum and Key.
Exiv2::XmpProperties::nsDesc
static const char * nsDesc(const std::string &prefix)
Return the namespace description for the schema associated with prefix.
Exiv2::XmpKey::XmpKey
XmpKey(const std::string &key)
Constructor to create an XMP key from a key string.
Exiv2::Internal::print0xa40c
std::ostream & print0xa40c(std::ostream &os, const Value &value, const ExifData *metadata)
Print subject distance range.
Definition: tags_int.cpp:2806
Exiv2::Key::AutoPtr
std::auto_ptr< Key > AutoPtr
Shortcut for a Key auto pointer.
Definition: metadatum.hpp:58
types.hpp
Type definitions for Exiv2 and related functionality.
Exiv2::XmpNsInfo::Ns::Ns
Ns(const std::string &ns)
Constructor.
Exiv2::Internal::printNormalSoftHard
std::ostream & printNormalSoftHard(std::ostream &os, const Value &value, const ExifData *metadata)
Print contrast, sharpness (normal, soft, hard)
Definition: tags_int.cpp:2829
Exiv2::Internal::printLong
std::ostream & printLong(std::ostream &os, const Value &value, const ExifData *)
Print the value converted to a long.
Definition: tags_int.cpp:2196
Exiv2::Internal::print0x9202
std::ostream & print0x9202(std::ostream &os, const Value &value, const ExifData *)
Print f-number converted from APEX aperture value.
Definition: tags_int.cpp:2503
Exiv2::XmpProperties::ns
static std::string ns(const std::string &prefix)
Return the namespace name for the schema associated with prefix.
Exiv2::Internal::print0x8822
std::ostream & print0x8822(std::ostream &os, const Value &value, const ExifData *metadata)
Print exposure program.
Definition: tags_int.cpp:2462
Exiv2::XmpKey::tag
virtual uint16_t tag() const
Properties don't have a tag number. Return 0.
Exiv2::XmpNsInfo::Prefix
For comparison with prefix.
Definition: properties.hpp:71
Exiv2::XmpNsInfo::operator==
bool operator==(const Ns &ns) const
Comparison operator for namespace.
EXV_COUNTOF
#define EXV_COUNTOF(a)
Macro to determine the size of an array.
Definition: types.hpp:517
Exiv2::Internal::printFloat
std::ostream & printFloat(std::ostream &os, const Value &value, const ExifData *)
Print a Rational or URational value in floating point format.
Definition: tags_int.cpp:2203
Exiv2::Internal::print0x0019
std::ostream & print0x0019(std::ostream &os, const Value &value, const ExifData *metadata)
Print GPS destination distance ref.
Definition: tags_int.cpp:2363
Exiv2::XmpKey
Concrete keys for XMP metadata.
Definition: properties.hpp:241
Exiv2::XmpNsInfo::Ns::ns_
std::string ns_
The namespace string.
Definition: properties.hpp:82
Exiv2::XmpProperties::registeredNamespaces
static void registeredNamespaces(Exiv2::Dictionary &nsDict)
Get all registered namespaces (for both Exiv2 and XMPsdk)
Exiv2::XmpPropertyInfo::desc_
const char * desc_
Property description.
Definition: properties.hpp:65
Exiv2::XmpNsInfo::ns_
const char * ns_
Namespace.
Definition: properties.hpp:89
Exiv2::Internal::printXmpDate
std::ostream & printXmpDate(std::ostream &os, const Value &value, const ExifData *)
Print a date following the format YYYY-MM-DDTHH:MM:SSZ.
Definition: tags_int.cpp:2858
Exiv2::XmpProperties::nsInfo
static const XmpNsInfo * nsInfo(const std::string &prefix)
Return information about a schema namespace for prefix. Always returns a valid pointer.
Exiv2::Internal::groupName
const char * groupName(IfdId ifdId)
Return the group name for a group id.
Definition: tags_int.cpp:2155
Exiv2::XmpPropertyInfo::xmpCategory_
XmpCategory xmpCategory_
Category (internal or external)
Definition: properties.hpp:64
Exiv2::Internal::print0x001e
std::ostream & print0x001e(std::ostream &os, const Value &value, const ExifData *metadata)
Print GPS differential correction.
Definition: tags_int.cpp:2368
Exiv2::PrintFct
std::ostream &(* PrintFct)(std::ostream &, const Value &, const ExifData *pExifData)
Type for a function pointer for functions interpreting the tag value.
Definition: tags.hpp:57
EXV_PRINT_TAG
#define EXV_PRINT_TAG(array)
Shortcut for the printTag template which requires typing the array name only once.
Definition: tags_int.hpp:241
Exiv2::XmpPropertyInfo
Information about one XMP property.
Definition: properties.hpp:56
Exiv2::invalidTypeId
@ invalidTypeId
Invalid type id.
Definition: types.hpp:157
Exiv2::Key
Abstract base class defining the Key of a metadatum. Keys are used to identify and group metadata.
Definition: metadatum.hpp:55
Exiv2::Internal::printGPSDirRef
std::ostream & printGPSDirRef(std::ostream &os, const Value &value, const ExifData *metadata)
Print GPS direction ref.
Definition: tags_int.cpp:2817
Exiv2::XmpProperties::unregisterNs
static void unregisterNs()
Unregister all custom namespaces.
Exiv2::Internal::print0xa402
std::ostream & print0xa402(std::ostream &os, const Value &value, const ExifData *metadata)
Print exposure mode.
Definition: tags_int.cpp:2711
Exiv2::XmpProperties::printProperties
static void printProperties(std::ostream &os, const std::string &prefix)
Print a list of properties of a schema namespace to output stream os.
Exiv2::Internal::print0xa407
std::ostream & print0xa407(std::ostream &os, const Value &value, const ExifData *metadata)
Print gain control.
Definition: tags_int.cpp:2780
Exiv2::xmpBag
@ xmpBag
XMP bag type.
Definition: types.hpp:154
Exiv2::Internal::print0x0112
std::ostream & print0x0112(std::ostream &os, const Value &value, const ExifData *metadata)
Print orientation.
Definition: tags_int.cpp:2373
Exiv2::XmpPropertyInfo::typeId_
TypeId typeId_
Exiv2 default type for the property.
Definition: properties.hpp:63
Exiv2::Internal::printValue
std::ostream & printValue(std::ostream &os, const Value &value, const ExifData *)
Default print function, using the Value output operator.
Definition: tags_int.cpp:2162
Exiv2::Internal::print0x000c
std::ostream & print0x000c(std::ostream &os, const Value &value, const ExifData *metadata)
Print GPS speed ref.
Definition: tags_int.cpp:2358
Exiv2::find
const T * find(T(&src)[N], const K &key)
Find an element that matches key in the array src.
Definition: types.hpp:508
Exiv2::Internal::print0x000a
std::ostream & print0x000a(std::ostream &os, const Value &value, const ExifData *metadata)
Print GPS measurement mode.
Definition: tags_int.cpp:2353
Exiv2::XmpProperties::propertyDesc
static const char * propertyDesc(const XmpKey &key)
Return the description of the property.
Exiv2::langAlt
@ langAlt
XMP language alternative type.
Definition: types.hpp:156
EXV_PRINT_VOCABULARY
#define EXV_PRINT_VOCABULARY(array)
Shortcut for the printTagVocabulary template which requires typing the array name only once.
Definition: tags_int.hpp:294
Exiv2::Internal::print0x9204
std::ostream & print0x9204(std::ostream &os, const Value &value, const ExifData *)
Print the exposure bias value.
Definition: tags_int.cpp:2518
Exiv2::operator<<
EXIV2API std::ostream & operator<<(std::ostream &os, const DataSet &dataSet)
Output operator for dataSet.
Definition: datasets.cpp:709
properties.hpp
XMP property and type information. References: XMP Specification from Adobe (Property descriptions c...
Exiv2::XmpProperties::NsRegistry
std::map< std::string, XmpNsInfo > NsRegistry
Type for the namespace registry.
Definition: properties.hpp:222
Exiv2
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: asfvideo.hpp:36
value.hpp
Value interface and concrete subclasses.
Exiv2::XmpProperties::propertyInfo
static const XmpPropertyInfo * propertyInfo(const XmpKey &key)
Return information for the property for key.
Exiv2::TypeId
TypeId
Exiv2 value type identifiers.
Definition: types.hpp:130
Exiv2::XmpProperties::propertyList
static const XmpPropertyInfo * propertyList(const std::string &prefix)
Return read-only list of built-in properties for prefix.
Exiv2::XmpNsInfo
Structure mapping XMP namespaces and (preferred) prefixes.
Definition: properties.hpp:69
Exiv2::XmpProperties::registerNs
static void registerNs(const std::string &ns, const std::string &prefix)
Register namespace ns with preferred prefix prefix.
Exiv2::XmpKey::key
virtual std::string key() const
Return the key of the metadatum as a string. The key is of the form 'familyName.groupName....
Exiv2::TypeInfo::typeName
static const char * typeName(TypeId typeId)
Return the name of the type, 0 if unknown.
Definition: types.cpp:107
EXV_WARNING
#define EXV_WARNING
Shorthand for a temp warning log message object and return its ostringstream.
Definition: error.hpp:148
Exiv2::XmpNsInfo::desc_
const char * desc_
Brief description of the namespace.
Definition: properties.hpp:92
Exiv2::RWLock
Class to provide a Read-Write Lock.
Definition: rwlock.hpp:89
Exiv2::Internal::operator==
bool operator==(const TagDetails &td, const LensTypeAndFocalLengthAndMaxAperture &ltfl)
Compare tag details with a lens entry.
Definition: canonmn_int.cpp:1809
Exiv2::XmpNsInfo::Prefix::Prefix
Prefix(const std::string &prefix)
Constructor.
Exiv2::Internal::print0x9201
std::ostream & print0x9201(std::ostream &os, const Value &value, const ExifData *)
Print exposure time converted from APEX shutter speed value.
Definition: tags_int.cpp:2490
Exiv2::XmpProperties::nsRegistry_
static NsRegistry nsRegistry_
Namespace registry.
Definition: properties.hpp:229
Exiv2::Internal::print0xa406
std::ostream & print0xa406(std::ostream &os, const Value &value, const ExifData *metadata)
Print scene capture type.
Definition: tags_int.cpp:2766
Exiv2::Internal::print0x9101
std::ostream & print0x9101(std::ostream &os, const Value &value, const ExifData *)
Print components configuration specific to compressed data.
Definition: tags_int.cpp:2472
Exiv2::XmpPropertyInfo::name_
const char * name_
Property name.
Definition: properties.hpp:60
Exiv2::Internal::print0xa217
std::ostream & print0xa217(std::ostream &os, const Value &value, const ExifData *metadata)
Print sensing method.
Definition: tags_int.cpp:2666
Exiv2::XmpKey::tagLabel
virtual std::string tagLabel() const
Return a label for the tag.
Exiv2::Internal::print0xa401
std::ostream & print0xa401(std::ostream &os, const Value &value, const ExifData *metadata)
Print custom rendered.
Definition: tags_int.cpp:2699
Exiv2::Internal::print0xa409
std::ostream & print0xa409(std::ostream &os, const Value &value, const ExifData *metadata)
Print saturation.
Definition: tags_int.cpp:2792
Exiv2::Internal::print0x0213
std::ostream & print0x0213(std::ostream &os, const Value &value, const ExifData *metadata)
Print YCbCrPositioning.
Definition: tags_int.cpp:2383
Exiv2::XmpKey::familyName
virtual const char * familyName() const
Return an identifier for the type of metadata (the first part of the key)
Exiv2::Internal::print0x829d
std::ostream & print0x829d(std::ostream &os, const Value &value, const ExifData *)
Print the f-number.
Definition: tags_int.cpp:2431
Exiv2::XmpKey::AutoPtr
std::auto_ptr< XmpKey > AutoPtr
Shortcut for an XmpKey auto pointer.
Definition: properties.hpp:245
tags_int.hpp
Internal Exif tag and type information.
Exiv2::XmpNsInfo::Ns
For comparison with namespace.
Definition: properties.hpp:78
Exiv2::Error
BasicError< char > Error
Error class used for exceptions (std::string based)
Definition: error.hpp:324
Exiv2::Internal::print0x0005
std::ostream & print0x0005(std::ostream &os, const Value &value, const ExifData *metadata)
Print GPS altitude ref.
Definition: tags_int.cpp:2292
Exiv2::xmpText
@ xmpText
XMP text type.
Definition: types.hpp:152
Exiv2::XmpProperties::prefix
static std::string prefix(const std::string &ns)
Return the (preferred) prefix for schema namespace ns.
Exiv2::Internal::printExifUnit
std::ostream & printExifUnit(std::ostream &os, const Value &value, const ExifData *metadata)
Print function for Exif units.
Definition: tags_int.cpp:2272
Exiv2::string
@ string
IPTC string type.
Definition: types.hpp:147
Exiv2::Dictionary
std::map< std::string, std::string > Dictionary
typedef for string:string map
Definition: datasets.hpp:364
Exiv2::Internal::print0xa300
std::ostream & print0xa300(std::ostream &os, const Value &value, const ExifData *metadata)
Print file source.
Definition: tags_int.cpp:2678
Exiv2::Internal::print0x9207
std::ostream & print0x9207(std::ostream &os, const Value &value, const ExifData *metadata)
Print metering mode.
Definition: tags_int.cpp:2577
Exiv2::Internal::print0xa403
std::ostream & print0xa403(std::ostream &os, const Value &value, const ExifData *metadata)
Print white balance.
Definition: tags_int.cpp:2722
Exiv2::xmpSeq
@ xmpSeq
XMP sequence type.
Definition: types.hpp:155
Exiv2::Internal::print0x920a
std::ostream & print0x920a(std::ostream &os, const Value &value, const ExifData *)
Print the actual focal length of the lens.
Definition: tags_int.cpp:2612
datasets.hpp
IPTC dataset and type information.
Exiv2::XmpProperties::rwLock_
static Exiv2::RWLock rwLock_
lock to be used while modifying properties
Definition: properties.hpp:210
Exiv2::XmpNsInfo::xmpPropertyInfo_
const XmpPropertyInfo * xmpPropertyInfo_
List of known properties.
Definition: properties.hpp:91
Exiv2::XmpProperties::printProperty
static std::ostream & printProperty(std::ostream &os, const std::string &key, const Value &value)
Interpret and print the value of an XMP property.
Exiv2::Internal::print0xa001
std::ostream & print0xa001(std::ostream &os, const Value &value, const ExifData *metadata)
Print color space.
Definition: tags_int.cpp:2650
Exiv2::XmpProperties
XMP property reference, implemented as a static class.
Definition: properties.hpp:96
Exiv2::XmpKey::operator=
XmpKey & operator=(const XmpKey &rhs)
Assignment operator.
Exiv2::XmpKey::~XmpKey
virtual ~XmpKey()
Virtual destructor.
Exiv2::XmpCategory
XmpCategory
Category of an XMP property.
Definition: properties.hpp:53
Exiv2::Internal::print0xa301
std::ostream & print0xa301(std::ostream &os, const Value &value, const ExifData *metadata)
Print scene type.
Definition: tags_int.cpp:2688
Exiv2::XmpProperties::lookupNsRegistry
static const XmpNsInfo * lookupNsRegistry(const XmpNsInfo::Prefix &prefix)
Get the registered namespace for a specific prefix from the registry.
error.hpp
Error class for exceptions, log message class.