File indexing completed on 2024-04-28 03:51:54
0001 /* 0002 This file is part of the KDE Baloo Project 0003 SPDX-FileCopyrightText: 2014-2015 Vishesh Handa <vhanda@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0006 */ 0007 0008 #include <QDebug> 0009 #include <QUuid> 0010 #include <QCoreApplication> 0011 #include <QCommandLineParser> 0012 #include <QCommandLineOption> 0013 0014 #include "document.h" 0015 0016 int main(int argc, char** argv) 0017 { 0018 QCoreApplication app(argc, argv); 0019 0020 QCommandLineParser parser; 0021 parser.addPositionalArgument(QStringLiteral("num"), QStringLiteral("The number of terms. Each term is of length 10")); 0022 parser.addOption(QCommandLineOption(QStringList () << QStringLiteral("p") << QStringLiteral("position"), QStringLiteral("Add positional information"))); 0023 parser.addHelpOption(); 0024 parser.process(app); 0025 0026 QStringList args = parser.positionalArguments(); 0027 if (args.size() != 1) { 0028 parser.showHelp(1); 0029 } 0030 0031 Baloo::Document doc; 0032 int size = args.first().toInt(); 0033 0034 for (int i = 0; i < size; i++) { 0035 QByteArray term = QUuid::createUuid().toByteArray().mid(1, 10); 0036 0037 if (parser.isSet(QStringLiteral("p"))) { 0038 doc.addPositionTerm(term, i); 0039 } 0040 else { 0041 doc.addTerm(term); 0042 } 0043 } 0044 0045 qDebug() << "Added" << size << "terms"; 0046 if (parser.isSet(QStringLiteral("p"))) { 0047 qDebug() << "With Positional Information"; 0048 } 0049 }