Added print mode option

v0.27.3
Andreas Huggel 22 years ago
parent ccd29216bc
commit 9890b51ed2

@ -22,13 +22,13 @@
Abstract: Command line program to display and manipulate image %Exif data Abstract: Command line program to display and manipulate image %Exif data
File: exiv2.cpp File: exiv2.cpp
Version: $Name: $ $Revision: 1.2 $ Version: $Name: $ $Revision: 1.3 $
Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net> Author(s): Andreas Huggel (ahu) <ahuggel@gmx.net>
History: 10-Dec-03, ahu: created History: 10-Dec-03, ahu: created
*/ */
// ***************************************************************************** // *****************************************************************************
#include "rcsid.hpp" #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 // included header files
@ -129,6 +129,9 @@ void Params::help(std::ostream& os) const
<< " -f Do not prompt before overwriting existing files (force).\n" << " -f Do not prompt before overwriting existing files (force).\n"
<< " -a time Time adjustment in the format [-]HH[:MM[:SS]]. This option\n" << " -a time Time adjustment in the format [-]HH[:MM[:SS]]. This option\n"
<< " is only used with the `adjust' action.\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" << " -r fmt Filename format for the `rename' action. The format string\n"
<< " follows strftime(3). Default filename format is " << " follows strftime(3). Default filename format is "
<< format_ << ".\n" << format_ << ".\n"
@ -144,22 +147,11 @@ int Params::option(int opt, const std::string& optarg, int optopt)
{ {
int rc = 0; int rc = 0;
switch (opt) { switch (opt) {
case 'h': case 'h': help_ = true; break;
help_ = true; case 'V': version_ = true; break;
break; case 'v': verbose_ = true; break;
case 'f': force_ = true; break;
case 'V': case 'r': format_ = optarg; break;
version_ = true;
break;
case 'v':
verbose_ = true;
break;
case 'f':
force_ = true;
break;
case 'a': case 'a':
adjust_ = parseTime(optarg, adjustment_); adjust_ = parseTime(optarg, adjustment_);
if (!adjust_) { if (!adjust_) {
@ -168,30 +160,34 @@ int Params::option(int opt, const std::string& optarg, int optopt)
rc = 1; rc = 1;
} }
break; break;
case 'm':
case 'r': switch (optarg[0]) {
format_ = optarg; 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; break;
case ':': case ':':
std::cerr << progname() << ": Option -" << static_cast<char>(optopt) std::cerr << progname() << ": Option -" << static_cast<char>(optopt)
<< " requires an argument\n"; << " requires an argument\n";
rc = 1; rc = 1;
break; break;
case '?': case '?':
std::cerr << progname() << ": Unrecognized option -" std::cerr << progname() << ": Unrecognized option -"
<< static_cast<char>(optopt) << "\n"; << static_cast<char>(optopt) << "\n";
rc = 1; rc = 1;
break; break;
default: default:
std::cerr << progname() std::cerr << progname()
<< ": getopt returned unexpected character code " << ": getopt returned unexpected character code "
<< std::hex << opt << "\n"; << std::hex << opt << "\n";
rc = 1; rc = 1;
} }
return rc; return rc;
} // Params::option } // Params::option

@ -21,7 +21,7 @@
/*! /*!
@file exiv2.hpp @file exiv2.hpp
@brief Defines class Params, used for the command line handling of exiv2 @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) @author Andreas Huggel (ahu)
<a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a> <a href="mailto:ahuggel@gmx.net">ahuggel@gmx.net</a>
@date 08-Dec-03, ahu: created @date 08-Dec-03, ahu: created
@ -85,13 +85,17 @@ public:
*/ */
static Params& instance(); static Params& instance();
//! Enumerates print modes
enum PrintMode { summary, interpreted, values, hexdump };
bool help_; //!< Help option flag. bool help_; //!< Help option flag.
bool version_; //!< Version option flag. bool version_; //!< Version option flag.
bool verbose_; //!< Verbose (talkative) option flag. bool verbose_; //!< Verbose (talkative) option flag.
bool force_; //!< Force overwrites flag. bool force_; //!< Force overwrites flag.
bool adjust_; //!< Adjustment flag. bool adjust_; //!< Adjustment flag.
PrintMode printMode_; //!< Print mode.
//! %Action (integer rather than TaskType to avoid dependency). //! %Action (integer rather than TaskType to avoid dependency).
int action_; int action_;
long adjustment_; //!< Adjustment in seconds. long adjustment_; //!< Adjustment in seconds.
std::string format_; //!< Filename format (-r option arg). std::string format_; //!< Filename format (-r option arg).
@ -106,12 +110,13 @@ private:
@brief Default constructor. Note that optstring_ is initialized here. @brief Default constructor. Note that optstring_ is initialized here.
Private to force instantiation through instance(). Private to force instantiation through instance().
*/ */
Params() : optstring_(":hVvfa:r:"), Params() : optstring_(":hVvfa:r:m:"),
help_(false), help_(false),
version_(false), version_(false),
verbose_(false), verbose_(false),
force_(false), force_(false),
adjust_(false), adjust_(false),
printMode_(summary),
action_(0), action_(0),
adjustment_(0), adjustment_(0),
format_("%Y%m%d_%H%M%S"), format_("%Y%m%d_%H%M%S"),

Loading…
Cancel
Save