32#include <exiv2/exiv2.hpp>
45#ifdef EXV_HAVE_UNISTD_H
54#if defined(__CYGWIN__) || defined(__MINGW__)
57#include <sys/select.h>
61#if defined(_WIN32) || defined(__CYGWIN__) || defined(__MINGW__) || defined(_MSC_VER)
71enum CmdId { invalidCmdId, add, set, del, reg };
77 , iptc = Exiv2::mdIptc
78 , exif = Exiv2::mdExif
141 std::string optstring_;
149 using Files = std::vector<std::string>;
153 using Keys = std::vector<std::string>;
214 enum Yod { yodYear, yodMonth, yodDay };
263 static const YodAdjust emptyYodAdjust_[];
272 Params() : optstring_(
":hVvqfbuktTFa:Y:O:D:r:p:P:d:e:i:c:m:M:l:S:g:K:n:Q:"),
288 target_(ctExif|ctIptc|ctComment|ctXmp),
294 yodAdjust_[yodYear] = emptyYodAdjust_[yodYear];
295 yodAdjust_[yodMonth] = emptyYodAdjust_[yodMonth];
301 int setLogLevel(
const std::string& optarg);
302 int evalGrep(
const std::string& optarg);
303 int evalKey(
const std::string& optarg);
304 int evalRename(
int opt,
const std::string& optarg);
305 int evalAdjust(
const std::string& optarg);
306 int evalYodAdjust(
const Yod& yod,
const std::string& optarg);
307 int evalPrint(
const std::string& optarg);
308 int evalPrintFlags(
const std::string& optarg);
309 int evalDelete(
const std::string& optarg);
310 int evalExtract(
const std::string& optarg);
311 int evalInsert(
const std::string& optarg);
312 int evalModify(
int opt,
const std::string& optarg);
326 int getopt(
int argc,
char*
const argv[]);
329 int option(
int opt,
const std::string& optarg,
int optopt)
override;
335 void usage(std::ostream& os =std::cout)
const;
338 void help(std::ostream& os =std::cout)
const;
341 static void version(
bool verbose =
false, std::ostream& os = std::cout);
344 static std::string
printTarget(
const std::string& before,
int target,
bool bPrint =
false,
345 std::ostream& out = std::cout);
Implements the command line handling for the program.
Definition: exiv2app.hpp:139
void usage(std::ostream &os=std::cout) const
Print a minimal usage note to an output stream.
Definition: exiv2.cpp:235
std::string charset_
Charset to use for UNICODE Exif user comment.
Definition: exiv2app.hpp:255
bool preserve_
Preserve timestamps flag.
Definition: exiv2app.hpp:229
void help(std::ostream &os=std::cout) const
Print further usage explanations to an output stream.
Definition: exiv2.cpp:261
int target_
What common target to process.
Definition: exiv2app.hpp:239
static std::string printTarget(const std::string &before, int target, bool bPrint=false, std::ostream &out=std::cout)
Print target_.
Definition: exiv2.cpp:242
bool version_
Version option flag.
Definition: exiv2app.hpp:224
std::vector< std::string > Files
Container to store filenames.
Definition: exiv2app.hpp:149
std::vector< std::string > Keys
Container for keys.
Definition: exiv2app.hpp:153
Yod
Enumerates year, month and day adjustments.
Definition: exiv2app.hpp:214
PrintMode printMode_
Print mode.
Definition: exiv2app.hpp:234
CmdFiles cmdFiles_
Names of the modification command files.
Definition: exiv2app.hpp:245
PreviewNumbers previewNumbers_
List of preview numbers.
Definition: exiv2app.hpp:252
std::string format_
Filename format (-r option arg).
Definition: exiv2app.hpp:243
bool verbose_
Verbose (talkative) option flag.
Definition: exiv2app.hpp:225
bool force_
Force overwrites flag.
Definition: exiv2app.hpp:226
std::vector< std::regex > greps_
List of keys to 'grep' from the metadata.
Definition: exiv2app.hpp:253
std::string jpegComment_
Jpeg comment to set in the image.
Definition: exiv2app.hpp:248
int getopt(int argc, char *const argv[])
Call Getopt::getopt() with optstring, to inititate command line argument parsing, perform consistency...
int nonoption(const std::string &argv) override
Handle non-option parameters.
std::vector< std::string > CmdFiles
Container for command files.
Definition: exiv2app.hpp:145
bool formatSet_
Whether the format is set with -r.
Definition: exiv2app.hpp:244
std::string directory_
Location for files to extract/insert.
Definition: exiv2app.hpp:249
unsigned long printTags_
Print tags (bitmap of MetadataId flags). Action (integer rather than TaskType to avoid dependency).
Definition: exiv2app.hpp:236
long adjustment_
Adjustment in seconds.
Definition: exiv2app.hpp:241
FileExistsPolicy
Enumerates the policies to handle existing files in rename action.
Definition: exiv2app.hpp:211
bool unknown_
Suppress unknown tags.
Definition: exiv2app.hpp:228
std::vector< std::string > CmdLines
Container for commands from the command line.
Definition: exiv2app.hpp:147
unsigned long printItems_
Print items.
Definition: exiv2app.hpp:235
CmdLines cmdLines_
Commands from the command line.
Definition: exiv2app.hpp:246
void getStdin(Exiv2::DataBuf &buf)
getStdin binary data read from stdin to DataBuf
static void cleanup()
Destructor.
Definition: exiv2.cpp:205
FileExistsPolicy fileExistsPolicy_
What to do if file to rename exists.
Definition: exiv2app.hpp:232
Exiv2::DataBuf stdinBuf
DataBuf with the binary bytes from stdin.
Definition: exiv2app.hpp:257
bool timestamp_
Rename also sets the file timestamp.
Definition: exiv2app.hpp:230
static void version(bool verbose=false, std::ostream &os=std::cout)
Print version information to an output stream.
Definition: exiv2.cpp:211
CommonTarget
Enumerates common targets, bitmap.
Definition: exiv2app.hpp:196
int option(int opt, const std::string &optarg, int optopt) override
Handle options and their arguments.
std::string suffix_
File extension of the file to insert.
Definition: exiv2app.hpp:250
std::set< int > PreviewNumbers
Container for preview image numbers.
Definition: exiv2app.hpp:151
PrintItem
Individual items to print, bitmap.
Definition: exiv2app.hpp:180
PrintMode
Enumerates print modes.
Definition: exiv2app.hpp:168
ModifyCmds modifyCmds_
Parsed modification commands.
Definition: exiv2app.hpp:247
Params(const Params &rhs)=delete
Prevent copy-construction: not implemented.
bool timestampOnly_
Rename only sets the file timestamp.
Definition: exiv2app.hpp:231
bool adjust_
Adjustment flag.
Definition: exiv2app.hpp:233
YodAdjust yodAdjust_[3]
Year, month and day adjustment info.
Definition: exiv2app.hpp:242
Files files_
List of non-option arguments.
Definition: exiv2app.hpp:251
static Params & instance()
Controls all access to the global Params instance.
Definition: exiv2.cpp:197
Keys keys_
List of keys to match from the metadata.
Definition: exiv2app.hpp:254
bool help_
Help option flag.
Definition: exiv2app.hpp:223
bool binary_
Suppress long binary values.
Definition: exiv2app.hpp:227
MetadataId
Metadata identifiers.
Definition: exiv2app.hpp:76
std::vector< ModifyCmd > ModifyCmds
Container for modification commands.
Definition: exiv2app.hpp:97
CmdId
Command identifiers.
Definition: exiv2app.hpp:71
Provides classes and functions to encode and decode Exif and Iptc data. The libexiv2 API consists of ...
Definition: basicio.hpp:43
TypeId
Exiv2 value type identifiers.
Definition: types.hpp:100
Structure to link command identifiers to strings.
Definition: exiv2app.hpp:99
CmdId cmdId_
Commands identifier.
Definition: exiv2app.hpp:100
std::string cmdString_
Command string.
Definition: exiv2app.hpp:101
Utility class containing a character array. All it does is to take care of memory allocation and dele...
Definition: types.hpp:162
Structure for one parsed modification command.
Definition: exiv2app.hpp:83
ModifyCmd()
C'tor.
Definition: exiv2app.hpp:85
Exiv2::TypeId typeId_
Exiv2 type identifier Flag to indicate if the type was explicitly specified (true)
Definition: exiv2app.hpp:91
CmdId cmdId_
Command identifier.
Definition: exiv2app.hpp:88
std::string value_
Data.
Definition: exiv2app.hpp:94
std::string key_
Exiv2 key string.
Definition: exiv2app.hpp:89
MetadataId metadataId_
Metadata identifier.
Definition: exiv2app.hpp:90
Structure for year, month and day adjustment command line arguments.
Definition: exiv2app.hpp:217
long adjustment_
Adjustment value.
Definition: exiv2app.hpp:220
const char * option_
Adjustment option string.
Definition: exiv2app.hpp:219
bool flag_
Adjustment flag.
Definition: exiv2app.hpp:218