kwave
18.07.70
|
#include <Parser.h>
Public Member Functions | |
Parser (const QString &init) | |
virtual | ~Parser () |
QString | command () |
const QStringList & | params () |
bool | hasParams () |
bool | hasMultipleCommands () |
QStringList | commandList () |
bool | isDone () const |
unsigned int | count () const |
const QString & | firstParam () |
const QString & | nextParam () |
QStringList | remainingParams () |
void | skipParam () |
bool | toBool () |
int | toInt () |
unsigned int | toUInt () |
sample_index_t | toSampleIndex () |
double | toDouble () |
Static Public Member Functions | |
static QString | escape (const QString &text) |
static QString | escapeForFileName (const QString &text) |
static QString | unescape (const QString &text) |
static QUrl | toUrl (const QString &command) |
static QString | fromUrl (const QUrl &url) |
Protected Member Functions | |
QStringList | splitCommands (QString &line) |
Private Attributes | |
QString | m_command |
QStringList | m_param |
unsigned int | m_current |
QStringList | m_commands |
Kwave::Parser::Parser | ( | const QString & | init | ) |
Constructor. Parses the given string into an optional command part and a list of parameters.
Definition at line 31 of file Parser.cpp.
References DBG, m_command, m_commands, m_param, splitCommands(), and unescape().
|
virtual |
|
inline |
Returns the command part of the line
Definition at line 47 of file Parser.h.
Referenced by Kwave::FileContext::delegateCommand(), Kwave::TopWidget::executeCommand(), Kwave::App::executeCommand(), Kwave::FileContext::executeCommand(), fromUrl(), Kwave::FileContext::parseCommands(), Kwave::MenuItem::specialCommand(), Kwave::MenuNode::specialCommand(), and toUrl().
|
inline |
Returns the list of commands
Definition at line 67 of file Parser.h.
Referenced by Kwave::FileContext::executeCommand().
|
inline |
Returns the number of parameters.
Definition at line 75 of file Parser.h.
References Kwave::toInt().
Referenced by Kwave::FileContext::delegateCommand(), Kwave::FileContext::executeCommand(), nextParam(), and toUrl().
|
static |
Escapes all characters that might be critical when parsing
text | a unicode text to escape |
Definition at line 277 of file Parser.cpp.
References _.
Referenced by Kwave::MenuManager::addNumberedMenuEntry(), Kwave::K3BExportPlugin::detectBlockMetaData(), Kwave::TopWidget::dropEvent(), Kwave::SignalView::dropEvent(), Kwave::AsciiEncoder::encode(), escapeForFileName(), Kwave::K3BExportPlugin::saveBlocks(), Kwave::MainWidget::saveLabels(), Kwave::SaveBlocksPlugin::setup(), and Kwave::K3BExportPlugin::setup().
|
static |
Escape all parts of a string that might be dangerous for using within a file name, like "/" and similar.
text | a unicode text to escape |
Definition at line 295 of file Parser.cpp.
Referenced by Kwave::SaveBlocksPlugin::createFileName(), and Kwave::K3BExportPlugin::saveBlocks().
const QString & Kwave::Parser::firstParam | ( | ) |
Returns the first parameter and sets the current position to the next.
Definition at line 168 of file Parser.cpp.
References m_current, and nextParam().
Referenced by Kwave::MenuManager::executeCommand(), Kwave::SignalManager::executeCommand(), Kwave::TopWidget::executeCommand(), Kwave::FileContext::executeCommand(), Kwave::Curve::fromCommand(), Kwave::TopWidget::openRecent(), Kwave::FileContext::parseCommands(), Kwave::MenuItem::specialCommand(), and Kwave::MenuNode::specialCommand().
|
static |
Converts a kwave:// URL into a string command
url | a URL using the kwave:// scheme |
Definition at line 360 of file Parser.cpp.
References _, command(), params(), and Kwave::urlScheme().
Referenced by Kwave::TopWidget::loadFile().
|
inline |
Returns true if a list of commands was parsed
Definition at line 62 of file Parser.h.
Referenced by Kwave::FileContext::executeCommand().
|
inline |
Returns true if the parameter list is not empty.
Definition at line 57 of file Parser.h.
Referenced by Kwave::App::executeCommand(), and Kwave::MainWidget::executeCommand().
|
inline |
Returns true if the end of the parameter list has been reached.
Definition at line 70 of file Parser.h.
Referenced by Kwave::MainWidget::executeCommand(), Kwave::Curve::fromCommand(), remainingParams(), and Kwave::AmplifyFreePlugin::setup().
const QString & Kwave::Parser::nextParam | ( | ) |
Returns the next parameter and increases the current position if not already at the end of the parameter list. If the end of the parameter list has been reached, the return value will be a zero-length string.
Definition at line 175 of file Parser.cpp.
References _, count(), m_current, and m_param.
Referenced by Kwave::MenuManager::executeCommand(), Kwave::SignalManager::executeCommand(), Kwave::TopWidget::executeCommand(), Kwave::MainWidget::executeCommand(), Kwave::FileContext::executeCommand(), Kwave::Filter::Filter(), firstParam(), remainingParams(), Kwave::AmplifyFreePlugin::setup(), skipParam(), Kwave::MenuItem::specialCommand(), Kwave::MenuNode::specialCommand(), toBool(), toDouble(), toInt(), toSampleIndex(), toUInt(), and toUrl().
|
inline |
Returns the complete list of parameters
Definition at line 52 of file Parser.h.
Referenced by Kwave::App::executeCommand(), fromUrl(), and toUrl().
QStringList Kwave::Parser::remainingParams | ( | ) |
Returns all remaining parameters in a string list
Definition at line 189 of file Parser.cpp.
References isDone(), and nextParam().
Referenced by Kwave::FileContext::delegateCommand(), and Kwave::FileContext::executeCommand().
void Kwave::Parser::skipParam | ( | ) |
Skips a parameter and advances the current position by one if the end has not already been reached.
Definition at line 183 of file Parser.cpp.
References nextParam().
|
protected |
Splits a line into a list of commands
Definition at line 113 of file Parser.cpp.
References _.
Referenced by Parser().
bool Kwave::Parser::toBool | ( | ) |
Gets the next parameter through calling nextParam() and interpretes it as a "bool" value. It will recognize the strings "true" and "false" (not case-sensitive) and numeric values (true means not zero). On errors the return value will be false.
Definition at line 198 of file Parser.cpp.
References _, DBG, and nextParam().
double Kwave::Parser::toDouble | ( | ) |
Gets the next parameter through calling nextParam() and interpretes it as a "double" value. On errors the return value will be zero.
Definition at line 262 of file Parser.cpp.
References DBG, and nextParam().
Referenced by Kwave::TopWidget::executeCommand(), Kwave::Filter::Filter(), and Kwave::Curve::fromCommand().
int Kwave::Parser::toInt | ( | ) |
Gets the next parameter through calling nextParam() and interpretes it as an "int" value. On errors the return value will be zero.
Definition at line 216 of file Parser.cpp.
References DBG, and nextParam().
Referenced by Kwave::SignalManager::executeCommand(), Kwave::MainWidget::executeCommand(), and Kwave::Filter::Filter().
sample_index_t Kwave::Parser::toSampleIndex | ( | ) |
Gets the next parameter through calling nextParam() and interpretes it as a "sample_index_t" value. On errors the return value will be zero.
Definition at line 246 of file Parser.cpp.
References DBG, and nextParam().
Referenced by Kwave::SignalManager::executeCommand(), Kwave::TopWidget::executeCommand(), and Kwave::MainWidget::executeCommand().
unsigned int Kwave::Parser::toUInt | ( | ) |
Gets the next parameter through calling nextParam() and interpretes it as an "unsigned int" value. On errors the return value will be zero.
Definition at line 231 of file Parser.cpp.
References DBG, and nextParam().
Referenced by Kwave::SignalManager::executeCommand(), and Kwave::TopWidget::executeCommand().
|
static |
Converts a string command into a URL suitable for passing to Kwave as command line parameter
command | the string command to encode as URL |
Definition at line 336 of file Parser.cpp.
References command(), count(), nextParam(), params(), and Kwave::urlScheme().
Referenced by Kwave::TopWidget::newSignal().
|
static |
Un-escapes all characters in a string previously escaped with escape()
text | a unicode text to un-escape |
Definition at line 314 of file Parser.cpp.
Referenced by Kwave::SaveBlocksPlugin::interpreteParameters(), Kwave::K3BExportPlugin::interpreteParameters(), Kwave::AsciiDecoder::open(), Parser(), Kwave::SaveBlocksPlugin::start(), and Kwave::SaveBlocksPlugin::updateExample().
|
private |
|
private |
|
private |
number of the "current" parameter
Definition at line 193 of file Parser.h.
Referenced by firstParam(), and nextParam().
|
private |
list of parsed parameters
Definition at line 190 of file Parser.h.
Referenced by nextParam(), and Parser().