kwave  18.07.70
Parser.h
Go to the documentation of this file.
1 /***************************************************************************
2  Parser.h - parser for Kwave's internal commands
3  -------------------
4  begin : Sat Feb 3 2001
5  copyright : (C) 2001 by Thomas Eschenbacher
6  email : Thomas Eschenbacher <thomas.eschenbacher@gmx.de>
7 
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 #ifndef PARSER_H
20 #define PARSER_H
21 
22 #include "config.h"
23 
24 #include <QtGlobal>
25 #include <QString>
26 #include <QStringList>
27 #include <QUrl>
28 
29 #include "libkwave/Sample.h" // for sample_index_t
30 
31 //*****************************************************************************
32 namespace Kwave
33 {
34  class Q_DECL_EXPORT Parser
35  {
36  public:
41  Parser(const QString &init);
42 
44  virtual ~Parser();
45 
47  inline QString command() {
48  return m_command;
49  }
50 
52  inline const QStringList &params() {
53  return m_param;
54  }
55 
57  inline bool hasParams() {
58  return (m_param.count() != 0);
59  }
60 
62  inline bool hasMultipleCommands() {
63  return (m_commands.count() > 1);
64  }
65 
67  inline QStringList commandList() { return m_commands; }
68 
70  inline bool isDone () const {
71  return (static_cast<int>(m_current) >= m_param.count());
72  }
73 
75  inline unsigned int count() const {
76  return m_param.count();
77  }
78 
83  const QString &firstParam();
84 
91  const QString &nextParam();
92 
94  QStringList remainingParams();
95 
100  void skipParam();
101 
109  bool toBool();
110 
116  int toInt();
117 
123  unsigned int toUInt();
124 
130  sample_index_t toSampleIndex();
131 
137  double toDouble();
138 
145  static QString escape(const QString &text);
146 
154  static QString escapeForFileName(const QString &text);
155 
163  static QString unescape(const QString &text);
164 
171  static QUrl toUrl(const QString &command);
172 
178  static QString fromUrl(const QUrl &url);
179 
180  protected:
181 
183  QStringList splitCommands(QString &line);
184 
185  private:
187  QString m_command;
188 
190  QStringList m_param;
191 
193  unsigned int m_current;
194 
196  QStringList m_commands;
197 
198  };
199 }
200 
201 #endif /* PARSER_H */
202 
203 //***************************************************************************
204 //***************************************************************************
Definition: App.h:33
QStringList m_commands
Definition: Parser.h:196
unsigned int m_current
Definition: Parser.h:193
quint64 sample_index_t
Definition: Sample.h:28
bool hasMultipleCommands()
Definition: Parser.h:62
QStringList commandList()
Definition: Parser.h:67
int toInt(T x)
Definition: Utils.h:127
QStringList m_param
Definition: Parser.h:190
bool hasParams()
Definition: Parser.h:57
bool isDone() const
Definition: Parser.h:70
const QStringList & params()
Definition: Parser.h:52
unsigned int count() const
Definition: Parser.h:75
QString command()
Definition: Parser.h:47
QString m_command
Definition: Parser.h:187