Warning, file /multimedia/kid3/src/app/cli/textcliformatter.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /** 0002 * \file textcliformatter.h 0003 * CLI formatter for standard text input and output. 0004 * 0005 * \b Project: Kid3 0006 * \author Urs Fleisch 0007 * \date 28 Jul 2019 0008 * 0009 * Copyright (C) 2019-2024 Urs Fleisch 0010 * 0011 * This file is part of Kid3. 0012 * 0013 * Kid3 is free software; you can redistribute it and/or modify 0014 * it under the terms of the GNU General Public License as published by 0015 * the Free Software Foundation; either version 2 of the License, or 0016 * (at your option) any later version. 0017 * 0018 * Kid3 is distributed in the hope that it will be useful, 0019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0021 * GNU General Public License for more details. 0022 * 0023 * You should have received a copy of the GNU General Public License 0024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0025 */ 0026 0027 #pragma once 0028 0029 #include "abstractcliformatter.h" 0030 0031 /** 0032 * CLI formatter for standard text input and output. 0033 */ 0034 class TextCliFormatter : public AbstractCliFormatter { 0035 Q_OBJECT 0036 public: 0037 /** 0038 * Constructor. 0039 * @param io I/O handler 0040 */ 0041 explicit TextCliFormatter(AbstractCliIO* io); 0042 0043 /** 0044 * Destructor. 0045 */ 0046 ~TextCliFormatter() override; 0047 0048 /** 0049 * Clear parser state. 0050 */ 0051 void clear() override; 0052 0053 /** 0054 * Get command and parameters from input line. 0055 * @param line input line 0056 * @return list of command and arguments, empty if not found or incomplete. 0057 */ 0058 QStringList parseArguments(const QString& line) override; 0059 0060 /** 0061 * Get error which occurred in previous method call. 0062 * @return error message, null if no error. 0063 */ 0064 QString getErrorMessage() const override; 0065 0066 /** 0067 * Check if format was recognized and parsed, but input is will be continued 0068 * in subsequent lines. 0069 * @return true if input is incomplete. 0070 */ 0071 bool isIncomplete() const override; 0072 0073 /** 0074 * Check if format was recognized and parsed. 0075 * @return true if format was recognized. 0076 */ 0077 bool isFormatRecognized() const override; 0078 0079 /** 0080 * Write error message. 0081 * @param errorCode error code 0082 */ 0083 void writeError(CliError errorCode) override; 0084 0085 /** 0086 * Write error message. 0087 * @param msg error message 0088 */ 0089 void writeError(const QString& msg) override; 0090 0091 /** 0092 * Write error message. 0093 * @param msg error message 0094 * @param errorCode error code 0095 */ 0096 void writeError(const QString& msg, CliError errorCode) override; 0097 0098 /** 0099 * Write result message. 0100 * @param str result as string 0101 */ 0102 void writeResult(const QString& str) override; 0103 0104 /** 0105 * Write result message. 0106 * @param strs result as string list 0107 */ 0108 void writeResult(const QStringList& strs) override; 0109 0110 /** 0111 * Write result message. 0112 * @param map result as map 0113 */ 0114 void writeResult(const QVariantMap& map) override; 0115 0116 /** 0117 * Write result message. 0118 * @param result result as boolean 0119 */ 0120 void writeResult(bool result) override; 0121 0122 /** 0123 * Called when a command is finished. 0124 */ 0125 void finishWriting() override; 0126 0127 private: 0128 QString m_errorMessage; 0129 QStringList m_args; 0130 };