Exiv2
metadatum.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 METADATUM_HPP_
32 #define METADATUM_HPP_
33 
34 // *****************************************************************************
35 #include "exiv2lib_export.h"
36 
37 // included header files
38 #include "value.hpp"
39 
40 // *****************************************************************************
41 // namespace extensions
42 namespace Exiv2 {
43 
44 // *****************************************************************************
45 // class declarations
46  class ExifData;
47 
48 // *****************************************************************************
49 // class definitions
50 
55  class EXIV2API Key {
56  public:
58  typedef std::auto_ptr<Key> AutoPtr;
59 
61 
62  virtual ~Key();
65 
67 
68 
74  virtual std::string key() const =0;
76  virtual const char* familyName() const =0;
78  virtual std::string groupName() const =0;
80  virtual std::string tagName() const =0;
82  virtual std::string tagLabel() const =0;
84  virtual uint16_t tag() const =0;
90  AutoPtr clone() const;
97  std::ostream& write(std::ostream& os) const { return os << key(); }
99 
100  protected:
102 
103 
107  Key& operator=(const Key& rhs);
109 
110  private:
112  virtual Key* clone_() const =0;
113 
114  }; // class Key
115 
117  inline std::ostream& operator<<(std::ostream& os, const Key& key)
118  {
119  return key.write(os);
120  }
121 
126  class EXIV2API Metadatum {
127  public:
129 
130  Metadatum();
133  Metadatum(const Metadatum& rhs);
135  virtual ~Metadatum();
137 
139 
140 
144  virtual void setValue(const Value* pValue) =0;
151  virtual int setValue(const std::string& buf) =0;
153 
155 
156 
161  std::string print(const ExifData* pMetadata =0) const;
173  virtual long copy(byte* buf, ByteOrder byteOrder) const =0;
195  virtual std::ostream& write(
196  std::ostream& os,
197  const ExifData* pMetadata =0
198  ) const =0;
205  virtual std::string key() const =0;
207  virtual const char* familyName() const =0;
209  virtual std::string groupName() const =0;
211  virtual std::string tagName() const =0;
213  virtual std::string tagLabel() const =0;
215  virtual uint16_t tag() const =0;
217  virtual TypeId typeId() const =0;
219  virtual const char* typeName() const =0;
221  virtual long typeSize() const =0;
223  virtual long count() const =0;
225  virtual long size() const =0;
227  virtual std::string toString() const =0;
233  virtual std::string toString(long n) const =0;
239  virtual long toLong(long n =0) const =0;
245  virtual float toFloat(long n =0) const =0;
251  virtual Rational toRational(long n =0) const =0;
265  virtual Value::AutoPtr getValue() const =0;
279  virtual const Value& value() const =0;
281 
282  protected:
284 
285 
289  Metadatum& operator=(const Metadatum& rhs);
291 
292  }; // class Metadatum
293 
298  inline std::ostream& operator<<(std::ostream& os, const Metadatum& md)
299  {
300  return md.write(os);
301  }
302 
307  EXIV2API bool cmpMetadataByTag(const Metadatum& lhs, const Metadatum& rhs);
312  EXIV2API bool cmpMetadataByKey(const Metadatum& lhs, const Metadatum& rhs);
313 
314 } // namespace Exiv2
315 
316 #endif // #ifndef METADATUM_HPP_
Exiv2::Metadatum::print
std::string print(const ExifData *pMetadata=0) const
Write the interpreted value to a string.
Definition: metadatum.cpp:71
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::Metadatum::~Metadatum
virtual ~Metadatum()
Destructor.
Definition: metadatum.cpp:62
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::Key::AutoPtr
std::auto_ptr< Key > AutoPtr
Shortcut for a Key auto pointer.
Definition: metadatum.hpp:58
Exiv2::Metadatum::Metadatum
Metadatum()
Default Constructor.
Definition: metadatum.cpp:54
Exiv2::Internal::groupName
const char * groupName(IfdId ifdId)
Return the group name for a group id.
Definition: tags_int.cpp:2155
Exiv2::Key
Abstract base class defining the Key of a metadatum. Keys are used to identify and group metadata.
Definition: metadatum.hpp:55
Exiv2::Metadatum::write
virtual std::ostream & write(std::ostream &os, const ExifData *pMetadata=0) const =0
Write the interpreted value to an output stream, return the stream.
Exiv2::Key::~Key
virtual ~Key()
Destructor.
Definition: metadatum.cpp:40
Exiv2::cmpMetadataByKey
EXIV2API bool cmpMetadataByKey(const Metadatum &lhs, const Metadatum &rhs)
Compare two metadata by key. Return true if the key of metadatum lhs is less than that of rhs.
Definition: metadatum.cpp:84
Exiv2::Key::clone
AutoPtr clone() const
Return an auto-pointer to a copy of itself (deep copy). The caller owns this copy and the auto-pointe...
Definition: metadatum.cpp:44
Exiv2::Metadatum
Abstract base class defining the interface to access information related to one metadata tag.
Definition: metadatum.hpp:126
Exiv2::operator<<
EXIV2API std::ostream & operator<<(std::ostream &os, const DataSet &dataSet)
Output operator for dataSet.
Definition: datasets.cpp:709
Exiv2
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: asfvideo.hpp:36
Exiv2::Rational
std::pair< int32_t, int32_t > Rational
8 byte signed rational type.
Definition: types.hpp:110
value.hpp
Value interface and concrete subclasses.
Exiv2::TypeId
TypeId
Exiv2 value type identifiers.
Definition: types.hpp:130
Exiv2::getValue
T getValue(const byte *buf, ByteOrder byteOrder)
Read a value of type T from the data buffer.
Definition: value.hpp:1372
Exiv2::Key::write
std::ostream & write(std::ostream &os) const
Write the key to an output stream. You do not usually have to use this function; it is used for the i...
Definition: metadatum.hpp:97
Exiv2::ByteOrder
ByteOrder
Type to express the byte order (little or big endian)
Definition: types.hpp:113
Exiv2::cmpMetadataByTag
EXIV2API bool cmpMetadataByTag(const Metadatum &lhs, const Metadatum &rhs)
Compare two metadata by tag. Return true if the tag of metadatum lhs is less than that of rhs.
Definition: metadatum.cpp:78
Exiv2::Metadatum::operator=
Metadatum & operator=(const Metadatum &rhs)
Assignment operator. Protected so that it can only be used by subclasses but not directly.
Definition: metadatum.cpp:66
Exiv2::string
@ string
IPTC string type.
Definition: types.hpp:147
Exiv2::Metadatum::key
virtual std::string key() const =0
Return the key of the metadatum. The key is of the form 'familyName.groupName.tagName'....
Exiv2::setValue
Exiv2::Exifdatum & setValue(Exiv2::Exifdatum &exifDatum, const T &value)
Set the value of exifDatum to value. If the object already has a value, it is replaced....
Definition: exif.cpp:193
Exiv2::toString
std::string toString(const T &arg)
Utility function to convert the argument of any type to a string.
Definition: types.hpp:521
Exiv2::Metadatum::tag
virtual uint16_t tag() const =0
Return the tag.
Exiv2::Value::AutoPtr
std::auto_ptr< Value > AutoPtr
Shortcut for a Value auto pointer.
Definition: value.hpp:63
Exiv2::ExifData
A container for Exif data. This is a top-level class of the Exiv2 library. The container holds Exifda...
Definition: exif.hpp:434