TTKMusicPlayer  3.7.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 - 2024 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 {
91 public:
95  TTKCommandLineParser() = default;
96 
100  void setDescription(const QString &description) noexcept;
101 
105  bool addOption(const TTKCommandLineOption &option);
109  bool addOptions(const QList<TTKCommandLineOption> &options);
110 
114  void process();
118  void process(const QStringList &arguments);
119 
123  bool isSet(const TTKCommandLineOption &option) const;
127  QString value(const TTKCommandLineOption &option) const;
128 
132  inline bool isEmpty() const noexcept { return m_commands.isEmpty(); }
133 
137  void showHelp() const;
138 
139 private:
140  QString m_description;
141  QHash<QString, QString> m_commands;
142  QList<TTKCommandLineOption> m_options;
143 
144 };
145 
146 #endif // TTKCOMMANDLINE_H
bool operator==(const VolumeSettings &v1, const VolumeSettings &v2)
Definition: volume.h:38
#define TTK_MODULE_EXPORT
QString description() const noexcept
TTKCommandLineOption(const QString &first, const QString &description) noexcept
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
#define TTK_DECLARE_MODULE(Class)
Definition: ttkqtglobal.h:152
bool isEmpty() const noexcept
bool operator!=(const VolumeSettings &v1, const VolumeSettings &v2)
Definition: volume.h:43
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