Blame include/exiv2/version.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    version.hpp
Packit Service 21b5d1
  @brief   Precompiler define and a function to test the %Exiv2 version.
Packit Service 21b5d1
           References: Similar versioning defines are used in KDE, GTK and other
Packit Service 21b5d1
           libraries. See http://apr.apache.org/versioning.html for accompanying
Packit Service 21b5d1
           guidelines.
Packit Service 21b5d1
  @author  Andreas Huggel (ahu)
Packit Service 21b5d1
           ahuggel@gmx.net
Packit Service 21b5d1
  @date    31-May-06, ahu: created
Packit Service 21b5d1
 */
Packit Service 21b5d1
#ifndef VERSION_HPP_
Packit Service 21b5d1
#define VERSION_HPP_
Packit Service 21b5d1
Packit Service 21b5d1
#include "exiv2lib_export.h"
Packit Service 21b5d1
#include "exv_conf.h"
Packit Service 21b5d1
Packit Service 21b5d1
// *****************************************************************************
Packit Service 21b5d1
// included header files
Packit Service 21b5d1
// + standard includes
Packit Service 21b5d1
#include <vector>
Packit Service 21b5d1
Packit Service 21b5d1
#if defined(EXV_HAVE_REGEX_H)
Packit Service 21b5d1
# include <regex.h>
Packit Service 21b5d1
  /*!
Packit Service 21b5d1
   @brief exv_grep_keys_t is a vector of keys to match to strings
Packit Service 21b5d1
  */
Packit Service 21b5d1
   typedef std::vector<regex_t> exv_grep_keys_t ;
Packit Service 21b5d1
# else
Packit Service 21b5d1
  /*!
Packit Service 21b5d1
   @brief exv_grep_key_t is a simple string and the ignore flag
Packit Service 21b5d1
  */
Packit Service 21b5d1
   struct Exiv2_grep_key_t {
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
    @brief Exiv2_grep_key_t constructor
Packit Service 21b5d1
    */
Packit Service 21b5d1
     Exiv2_grep_key_t(std::string pattern,bool bIgnoreCase)
Packit Service 21b5d1
       :pattern_(pattern),bIgnoreCase_(bIgnoreCase) {}
Packit Service 21b5d1
Packit Service 21b5d1
     //! simple string to match
Packit Service 21b5d1
     std::string pattern_;
Packit Service 21b5d1
Packit Service 21b5d1
     //! should we ignore cast in the match?
Packit Service 21b5d1
     bool        bIgnoreCase_;
Packit Service 21b5d1
   };
Packit Service 21b5d1
  /*!
Packit Service 21b5d1
   @brief exv_grep_keys_t is a vector of keys to match to strings
Packit Service 21b5d1
  */
Packit Service 21b5d1
   typedef std::vector<Exiv2_grep_key_t> exv_grep_keys_t ;
Packit Service 21b5d1
#endif
Packit Service 21b5d1
Packit Service 21b5d1
/*!
Packit Service 21b5d1
  @brief Make an integer version number for comparison from a major, minor and
Packit Service 21b5d1
         a patch version number.
Packit Service 21b5d1
 */
Packit Service 21b5d1
#define EXIV2_MAKE_VERSION(major,minor,patch) \
Packit Service 21b5d1
    (((major) << 16) | ((minor) << 8) | (patch))
Packit Service 21b5d1
/*!
Packit Service 21b5d1
  @brief The %Exiv2 version number of the library used at compile-time as
Packit Service 21b5d1
         an integer number for easy comparison.
Packit Service 21b5d1
 */
Packit Service 21b5d1
#define EXIV2_VERSION \
Packit Service 21b5d1
    EXIV2_MAKE_VERSION(EXIV2_MAJOR_VERSION,EXIV2_MINOR_VERSION,EXIV2_PATCH_VERSION)
Packit Service 21b5d1
Packit Service 21b5d1
/*!
Packit Service 21b5d1
  @brief Macro to test the version the %Exiv2 library at compile-time.
Packit Service 21b5d1
         Return true if it is the same as or newer than the passed-in version.
Packit Service 21b5d1
Packit Service 21b5d1
  Versions prior to v0.27 are denoted using a triplet of integers: \em MAJOR.MINOR.PATCH .
Packit Service 21b5d1
  From v0.27 forward, the fourth digit is a "tweak" and designates the pre-release number of the version.
Packit Service 21b5d1
Packit Service 21b5d1
  @code
Packit Service 21b5d1
  // Application code is expected to include <exiv2/exiv2.hpp>
Packit Service 21b5d1
  // Don't include the <exiv2/version.hpp> file directly
Packit Service 21b5d1
  // Early Exiv2 versions didn't have version.hpp and the macros.
Packit Service 21b5d1
Packit Service 21b5d1
  #include <exiv2/exiv2.hpp>
Packit Service 21b5d1
Packit Service 21b5d1
  // Make sure an EXIV2_TEST_VERSION macro exists:
Packit Service 21b5d1
  #ifdef EXIV2_VERSION
Packit Service 21b5d1
  # ifndef EXIV2_TEST_VERSION
Packit Service 21b5d1
  # define EXIV2_TEST_VERSION(major,minor,patch) \
Packit Service 21b5d1
      ( EXIV2_VERSION >= EXIV2_MAKE_VERSION(major,minor,patch) )
Packit Service 21b5d1
  # endif
Packit Service 21b5d1
  #else
Packit Service 21b5d1
  # define EXIV2_TEST_VERSION(major,minor,patch) (false)
Packit Service 21b5d1
  #endif
Packit Service 21b5d1
Packit Service 21b5d1
  std::cout << "Compiled with Exiv2 version " << EXV_PACKAGE_VERSION << "\n"
Packit Service 21b5d1
            << "Runtime Exiv2 version is    " << Exiv2::version()    << "\n";
Packit Service 21b5d1
Packit Service 21b5d1
  // Test the Exiv2 version available at runtime but compile the if-clause only if
Packit Service 21b5d1
  // the compile-time version is at least 0.15. Earlier versions didn't have a
Packit Service 21b5d1
  // testVersion() function:
Packit Service 21b5d1
Packit Service 21b5d1
  #if EXIV2_TEST_VERSION(0,15,0)
Packit Service 21b5d1
  if (Exiv2::testVersion(0,13,0)) {
Packit Service 21b5d1
      std::cout << "Available Exiv2 version is equal to or greater than 0.13\n";
Packit Service 21b5d1
  }
Packit Service 21b5d1
  else {
Packit Service 21b5d1
      std::cout << "Installed Exiv2 version is less than 0.13\n";
Packit Service 21b5d1
  }
Packit Service 21b5d1
  #else
Packit Service 21b5d1
  std::cout << "Compile-time Exiv2 version doesn't have Exiv2::testVersion()\n";
Packit Service 21b5d1
  #endif
Packit Service 21b5d1
  @endcode
Packit Service 21b5d1
 */
Packit Service 21b5d1
#define EXIV2_TEST_VERSION(major,minor,patch) \
Packit Service 21b5d1
    ( EXIV2_VERSION >= EXIV2_MAKE_VERSION(major,minor,patch) )
Packit Service 21b5d1
Packit Service 21b5d1
// *****************************************************************************
Packit Service 21b5d1
// namespace extensions
Packit Service 21b5d1
namespace Exiv2 {
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief Return the version of %Exiv2 available at runtime as an integer.
Packit Service 21b5d1
    */
Packit Service 21b5d1
    EXIV2API int versionNumber();
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief Return the version string Example: "0.25.0" (major.minor.patch)
Packit Service 21b5d1
    */
Packit Service 21b5d1
    EXIV2API std::string versionString();
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief Return the version of %Exiv2 as hex string of fixed length 6.
Packit Service 21b5d1
    */
Packit Service 21b5d1
    EXIV2API std::string versionNumberHexString();
Packit Service 21b5d1
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief Return the version of %Exiv2 as "C" string eg "0.27.0.2".
Packit Service 21b5d1
    */
Packit Service 21b5d1
    EXIV2API const char* version();
Packit Service 21b5d1
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief Test the version of the available %Exiv2 library at runtime. Return
Packit Service 21b5d1
             true if it is the same as or newer than the passed-in version.
Packit Service 21b5d1
Packit Service 21b5d1
      Versions are denoted using a triplet of integers: \em major.minor.patch .
Packit Service 21b5d1
      The fourth version number is designated a "tweak" an used by Release Candidates
Packit Service 21b5d1
    */
Packit Service 21b5d1
    EXIV2API bool testVersion(int major, int minor, int patch);
Packit Service 21b5d1
    /*!
Packit Service 21b5d1
      @brief dumpLibraryInfo implements the exiv2 option --version --verbose
Packit Service 21b5d1
             used by exiv2 test suite to inspect libraries loaded at run-time
Packit Service 21b5d1
     */
Packit Service 21b5d1
    EXIV2API void dumpLibraryInfo(std::ostream& os,const exv_grep_keys_t& keys);
Packit Service 21b5d1
}                                       // namespace Exiv2
Packit Service 21b5d1
Packit Service 21b5d1
Packit Service 21b5d1
Packit Service 21b5d1
#endif                                  // VERSION_HPP_