properties.hpp
// ***************************************************************** -*- C++ -*-
/*
* Copyright (C) 2004-2021 Exiv2 authors
* This program is part of the Exiv2 distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
*/
#ifndef PROPERTIES_HPP_
#define PROPERTIES_HPP_
// *****************************************************************************
#include "exiv2lib_export.h"
// included header files
#include "datasets.hpp"
#include "rwlock.hpp"
// *****************************************************************************
// namespace extensions
namespace Exiv2 {
// *****************************************************************************
// class declarations
class XmpKey;
// *****************************************************************************
// class definitions
enum XmpCategory { xmpInternal, xmpExternal };
struct EXIV2API XmpPropertyInfo {
bool operator==(const std::string& name) const;
const char* name_;
const char* title_;
const char* xmpValueType_;
TypeId typeId_;
XmpCategory xmpCategory_;
const char* desc_;
};
struct EXIV2API XmpNsInfo {
struct Prefix {
explicit Prefix(const std::string& prefix);
std::string prefix_;
};
struct Ns {
explicit Ns(const std::string& ns);
std::string ns_;
};
bool operator==(const Ns& ns) const;
bool operator==(const Prefix& prefix) const;
const char* ns_;
const char* prefix_;
const XmpPropertyInfo* xmpPropertyInfo_;
const char* desc_;
};
class EXIV2API XmpProperties {
XmpProperties();
XmpProperties(const XmpProperties& rhs);
XmpProperties& operator=(const XmpProperties& rhs);
private:
static const XmpNsInfo* nsInfoUnsafe(const std::string& prefix);
static void unregisterNsUnsafe(const std::string& ns);
static const XmpNsInfo* lookupNsRegistryUnsafe(const XmpNsInfo::Prefix& prefix);
public:
static const char* propertyTitle(const XmpKey& key);
static const char* propertyDesc(const XmpKey& key);
static TypeId propertyType(const XmpKey& key);
static const XmpPropertyInfo* propertyInfo(const XmpKey& key);
static std::string ns(const std::string& prefix);
static const char* nsDesc(const std::string& prefix);
static const XmpPropertyInfo* propertyList(const std::string& prefix);
static const XmpNsInfo* nsInfo(const std::string& prefix);
static std::string prefix(const std::string& ns);
static void printProperties(std::ostream& os, const std::string& prefix);
static std::ostream& printProperty(std::ostream& os,
const std::string& key,
const Value& value);
static void registerNs(const std::string& ns, const std::string& prefix);
static void unregisterNs(const std::string& ns);
static Exiv2::RWLock rwLock_;
static void unregisterNs();
typedef std::map<std::string, XmpNsInfo> NsRegistry;
static const XmpNsInfo* lookupNsRegistry(const XmpNsInfo::Prefix& prefix);
// DATA
static NsRegistry nsRegistry_;
static void registeredNamespaces(Exiv2::Dictionary& nsDict);
}; // class XmpProperties
class EXIV2API XmpKey : public Key
{
public:
typedef std::auto_ptr<XmpKey> AutoPtr;
explicit XmpKey(const std::string& key);
XmpKey(const std::string& prefix, const std::string& property);
XmpKey(const XmpKey& rhs);
virtual ~XmpKey();
XmpKey& operator=(const XmpKey& rhs);
virtual std::string key() const;
virtual const char* familyName() const;
virtual std::string groupName() const;
virtual std::string tagName() const;
virtual std::string tagLabel() const;
virtual uint16_t tag() const;
AutoPtr clone() const;
// Todo: Should this be removed? What about tagLabel then?
std::string ns() const;
private:
virtual XmpKey* clone_() const;
private:
// Pimpl idiom
struct Impl;
std::auto_ptr<Impl> p_;
}; // class XmpKey
// *****************************************************************************
// free functions
EXIV2API std::ostream& operator<<(std::ostream& os, const XmpPropertyInfo& propertyInfo);
} // namespace Exiv2
#endif // #ifndef PROPERTIES_HPP_
Exiv2::Key
Abstract base class defining the Key of a metadatum. Keys are used to identify and group metadata.
Definition: metadatum.hpp:44
Exiv2::Key::AutoPtr
std::auto_ptr< Key > AutoPtr
Shortcut for a Key auto pointer.
Definition: metadatum.hpp:47
Exiv2::RWLock
Class to provide a Read-Write Lock.
Definition: rwlock.hpp:90
Exiv2::Value
Common interface for all types of values used with metadata.
Definition: value.hpp:51
Exiv2::XmpKey
Concrete keys for XMP metadata.
Definition: properties.hpp:231
Exiv2::XmpKey::familyName
virtual const char * familyName() const
Return an identifier for the type of metadata (the first part of the key)
Exiv2::XmpKey::tagName
virtual std::string tagName() const
Return the name of the tag (which is also the third part of the key)
Exiv2::XmpKey::~XmpKey
virtual ~XmpKey()
Virtual destructor.
Exiv2::XmpKey::XmpKey
XmpKey(const XmpKey &rhs)
Copy constructor.
Exiv2::XmpKey::tag
virtual uint16_t tag() const
Properties don't have a tag number. Return 0.
Exiv2::XmpKey::ns
std::string ns() const
Return the schema namespace for the prefix of the key.
Exiv2::XmpKey::AutoPtr
std::auto_ptr< XmpKey > AutoPtr
Shortcut for an XmpKey auto pointer.
Definition: properties.hpp:234
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::XmpKey::XmpKey
XmpKey(const std::string &key)
Constructor to create an XMP key from a key string.
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::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::tagLabel
virtual std::string tagLabel() const
Return a label for the tag.
Exiv2::XmpProperties
XMP property reference, implemented as a static class.
Definition: properties.hpp:85
Exiv2::XmpProperties::propertyType
static TypeId propertyType(const XmpKey &key)
Return the type for property key. The default for unknown keys is xmpText.
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::nsRegistry_
static NsRegistry nsRegistry_
Namespace registry.
Definition: properties.hpp:218
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::nsInfo
static const XmpNsInfo * nsInfo(const std::string &prefix)
Return information about a schema namespace for prefix. Always returns a valid pointer.
Exiv2::XmpProperties::lookupNsRegistry
static const XmpNsInfo * lookupNsRegistry(const XmpNsInfo::Prefix &prefix)
Get the registered namespace for a specific prefix from the registry.
Exiv2::XmpProperties::rwLock_
static Exiv2::RWLock rwLock_
lock to be used while modifying properties
Definition: properties.hpp:199
Exiv2::XmpProperties::prefix
static std::string prefix(const std::string &ns)
Return the (preferred) prefix for schema namespace ns.
Exiv2::XmpProperties::propertyInfo
static const XmpPropertyInfo * propertyInfo(const XmpKey &key)
Return information for the property for key.
Exiv2::XmpProperties::nsDesc
static const char * nsDesc(const std::string &prefix)
Return the namespace description for the schema associated with 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::propertyDesc
static const char * propertyDesc(const XmpKey &key)
Return the description of the property.
Exiv2::XmpProperties::NsRegistry
std::map< std::string, XmpNsInfo > NsRegistry
Type for the namespace registry.
Definition: properties.hpp:211
Exiv2::XmpProperties::propertyTitle
static const char * propertyTitle(const XmpKey &key)
Return the title (label) of the property.
Exiv2::XmpProperties::propertyList
static const XmpPropertyInfo * propertyList(const std::string &prefix)
Return read-only list of built-in properties for prefix.
Exiv2::XmpProperties::registerNs
static void registerNs(const std::string &ns, const std::string &prefix)
Register namespace ns with preferred prefix prefix.
datasets.hpp
IPTC dataset and type information.
Exiv2
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: asfvideo.hpp:36
Exiv2::operator<<
EXIV2API std::ostream & operator<<(std::ostream &os, const DataSet &dataSet)
Output operator for dataSet.
Definition: datasets.cpp:709
Exiv2::TypeId
TypeId
Exiv2 value type identifiers.
Definition: types.hpp:119
Exiv2::XmpCategory
XmpCategory
Category of an XMP property.
Definition: properties.hpp:42
Exiv2::Dictionary
std::map< std::string, std::string > Dictionary
typedef for string:string map
Definition: datasets.hpp:364
Exiv2::XmpNsInfo::Ns
For comparison with namespace.
Definition: properties.hpp:67
Exiv2::XmpNsInfo::Ns::Ns
Ns(const std::string &ns)
Constructor.
Exiv2::XmpNsInfo::Ns::ns_
std::string ns_
The namespace string.
Definition: properties.hpp:71
Exiv2::XmpNsInfo::Prefix
For comparison with prefix.
Definition: properties.hpp:60
Exiv2::XmpNsInfo::Prefix::prefix_
std::string prefix_
The prefix string.
Definition: properties.hpp:64
Exiv2::XmpNsInfo::Prefix::Prefix
Prefix(const std::string &prefix)
Constructor.
Exiv2::XmpNsInfo
Structure mapping XMP namespaces and (preferred) prefixes.
Definition: properties.hpp:58
Exiv2::XmpNsInfo::xmpPropertyInfo_
const XmpPropertyInfo * xmpPropertyInfo_
List of known properties.
Definition: properties.hpp:80
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:81
Exiv2::XmpNsInfo::prefix_
const char * prefix_
(Preferred) prefix
Definition: properties.hpp:79
Exiv2::XmpNsInfo::ns_
const char * ns_
Namespace.
Definition: properties.hpp:78
Exiv2::XmpNsInfo::operator==
bool operator==(const Ns &ns) const
Comparison operator for namespace.
Exiv2::XmpPropertyInfo
Information about one XMP property.
Definition: properties.hpp:45
Exiv2::XmpPropertyInfo::name_
const char * name_
Property name.
Definition: properties.hpp:49
Exiv2::XmpPropertyInfo::desc_
const char * desc_
Property description.
Definition: properties.hpp:54
Exiv2::XmpPropertyInfo::title_
const char * title_
Property title or label.
Definition: properties.hpp:50
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:53
Exiv2::XmpPropertyInfo::xmpValueType_
const char * xmpValueType_
XMP value type (for info only)
Definition: properties.hpp:51
Exiv2::XmpPropertyInfo::typeId_
TypeId typeId_
Exiv2 default type for the property.
Definition: properties.hpp:52