Blame include/exiv2/value.hpp

Packit Service 21b5d1
// ***************************************************************** -*- C++ -*-
Packit Service 21b5d1
/*
Packit Service 21b5d1
 * Copyright (C) 2004-2018 Exiv2 authors
Packit Service 21b5d1
 * This program is part of the Exiv2 distribution.
Packit Service 21b5d1
 *
Packit Service 21b5d1
 * This program is free software; you can redistribute it and/or
Packit Service 21b5d1
 * modify it under the terms of the GNU General Public License
Packit Service 21b5d1
 * as published by the Free Software Foundation; either version 2
Packit Service 21b5d1
 * of the License, or (at your option) any later version.
Packit Service 21b5d1
 *
Packit Service 21b5d1
 * This program is distributed in the hope that it will be useful,
Packit Service 21b5d1
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 21b5d1
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 21b5d1
 * GNU General Public License for more details.
Packit Service 21b5d1
 *
Packit Service 21b5d1
 * You should have received a copy of the GNU General Public License
Packit Service 21b5d1
 * along with this program; if not, write to the Free Software
Packit Service 21b5d1
 * Foundation, Inc., 51 Franklin Street, 5th Floor, Boston, MA 02110-1301 USA.
Packit Service 21b5d1
 */
Packit Service 21b5d1
/*!
Packit Service 21b5d1
  @file    value.hpp
Packit Service 21b5d1
  @brief   Value interface and concrete subclasses
Packit Service 21b5d1
  @author  Andreas Huggel (ahu)
Packit Service 21b5d1
           ahuggel@gmx.net
Packit Service 21b5d1
  @date    09-Jan-04, ahu: created
Packit Service 21b5d1
           11-Feb-04, ahu: isolated as a component
Packit Service 21b5d1
           31-Jul-04, brad: added Time, Data and String values
Packit Service 21b5d1
 */
Packit Service 21b5d1
#ifndef VALUE_HPP_
Packit Service 21b5d1
#define VALUE_HPP_
Packit Service 21b5d1
Packit Service 21b5d1
// *****************************************************************************
Packit Service 21b5d1
#include "exiv2lib_export.h"
Packit Service 21b5d1
Packit Service 21b5d1
// included header files
Packit Service 21b5d1
#include "types.hpp"
Packit Service 21b5d1
Packit Service 21b5d1
// + standard includes
Packit Service 21b5d1
#include <map>
Packit Service 21b5d1
#include <iomanip>
Packit Service 21b5d1
#include <memory>
Packit Service 21b5d1
#include <cstring>
Packit Service 21b5d1
#include <climits>
Packit Service 21b5d1
Packit Service 21b5d1
// *****************************************************************************
Packit Service 21b5d1
// namespace extensions
Packit Service 21b5d1
namespace Exiv2 {
Packit Service 21b5d1
Packit Service 21b5d1
// *****************************************************************************
Packit Service 21b5d1
// class definitions
Packit Service 21b5d1
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief Common interface for all types of values used with metadata.
Packit Service 21b5d1
Packit Service 21b5d1
      The interface provides a uniform way to access values independent of
Packit Service 21b5d1
      their actual C++ type for simple tasks like reading the values from a
Packit Service 21b5d1
      string or data buffer.  For other tasks, like modifying values you may
Packit Service 21b5d1
      need to downcast it to a specific subclass to access its interface.
Packit Service 21b5d1
     */
Packit Service 21b5d1
    class EXIV2API Value {
Packit Service 21b5d1
    public:
Packit Service 21b5d1
        //! Shortcut for a %Value auto pointer.
Packit Service 21b5d1
        typedef std::auto_ptr<Value> AutoPtr;
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Creators
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        //! Constructor, taking a type id to initialize the base class with
Packit Service 21b5d1
        explicit Value(TypeId typeId);
Packit Service 21b5d1
        //! Virtual destructor.
Packit Service 21b5d1
        virtual ~Value();
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
        //! @name Manipulators
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Read the value from a character buffer.
Packit Service 21b5d1
Packit Service 21b5d1
          @param buf Pointer to the data buffer to read from
Packit Service 21b5d1
          @param len Number of bytes in the data buffer
Packit Service 21b5d1
          @param byteOrder Applicable byte order (little or big endian).
Packit Service 21b5d1
Packit Service 21b5d1
          @return 0 if successful.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual int read(const byte* buf, long len, ByteOrder byteOrder) =0;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Set the value from a string buffer. The format of the string
Packit Service 21b5d1
                 corresponds to that of the write() method, i.e., a string
Packit Service 21b5d1
                 obtained through the write() method can be read by this
Packit Service 21b5d1
                 function.
Packit Service 21b5d1
Packit Service 21b5d1
          @param buf The string to read from.
Packit Service 21b5d1
Packit Service 21b5d1
          @return 0 if successful.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual int read(const std::string& buf) =0;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Set the data area, if the value has one by copying (cloning)
Packit Service 21b5d1
                 the buffer pointed to by buf.
Packit Service 21b5d1
Packit Service 21b5d1
          Values may have a data area, which can contain additional
Packit Service 21b5d1
          information besides the actual value. This method is used to set such
Packit Service 21b5d1
          a data area.
Packit Service 21b5d1
Packit Service 21b5d1
          @param buf Pointer to the source data area
Packit Service 21b5d1
          @param len Size of the data area
Packit Service 21b5d1
          @return Return -1 if the value has no data area, else 0.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual int setDataArea(const byte* buf, long len);
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Accessors
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        //! Return the type identifier (Exif data format type).
Packit Service 21b5d1
        TypeId typeId() const { return type_; }
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Return an auto-pointer to a copy of itself (deep copy).
Packit Service 21b5d1
                 The caller owns this copy and the auto-pointer ensures that
Packit Service 21b5d1
                 it will be deleted.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        AutoPtr clone() const { return AutoPtr(clone_()); }
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Write value to a data buffer.
Packit Service 21b5d1
Packit Service 21b5d1
          The user must ensure that the buffer has enough memory. Otherwise
Packit Service 21b5d1
          the call results in undefined behaviour.
Packit Service 21b5d1
Packit Service 21b5d1
          @param buf Data buffer to write to.
Packit Service 21b5d1
          @param byteOrder Applicable byte order (little or big endian).
Packit Service 21b5d1
          @return Number of bytes written.
Packit Service 21b5d1
        */
Packit Service 21b5d1
        virtual long copy(byte* buf, ByteOrder byteOrder) const =0;
Packit Service 21b5d1
        //! Return the number of components of the value
Packit Service 21b5d1
        virtual long count() const =0;
Packit Service 21b5d1
        //! Return the size of the value in bytes
Packit Service 21b5d1
        virtual long size() const =0;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Write the value to an output stream. You do not usually have
Packit Service 21b5d1
                 to use this function; it is used for the implementation of
Packit Service 21b5d1
                 the output operator for %Value,
Packit Service 21b5d1
                 operator<<(std::ostream &os, const Value &value).
Packit Service 21b5d1
        */
Packit Service 21b5d1
        virtual std::ostream& write(std::ostream& os) const =0;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Return the value as a string. Implemented in terms of
Packit Service 21b5d1
                 write(std::ostream& os) const of the concrete class.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        std::string toString() const;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Return the n-th component of the value as a string.
Packit Service 21b5d1
                 The default implementation returns toString(). The behaviour
Packit Service 21b5d1
                 of this method may be undefined if there is no n-th
Packit Service 21b5d1
                 component.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual std::string toString(long n) const;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Convert the n-th component of the value to a long.
Packit Service 21b5d1
                 The behaviour of this method may be undefined if there is no
Packit Service 21b5d1
                 n-th component.
Packit Service 21b5d1
Packit Service 21b5d1
          @return The converted value.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual long toLong(long n =0) const =0;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Convert the n-th component of the value to a float.
Packit Service 21b5d1
                 The behaviour of this method may be undefined if there is no
Packit Service 21b5d1
                 n-th component.
Packit Service 21b5d1
Packit Service 21b5d1
          @return The converted value.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual float toFloat(long n =0) const =0;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Convert the n-th component of the value to a Rational.
Packit Service 21b5d1
                 The behaviour of this method may be undefined if there is no
Packit Service 21b5d1
                 n-th component.
Packit Service 21b5d1
Packit Service 21b5d1
          @return The converted value.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual Rational toRational(long n =0) const =0;
Packit Service 21b5d1
        //! Return the size of the data area, 0 if there is none.
Packit Service 21b5d1
        virtual long sizeDataArea() const;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Return a copy of the data area if the value has one. The
Packit Service 21b5d1
                 caller owns this copy and DataBuf ensures that it will be
Packit Service 21b5d1
                 deleted.
Packit Service 21b5d1
Packit Service 21b5d1
          Values may have a data area, which can contain additional
Packit Service 21b5d1
          information besides the actual value. This method is used to access
Packit Service 21b5d1
          such a data area.
Packit Service 21b5d1
Packit Service 21b5d1
          @return A DataBuf containing a copy of the data area or an empty
Packit Service 21b5d1
                  DataBuf if the value does not have a data area assigned.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual DataBuf dataArea() const;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Check the \em ok status indicator. After a to<Type> conversion,
Packit Service 21b5d1
                 this indicator shows whether the conversion was successful.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        bool ok() const { return ok_; }
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief A (simple) factory to create a Value type.
Packit Service 21b5d1
Packit Service 21b5d1
          The following Value subclasses are created depending on typeId:

Packit Service 21b5d1
          
Packit Service 21b5d1
          typeId%Value subclass
Packit Service 21b5d1
          invalidTypeId%DataValue(invalidTypeId)
Packit Service 21b5d1
          unsignedByte%DataValue(unsignedByte)
Packit Service 21b5d1
          asciiString%AsciiValue
Packit Service 21b5d1
          string%StringValue
Packit Service 21b5d1
          unsignedShort%ValueType < uint16_t >
Packit Service 21b5d1
          unsignedLong%ValueType < uint32_t >
Packit Service 21b5d1
          unsignedRational%ValueType < URational >
Packit Service 21b5d1
          invalid6%DataValue(invalid6)
Packit Service 21b5d1
          undefined%DataValue
Packit Service 21b5d1
          signedShort%ValueType < int16_t >
Packit Service 21b5d1
          signedLong%ValueType < int32_t >
Packit Service 21b5d1
          signedRational%ValueType < Rational >
Packit Service 21b5d1
          tiffFloat%ValueType < float >
Packit Service 21b5d1
          tiffDouble%ValueType < double >
Packit Service 21b5d1
          tiffIfd%ValueType < uint32_t >
Packit Service 21b5d1
          date%DateValue
Packit Service 21b5d1
          time%TimeValue
Packit Service 21b5d1
          comment%CommentValue
Packit Service 21b5d1
          xmpText%XmpTextValue
Packit Service 21b5d1
          xmpBag%XmpArrayValue
Packit Service 21b5d1
          xmpSeq%XmpArrayValue
Packit Service 21b5d1
          xmpAlt%XmpArrayValue
Packit Service 21b5d1
          langAlt%LangAltValue
Packit Service 21b5d1
          default%DataValue(typeId)
Packit Service 21b5d1
          
Packit Service 21b5d1
Packit Service 21b5d1
          @param typeId Type of the value.
Packit Service 21b5d1
          @return Auto-pointer to the newly created Value. The caller owns this
Packit Service 21b5d1
                  copy and the auto-pointer ensures that it will be deleted.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        static AutoPtr create(TypeId typeId);
Packit Service 21b5d1
Packit Service 21b5d1
    protected:
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Assignment operator. Protected so that it can only be used
Packit Service 21b5d1
                 by subclasses but not directly.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        Value& operator=(const Value& rhs);
Packit Service 21b5d1
        // DATA
Packit Service 21b5d1
        mutable bool ok_;                //!< Indicates the status of the previous to<Type> conversion
Packit Service 21b5d1
Packit Service 21b5d1
    private:
Packit Service 21b5d1
        //! Internal virtual copy constructor.
Packit Service 21b5d1
        virtual Value* clone_() const =0;
Packit Service 21b5d1
        // DATA
Packit Service 21b5d1
        TypeId type_;                    //!< Type of the data
Packit Service 21b5d1
Packit Service 21b5d1
    }; // class Value
Packit Service 21b5d1
Packit Service 21b5d1
    //! Output operator for Value types
Packit Service 21b5d1
    inline std::ostream& operator<<(std::ostream& os, const Value& value)
Packit Service 21b5d1
    {
Packit Service 21b5d1
        return value.write(os);
Packit Service 21b5d1
    }
Packit Service 21b5d1
Packit Service 21b5d1
    //! %Value for an undefined data type.
Packit Service 21b5d1
    class EXIV2API DataValue : public Value {
Packit Service 21b5d1
    public:
Packit Service 21b5d1
        //! Shortcut for a %DataValue auto pointer.
Packit Service 21b5d1
        typedef std::auto_ptr<DataValue> AutoPtr;
Packit Service 21b5d1
Packit Service 21b5d1
        explicit DataValue(TypeId typeId =undefined);
Packit Service 21b5d1
Packit Service 21b5d1
        DataValue(const byte* buf,
Packit Service 21b5d1
                  long len, ByteOrder byteOrder =invalidByteOrder,
Packit Service 21b5d1
                  TypeId typeId =undefined);
Packit Service 21b5d1
Packit Service 21b5d1
        virtual ~DataValue();
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Manipulators
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Read the value from a character buffer.
Packit Service 21b5d1
Packit Service 21b5d1
          @note The byte order is required by the interface but not
Packit Service 21b5d1
                used by this method, so just use the default.
Packit Service 21b5d1
Packit Service 21b5d1
          @param buf Pointer to the data buffer to read from
Packit Service 21b5d1
          @param len Number of bytes in the data buffer
Packit Service 21b5d1
          @param byteOrder Byte order. Not needed.
Packit Service 21b5d1
Packit Service 21b5d1
          @return 0 if successful.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual int read(const byte* buf,
Packit Service 21b5d1
                          long len,
Packit Service 21b5d1
                          ByteOrder byteOrder =invalidByteOrder);
Packit Service 21b5d1
        //! Set the data from a string of integer values (e.g., "0 1 2 3")
Packit Service 21b5d1
        virtual int read(const std::string& buf);
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Accessors
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        AutoPtr clone() const { return AutoPtr(clone_()); }
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Write value to a character data buffer.
Packit Service 21b5d1
Packit Service 21b5d1
          @note The byte order is required by the interface but not used by this
Packit Service 21b5d1
                method, so just use the default.
Packit Service 21b5d1
Packit Service 21b5d1
          The user must ensure that the buffer has enough memory. Otherwise
Packit Service 21b5d1
          the call results in undefined behaviour.
Packit Service 21b5d1
Packit Service 21b5d1
          @param buf Data buffer to write to.
Packit Service 21b5d1
          @param byteOrder Byte order. Not needed.
Packit Service 21b5d1
          @return Number of characters written.
Packit Service 21b5d1
        */
Packit Service 21b5d1
        virtual long copy(byte* buf, ByteOrder byteOrder =invalidByteOrder) const;
Packit Service 21b5d1
        virtual long count() const;
Packit Service 21b5d1
        virtual long size() const;
Packit Service 21b5d1
        virtual std::ostream& write(std::ostream& os) const;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Return the n-th component of the value as a string.
Packit Service 21b5d1
                 The behaviour of this method may be undefined if there is no
Packit Service 21b5d1
                 n-th component.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual std::string toString(long n) const;
Packit Service 21b5d1
        virtual long toLong(long n =0) const;
Packit Service 21b5d1
        virtual float toFloat(long n =0) const;
Packit Service 21b5d1
        virtual Rational toRational(long n =0) const;
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
    private:
Packit Service 21b5d1
        //! Internal virtual copy constructor.
Packit Service 21b5d1
        virtual DataValue* clone_() const;
Packit Service 21b5d1
Packit Service 21b5d1
        //! Type used to store the data.
Packit Service 21b5d1
        typedef std::vector<byte> ValueType;
Packit Service 21b5d1
        // DATA
Packit Service 21b5d1
        ValueType value_;                       //!< Stores the data value
Packit Service 21b5d1
Packit Service 21b5d1
    }; // class DataValue
Packit Service 21b5d1
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief Abstract base class for a string based %Value type.
Packit Service 21b5d1
Packit Service 21b5d1
      Uses a std::string to store the value and implements defaults for
Packit Service 21b5d1
      most operations.
Packit Service 21b5d1
     */
Packit Service 21b5d1
    class EXIV2API StringValueBase : public Value {
Packit Service 21b5d1
    public:
Packit Service 21b5d1
        //! Shortcut for a %StringValueBase auto pointer.
Packit Service 21b5d1
        typedef std::auto_ptr<StringValueBase> AutoPtr;
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Creators
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        //! Constructor for subclasses
Packit Service 21b5d1
        explicit StringValueBase(TypeId typeId);
Packit Service 21b5d1
        //! Constructor for subclasses
Packit Service 21b5d1
        StringValueBase(TypeId typeId, const std::string& buf);
Packit Service 21b5d1
        //! Copy constructor
Packit Service 21b5d1
        StringValueBase(const StringValueBase& rhs);
Packit Service 21b5d1
        //! Virtual destructor.
Packit Service 21b5d1
        virtual ~StringValueBase();
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Manipulators
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        //! Read the value from buf. This default implementation uses buf as it is.
Packit Service 21b5d1
        virtual int read(const std::string& buf);
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Read the value from a character buffer.
Packit Service 21b5d1
Packit Service 21b5d1
          @note The byte order is required by the interface but not used by this
Packit Service 21b5d1
                method, so just use the default.
Packit Service 21b5d1
Packit Service 21b5d1
          @param buf Pointer to the data buffer to read from
Packit Service 21b5d1
          @param len Number of bytes in the data buffer
Packit Service 21b5d1
          @param byteOrder Byte order. Not needed.
Packit Service 21b5d1
Packit Service 21b5d1
          @return 0 if successful.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual int read(const byte* buf,
Packit Service 21b5d1
                         long len,
Packit Service 21b5d1
                         ByteOrder byteOrder =invalidByteOrder);
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Accessors
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        AutoPtr clone() const { return AutoPtr(clone_()); }
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Write value to a character data buffer.
Packit Service 21b5d1
Packit Service 21b5d1
          The user must ensure that the buffer has enough memory. Otherwise
Packit Service 21b5d1
          the call results in undefined behaviour.
Packit Service 21b5d1
Packit Service 21b5d1
          @note The byte order is required by the interface but not used by this
Packit Service 21b5d1
                method, so just use the default.
Packit Service 21b5d1
Packit Service 21b5d1
          @param buf Data buffer to write to.
Packit Service 21b5d1
          @param byteOrder Byte order. Not used.
Packit Service 21b5d1
          @return Number of characters written.
Packit Service 21b5d1
        */
Packit Service 21b5d1
        virtual long copy(byte* buf, ByteOrder byteOrder =invalidByteOrder) const;
Packit Service 21b5d1
        virtual long count() const;
Packit Service 21b5d1
        virtual long size() const;
Packit Service 21b5d1
        virtual long toLong(long n =0) const;
Packit Service 21b5d1
        virtual float toFloat(long n =0) const;
Packit Service 21b5d1
        virtual Rational toRational(long n =0) const;
Packit Service 21b5d1
        virtual std::ostream& write(std::ostream& os) const;
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
    protected:
Packit Service 21b5d1
        //! Assignment operator.
Packit Service 21b5d1
        StringValueBase& operator=(const StringValueBase& rhs);
Packit Service 21b5d1
        //! Internal virtual copy constructor.
Packit Service 21b5d1
        virtual StringValueBase* clone_() const =0;
Packit Service 21b5d1
Packit Service 21b5d1
    public:
Packit Service 21b5d1
        // DATA
Packit Service 21b5d1
        std::string value_;                     //!< Stores the string value.
Packit Service 21b5d1
Packit Service 21b5d1
    }; // class StringValueBase
Packit Service 21b5d1
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief %Value for string type.
Packit Service 21b5d1
Packit Service 21b5d1
      This can be a plain Ascii string or a multipe byte encoded string. It is
Packit Service 21b5d1
      left to caller to decode and encode the string to and from readable
Packit Service 21b5d1
      text if that is required.
Packit Service 21b5d1
    */
Packit Service 21b5d1
    class EXIV2API StringValue : public StringValueBase {
Packit Service 21b5d1
    public:
Packit Service 21b5d1
        //! Shortcut for a %StringValue auto pointer.
Packit Service 21b5d1
        typedef std::auto_ptr<StringValue> AutoPtr;
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Creators
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        //! Default constructor.
Packit Service 21b5d1
        StringValue();
Packit Service 21b5d1
        //! Constructor
Packit Service 21b5d1
        explicit StringValue(const std::string& buf);
Packit Service 21b5d1
        //! Virtual destructor.
Packit Service 21b5d1
        virtual ~StringValue();
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Accessors
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        AutoPtr clone() const { return AutoPtr(clone_()); }
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
    private:
Packit Service 21b5d1
        //! Internal virtual copy constructor.
Packit Service 21b5d1
        virtual StringValue* clone_() const;
Packit Service 21b5d1
Packit Service 21b5d1
    }; // class StringValue
Packit Service 21b5d1
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief %Value for an Ascii string type.
Packit Service 21b5d1
Packit Service 21b5d1
      This class is for null terminated single byte Ascii strings.
Packit Service 21b5d1
      This class also ensures that the string is null terminated.
Packit Service 21b5d1
     */
Packit Service 21b5d1
    class EXIV2API AsciiValue : public StringValueBase {
Packit Service 21b5d1
    public:
Packit Service 21b5d1
        //! Shortcut for a %AsciiValue auto pointer.
Packit Service 21b5d1
        typedef std::auto_ptr<AsciiValue> AutoPtr;
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Creators
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        //! Default constructor.
Packit Service 21b5d1
        AsciiValue();
Packit Service 21b5d1
        //! Constructor
Packit Service 21b5d1
        explicit AsciiValue(const std::string& buf);
Packit Service 21b5d1
        //! Virtual destructor.
Packit Service 21b5d1
        virtual ~AsciiValue();
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Manipulators
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        using StringValueBase::read;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Set the value to that of the string buf. Overrides base class
Packit Service 21b5d1
                 to append a terminating '\\0' character if buf doesn't end
Packit Service 21b5d1
                 with '\\0'.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual int read(const std::string& buf);
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Accessors
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        AutoPtr clone() const { return AutoPtr(clone_()); }
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Write the ASCII value up to the the first '\\0' character to an
Packit Service 21b5d1
                 output stream.  Any further characters are ignored and not
Packit Service 21b5d1
                 written to the output stream.
Packit Service 21b5d1
        */
Packit Service 21b5d1
        virtual std::ostream& write(std::ostream& os) const;
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
    private:
Packit Service 21b5d1
        //! Internal virtual copy constructor.
Packit Service 21b5d1
        virtual AsciiValue* clone_() const;
Packit Service 21b5d1
Packit Service 21b5d1
    }; // class AsciiValue
Packit Service 21b5d1
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief %Value for an Exif comment.
Packit Service 21b5d1
Packit Service 21b5d1
      This can be a plain Ascii string or a multipe byte encoded string. The
Packit Service 21b5d1
      comment is expected to be encoded in the character set indicated (default
Packit Service 21b5d1
      undefined), but this is not checked. It is left to caller to decode and
Packit Service 21b5d1
      encode the string to and from readable text if that is required.
Packit Service 21b5d1
    */
Packit Service 21b5d1
    class EXIV2API CommentValue : public StringValueBase {
Packit Service 21b5d1
    public:
Packit Service 21b5d1
        //! Character set identifiers for the character sets defined by %Exif
Packit Service 21b5d1
        enum CharsetId { ascii, jis, unicode, undefined,
Packit Service 21b5d1
                         invalidCharsetId, lastCharsetId };
Packit Service 21b5d1
        //! Information pertaining to the defined character sets
Packit Service 21b5d1
        struct CharsetTable {
Packit Service 21b5d1
            //! Constructor
Packit Service 21b5d1
            CharsetTable(CharsetId charsetId,
Packit Service 21b5d1
                         const char* name,
Packit Service 21b5d1
                         const char* code);
Packit Service 21b5d1
            CharsetId charsetId_;                   //!< Charset id
Packit Service 21b5d1
            const char* name_;                      //!< Name of the charset
Packit Service 21b5d1
            const char* code_;                      //!< Code of the charset
Packit Service 21b5d1
        }; // struct CharsetTable
Packit Service 21b5d1
Packit Service 21b5d1
        //! Charset information lookup functions. Implemented as a static class.
Packit Service 21b5d1
        class EXIV2API CharsetInfo {
Packit Service 21b5d1
            //! Prevent construction: not implemented.
Packit Service 21b5d1
            CharsetInfo() {}
Packit Service 21b5d1
            //! Prevent copy-construction: not implemented.
Packit Service 21b5d1
            CharsetInfo(const CharsetInfo&);
Packit Service 21b5d1
            //! Prevent assignment: not implemented.
Packit Service 21b5d1
            CharsetInfo& operator=(const CharsetInfo&);
Packit Service 21b5d1
Packit Service 21b5d1
        public:
Packit Service 21b5d1
            //! Return the name for a charset id
Packit Service 21b5d1
            static const char* name(CharsetId charsetId);
Packit Service 21b5d1
            //! Return the code for a charset id
Packit Service 21b5d1
            static const char* code(CharsetId charsetId);
Packit Service 21b5d1
            //! Return the charset id for a name
Packit Service 21b5d1
            static CharsetId charsetIdByName(const std::string& name);
Packit Service 21b5d1
            //! Return the charset id for a code
Packit Service 21b5d1
            static CharsetId charsetIdByCode(const std::string& code);
Packit Service 21b5d1
Packit Service 21b5d1
        private:
Packit Service 21b5d1
            static const CharsetTable charsetTable_[];
Packit Service 21b5d1
        }; // class CharsetInfo
Packit Service 21b5d1
Packit Service 21b5d1
        //! Shortcut for a %CommentValue auto pointer.
Packit Service 21b5d1
        typedef std::auto_ptr<CommentValue> AutoPtr;
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Creators
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        //! Default constructor.
Packit Service 21b5d1
        CommentValue();
Packit Service 21b5d1
        //! Constructor, uses read(const std::string& comment)
Packit Service 21b5d1
        explicit CommentValue(const std::string& comment);
Packit Service 21b5d1
        //! Virtual destructor.
Packit Service 21b5d1
        virtual ~CommentValue();
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Manipulators
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Read the value from a comment
Packit Service 21b5d1
Packit Service 21b5d1
          The format of \em comment is:
Packit Service 21b5d1
          
Packit Service 21b5d1
          [charset=["]Ascii|Jis|Unicode|Undefined["] ]comment
Packit Service 21b5d1
          
Packit Service 21b5d1
          The default charset is Undefined.
Packit Service 21b5d1
Packit Service 21b5d1
          @return 0 if successful
Packit Service 21b5d1
                  1 if an invalid character set is encountered
Packit Service 21b5d1
        */
Packit Service 21b5d1
        int read(const std::string& comment);
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Read the comment from a byte buffer.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        int read(const byte* buf, long len, ByteOrder byteOrder);
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Accessors
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        AutoPtr clone() const { return AutoPtr(clone_()); }
Packit Service 21b5d1
        long copy(byte* buf, ByteOrder byteOrder) const;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Write the comment in a format which can be read by
Packit Service 21b5d1
          read(const std::string& comment).
Packit Service 21b5d1
         */
Packit Service 21b5d1
        std::ostream& write(std::ostream& os) const;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Return the comment (without a charset="..." prefix)
Packit Service 21b5d1
Packit Service 21b5d1
          The comment is decoded to UTF-8. For Exif UNICODE comments, the
Packit Service 21b5d1
          function makes an attempt to correctly determine the character
Packit Service 21b5d1
          encoding of the value. Alternatively, the optional \em encoding
Packit Service 21b5d1
          parameter can be used to specify it.
Packit Service 21b5d1
Packit Service 21b5d1
          @param encoding Optional argument to specify the character encoding
Packit Service 21b5d1
              that the comment is encoded in, as an iconv(3) name. Only used
Packit Service 21b5d1
              for Exif UNICODE comments.
Packit Service 21b5d1
Packit Service 21b5d1
          @return A string containing the comment converted to UTF-8.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        std::string comment(const char* encoding =0) const;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Determine the character encoding that was used to encode the
Packit Service 21b5d1
              UNICODE comment value as an iconv(3) name.
Packit Service 21b5d1
Packit Service 21b5d1
          If the comment \em c starts with a BOM, the BOM is interpreted and
Packit Service 21b5d1
          removed from the string.
Packit Service 21b5d1
Packit Service 21b5d1
          Todo: Implement rules to guess if the comment is UTF-8 encoded.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        const char* detectCharset(std::string& c) const;
Packit Service 21b5d1
        //! Return the Exif charset id of the comment
Packit Service 21b5d1
        CharsetId charsetId() const;
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
    private:
Packit Service 21b5d1
        //! Internal virtual copy constructor.
Packit Service 21b5d1
        virtual CommentValue* clone_() const;
Packit Service 21b5d1
Packit Service 21b5d1
    public:
Packit Service 21b5d1
        // DATA
Packit Service 21b5d1
        ByteOrder byteOrder_;      //!< Byte order of the comment string that was read
Packit Service 21b5d1
Packit Service 21b5d1
    }; // class CommentValue
Packit Service 21b5d1
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief Base class for all Exiv2 values used to store XMP property values.
Packit Service 21b5d1
     */
Packit Service 21b5d1
    class EXIV2API XmpValue : public Value {
Packit Service 21b5d1
    public:
Packit Service 21b5d1
        //! Shortcut for a %XmpValue auto pointer.
Packit Service 21b5d1
        typedef std::auto_ptr<XmpValue> AutoPtr;
Packit Service 21b5d1
Packit Service 21b5d1
        //! XMP array types.
Packit Service 21b5d1
        enum XmpArrayType { xaNone, xaAlt, xaBag, xaSeq };
Packit Service 21b5d1
        //! XMP structure indicator.
Packit Service 21b5d1
        enum XmpStruct { xsNone, xsStruct };
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Creators
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        explicit XmpValue(TypeId typeId);
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Accessors
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        //! Return XMP array type, indicates if an XMP value is an array.
Packit Service 21b5d1
        XmpArrayType xmpArrayType() const;
Packit Service 21b5d1
        //! Return XMP struct, indicates if an XMP value is a structure.
Packit Service 21b5d1
        XmpStruct xmpStruct() const;
Packit Service 21b5d1
        virtual long size() const;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Write value to a character data buffer.
Packit Service 21b5d1
Packit Service 21b5d1
          The user must ensure that the buffer has enough memory. Otherwise
Packit Service 21b5d1
          the call results in undefined behaviour.
Packit Service 21b5d1
Packit Service 21b5d1
          @note The byte order is required by the interface but not used by this
Packit Service 21b5d1
                method, so just use the default.
Packit Service 21b5d1
Packit Service 21b5d1
          @param buf Data buffer to write to.
Packit Service 21b5d1
          @param byteOrder Byte order. Not used.
Packit Service 21b5d1
          @return Number of characters written.
Packit Service 21b5d1
        */
Packit Service 21b5d1
        virtual long copy(byte* buf, ByteOrder byteOrder =invalidByteOrder) const;
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Manipulators
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        //! Set the XMP array type to indicate that an XMP value is an array.
Packit Service 21b5d1
        void setXmpArrayType(XmpArrayType xmpArrayType);
Packit Service 21b5d1
        //! Set the XMP struct type to indicate that an XMP value is a structure.
Packit Service 21b5d1
        void setXmpStruct(XmpStruct xmpStruct =xsStruct);
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Read the value from a character buffer.
Packit Service 21b5d1
Packit Service 21b5d1
          Uses read(const std::string& buf)
Packit Service 21b5d1
Packit Service 21b5d1
          @note The byte order is required by the interface but not used by this
Packit Service 21b5d1
                method, so just use the default.
Packit Service 21b5d1
Packit Service 21b5d1
          @param buf Pointer to the data buffer to read from
Packit Service 21b5d1
          @param len Number of bytes in the data buffer
Packit Service 21b5d1
          @param byteOrder Byte order. Not needed.
Packit Service 21b5d1
Packit Service 21b5d1
          @return 0 if successful.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual int read(const byte* buf,
Packit Service 21b5d1
                         long len,
Packit Service 21b5d1
                         ByteOrder byteOrder =invalidByteOrder);
Packit Service 21b5d1
        virtual int read(const std::string& buf) =0;
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Return XMP array type for an array Value TypeId, xaNone if
Packit Service 21b5d1
                 \em typeId is not an XMP array value type.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        static XmpArrayType xmpArrayType(TypeId typeId);
Packit Service 21b5d1
Packit Service 21b5d1
    protected:
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Assignment operator. Protected so that it can only be used
Packit Service 21b5d1
                 by subclasses but not directly.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        XmpValue& operator=(const XmpValue& rhs);
Packit Service 21b5d1
Packit Service 21b5d1
    private:
Packit Service 21b5d1
        // DATA
Packit Service 21b5d1
        XmpArrayType xmpArrayType_;             //!< Type of XMP array
Packit Service 21b5d1
        XmpStruct    xmpStruct_;                //!< XMP structure indicator
Packit Service 21b5d1
Packit Service 21b5d1
    }; // class XmpValue
Packit Service 21b5d1
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief %Value type suitable for simple XMP properties and
Packit Service 21b5d1
             XMP nodes of complex types which are not parsed into
Packit Service 21b5d1
             specific values.
Packit Service 21b5d1
Packit Service 21b5d1
      Uses a std::string to store the value.
Packit Service 21b5d1
     */
Packit Service 21b5d1
    class EXIV2API XmpTextValue : public XmpValue {
Packit Service 21b5d1
    public:
Packit Service 21b5d1
        //! Shortcut for a %XmpTextValue auto pointer.
Packit Service 21b5d1
        typedef std::auto_ptr<XmpTextValue> AutoPtr;
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Creators
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        //! Constructor.
Packit Service 21b5d1
        XmpTextValue();
Packit Service 21b5d1
        //! Constructor, reads the value from a string.
Packit Service 21b5d1
        explicit XmpTextValue(const std::string& buf);
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Manipulators
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        using XmpValue::read;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Read a simple property value from \em buf to set the value.
Packit Service 21b5d1
Packit Service 21b5d1
          Sets the value to the contents of \em buf. A optional keyword,
Packit Service 21b5d1
          \em type is supported to set the XMP value type. This is useful for
Packit Service 21b5d1
          complex value types for which Exiv2 does not have direct support.
Packit Service 21b5d1
Packit Service 21b5d1
          The format of \em buf is:
Packit Service 21b5d1
          
Packit Service 21b5d1
          [type=["]Alt|Bag|Seq|Struct["] ]text
Packit Service 21b5d1
          
Packit Service 21b5d1
Packit Service 21b5d1
          @return 0 if successful.
Packit Service 21b5d1
         */
Packit Service 21b5d1
Packit Service 21b5d1
        virtual int read(const std::string& buf);
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Accessors
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        AutoPtr clone() const;
Packit Service 21b5d1
        long size() const;
Packit Service 21b5d1
        virtual long count() const;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Convert the value to a long.
Packit Service 21b5d1
                 The optional parameter \em n is not used and is ignored.
Packit Service 21b5d1
Packit Service 21b5d1
          @return The converted value.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual long toLong(long n =0) const;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Convert the value to a float.
Packit Service 21b5d1
                 The optional parameter \em n is not used and is ignored.
Packit Service 21b5d1
Packit Service 21b5d1
          @return The converted value.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual float toFloat(long n =0) const;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Convert the value to a Rational.
Packit Service 21b5d1
                 The optional parameter \em n is not used and is ignored.
Packit Service 21b5d1
Packit Service 21b5d1
          @return The converted value.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual Rational toRational(long n =0) const;
Packit Service 21b5d1
        virtual std::ostream& write(std::ostream& os) const;
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
    private:
Packit Service 21b5d1
        //! Internal virtual copy constructor.
Packit Service 21b5d1
        virtual XmpTextValue* clone_() const;
Packit Service 21b5d1
Packit Service 21b5d1
    public:
Packit Service 21b5d1
        // DATA
Packit Service 21b5d1
        std::string value_;                     //!< Stores the string values.
Packit Service 21b5d1
Packit Service 21b5d1
    }; // class XmpTextValue
Packit Service 21b5d1
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief %Value type for simple arrays. Each item in the array is a simple
Packit Service 21b5d1
             value, without qualifiers. The array may be an ordered (\em seq),
Packit Service 21b5d1
             unordered (\em bag) or alternative array (\em alt). The array
Packit Service 21b5d1
             items must not contain qualifiers. For language alternatives use
Packit Service 21b5d1
             LangAltValue.
Packit Service 21b5d1
Packit Service 21b5d1
      Uses a vector of std::string to store the value(s).
Packit Service 21b5d1
     */
Packit Service 21b5d1
    class EXIV2API XmpArrayValue : public XmpValue {
Packit Service 21b5d1
    public:
Packit Service 21b5d1
        //! Shortcut for a %XmpArrayValue auto pointer.
Packit Service 21b5d1
        typedef std::auto_ptr<XmpArrayValue> AutoPtr;
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Creators
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        //! Constructor. \em typeId can be one of xmpBag, xmpSeq or xmpAlt.
Packit Service 21b5d1
        explicit XmpArrayValue(TypeId typeId =xmpBag);
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Manipulators
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        using XmpValue::read;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Read a simple property value from \em buf and append it
Packit Service 21b5d1
                 to the value.
Packit Service 21b5d1
Packit Service 21b5d1
          Appends \em buf to the value after the last existing array element.
Packit Service 21b5d1
          Subsequent calls will therefore populate multiple array elements in
Packit Service 21b5d1
          the order they are read.
Packit Service 21b5d1
Packit Service 21b5d1
          @return 0 if successful.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual int read(const std::string& buf);
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Accessors
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        AutoPtr clone() const;
Packit Service 21b5d1
        virtual long count() const;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Return the n-th component of the value as a string.
Packit Service 21b5d1
                 The behaviour of this method may be undefined if there is no
Packit Service 21b5d1
                 n-th component.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual std::string toString(long n) const;
Packit Service 21b5d1
        virtual long toLong(long n =0) const;
Packit Service 21b5d1
        virtual float toFloat(long n =0) const;
Packit Service 21b5d1
        virtual Rational toRational(long n =0) const;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Write all elements of the value to \em os, separated by commas.
Packit Service 21b5d1
Packit Service 21b5d1
          @note The output of this method cannot directly be used as the parameter
Packit Service 21b5d1
                for read().
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual std::ostream& write(std::ostream& os) const;
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
    private:
Packit Service 21b5d1
        //! Internal virtual copy constructor.
Packit Service 21b5d1
        virtual XmpArrayValue* clone_() const;
Packit Service 21b5d1
Packit Service 21b5d1
        std::vector<std::string> value_;        //!< Stores the string values.
Packit Service 21b5d1
Packit Service 21b5d1
    }; // class XmpArrayValue
Packit Service 21b5d1
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief %LangAltValueComparator
Packit Service 21b5d1
Packit Service 21b5d1
      #1058
Packit Service 21b5d1
      https://www.adobe.com/content/dam/Adobe/en/devnet/xmp/pdfs/XMPSpecificationPart1.pdf
Packit Service 21b5d1
      XMP spec chapter B.4 (page 42) the xml:lang qualifier is to be compared case insensitive.
Packit Service 21b5d1
      */
Packit Service 21b5d1
    struct LangAltValueComparator {
Packit Service 21b5d1
        //! LangAltValueComparator comparison case insensitive function
Packit Service 21b5d1
        bool operator() (const std::string& str1, const std::string& str2) const
Packit Service 21b5d1
        {
Packit Service 21b5d1
            int result = str1.size() < str2.size() ?  1
Packit Service 21b5d1
                       : str1.size() > str2.size() ? -1
Packit Service 21b5d1
                       : 0
Packit Service 21b5d1
                       ;
Packit Service 21b5d1
            std::string::const_iterator c1 = str1.begin();
Packit Service 21b5d1
            std::string::const_iterator c2 = str2.begin();
Packit Service 21b5d1
            if (  result==0 ) for (
Packit Service 21b5d1
                ; result==0 && c1 != str1.end()
Packit Service 21b5d1
                ; ++c1, ++c2
Packit Service 21b5d1
                ) {
Packit Service 21b5d1
                result = tolower(*c1) < tolower(*c2) ?  1
Packit Service 21b5d1
                       : tolower(*c1) > tolower(*c2) ? -1
Packit Service 21b5d1
                       : 0
Packit Service 21b5d1
                       ;
Packit Service 21b5d1
            }
Packit Service 21b5d1
            return result < 0 ;
Packit Service 21b5d1
        }
Packit Service 21b5d1
    };
Packit Service 21b5d1
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief %Value type for XMP language alternative properties.
Packit Service 21b5d1
Packit Service 21b5d1
      A language alternative is an array consisting of simple text values,
Packit Service 21b5d1
      each of which has a language qualifier.
Packit Service 21b5d1
     */
Packit Service 21b5d1
    class EXIV2API LangAltValue : public XmpValue {
Packit Service 21b5d1
    public:
Packit Service 21b5d1
        //! Shortcut for a %LangAltValue auto pointer.
Packit Service 21b5d1
        typedef std::auto_ptr<LangAltValue> AutoPtr;
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Creators
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        //! Constructor.
Packit Service 21b5d1
        LangAltValue();
Packit Service 21b5d1
        //! Constructor, reads the value from a string.
Packit Service 21b5d1
        explicit LangAltValue(const std::string& buf);
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Manipulators
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        using XmpValue::read;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Read a simple property value from \em buf and append it
Packit Service 21b5d1
                 to the value.
Packit Service 21b5d1
Packit Service 21b5d1
          Appends \em buf to the value after the last existing array element.
Packit Service 21b5d1
          Subsequent calls will therefore populate multiple array elements in
Packit Service 21b5d1
          the order they are read.
Packit Service 21b5d1
Packit Service 21b5d1
          The format of \em buf is:
Packit Service 21b5d1
          
Packit Service 21b5d1
          [lang=["]language code["] ]text
Packit Service 21b5d1
          
Packit Service 21b5d1
          The XMP default language code x-default is used if
Packit Service 21b5d1
          \em buf doesn't start with the keyword lang.
Packit Service 21b5d1
Packit Service 21b5d1
          @return 0 if successful.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual int read(const std::string& buf);
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Accessors
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        AutoPtr clone() const;
Packit Service 21b5d1
        virtual long count() const;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Return the text value associated with the default language
Packit Service 21b5d1
                 qualifier \c x-default. The parameter \em n is not used, but
Packit Service 21b5d1
                 it is suggested that only 0 is passed in. Returns an empty
Packit Service 21b5d1
                 string and sets the ok-flag to \c false if there is no
Packit Service 21b5d1
                 default value.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual std::string toString(long n) const;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Return the text value associated with the language qualifier
Packit Service 21b5d1
                 \em qualifier. Returns an empty string and sets the ok-flag
Packit Service 21b5d1
                 to \c false if there is no entry for the language qualifier.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        std::string toString(const std::string& qualifier) const;
Packit Service 21b5d1
        virtual long toLong(long n =0) const;
Packit Service 21b5d1
        virtual float toFloat(long n =0) const;
Packit Service 21b5d1
        virtual Rational toRational(long n =0) const;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Write all elements of the value to \em os, separated by commas.
Packit Service 21b5d1
Packit Service 21b5d1
          @note The output of this method cannot directly be used as the parameter
Packit Service 21b5d1
                for read().
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual std::ostream& write(std::ostream& os) const;
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
    private:
Packit Service 21b5d1
        //! Internal virtual copy constructor.
Packit Service 21b5d1
        virtual LangAltValue* clone_() const;
Packit Service 21b5d1
Packit Service 21b5d1
    public:
Packit Service 21b5d1
        //! Type used to store language alternative arrays.
Packit Service 21b5d1
        typedef std::map<std::string, std::string,LangAltValueComparator>  ValueType;
Packit Service 21b5d1
        // DATA
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Map to store the language alternative values. The language
Packit Service 21b5d1
                 qualifier is used as the key for the map entries.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        ValueType value_;
Packit Service 21b5d1
Packit Service 21b5d1
    }; // class LangAltValue
Packit Service 21b5d1
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief %Value for simple ISO 8601 dates
Packit Service 21b5d1
Packit Service 21b5d1
      This class is limited to parsing simple date strings in the ISO 8601
Packit Service 21b5d1
      format CCYYMMDD (century, year, month, day).
Packit Service 21b5d1
     */
Packit Service 21b5d1
    class EXIV2API DateValue : public Value {
Packit Service 21b5d1
    public:
Packit Service 21b5d1
        //! Shortcut for a %DateValue auto pointer.
Packit Service 21b5d1
        typedef std::auto_ptr<DateValue> AutoPtr;
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Creators
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        //! Default constructor.
Packit Service 21b5d1
        DateValue();
Packit Service 21b5d1
        //! Constructor
Packit Service 21b5d1
        DateValue(int year, int month, int day);
Packit Service 21b5d1
        //! Virtual destructor.
Packit Service 21b5d1
        virtual ~DateValue();
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        //! Simple Date helper structure
Packit Service 21b5d1
        struct EXIV2API Date {
Packit Service 21b5d1
            Date() : year(0), month(0), day(0) {}
Packit Service 21b5d1
            int year;                           //!< Year
Packit Service 21b5d1
            int month;                          //!< Month
Packit Service 21b5d1
            int day;                            //!< Day
Packit Service 21b5d1
        };
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Manipulators
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Read the value from a character buffer.
Packit Service 21b5d1
Packit Service 21b5d1
          @note The byte order is required by the interface but not used by this
Packit Service 21b5d1
                method, so just use the default.
Packit Service 21b5d1
Packit Service 21b5d1
          @param buf Pointer to the data buffer to read from
Packit Service 21b5d1
          @param len Number of bytes in the data buffer
Packit Service 21b5d1
          @param byteOrder Byte order. Not needed.
Packit Service 21b5d1
Packit Service 21b5d1
          @return 0 if successful
Packit Service 21b5d1
                  1 in case of an unsupported date format
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual int read(const byte* buf,
Packit Service 21b5d1
                         long len,
Packit Service 21b5d1
                         ByteOrder byteOrder =invalidByteOrder);
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Set the value to that of the string buf.
Packit Service 21b5d1
Packit Service 21b5d1
          @param buf String containing the date
Packit Service 21b5d1
Packit Service 21b5d1
          @return 0 if successful
Packit Service 21b5d1
                  1 in case of an unsupported date format
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual int read(const std::string& buf);
Packit Service 21b5d1
        //! Set the date
Packit Service 21b5d1
        void setDate(const Date& src);
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Accessors
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        AutoPtr clone() const { return AutoPtr(clone_()); }
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Write value to a character data buffer.
Packit Service 21b5d1
Packit Service 21b5d1
          The user must ensure that the buffer has enough memory. Otherwise
Packit Service 21b5d1
          the call results in undefined behaviour.
Packit Service 21b5d1
Packit Service 21b5d1
          @note The byte order is required by the interface but not used by this
Packit Service 21b5d1
                method, so just use the default.
Packit Service 21b5d1
Packit Service 21b5d1
          @param buf Data buffer to write to.
Packit Service 21b5d1
          @param byteOrder Byte order. Not used.
Packit Service 21b5d1
          @return Number of characters written.
Packit Service 21b5d1
        */
Packit Service 21b5d1
        virtual long copy(byte* buf, ByteOrder byteOrder =invalidByteOrder) const;
Packit Service 21b5d1
        //! Return date struct containing date information
Packit Service 21b5d1
        virtual const Date& getDate() const;
Packit Service 21b5d1
        virtual long count() const;
Packit Service 21b5d1
        virtual long size() const;
Packit Service 21b5d1
        virtual std::ostream& write(std::ostream& os) const;
Packit Service 21b5d1
        //! Return the value as a UNIX calender time converted to long.
Packit Service 21b5d1
        virtual long toLong(long n =0) const;
Packit Service 21b5d1
        //! Return the value as a UNIX calender time converted to float.
Packit Service 21b5d1
        virtual float toFloat(long n =0) const;
Packit Service 21b5d1
        //! Return the value as a UNIX calender time  converted to Rational.
Packit Service 21b5d1
        virtual Rational toRational(long n =0) const;
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
    private:
Packit Service 21b5d1
        //! Internal virtual copy constructor.
Packit Service 21b5d1
        virtual DateValue* clone_() const;
Packit Service 21b5d1
Packit Service 21b5d1
        // DATA
Packit Service 21b5d1
        Date date_;
Packit Service 21b5d1
Packit Service 21b5d1
    }; // class DateValue
Packit Service 21b5d1
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
     @brief %Value for simple ISO 8601 times.
Packit Service 21b5d1
Packit Service 21b5d1
     This class is limited to handling simple time strings in the ISO 8601
Packit Service 21b5d1
     format HHMMSS±HHMM where HHMMSS refers to local hour, minute and
Packit Service 21b5d1
     seconds and ±HHMM refers to hours and minutes ahead or behind
Packit Service 21b5d1
     Universal Coordinated Time.
Packit Service 21b5d1
     */
Packit Service 21b5d1
    class EXIV2API TimeValue : public Value {
Packit Service 21b5d1
    public:
Packit Service 21b5d1
        //! Shortcut for a %TimeValue auto pointer.
Packit Service 21b5d1
        typedef std::auto_ptr<TimeValue> AutoPtr;
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Creators
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        //! Default constructor.
Packit Service 21b5d1
        TimeValue();
Packit Service 21b5d1
        //! Constructor
Packit Service 21b5d1
        TimeValue(int hour, int minute, int second =0,
Packit Service 21b5d1
                  int tzHour =0, int tzMinute =0);
Packit Service 21b5d1
Packit Service 21b5d1
        //! Virtual destructor.
Packit Service 21b5d1
        virtual ~TimeValue();
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        //! Simple Time helper structure
Packit Service 21b5d1
        struct Time
Packit Service 21b5d1
        {
Packit Service 21b5d1
            Time() : hour(0), minute(0), second(0), tzHour(0), tzMinute(0) {}
Packit Service 21b5d1
Packit Service 21b5d1
            int hour;                           //!< Hour
Packit Service 21b5d1
            int minute;                         //!< Minute
Packit Service 21b5d1
            int second;                         //!< Second
Packit Service 21b5d1
            int tzHour;                         //!< Hours ahead or behind UTC
Packit Service 21b5d1
            int tzMinute;                       //!< Minutes ahead or behind UTC
Packit Service 21b5d1
        };
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Manipulators
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Read the value from a character buffer.
Packit Service 21b5d1
Packit Service 21b5d1
          @note The byte order is required by the interface but not used by this
Packit Service 21b5d1
                method, so just use the default.
Packit Service 21b5d1
Packit Service 21b5d1
          @param buf Pointer to the data buffer to read from
Packit Service 21b5d1
          @param len Number of bytes in the data buffer
Packit Service 21b5d1
          @param byteOrder Byte order. Not needed.
Packit Service 21b5d1
Packit Service 21b5d1
          @return 0 if successful
Packit Service 21b5d1
                  1 in case of an unsupported time format
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual int read(const byte* buf,
Packit Service 21b5d1
                         long len,
Packit Service 21b5d1
                         ByteOrder byteOrder =invalidByteOrder);
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Set the value to that of the string buf.
Packit Service 21b5d1
Packit Service 21b5d1
          @param buf String containing the time.
Packit Service 21b5d1
Packit Service 21b5d1
          @return 0 if successful
Packit Service 21b5d1
                  1 in case of an unsupported time format
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual int read(const std::string& buf);
Packit Service 21b5d1
        //! Set the time
Packit Service 21b5d1
        void setTime(const Time& src);
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Accessors
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        AutoPtr clone() const { return AutoPtr(clone_()); }
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Write value to a character data buffer.
Packit Service 21b5d1
Packit Service 21b5d1
          The user must ensure that the buffer has enough memory. Otherwise
Packit Service 21b5d1
          the call results in undefined behaviour.
Packit Service 21b5d1
Packit Service 21b5d1
          @note The byte order is required by the interface but not used by this
Packit Service 21b5d1
                method, so just use the default.
Packit Service 21b5d1
Packit Service 21b5d1
          @param buf Data buffer to write to.
Packit Service 21b5d1
          @param byteOrder Byte order. Not used.
Packit Service 21b5d1
          @return Number of characters written.
Packit Service 21b5d1
        */
Packit Service 21b5d1
        virtual long copy(byte* buf, ByteOrder byteOrder =invalidByteOrder) const;
Packit Service 21b5d1
        //! Return time struct containing time information
Packit Service 21b5d1
        virtual const Time& getTime() const;
Packit Service 21b5d1
        virtual long count() const;
Packit Service 21b5d1
        virtual long size() const;
Packit Service 21b5d1
        virtual std::ostream& write(std::ostream& os) const;
Packit Service 21b5d1
        //! Returns number of seconds in the day in UTC.
Packit Service 21b5d1
        virtual long toLong(long n =0) const;
Packit Service 21b5d1
        //! Returns number of seconds in the day in UTC converted to float.
Packit Service 21b5d1
        virtual float toFloat(long n =0) const;
Packit Service 21b5d1
        //! Returns number of seconds in the day in UTC converted to Rational.
Packit Service 21b5d1
        virtual Rational toRational(long n =0) const;
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
    private:
Packit Service 21b5d1
        //! @name Manipulators
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Set time from \em buf if it conforms to \em format
Packit Service 21b5d1
                 (3 input items).
Packit Service 21b5d1
Packit Service 21b5d1
          This function only sets the hour, minute and second parts of time_.
Packit Service 21b5d1
Packit Service 21b5d1
          @param buf    A 0 terminated C-string containing the time to parse.
Packit Service 21b5d1
          @param format Format string for sscanf().
Packit Service 21b5d1
          @return 0 if successful, else 1.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        int scanTime3(const char* buf, const char* format);
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Set time from \em buf if it conforms to \em format
Packit Service 21b5d1
                 (6 input items).
Packit Service 21b5d1
Packit Service 21b5d1
          This function sets all parts of time_.
Packit Service 21b5d1
Packit Service 21b5d1
          @param buf    A 0 terminated C-string containing the time to parse.
Packit Service 21b5d1
          @param format Format string for sscanf().
Packit Service 21b5d1
          @return 0 if successful, else 1.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        int scanTime6(const char* buf, const char* format);
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Accessors
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        //! Internal virtual copy constructor.
Packit Service 21b5d1
        virtual TimeValue* clone_() const;
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        // DATA
Packit Service 21b5d1
        Time time_;
Packit Service 21b5d1
Packit Service 21b5d1
    }; // class TimeValue
Packit Service 21b5d1
Packit Service 21b5d1
    //! Template to determine the TypeId for a type T
Packit Service 21b5d1
    template<typename T> TypeId getType();
Packit Service 21b5d1
Packit Service 21b5d1
    //! Specialization for an unsigned short
Packit Service 21b5d1
    template<> inline TypeId getType<uint16_t>() { return unsignedShort; }
Packit Service 21b5d1
    //! Specialization for an unsigned long
Packit Service 21b5d1
    template<> inline TypeId getType<uint32_t>() { return unsignedLong; }
Packit Service 21b5d1
    //! Specialization for an unsigned rational
Packit Service 21b5d1
    template<> inline TypeId getType<URational>() { return unsignedRational; }
Packit Service 21b5d1
    //! Specialization for a signed short
Packit Service 21b5d1
    template<> inline TypeId getType<int16_t>() { return signedShort; }
Packit Service 21b5d1
    //! Specialization for a signed long
Packit Service 21b5d1
    template<> inline TypeId getType<int32_t>() { return signedLong; }
Packit Service 21b5d1
    //! Specialization for a signed rational
Packit Service 21b5d1
    template<> inline TypeId getType<Rational>() { return signedRational; }
Packit Service 21b5d1
    //! Specialization for a float
Packit Service 21b5d1
    template<> inline TypeId getType<float>() { return tiffFloat; }
Packit Service 21b5d1
    //! Specialization for a double
Packit Service 21b5d1
    template<> inline TypeId getType<double>() { return tiffDouble; }
Packit Service 21b5d1
Packit Service 21b5d1
    // No default implementation: let the compiler/linker complain
Packit Service 21b5d1
    // template<typename T> inline TypeId getType() { return invalid; }
Packit Service 21b5d1
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief Template for a %Value of a basic type. This is used for unsigned
Packit Service 21b5d1
             and signed short, long and rationals.
Packit Service 21b5d1
     */
Packit Service 21b5d1
    template<typename T>
Packit Service 21b5d1
    class ValueType : public Value {
Packit Service 21b5d1
    public:
Packit Service 21b5d1
        //! Shortcut for a %ValueType\<T\> auto pointer.
Packit Service 21b5d1
        typedef std::auto_ptr<ValueType<T> > AutoPtr;
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Creators
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        //! Default Constructor.
Packit Service 21b5d1
        ValueType();
Packit Service 21b5d1
        //! Constructor.
Packit Service 21b5d1
        // The default c'tor and this one can be combined, but that causes MSVC 7.1 to fall on its nose
Packit Service 21b5d1
        explicit ValueType(TypeId typeId);
Packit Service 21b5d1
        //! Constructor.
Packit Service 21b5d1
        ValueType(const byte* buf, long len, ByteOrder byteOrder, TypeId typeId =getType<T>());
Packit Service 21b5d1
        //! Constructor.
Packit Service 21b5d1
        explicit ValueType(const T& val, TypeId typeId =getType<T>());
Packit Service 21b5d1
        //! Copy constructor
Packit Service 21b5d1
        ValueType(const ValueType<T>& rhs);
Packit Service 21b5d1
        //! Virtual destructor.
Packit Service 21b5d1
        virtual ~ValueType();
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Manipulators
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        //! Assignment operator.
Packit Service 21b5d1
        ValueType<T>& operator=(const ValueType<T>& rhs);
Packit Service 21b5d1
        virtual int read(const byte* buf, long len, ByteOrder byteOrder);
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Set the data from a string of values of type T (e.g.,
Packit Service 21b5d1
                 "0 1 2 3" or "1/2 1/3 1/4" depending on what T is).
Packit Service 21b5d1
                 Generally, the accepted input format is the same as that
Packit Service 21b5d1
                 produced by the write() method.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual int read(const std::string& buf);
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Set the data area. This method copies (clones) the buffer
Packit Service 21b5d1
                 pointed to by buf.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual int setDataArea(const byte* buf, long len);
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        //! @name Accessors
Packit Service 21b5d1
        //@{
Packit Service 21b5d1
        AutoPtr clone() const { return AutoPtr(clone_()); }
Packit Service 21b5d1
        virtual long copy(byte* buf, ByteOrder byteOrder) const;
Packit Service 21b5d1
        virtual long count() const;
Packit Service 21b5d1
        virtual long size() const;
Packit Service 21b5d1
        virtual std::ostream& write(std::ostream& os) const;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Return the n-th component of the value as a string.
Packit Service 21b5d1
                 The behaviour of this method may be undefined if there is no
Packit Service 21b5d1
                 n-th
Packit Service 21b5d1
                 component.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual std::string toString(long n) const;
Packit Service 21b5d1
        virtual long toLong(long n =0) const;
Packit Service 21b5d1
        virtual float toFloat(long n =0) const;
Packit Service 21b5d1
        virtual Rational toRational(long n =0) const;
Packit Service 21b5d1
        //! Return the size of the data area.
Packit Service 21b5d1
        virtual long sizeDataArea() const;
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief Return a copy of the data area in a DataBuf. The caller owns
Packit Service 21b5d1
                 this copy and DataBuf ensures that it will be deleted.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        virtual DataBuf dataArea() const;
Packit Service 21b5d1
        //@}
Packit Service 21b5d1
Packit Service 21b5d1
        //! Container for values
Packit Service 21b5d1
        typedef std::vector<T> ValueList;
Packit Service 21b5d1
        //! Iterator type defined for convenience.
Packit Service 21b5d1
        typedef typename std::vector<T>::iterator iterator;
Packit Service 21b5d1
        //! Const iterator type defined for convenience.
Packit Service 21b5d1
        typedef typename std::vector<T>::const_iterator const_iterator;
Packit Service 21b5d1
Packit Service 21b5d1
        // DATA
Packit Service 21b5d1
        /*!
Packit Service 21b5d1
          @brief The container for all values. In your application, if you know
Packit Service 21b5d1
                 what subclass of Value you're dealing with (and possibly the T)
Packit Service 21b5d1
                 then you can access this STL container through the usual
Packit Service 21b5d1
                 standard library functions.
Packit Service 21b5d1
         */
Packit Service 21b5d1
        ValueList value_;
Packit Service 21b5d1
Packit Service 21b5d1
    private:
Packit Service 21b5d1
        //! Internal virtual copy constructor.
Packit Service 21b5d1
        virtual ValueType<T>* clone_() const;
Packit Service 21b5d1
Packit Service 21b5d1
        // DATA
Packit Service 21b5d1
        //! Pointer to the buffer, 0 if none has been allocated
Packit Service 21b5d1
        byte* pDataArea_;
Packit Service 21b5d1
        //! The current size of the buffer
Packit Service 21b5d1
        long sizeDataArea_;
Packit Service 21b5d1
    }; // class ValueType
Packit Service 21b5d1
Packit Service 21b5d1
    //! Unsigned short value type
Packit Service 21b5d1
    typedef ValueType<uint16_t> UShortValue;
Packit Service 21b5d1
    //! Unsigned long value type
Packit Service 21b5d1
    typedef ValueType<uint32_t> ULongValue;
Packit Service 21b5d1
    //! Unsigned rational value type
Packit Service 21b5d1
    typedef ValueType<URational> URationalValue;
Packit Service 21b5d1
    //! Signed short value type
Packit Service 21b5d1
    typedef ValueType<int16_t> ShortValue;
Packit Service 21b5d1
    //! Signed long value type
Packit Service 21b5d1
    typedef ValueType<int32_t> LongValue;
Packit Service 21b5d1
    //! Signed rational value type
Packit Service 21b5d1
    typedef ValueType<Rational> RationalValue;
Packit Service 21b5d1
    //! Float value type
Packit Service 21b5d1
    typedef ValueType<float> FloatValue;
Packit Service 21b5d1
    //! Double value type
Packit Service 21b5d1
    typedef ValueType<double> DoubleValue;
Packit Service 21b5d1
Packit Service 21b5d1
// *****************************************************************************
Packit Service 21b5d1
// free functions, template and inline definitions
Packit Service 21b5d1
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief Read a value of type T from the data buffer.
Packit Service 21b5d1
Packit Service 21b5d1
      We need this template function for the ValueType template classes.
Packit Service 21b5d1
      There are only specializations of this function available; no default
Packit Service 21b5d1
      implementation is provided.
Packit Service 21b5d1
Packit Service 21b5d1
      @param buf Pointer to the data buffer to read from.
Packit Service 21b5d1
      @param byteOrder Applicable byte order (little or big endian).
Packit Service 21b5d1
      @return A value of type T.
Packit Service 21b5d1
     */
Packit Service 21b5d1
    template<typename T> T getValue(const byte* buf, ByteOrder byteOrder);
Packit Service 21b5d1
    // Specialization for a 2 byte unsigned short value.
Packit Service 21b5d1
    template<>
Packit Service 21b5d1
    inline uint16_t getValue(const byte* buf, ByteOrder byteOrder)
Packit Service 21b5d1
    {
Packit Service 21b5d1
        return getUShort(buf, byteOrder);
Packit Service 21b5d1
    }
Packit Service 21b5d1
    // Specialization for a 4 byte unsigned long value.
Packit Service 21b5d1
    template<>
Packit Service 21b5d1
    inline uint32_t getValue(const byte* buf, ByteOrder byteOrder)
Packit Service 21b5d1
    {
Packit Service 21b5d1
        return getULong(buf, byteOrder);
Packit Service 21b5d1
    }
Packit Service 21b5d1
    // Specialization for an 8 byte unsigned rational value.
Packit Service 21b5d1
    template<>
Packit Service 21b5d1
    inline URational getValue(const byte* buf, ByteOrder byteOrder)
Packit Service 21b5d1
    {
Packit Service 21b5d1
        return getURational(buf, byteOrder);
Packit Service 21b5d1
    }
Packit Service 21b5d1
    // Specialization for a 2 byte signed short value.
Packit Service 21b5d1
    template<>
Packit Service 21b5d1
    inline int16_t getValue(const byte* buf, ByteOrder byteOrder)
Packit Service 21b5d1
    {
Packit Service 21b5d1
        return getShort(buf, byteOrder);
Packit Service 21b5d1
    }
Packit Service 21b5d1
    // Specialization for a 4 byte signed long value.
Packit Service 21b5d1
    template<>
Packit Service 21b5d1
    inline int32_t getValue(const byte* buf, ByteOrder byteOrder)
Packit Service 21b5d1
    {
Packit Service 21b5d1
        return getLong(buf, byteOrder);
Packit Service 21b5d1
    }
Packit Service 21b5d1
    // Specialization for an 8 byte signed rational value.
Packit Service 21b5d1
    template<>
Packit Service 21b5d1
    inline Rational getValue(const byte* buf, ByteOrder byteOrder)
Packit Service 21b5d1
    {
Packit Service 21b5d1
        return getRational(buf, byteOrder);
Packit Service 21b5d1
    }
Packit Service 21b5d1
    // Specialization for a 4 byte float value.
Packit Service 21b5d1
    template<>
Packit Service 21b5d1
    inline float getValue(const byte* buf, ByteOrder byteOrder)
Packit Service 21b5d1
    {
Packit Service 21b5d1
        return getFloat(buf, byteOrder);
Packit Service 21b5d1
    }
Packit Service 21b5d1
    // Specialization for a 8 byte double value.
Packit Service 21b5d1
    template<>
Packit Service 21b5d1
    inline double getValue(const byte* buf, ByteOrder byteOrder)
Packit Service 21b5d1
    {
Packit Service 21b5d1
        return getDouble(buf, byteOrder);
Packit Service 21b5d1
    }
Packit Service 21b5d1
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief Convert a value of type T to data, write the data to the data buffer.
Packit Service 21b5d1
Packit Service 21b5d1
      We need this template function for the ValueType template classes.
Packit Service 21b5d1
      There are only specializations of this function available; no default
Packit Service 21b5d1
      implementation is provided.
Packit Service 21b5d1
Packit Service 21b5d1
      @param buf Pointer to the data buffer to write to.
Packit Service 21b5d1
      @param t Value to be converted.
Packit Service 21b5d1
      @param byteOrder Applicable byte order (little or big endian).
Packit Service 21b5d1
      @return The number of bytes written to the buffer.
Packit Service 21b5d1
     */
Packit Service 21b5d1
    template<typename T> long toData(byte* buf, T t, ByteOrder byteOrder);
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief Specialization to write an unsigned short to the data buffer.
Packit Service 21b5d1
             Return the number of bytes written.
Packit Service 21b5d1
     */
Packit Service 21b5d1
    template<>
Packit Service 21b5d1
    inline long toData(byte* buf, uint16_t t, ByteOrder byteOrder)
Packit Service 21b5d1
    {
Packit Service 21b5d1
        return us2Data(buf, t, byteOrder);
Packit Service 21b5d1
    }
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief Specialization to write an unsigned long to the data buffer.
Packit Service 21b5d1
             Return the number of bytes written.
Packit Service 21b5d1
     */
Packit Service 21b5d1
    template<>
Packit Service 21b5d1
    inline long toData(byte* buf, uint32_t t, ByteOrder byteOrder)
Packit Service 21b5d1
    {
Packit Service 21b5d1
        return ul2Data(buf, t, byteOrder);
Packit Service 21b5d1
    }
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief Specialization to write an unsigned rational to the data buffer.
Packit Service 21b5d1
             Return the number of bytes written.
Packit Service 21b5d1
     */
Packit Service 21b5d1
    template<>
Packit Service 21b5d1
    inline long toData(byte* buf, URational t, ByteOrder byteOrder)
Packit Service 21b5d1
    {
Packit Service 21b5d1
        return ur2Data(buf, t, byteOrder);
Packit Service 21b5d1
    }
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief Specialization to write a signed short to the data buffer.
Packit Service 21b5d1
             Return the number of bytes written.
Packit Service 21b5d1
     */
Packit Service 21b5d1
    template<>
Packit Service 21b5d1
    inline long toData(byte* buf, int16_t t, ByteOrder byteOrder)
Packit Service 21b5d1
    {
Packit Service 21b5d1
        return s2Data(buf, t, byteOrder);
Packit Service 21b5d1
    }
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief Specialization to write a signed long to the data buffer.
Packit Service 21b5d1
             Return the number of bytes written.
Packit Service 21b5d1
     */
Packit Service 21b5d1
    template<>
Packit Service 21b5d1
    inline long toData(byte* buf, int32_t t, ByteOrder byteOrder)
Packit Service 21b5d1
    {
Packit Service 21b5d1
        return l2Data(buf, t, byteOrder);
Packit Service 21b5d1
    }
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief Specialization to write a signed rational to the data buffer.
Packit Service 21b5d1
             Return the number of bytes written.
Packit Service 21b5d1
     */
Packit Service 21b5d1
    template<>
Packit Service 21b5d1
    inline long toData(byte* buf, Rational t, ByteOrder byteOrder)
Packit Service 21b5d1
    {
Packit Service 21b5d1
        return r2Data(buf, t, byteOrder);
Packit Service 21b5d1
    }
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief Specialization to write a float to the data buffer.
Packit Service 21b5d1
             Return the number of bytes written.
Packit Service 21b5d1
     */
Packit Service 21b5d1
    template<>
Packit Service 21b5d1
    inline long toData(byte* buf, float t, ByteOrder byteOrder)
Packit Service 21b5d1
    {
Packit Service 21b5d1
        return f2Data(buf, t, byteOrder);
Packit Service 21b5d1
    }
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief Specialization to write a double to the data buffer.
Packit Service 21b5d1
             Return the number of bytes written.
Packit Service 21b5d1
     */
Packit Service 21b5d1
    template<>
Packit Service 21b5d1
    inline long toData(byte* buf, double t, ByteOrder byteOrder)
Packit Service 21b5d1
    {
Packit Service 21b5d1
        return d2Data(buf, t, byteOrder);
Packit Service 21b5d1
    }
Packit Service 21b5d1
Packit Service 21b5d1
    template<typename T>
Packit Service 21b5d1
    ValueType<T>::ValueType()
Packit Service 21b5d1
        : Value(getType<T>()), pDataArea_(0), sizeDataArea_(0)
Packit Service 21b5d1
    {
Packit Service 21b5d1
    }
Packit Service 21b5d1
Packit Service 21b5d1
    template<typename T>
Packit Service 21b5d1
    ValueType<T>::ValueType(TypeId typeId)
Packit Service 21b5d1
        : Value(typeId), pDataArea_(0), sizeDataArea_(0)
Packit Service 21b5d1
    {
Packit Service 21b5d1
    }
Packit Service 21b5d1
Packit Service 21b5d1
    template<typename T>
Packit Service 21b5d1
    ValueType<T>::ValueType(const byte* buf, long len, ByteOrder byteOrder, TypeId typeId)
Packit Service 21b5d1
        : Value(typeId), pDataArea_(0), sizeDataArea_(0)
Packit Service 21b5d1
    {
Packit Service 21b5d1
        read(buf, len, byteOrder);
Packit Service 21b5d1
    }
Packit Service 21b5d1
Packit Service 21b5d1
    template<typename T>
Packit Service 21b5d1
    ValueType<T>::ValueType(const T& val, TypeId typeId)
Packit Service 21b5d1
        : Value(typeId), pDataArea_(0), sizeDataArea_(0)
Packit Service 21b5d1
    {
Packit Service 21b5d1
        value_.push_back(val);
Packit Service 21b5d1
    }
Packit Service 21b5d1
Packit Service 21b5d1
    template<typename T>
Packit Service 21b5d1
    ValueType<T>::ValueType(const ValueType<T>& rhs)
Packit Service 21b5d1
        : Value(rhs), value_(rhs.value_), pDataArea_(0), sizeDataArea_(0)
Packit Service 21b5d1
    {
Packit Service 21b5d1
        if (rhs.sizeDataArea_ > 0) {
Packit Service 21b5d1
            pDataArea_ = new byte[rhs.sizeDataArea_];
Packit Service 21b5d1
            std::memcpy(pDataArea_, rhs.pDataArea_, rhs.sizeDataArea_);
Packit Service 21b5d1
            sizeDataArea_ = rhs.sizeDataArea_;
Packit Service 21b5d1
        }
Packit Service 21b5d1
    }
Packit Service 21b5d1
Packit Service 21b5d1
    template<typename T>
Packit Service 21b5d1
    ValueType<T>::~ValueType()
Packit Service 21b5d1
    {
Packit Service 21b5d1
        delete[] pDataArea_;
Packit Service 21b5d1
    }
Packit Service 21b5d1
Packit Service 21b5d1
    template<typename T>
Packit Service 21b5d1
    ValueType<T>& ValueType<T>::operator=(const ValueType<T>& rhs)
Packit Service 21b5d1
    {
Packit Service 21b5d1
        if (this == &rhs) return *this;
Packit Service 21b5d1
        Value::operator=(rhs);
Packit Service 21b5d1
        value_ = rhs.value_;
Packit Service 21b5d1
Packit Service 21b5d1
        byte* tmp = 0;
Packit Service 21b5d1
        if (rhs.sizeDataArea_ > 0) {
Packit Service 21b5d1
            tmp = new byte[rhs.sizeDataArea_];
Packit Service 21b5d1
            std::memcpy(tmp, rhs.pDataArea_, rhs.sizeDataArea_);
Packit Service 21b5d1
        }
Packit Service 21b5d1
        delete[] pDataArea_;
Packit Service 21b5d1
        pDataArea_ = tmp;
Packit Service 21b5d1
        sizeDataArea_ = rhs.sizeDataArea_;
Packit Service 21b5d1
Packit Service 21b5d1
        return *this;
Packit Service 21b5d1
    }
Packit Service 21b5d1
Packit Service 21b5d1
    template<typename T>
Packit Service 21b5d1
    int ValueType<T>::read(const byte* buf, long len, ByteOrder byteOrder)
Packit Service 21b5d1
    {
Packit Service 21b5d1
        value_.clear();
Packit Service 21b5d1
        long ts = TypeInfo::typeSize(typeId());
Packit Service 21b5d1
        if (ts != 0)
Packit Service 21b5d1
            if (len % ts != 0) len = (len / ts) * ts;
Packit Service 21b5d1
        for (long i = 0; i < len; i += ts) {
Packit Service 21b5d1
            value_.push_back(getValue<T>(buf + i, byteOrder));
Packit Service 21b5d1
        }
Packit Service 21b5d1
        return 0;
Packit Service 21b5d1
    }
Packit Service 21b5d1
Packit Service 21b5d1
    template<typename T>
Packit Service 21b5d1
    int ValueType<T>::read(const std::string& buf)
Packit Service 21b5d1
    {
Packit Service 21b5d1
        std::istringstream is(buf);
Packit Service 21b5d1
        T tmp;
Packit Service 21b5d1
        ValueList val;
Packit Service 21b5d1
        while (!(is.eof())) {
Packit Service 21b5d1
            is >> tmp;
Packit Service 21b5d1
            if (is.fail()) return 1;
Packit Service 21b5d1
            val.push_back(tmp);
Packit Service 21b5d1
        }
Packit Service 21b5d1
        value_.swap(val);
Packit Service 21b5d1
        return 0;
Packit Service 21b5d1
    }
Packit Service 21b5d1
Packit Service 21b5d1
    template<typename T>
Packit Service 21b5d1
    long ValueType<T>::copy(byte* buf, ByteOrder byteOrder) const
Packit Service 21b5d1
    {
Packit Service 21b5d1
        long offset = 0;
Packit Service 21b5d1
        typename ValueList::const_iterator end = value_.end();
Packit Service 21b5d1
        for (typename ValueList::const_iterator i = value_.begin(); i != end; ++i) {
Packit Service 21b5d1
            offset += toData(buf + offset, *i, byteOrder);
Packit Service 21b5d1
        }
Packit Service 21b5d1
        return offset;
Packit Service 21b5d1
    }
Packit Service 21b5d1
Packit Service 21b5d1
    template<typename T>
Packit Service 21b5d1
    long ValueType<T>::count() const
Packit Service 21b5d1
    {
Packit Service 21b5d1
        return static_cast<long>(value_.size());
Packit Service 21b5d1
    }
Packit Service 21b5d1
Packit Service 21b5d1
    template<typename T>
Packit Service 21b5d1
    long ValueType<T>::size() const
Packit Service 21b5d1
    {
Packit Service 21b5d1
        return static_cast<long>(TypeInfo::typeSize(typeId()) * value_.size());
Packit Service 21b5d1
    }
Packit Service 21b5d1
Packit Service 21b5d1
    template<typename T>
Packit Service 21b5d1
    ValueType<T>* ValueType<T>::clone_() const
Packit Service 21b5d1
    {
Packit Service 21b5d1
        return new ValueType<T>(*this);
Packit Service 21b5d1
    }
Packit Service 21b5d1
Packit Service 21b5d1
    template<typename T>
Packit Service 21b5d1
    std::ostream& ValueType<T>::write(std::ostream& os) const
Packit Service 21b5d1
    {
Packit Service 21b5d1
        typename ValueList::const_iterator end = value_.end();
Packit Service 21b5d1
        typename ValueList::const_iterator i = value_.begin();
Packit Service 21b5d1
        while (i != end) {
Packit Service 21b5d1
            os << std::setprecision(15) << *i;
Packit Service 21b5d1
            if (++i != end) os << " ";
Packit Service 21b5d1
        }
Packit Service 21b5d1
        return os;
Packit Service 21b5d1
    }
Packit Service 21b5d1
Packit Service 21b5d1
    template<typename T>
Packit Service 21b5d1
    std::string ValueType<T>::toString(long n) const
Packit Service 21b5d1
    {
Packit Service 21b5d1
        ok_ = true;
Packit Service 21b5d1
        return Exiv2::toString<T>(value_[n]);
Packit Service 21b5d1
    }
Packit Service 21b5d1
Packit Service 21b5d1
    // Default implementation
Packit Service 21b5d1
    template<typename T>
Packit Service 21b5d1
    long ValueType<T>::toLong(long n) const
Packit Service 21b5d1
    {
Packit Service 21b5d1
        ok_ = true;
Packit Service 21b5d1
        return static_cast<long>(value_[n]);
Packit Service 21b5d1
    }
Packit Service 21b5d1
// #55 crash when value_[n].first == LONG_MIN
Packit Service 21b5d1
#define LARGE_INT 1000000
Packit Service 21b5d1
    // Specialization for rational
Packit Service 21b5d1
    template<>
Packit Service 21b5d1
    inline long ValueType<Rational>::toLong(long n) const
Packit Service 21b5d1
    {
Packit Service 21b5d1
        ok_ = (value_[n].second != 0 && INT_MIN < value_[n].first && value_[n].first < INT_MAX );
Packit Service 21b5d1
        if (!ok_) return 0;
Packit Service 21b5d1
        return value_[n].first / value_[n].second;
Packit Service 21b5d1
    }
Packit Service 21b5d1
    // Specialization for unsigned rational
Packit Service 21b5d1
    template<>
Packit Service 21b5d1
    inline long ValueType<URational>::toLong(long n) const
Packit Service 21b5d1
    {
Packit Service 21b5d1
        ok_ = (value_[n].second != 0 && value_[n].first < LARGE_INT);
Packit Service 21b5d1
        if (!ok_) return 0;
Packit Service 21b5d1
        return value_[n].first / value_[n].second;
Packit Service 21b5d1
    }
Packit Service 21b5d1
    // Default implementation
Packit Service 21b5d1
    template<typename T>
Packit Service 21b5d1
    float ValueType<T>::toFloat(long n) const
Packit Service 21b5d1
    {
Packit Service 21b5d1
        ok_ = true;
Packit Service 21b5d1
        return static_cast<float>(value_[n]);
Packit Service 21b5d1
    }
Packit Service 21b5d1
    // Specialization for rational
Packit Service 21b5d1
    template<>
Packit Service 21b5d1
    inline float ValueType<Rational>::toFloat(long n) const
Packit Service 21b5d1
    {
Packit Service 21b5d1
        ok_ = (value_[n].second != 0);
Packit Service 21b5d1
        if (!ok_) return 0.0f;
Packit Service 21b5d1
        return static_cast<float>(value_[n].first) / value_[n].second;
Packit Service 21b5d1
    }
Packit Service 21b5d1
    // Specialization for unsigned rational
Packit Service 21b5d1
    template<>
Packit Service 21b5d1
    inline float ValueType<URational>::toFloat(long n) const
Packit Service 21b5d1
    {
Packit Service 21b5d1
        ok_ = (value_[n].second != 0);
Packit Service 21b5d1
        if (!ok_) return 0.0f;
Packit Service 21b5d1
        return static_cast<float>(value_[n].first) / value_[n].second;
Packit Service 21b5d1
    }
Packit Service 21b5d1
    // Default implementation
Packit Service 21b5d1
    template<typename T>
Packit Service 21b5d1
    Rational ValueType<T>::toRational(long n) const
Packit Service 21b5d1
    {
Packit Service 21b5d1
        ok_ = true;
Packit Service 21b5d1
        return Rational(value_[n], 1);
Packit Service 21b5d1
    }
Packit Service 21b5d1
    // Specialization for rational
Packit Service 21b5d1
    template<>
Packit Service 21b5d1
    inline Rational ValueType<Rational>::toRational(long n) const
Packit Service 21b5d1
    {
Packit Service 21b5d1
        ok_ = true;
Packit Service 21b5d1
        return Rational(value_[n].first, value_[n].second);
Packit Service 21b5d1
    }
Packit Service 21b5d1
    // Specialization for unsigned rational
Packit Service 21b5d1
    template<>
Packit Service 21b5d1
    inline Rational ValueType<URational>::toRational(long n) const
Packit Service 21b5d1
    {
Packit Service 21b5d1
        ok_ = true;
Packit Service 21b5d1
        return Rational(value_[n].first, value_[n].second);
Packit Service 21b5d1
    }
Packit Service 21b5d1
    // Specialization for float.
Packit Service 21b5d1
    template<>
Packit Service 21b5d1
    inline Rational ValueType<float>::toRational(long n) const
Packit Service 21b5d1
    {
Packit Service 21b5d1
        ok_ = true;
Packit Service 21b5d1
        // Warning: This is a very simple conversion, see floatToRationalCast()
Packit Service 21b5d1
        return floatToRationalCast(value_[n]);
Packit Service 21b5d1
    }
Packit Service 21b5d1
    // Specialization for double.
Packit Service 21b5d1
    template<>
Packit Service 21b5d1
    inline Rational ValueType<double>::toRational(long n) const
Packit Service 21b5d1
    {
Packit Service 21b5d1
        ok_ = true;
Packit Service 21b5d1
        // Warning: This is a very simple conversion, see floatToRationalCast()
Packit Service 21b5d1
        return floatToRationalCast(static_cast<float>(value_[n]));
Packit Service 21b5d1
    }
Packit Service 21b5d1
Packit Service 21b5d1
    template<typename T>
Packit Service 21b5d1
    long ValueType<T>::sizeDataArea() const
Packit Service 21b5d1
    {
Packit Service 21b5d1
        return sizeDataArea_;
Packit Service 21b5d1
    }
Packit Service 21b5d1
Packit Service 21b5d1
    template<typename T>
Packit Service 21b5d1
    DataBuf ValueType<T>::dataArea() const
Packit Service 21b5d1
    {
Packit Service 21b5d1
        return DataBuf(pDataArea_, sizeDataArea_);
Packit Service 21b5d1
    }
Packit Service 21b5d1
Packit Service 21b5d1
    template<typename T>
Packit Service 21b5d1
    int ValueType<T>::setDataArea(const byte* buf, long len)
Packit Service 21b5d1
    {
Packit Service 21b5d1
        byte* tmp = 0;
Packit Service 21b5d1
        if (len > 0) {
Packit Service 21b5d1
            tmp = new byte[len];
Packit Service 21b5d1
            std::memcpy(tmp, buf, len);
Packit Service 21b5d1
        }
Packit Service 21b5d1
        delete[] pDataArea_;
Packit Service 21b5d1
        pDataArea_ = tmp;
Packit Service 21b5d1
        sizeDataArea_ = len;
Packit Service 21b5d1
        return 0;
Packit Service 21b5d1
    }
Packit Service 21b5d1
}                                       // namespace Exiv2
Packit Service 21b5d1
Packit Service 21b5d1
#endif                                  // #ifndef VALUE_HPP_