TTKMusicPlayer  4.3.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
ttkcommandline.h
Go to the documentation of this file.
1 #ifndef TTKCOMMANDLINE_H
2 #define TTKCOMMANDLINE_H
3 
4 /***************************************************************************
5  * This file is part of the TTK Library Module project
6  * Copyright (C) 2015 - 2026 Greedysky Studio
7 
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Lesser General Public License for more details.
17 
18  * You should have received a copy of the GNU Lesser General Public License along
19  * with this program; If not, see <http://www.gnu.org/licenses/>.
20  ***************************************************************************/
21 
22 #include <QCoreApplication>
23 #include "ttkmoduleexport.h"
24 
29 {
30 public:
34  TTKCommandLineOption(const QString &first) noexcept
35  : m_first(first)
36  {
37 
38  }
39 
40  TTKCommandLineOption(const QString &first, const QString &description) noexcept
41  : m_first(first),
42  m_description(description)
43  {
44 
45  }
46 
47  TTKCommandLineOption(const QString &first, const QString &second, const QString &description) noexcept
48  : m_first(first),
49  m_second(second),
50  m_description(description)
51  {
52 
53  }
54 
58  inline QString first() const noexcept { return m_first; }
62  inline QString second() const noexcept { return m_second; }
66  inline QString description() const noexcept { return m_description; }
67 
68  inline bool operator== (const TTKCommandLineOption &other) const noexcept
69  {
70  return m_first == other.m_first && m_second == other.m_second;
71  }
72  inline bool operator!= (const TTKCommandLineOption &other) const noexcept
73  {
74  return m_first != other.m_first || m_second != other.m_second;
75  }
76 
77 private:
78  QString m_first;
79  QString m_second;
80  QString m_description;
81 
82 };
83 
84 
89 {
90 public:
94  TTKCommandLineParser() = default;
95 
99  void setDescription(const QString &description) noexcept;
100 
104  bool addOption(const TTKCommandLineOption &option);
108  bool addOptions(const QList<TTKCommandLineOption> &options);
109 
113  void process();
117  void process(const QStringList &arguments);
118 
122  bool isSet(const TTKCommandLineOption &option) const;
126  QString value(const TTKCommandLineOption &option) const;
127 
131  inline bool isEmpty() const noexcept { return m_commands.isEmpty(); }
132 
136  void showHelp() const;
137 
138 private:
139  QString m_description;
140  QHash<QString, QString> m_commands;
141  QList<TTKCommandLineOption> m_options;
142 
143 };
144 
145 #endif // TTKCOMMANDLINE_H
#define TTK_MODULE_EXPORT
QString description() const noexcept
TTKCommandLineOption(const QString &first, const QString &description) noexcept
bool operator==(const TTKOptional< T > &v, const T &other)
Definition: ttkoptional.h:144
The class of the command line option.
QList< TTKCommandLineOption > m_options
TTKCommandLineOption(const QString &first, const QString &second, const QString &description) noexcept
QString second() const noexcept
bool operator!=(const TTKOptional< T > &v, const T &other)
Definition: ttkoptional.h:156
bool isEmpty() const noexcept
TTKCommandLineOption(const QString &first) noexcept
QString first() const noexcept
QHash< QString, QString > m_commands
#define const
Definition: zconf.h:233
The class of the command line parser.
const char * description
Definition: http_parser.c:459