[SCM] exiv2 packaging branch, master, updated. debian/0.25-3.1-3734-gdcbc29a

Maximiliano Curia maxy at moszumanska.debian.org
Thu Jul 13 17:35:59 UTC 2017


Gitweb-URL: http://git.debian.org/?p=pkg-kde/kde-extras/exiv2.git;a=commitdiff;h=4407d0b

The following commit has been merged in the master branch:
commit 4407d0b25f437f20760770381cac0c0057228c90
Author: Andreas Huggel <ahuggel at gmx.net>
Date:   Fri Feb 6 12:14:46 2004 +0000

    Reverted exifprint back to a very simple example program
---
 src/exifprint.cpp | 146 ++++++++++++++++--------------------------------------
 src/exifprint.hpp | 145 -----------------------------------------------------
 2 files changed, 42 insertions(+), 249 deletions(-)

diff --git a/src/exifprint.cpp b/src/exifprint.cpp
index de333d3..c379bcb 100644
--- a/src/exifprint.cpp
+++ b/src/exifprint.cpp
@@ -22,16 +22,15 @@
   Abstract : Sample program to print the Exif metadata of an image
 
   Author(s): Andreas Huggel (ahu) <ahuggel at gmx.net>
-  Version  : $Name:  $ $Revision: 1.4 $
+  Version  : $Name:  $ $Revision: 1.5 $
   History  : 26-Jan-04, ahu: created
  */
 // *****************************************************************************
 #include "rcsid.hpp"
-EXIV2_RCSID("@(#) $Name:  $ $Revision: 1.4 $ $RCSfile: exifprint.cpp,v $")
+EXIV2_RCSID("@(#) $Name:  $ $Revision: 1.5 $ $RCSfile: exifprint.cpp,v $")
 
 // *****************************************************************************
 // included header files
-#include "exifprint.hpp"
 #include "exif.hpp"
 #include "utils.hpp"
 
@@ -46,46 +45,39 @@ EXIV2_RCSID("@(#) $Name:  $ $Revision: 1.4 $ $RCSfile: exifprint.cpp,v $")
 
 using namespace Exif;
 
+std::string readError(int rc, const char* file);
+
 // *****************************************************************************
 // Main
 int main(int argc, char* const argv[])
 try {
-    // Handle command line arguments
-    Params& params = Params::instance();
-    if (params.getopt(argc, argv)) {
-        params.usage();
+
+    if (argc != 2) {
+        std::cout << "Usage: " << argv[0] << " file
";
         return 1;
     }
-    if (params.help_) {
-        params.help();
-        return 0;
-    }
-    if (params.version_) {
-        params.version();
-        return 0;
-    }
 
     ExifData exifData;
     int rc = exifData.read(argv[1]);
+    if (rc) {
+        std::string error = readError(rc, argv[1]);
+        throw Error(error);
+    }
 
-    if (rc == 0) {
-        ExifData::const_iterator beg = exifData.begin();
-        ExifData::const_iterator end = exifData.end();
-        ExifData::const_iterator i = beg;
-        for (; i != end; ++i) {
-            std::cout << "0x" 
-                      << std::hex << std::setw(4) << std::setfill('0') << std::right
-                      << i->tag() << " " 
-                      << std::setw(27) << std::setfill(' ') << std::left
-//                      << i->tagName() << " "
-                      << i->key() << " "
-                      << std::setw(17) << std::setfill(' ') << std::left
-                      << i->typeName() << " "
-                      << std::dec << std::setw(3) 
-                      << std::setfill(' ') << std::right
-                      << i->count() << "   " 
-                      << std::dec << i->value() << "
";
-        }
+    ExifData::const_iterator end = exifData.end();
+    for (ExifData::const_iterator i = exifData.begin(); i != end; ++i) {
+        std::cout << "0x" 
+                  << std::hex << std::setw(4) << std::setfill('0') << std::right
+                  << i->tag() << " " 
+                  << std::setw(27) << std::setfill(' ') << std::left
+                  << i->tagName() << " "
+//                  << i->key() << " "
+                  << std::setw(17) << std::setfill(' ') << std::left
+                  << i->typeName() << " "
+                  << std::dec << std::setw(3) 
+                  << std::setfill(' ') << std::right
+                  << i->count() << "   " 
+                  << std::dec << i->value() << "
";
     }
 
     return rc;
@@ -98,82 +90,28 @@ catch (Error& e) {
 // *****************************************************************************
 // local definitions
 
-// *****************************************************************************
-// class Params
-Params* Params::instance_ = 0;
-
-Params& Params::instance()
-{
-    if (0 == instance_) {
-        instance_ = new Params;
-    }
-    return *instance_;
-}
-
-void Params::version(std::ostream& os) const
-{
-    os << "Exifprint 0.1

" 
-       << "Copyright (C) 2004 Andreas Huggel <ahuggel at gmx.net>
"; 
-}
-
-void Params::usage(std::ostream& os) const
+std::string readError(int rc, const char* file)
 {
-    os << "Usage: " << progname() 
-       << " [ -hv ] file ...

"
-       << "Print the Exif metadata of the image files.
";
-}
-
-void Params::help(std::ostream& os) const
-{
-    usage(os);
-    os << "
Options:
"
-       << "   -h      Display this help and exit.
"
-       << "   -v      Show the program version and exit.

";
-}
-
-int Params::option(int opt, const std::string& optarg, int optopt)
-{
-    int rc = 0;
-    switch (opt) {
-    case 'h':
-        help_ = true;
+    std::string error;
+    switch (rc) {
+    case -1:
+        error = "Couldn't open file `" + std::string(file) + "'";
         break;
-    case 'v':
-        version_ = true;
+    case 1:
+        error = "Couldn't read from the input stream";
         break;
-    case ':':
-        std::cerr << progname() << ": Option -" << static_cast<char>(optopt) 
-                  << " requires an argument
";
-        rc = 1;
+    case 2:
+        error = "This does not look like a JPEG image";
         break;
-    case '?':
-        std::cerr << progname() << ": Unrecognized option -" 
-                  << static_cast<char>(optopt) << "
";
-        rc = 1;
+    case 3:
+        error = "No Exif data found in the file";
+        break;
+    case -99:
+        error = "Unsupported Exif or GPS data found in IFD 1";
         break;
     default:
-        std::cerr << progname() 
-                  << ": getopt returned unexpected character code " 
-                  << std::hex << opt << "
";
-        rc = 1;
-    }
-    return rc;
-}
-
-int Params::nonoption(const std::string& argv)
-{
-    files_.push_back(argv);
-    return 0;
-}
-
-int Params::getopt(int argc, char* const argv[])
-{
-    int rc = Util::Getopt::getopt(argc, argv, optstring_);
-    // Further consistency checks
-    if (help_ || version_) return 0;
-    if (0 == files_.size()) {
-        std::cerr << progname() << ": At least one file is required
";
-        rc = 1;
+        error = "Reading Exif data failed, rc = " + toString(rc);
+        break;
     }
-    return rc;
+    return error;
 }
diff --git a/src/exifprint.hpp b/src/exifprint.hpp
deleted file mode 100644
index c68e8b6..0000000
--- a/src/exifprint.hpp
+++ /dev/null
@@ -1,145 +0,0 @@
-// ***************************************************************** -*- C++ -*-
-/*
- * Copyright (C) 2004 Andreas Huggel <ahuggel at gmx.net>
- * 
- * This program is part of the Exiv2 distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
- */
-/*!
-  @file    exifprint.hpp
-  @brief   Utility to print Exif data of input files to standard out
-  @version $Name:  $ $Revision: 1.2 $
-  @author  Andreas Huggel (ahu)
-           <a href="mailto:ahuggel at gmx.net">ahuggel at gmx.net</a>
-  @date    26-Jan-04, ahu: created
- */
-#ifndef EXIFPRINT_HPP_
-#define EXIFPRINT_HPP_
-
-// *****************************************************************************
-// included header files
-#include "utils.hpp"
-
-// + standard includes
-#include <string>
-#include <vector>
-#include <iostream>
-
-// *****************************************************************************
-// namespace extensions
-
-// *****************************************************************************
-// class declarations
-
-// *****************************************************************************
-// class definitions
-/*!
-  @brief Implements the command line handling for the program.
-
-  Derives from Util::Getopt to use the command line argument parsing
-  functionalty provided there. This class is implemented as a Singleton,
-  i.e., there is only one global instance of it, which can be accessed
-  from everywhere.
-
-  <b>Usage example:</b> <br>
-  @code
-  #include "exifprint.hpp"
-
-  int main(int argc, char* const argv[])
-  {
-      Params& params = Params::instance();
-      if (params.getopt(argc, argv)) {
-          params.usage();
-          return 1;
-      }
-      if (params.help_) {
-          params.help();
-          return 0;
-      }
-      if (params.version_) {
-          params.version();
-          return 0;
-      }
-
-      // do something useful here...
-
-      return 0;
-  }
-  @endcode
- */
-class Params : public Util::Getopt {
-private:
-    std::string optstring_;
-
-public:
-    /*!
-      @brief Controls all access to the global Params instance.
-      
-      @return Reference to the global Params instance.
-    */
-    static Params& instance();
-
-    /*!
-      @brief Call Getopt::getopt() with optstring, perform consistency
-             checks after all command line arguments are parsed.
-
-      @param argc Argument count as passed to main() on  program invocation.
-      @param argv Argument array as passed to main() on  program invocation.
-
-      @return 0 if successful, >0 in case of errors.
-     */
-    int getopt(int argc, char* const argv[]);
-
-    //! Handle options and their arguments.
-    virtual int option(int opt, const std::string& optarg, int optopt);
-
-    //! Handle non-option parameters.
-    virtual int nonoption(const std::string& argv);
-
-    //! Print a minimal usage note to an output stream.
-    void usage(std::ostream& os =std::cout) const;
-
-    //! Print further usage explanations to an output stream.
-    void help(std::ostream& os =std::cout) const;
-
-    //! Print version information to an output stream.
-    void version(std::ostream& os =std::cout) const;
-
-    //! Container to store filenames.
-    typedef std::vector<std::string> Files;
-
-    //! List of non-option arguments.
-    Files files_; 
-
-    bool help_;                         //!< Help option flag.
-    bool version_;                      //!< Version option flag.
-
-private:
-    /*!
-      @brief Default constructor. Note that optstring_ is initialized here.
-             Private to force instantiation through instance().
-     */
-    Params() : optstring_(":hv"),
-               help_(false), 
-               version_(false) {}
-    //! Prevent copy-construction: not implemented.
-    Params(const Params& rhs);
-    //! Pointer to the global Params object.
-    static Params* instance_;
-
-};
-
-#endif                                  // #ifndef EXIFPRINT_HPP_

-- 
exiv2 packaging



More information about the pkg-kde-commits mailing list