| Exiv2

Loading...
Searching...
No Matches
properties.hpp
1// SPDX-License-Identifier: GPL-2.0-or-later
2
3#ifndef PROPERTIES_HPP_
4#define PROPERTIES_HPP_
5
6// *****************************************************************************
7#include "exiv2lib_export.h"
8
9// included header files
10#include <mutex>
11
12#include "datasets.hpp"
13
14// *****************************************************************************
15// namespace extensions
16 namespace Exiv2 {
17// *****************************************************************************
18// class declarations
19 class XmpKey;
20
21// *****************************************************************************
22// class definitions
23
25 enum XmpCategory { xmpInternal, xmpExternal };
26
28 struct EXIV2API XmpPropertyInfo {
30 bool operator==(const std::string& name) const;
31
32 const char* name_;
33 const char* title_;
34 const char* xmpValueType_;
35 TypeId typeId_;
36 XmpCategory xmpCategory_;
37 const char* desc_;
38};
39
41 struct EXIV2API XmpNsInfo {
43 struct Prefix {
45 std::string prefix_;
46 };
47
48 struct Ns {
50 std::string ns_;
51 };
52
53 bool operator==(const Ns& ns) const;
55 bool operator==(const Prefix& prefix) const;
56
57 const char* ns_;
58 const char* prefix_;
59 const XmpPropertyInfo* xmpPropertyInfo_;
60 const char* desc_;
61};
62
64 class EXIV2API XmpProperties {
65 private:
66 static const XmpNsInfo* nsInfoUnsafe(const std::string& prefix);
67 static void unregisterNsUnsafe(const std::string& ns);
68 static const XmpNsInfo* lookupNsRegistryUnsafe(const XmpNsInfo::Prefix& prefix);
69
70 public:
77 static const char* propertyTitle(const XmpKey& key);
84 static const char* propertyDesc(const XmpKey& key);
91 static TypeId propertyType(const XmpKey& key);
103 static const XmpPropertyInfo* propertyInfo(const XmpKey& key);
111 static std::string ns(const std::string& prefix);
119 static const char* nsDesc(const std::string& prefix);
127 static const XmpPropertyInfo* propertyList(const std::string& prefix);
135 static const XmpNsInfo* nsInfo(const std::string& prefix);
136
143 static std::string prefix(const std::string& ns);
145 static void printProperties(std::ostream& os, const std::string& prefix);
146
148 static std::ostream& printProperty(std::ostream& os, const std::string& key, const Value& value);
157 static void registerNs(const std::string& ns, const std::string& prefix);
166 static void unregisterNs(const std::string& ns);
167
176 static std::mutex mutex_;
177
186 static void unregisterNs();
188 using NsRegistry = std::map<std::string, XmpNsInfo>;
192 static const XmpNsInfo* lookupNsRegistry(const XmpNsInfo::Prefix& prefix);
193
194 // DATA
195 static NsRegistry nsRegistry_;
196
200 static void registeredNamespaces(Exiv2::Dictionary& nsDict);
201
202}; // class XmpProperties
203
207 class EXIV2API XmpKey : public Key {
208 public:
210 using UniquePtr = std::unique_ptr<XmpKey>;
211
213
214
222 explicit XmpKey(const std::string& key);
232 XmpKey(const std::string& prefix, const std::string& property);
234 XmpKey(const XmpKey& rhs);
236 ~XmpKey() override;
238
240
241
242 XmpKey& operator=(const XmpKey& rhs);
244
246
247 [[nodiscard]] std::string key() const override;
248 [[nodiscard]] const char* familyName() const override;
253 [[nodiscard]] std::string groupName() const override;
254 [[nodiscard]] std::string tagName() const override;
255 [[nodiscard]] std::string tagLabel() const override;
256 [[nodiscard]] std::string tagDesc() const override;
258 [[nodiscard]] uint16_t tag() const override;
259
260 [[nodiscard]] UniquePtr clone() const;
261
262 // Todo: Should this be removed? What about tagLabel then?
264 [[nodiscard]] std::string ns() const;
266
267 private:
269 [[nodiscard]] XmpKey* clone_() const override;
270
271 // Pimpl idiom
272 struct Impl;
273 std::unique_ptr<Impl> p_;
274
275}; // class XmpKey
276
277// *****************************************************************************
278// free functions
279
281EXIV2API std::ostream& operator<<(std::ostream& os, const XmpPropertyInfo& propertyInfo);
282
283} // namespace Exiv2
284
285#endif // #ifndef PROPERTIES_HPP_
Exiv2::Value
Common interface for all types of values used with metadata.
Definition value.hpp:33
Exiv2::XmpKey
Concrete keys for XMP metadata.
Definition properties.hpp:207
Exiv2::XmpKey::groupName
std::string groupName() const override
Return the name of the group (the second part of the key). For XMP keys, the group name is the schema...
Exiv2::XmpKey::tag
uint16_t tag() const override
Properties don't have a tag number. Return 0.
Exiv2::XmpKey::tagDesc
std::string tagDesc() const override
Return a description for the tag.
Exiv2::XmpKey::tagName
std::string tagName() const override
Return the name of the tag (which is also the third part of the key).
Exiv2::XmpKey::XmpKey
XmpKey(const XmpKey &rhs)
Copy constructor.
Exiv2::XmpKey::UniquePtr
std::unique_ptr< XmpKey > UniquePtr
Shortcut for an XmpKey auto pointer.
Definition properties.hpp:210
Exiv2::XmpKey::key
std::string key() const override
Return the key of the metadatum as a string. The key is of the form 'familyName.groupName....
Exiv2::XmpKey::tagLabel
std::string tagLabel() const override
Return a label for the tag.
Exiv2::XmpKey::ns
std::string ns() const
Return the schema namespace for the prefix of the key.
Exiv2::XmpKey::operator=
XmpKey & operator=(const XmpKey &rhs)
Assignment operator.
Exiv2::XmpKey::familyName
const char * familyName() const override
Return an identifier for the type of metadata (the first part of the key).
Exiv2::XmpKey::XmpKey
XmpKey(const std::string &key)
Constructor to create an XMP key from a key string.
Exiv2::XmpKey::XmpKey
XmpKey(const std::string &prefix, const std::string &property)
Constructor to create an XMP key from a schema prefix and a property name.
Exiv2::XmpKey::~XmpKey
~XmpKey() override
Virtual destructor.
Exiv2::XmpProperties
XMP property reference, implemented as a static class.
Definition properties.hpp:64
Exiv2::XmpProperties::nsDesc
static const char * nsDesc(const std::string &prefix)
Return the namespace description for the schema associated with prefix.
Exiv2::XmpProperties::NsRegistry
std::map< std::string, XmpNsInfo > NsRegistry
Type for the namespace registry.
Definition properties.hpp:188
Exiv2::XmpProperties::propertyType
static TypeId propertyType(const XmpKey &key)
Return the type for property key. The default for unknown keys is xmpText.
Exiv2::XmpProperties::propertyDesc
static const char * propertyDesc(const XmpKey &key)
Return the description of the property.
Exiv2::XmpProperties::mutex_
static std::mutex mutex_
Lock to be used while modifying properties.
Definition properties.hpp:176
Exiv2::XmpProperties::nsRegistry_
static NsRegistry nsRegistry_
Namespace registry.
Definition properties.hpp:195
Exiv2::XmpProperties::lookupNsRegistry
static const XmpNsInfo * lookupNsRegistry(const XmpNsInfo::Prefix &prefix)
Get the registered namespace for a specific prefix from the registry.
Exiv2::XmpProperties::unregisterNs
static void unregisterNs()
Unregister all custom namespaces.
Exiv2::XmpProperties::ns
static std::string ns(const std::string &prefix)
Return the namespace name for the schema associated with prefix.
Exiv2::XmpProperties::unregisterNs
static void unregisterNs(const std::string &ns)
Unregister a custom namespace ns.
Exiv2::XmpProperties::propertyInfo
static const XmpPropertyInfo * propertyInfo(const XmpKey &key)
Return information for the property for key.
Exiv2::XmpProperties::prefix
static std::string prefix(const std::string &ns)
Return the (preferred) prefix for schema namespace ns.
Exiv2::XmpProperties::propertyList
static const XmpPropertyInfo * propertyList(const std::string &prefix)
Return read-only list of built-in properties for prefix.
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::XmpProperties::registeredNamespaces
static void registeredNamespaces(Exiv2::Dictionary &nsDict)
Get all registered namespaces (for both Exiv2 and XMPsdk).
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::XmpProperties::propertyTitle
static const char * propertyTitle(const XmpKey &key)
Return the title (label) of the property.
Exiv2::XmpProperties::registerNs
static void registerNs(const std::string &ns, const std::string &prefix)
Register namespace ns with preferred prefix prefix.
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
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::TypeId
TypeId
Exiv2 value type identifiers.
Definition types.hpp:70
Exiv2::Dictionary
std::map< std::string, std::string > Dictionary
typedef for string:string map
Definition datasets.hpp:312
Exiv2::XmpCategory
XmpCategory
Category of an XMP property.
Definition properties.hpp:25
Exiv2::XmpNsInfo::Ns
For comparison with namespace.
Definition properties.hpp:48
Exiv2::XmpNsInfo::Ns::ns_
std::string ns_
The namespace string.
Definition properties.hpp:50
Exiv2::XmpNsInfo::Prefix
For comparison with prefix.
Definition properties.hpp:43
Exiv2::XmpNsInfo::Prefix::prefix_
std::string prefix_
The prefix string.
Definition properties.hpp:45
Exiv2::XmpNsInfo
Structure mapping XMP namespaces and (preferred) prefixes.
Definition properties.hpp:41
Exiv2::XmpNsInfo::xmpPropertyInfo_
const XmpPropertyInfo * xmpPropertyInfo_
List of known properties.
Definition properties.hpp:59
Exiv2::XmpNsInfo::operator==
bool operator==(const Prefix &prefix) const
Comparison operator for prefix.
Exiv2::XmpNsInfo::desc_
const char * desc_
Brief description of the namespace.
Definition properties.hpp:60
Exiv2::XmpNsInfo::prefix_
const char * prefix_
(Preferred) prefix
Definition properties.hpp:58
Exiv2::XmpNsInfo::ns_
const char * ns_
Namespace.
Definition properties.hpp:57
Exiv2::XmpNsInfo::operator==
bool operator==(const Ns &ns) const
Comparison operator for namespace.
Exiv2::XmpPropertyInfo
Information about one XMP property.
Definition properties.hpp:28
Exiv2::XmpPropertyInfo::name_
const char * name_
Property name.
Definition properties.hpp:32
Exiv2::XmpPropertyInfo::desc_
const char * desc_
Property description.
Definition properties.hpp:37
Exiv2::XmpPropertyInfo::title_
const char * title_
Property title or label.
Definition properties.hpp:33
Exiv2::XmpPropertyInfo::operator==
bool operator==(const std::string &name) const
Comparison operator for name.
Exiv2::XmpPropertyInfo::xmpCategory_
XmpCategory xmpCategory_
Category (internal or external).
Definition properties.hpp:36
Exiv2::XmpPropertyInfo::xmpValueType_
const char * xmpValueType_
XMP value type (for info only).
Definition properties.hpp:34
Exiv2::XmpPropertyInfo::typeId_
TypeId typeId_
Exiv2 default type for the property.
Definition properties.hpp:35