diff --git a/src/exiv2.cpp b/src/exiv2.cpp index 1de751f9..88f3158f 100644 --- a/src/exiv2.cpp +++ b/src/exiv2.cpp @@ -22,13 +22,13 @@ Abstract: Command line program to display and manipulate image %Exif data File: exiv2.cpp - Version: $Name: $ $Revision: 1.2 $ + Version: $Name: $ $Revision: 1.3 $ Author(s): Andreas Huggel (ahu) History: 10-Dec-03, ahu: created */ // ***************************************************************************** #include "rcsid.hpp" -EXIV2_RCSID("@(#) $Name: $ $Revision: 1.2 $ $RCSfile: exiv2.cpp,v $") +EXIV2_RCSID("@(#) $Name: $ $Revision: 1.3 $ $RCSfile: exiv2.cpp,v $") // ***************************************************************************** // included header files @@ -129,6 +129,9 @@ void Params::help(std::ostream& os) const << " -f Do not prompt before overwriting existing files (force).\n" << " -a time Time adjustment in the format [-]HH[:MM[:SS]]. This option\n" << " is only used with the `adjust' action.\n" + << " -m mode Print mode for the `print' action. Possible modes are `s'\n" + << " for a summary (the default), `i' for interpreted data, `v'\n" + << " for uninterpreted data values and `h' for a hexdump\n" << " -r fmt Filename format for the `rename' action. The format string\n" << " follows strftime(3). Default filename format is " << format_ << ".\n" @@ -144,22 +147,11 @@ int Params::option(int opt, const std::string& optarg, int optopt) { int rc = 0; switch (opt) { - case 'h': - help_ = true; - break; - - case 'V': - version_ = true; - break; - - case 'v': - verbose_ = true; - break; - - case 'f': - force_ = true; - break; - + case 'h': help_ = true; break; + case 'V': version_ = true; break; + case 'v': verbose_ = true; break; + case 'f': force_ = true; break; + case 'r': format_ = optarg; break; case 'a': adjust_ = parseTime(optarg, adjustment_); if (!adjust_) { @@ -168,30 +160,34 @@ int Params::option(int opt, const std::string& optarg, int optopt) rc = 1; } break; - - case 'r': - format_ = optarg; + case 'm': + switch (optarg[0]) { + case 's': printMode_ = summary; break; + case 'i': printMode_ = interpreted; break; + case 'v': printMode_ = values; break; + case 'h': printMode_ = hexdump; break; + default: + std::cerr << progname() << ": Unrecognized print mode `" + << optarg << "'\n"; + rc = 1; + } break; - case ':': std::cerr << progname() << ": Option -" << static_cast(optopt) << " requires an argument\n"; rc = 1; break; - case '?': std::cerr << progname() << ": Unrecognized option -" << static_cast(optopt) << "\n"; rc = 1; break; - default: std::cerr << progname() << ": getopt returned unexpected character code " << std::hex << opt << "\n"; rc = 1; } - return rc; } // Params::option diff --git a/src/exiv2.hpp b/src/exiv2.hpp index 86237175..0c48fcad 100644 --- a/src/exiv2.hpp +++ b/src/exiv2.hpp @@ -21,7 +21,7 @@ /*! @file exiv2.hpp @brief Defines class Params, used for the command line handling of exiv2 - @version $Name: $ $Revision: 1.1 $ + @version $Name: $ $Revision: 1.2 $ @author Andreas Huggel (ahu) ahuggel@gmx.net @date 08-Dec-03, ahu: created @@ -85,13 +85,17 @@ public: */ static Params& instance(); + //! Enumerates print modes + enum PrintMode { summary, interpreted, values, hexdump }; + bool help_; //!< Help option flag. bool version_; //!< Version option flag. bool verbose_; //!< Verbose (talkative) option flag. bool force_; //!< Force overwrites flag. bool adjust_; //!< Adjustment flag. + PrintMode printMode_; //!< Print mode. //! %Action (integer rather than TaskType to avoid dependency). - int action_; + int action_; long adjustment_; //!< Adjustment in seconds. std::string format_; //!< Filename format (-r option arg). @@ -106,12 +110,13 @@ private: @brief Default constructor. Note that optstring_ is initialized here. Private to force instantiation through instance(). */ - Params() : optstring_(":hVvfa:r:"), + Params() : optstring_(":hVvfa:r:m:"), help_(false), version_(false), verbose_(false), force_(false), adjust_(false), + printMode_(summary), action_(0), adjustment_(0), format_("%Y%m%d_%H%M%S"),