| Exiv2

Loading...
Searching...
No Matches
metadatum.hpp
1// SPDX-License-Identifier: GPL-2.0-or-later
2
3#ifndef METADATUM_HPP_
4#define METADATUM_HPP_
5
6// *****************************************************************************
7#include "exiv2lib_export.h"
8
9// included header files
10#include "value.hpp"
11
12// *****************************************************************************
13// namespace extensions
14 namespace Exiv2 {
15// *****************************************************************************
16// class declarations
17 class ExifData;
18
19// *****************************************************************************
20// class definitions
21
26 class EXIV2API Key {
27 public:
29 using UniquePtr = std::unique_ptr<Key>;
30
32
33
34 virtual ~Key() = default;
36 Key(Key&&) = delete;
37 Key& operator=(Key&&) = delete;
39
40
46 [[nodiscard]] virtual std::string key() const = 0;
48 [[nodiscard]] virtual const char* familyName() const = 0;
50 [[nodiscard]] virtual std::string groupName() const = 0;
52 [[nodiscard]] virtual std::string tagName() const = 0;
54 [[nodiscard]] virtual std::string tagLabel() const = 0;
56 [[nodiscard]] virtual std::string tagDesc() const = 0;
58 [[nodiscard]] virtual uint16_t tag() const = 0;
64 [[nodiscard]] UniquePtr clone() const;
71 std::ostream& write(std::ostream& os) const {
72 return os << key();
73 }
74
75
76 protected:
77 Key() = default;
78 Key(const Key&) = default;
80
81
85 Key& operator=(const Key&) = default;
87
88 private:
90 [[nodiscard]] virtual Key* clone_() const = 0;
91
92}; // class Key
93
95 inline std::ostream& operator<<(std::ostream& os, const Key& key) {
96 return key.write(os);
97}
98
103 class EXIV2API Metadatum {
104 public:
106
107
108 virtual ~Metadatum() = default;
110
112
113
117 virtual void setValue(const Value* pValue) = 0;
124 virtual int setValue(const std::string& buf) = 0;
126
128
129
134 std::string print(const ExifData* pMetadata = nullptr) const;
146 virtual size_t copy(byte* buf, ByteOrder byteOrder) const = 0;
168 virtual std::ostream& write(std::ostream& os, const ExifData* pMetadata = nullptr) const = 0;
175 [[nodiscard]] virtual std::string key() const = 0;
177 [[nodiscard]] virtual const char* familyName() const = 0;
179 [[nodiscard]] virtual std::string groupName() const = 0;
181 [[nodiscard]] virtual std::string tagName() const = 0;
183 [[nodiscard]] virtual std::string tagLabel() const = 0;
185 [[nodiscard]] virtual std::string tagDesc() const = 0;
187 [[nodiscard]] virtual uint16_t tag() const = 0;
189 [[nodiscard]] virtual TypeId typeId() const = 0;
191 [[nodiscard]] virtual const char* typeName() const = 0;
193 [[nodiscard]] virtual size_t typeSize() const = 0;
195 [[nodiscard]] virtual size_t count() const = 0;
197 [[nodiscard]] virtual size_t size() const = 0;
199 [[nodiscard]] virtual std::string toString() const = 0;
205 [[nodiscard]] virtual std::string toString(size_t n) const = 0;
211 [[nodiscard]] virtual int64_t toInt64(size_t n = 0) const = 0;
215 [[nodiscard]] uint32_t toUint32(size_t n = 0) const;
221 [[nodiscard]] virtual float toFloat(size_t n = 0) const = 0;
227 [[nodiscard]] virtual Rational toRational(size_t n = 0) const = 0;
241 [[nodiscard]] virtual Value::UniquePtr getValue() const = 0;
255 [[nodiscard]] virtual const Value& value() const = 0;
257
258 protected:
259 Metadatum() = default;
260 Metadatum(const Metadatum&) = default;
262
263
267 Metadatum& operator=(const Metadatum&) = default;
269
270}; // class Metadatum
271
276 inline std::ostream& operator<<(std::ostream& os, const Metadatum& md) {
277 return md.write(os);
278}
279
284EXIV2API bool cmpMetadataByTag(const Metadatum& lhs, const Metadatum& rhs);
289EXIV2API bool cmpMetadataByKey(const Metadatum& lhs, const Metadatum& rhs);
290
291} // namespace Exiv2
292
293#endif // #ifndef METADATUM_HPP_
Exiv2::ExifData
A container for Exif data. This is a top-level class of the Exiv2 library. The container holds Exifda...
Definition exif.hpp:379
Exiv2::Key
Abstract base class defining the Key of a metadatum. Keys are used to identify and group metadata.
Definition metadatum.hpp:26
Exiv2::Key::clone
UniquePtr 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:6
Exiv2::Key::groupName
virtual std::string groupName() const =0
Return the name of the group (the second part of the key).
Exiv2::Key::key
virtual std::string key() const =0
Return the key of the metadatum as a string. The key is of the form 'familyName.groupName....
Exiv2::Key::tagLabel
virtual std::string tagLabel() const =0
Return a label for the tag.
Exiv2::Key::tagDesc
virtual std::string tagDesc() const =0
Return a description for the tag.
Exiv2::Key::UniquePtr
std::unique_ptr< Key > UniquePtr
Shortcut for a Key auto pointer.
Definition metadatum.hpp:29
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:71
Exiv2::Key::tag
virtual uint16_t tag() const =0
Return the tag number.
Exiv2::Key::operator=
Key & operator=(const Key &)=default
Assignment operator. Protected so that it can only be used by subclasses but not directly.
Exiv2::Key::~Key
virtual ~Key()=default
Destructor.
Exiv2::Key::tagName
virtual std::string tagName() const =0
Return the name of the tag (which is also the third part of the key).
Exiv2::Key::familyName
virtual const char * familyName() const =0
Return an identifier for the type of metadata (the first part of the key).
Exiv2::Metadatum
Abstract base class defining the interface to access information related to one metadata tag.
Definition metadatum.hpp:103
Exiv2::Metadatum::typeId
virtual TypeId typeId() const =0
Return the type id of the value.
Exiv2::Metadatum::~Metadatum
virtual ~Metadatum()=default
Destructor.
Exiv2::Metadatum::toString
virtual std::string toString(size_t n) const =0
Return the n-th component of the value converted to a string. The behaviour of the method is undefine...
Exiv2::Metadatum::setValue
virtual int setValue(const std::string &buf)=0
Set the value to the string buf. Uses Value::read(const std::string& buf). If the metadatum does not ...
Exiv2::Metadatum::write
virtual std::ostream & write(std::ostream &os, const ExifData *pMetadata=nullptr) const =0
Write the interpreted value to an output stream, return the stream.
Exiv2::Metadatum::tag
virtual uint16_t tag() const =0
Return the tag.
Exiv2::Metadatum::getValue
virtual Value::UniquePtr getValue() const =0
Return an auto-pointer to a copy (clone) of the value. The caller owns this copy and the auto-poiner ...
Exiv2::Metadatum::typeName
virtual const char * typeName() const =0
Return the name of the type.
Exiv2::Metadatum::tagLabel
virtual std::string tagLabel() const =0
Return a label for the tag.
Exiv2::Metadatum::toUint32
uint32_t toUint32(size_t n=0) const
Return the n-th component of the value converted to uint32_t.
Definition metadatum.cpp:16
Exiv2::Metadatum::familyName
virtual const char * familyName() const =0
Return the name of the metadata family (which is also the first part of the key).
Exiv2::Metadatum::value
virtual const Value & value() const =0
Return a constant reference to the value.
Exiv2::Metadatum::typeSize
virtual size_t typeSize() const =0
Return the size in bytes of one component of this type.
Exiv2::Metadatum::copy
virtual size_t copy(byte *buf, ByteOrder byteOrder) const =0
Write value to a data buffer and return the number of bytes written.
Exiv2::Metadatum::tagName
virtual std::string tagName() const =0
Return the name of the tag (which is also the third part of the key).
Exiv2::Metadatum::toString
virtual std::string toString() const =0
Return the value as a string.
Exiv2::Metadatum::groupName
virtual std::string groupName() const =0
Return the name of the metadata group (which is also the second part of the key).
Exiv2::Metadatum::toRational
virtual Rational toRational(size_t n=0) const =0
Return the n-th component of the value converted to Rational. The return value is -1/1 if the value i...
Exiv2::Metadatum::toFloat
virtual float toFloat(size_t n=0) const =0
Return the n-th component of the value converted to float. The return value is -1 if the value is not...
Exiv2::Metadatum::toInt64
virtual int64_t toInt64(size_t n=0) const =0
Return the n-th component of the value converted to int64_t. The return value is -1 if the value is n...
Exiv2::Metadatum::operator=
Metadatum & operator=(const Metadatum &)=default
Assignment operator. Protected so that it can only be used by subclasses but not directly.
Exiv2::Metadatum::count
virtual size_t count() const =0
Return the number of components in the value.
Exiv2::Metadatum::tagDesc
virtual std::string tagDesc() const =0
Return a description for the tag.
Exiv2::Metadatum::setValue
virtual void setValue(const Value *pValue)=0
Set the value. This method copies (clones) the value pointed to by pValue.
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::Metadatum::size
virtual size_t size() const =0
Return the size of the value in bytes.
Exiv2::Metadatum::print
std::string print(const ExifData *pMetadata=nullptr) const
Write the interpreted value to a string.
Definition metadatum.cpp:10
Exiv2::Value
Common interface for all types of values used with metadata.
Definition value.hpp:33
Exiv2::Value::UniquePtr
std::unique_ptr< Value > UniquePtr
Shortcut for a Value auto pointer.
Definition value.hpp:36
Exiv2
Class CrwImage to access Canon CRW images. References: The Canon RAW (CRW) File Format by Phil Harv...
Definition asfvideo.hpp:15
Exiv2::operator<<
EXIV2API std::ostream & operator<<(std::ostream &os, const DataSet &dataSet)
Output operator for dataSet.
Definition datasets.cpp:590
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:20
Exiv2::TypeId
TypeId
Exiv2 value type identifiers.
Definition types.hpp:70
Exiv2::Rational
std::pair< int32_t, int32_t > Rational
8 byte signed rational type.
Definition types.hpp:31
Exiv2::ByteOrder
ByteOrder
Type to express the byte order (little or big endian).
Definition types.hpp:34
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:24