File indexing completed on 2025-01-05 03:58:13

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2013-11-28
0007  * Description : a command line tool to test ExifTool stream parsing.
0008  *
0009  * SPDX-FileCopyrightText: 2012-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 // Qt includes
0016 
0017 #include <QString>
0018 #include <QByteArray>
0019 #include <QCoreApplication>
0020 #include <QFile>
0021 #include <QObject>
0022 
0023 // Local includes
0024 
0025 #include "digikam_debug.h"
0026 #include "exiftoolparser.h"
0027 #include "exiftoolprocess.h"
0028 
0029 using namespace Digikam;
0030 
0031 int main(int argc, char** argv)
0032 {
0033     QCoreApplication app(argc, argv);
0034 
0035     if (argc != 2)
0036     {
0037         qCDebug(DIGIKAM_TESTS_LOG) << "exiftoolparserout_cli - CLI tool to check ExifTool stream parsing";
0038         qCDebug(DIGIKAM_TESTS_LOG) << "Usage: <ExifTool input stream>";
0039         return -1;
0040     }
0041 
0042     QFile input(QString::fromUtf8(argv[1]));
0043 
0044     if (!input.open(QIODevice::ReadOnly))
0045     {
0046         qCDebug(DIGIKAM_TESTS_LOG) << "Cannot open ExifTool input stream to read...";
0047         return -1;
0048     }
0049 
0050     QByteArray stdOut            = input.readAll();
0051 
0052     ExifToolParser* const parser = new ExifToolParser(qApp);
0053 
0054     parser->setOutputStream(ExifToolProcess::LOAD_METADATA,     // Command action ID
0055                             stdOut,                             // Output channel
0056                             QByteArray());                      // Error channel
0057 
0058     return 0;
0059 }