Detailed Description
The QAtResultParser class provides support for parsing the response to AT modem commands and unsolicited notifications.
The following example demonstrates how to parse the response to a AT+CPOL (preferred operator list) query:
QAtResultParser parser( result );
while ( parser.next( "+CPOL:" ) ) {
uint index = parser.readNumeric();
uint format = parser.readNumeric();
QString name;
if ( format == 2 )
name = QString::number( parser.readNumeric() );
else
name = parser.readString();
}
See also QAtResult.
Member Function Documentation
QAtResultParser::QAtResultParser ( const QAtResult & result )
Construct an AT modem result parser to parse the content of result. The caller will typically follow this with a call to next() to position the parser on the first line of relevant result data.
QAtResultParser::QAtResultParser ( const QString & notification )
Construct an AT modem result parser and initialize it to parse the specified unsolicited notification. Notifications are expected to have the format NAME: VALUE. The next() function will be called internally to position the parser at VALUE.
QAtResultParser::~QAtResultParser ()
Destruct this AT modem result parser.
QString QAtResultParser::line ()
Returns the full content of the line that next() positioned us on. The line's prefix is not included in the return value.
See also next(), readNumeric(), and readString().
QStringList QAtResultParser::lines ( const QString & prefix )
Returns the content of all lines that begin with prefix starting at the current position.
See also next().
bool QAtResultParser::next ( const QString & prefix )
Position this AT modem result parser on the next line that begins with prefix. Returns true on success; otherwise returns false.
See also line(), lines(), readNumeric(), and readString().
Read a list of values surrounded by parentheses. This is for complex command results that cannot be parsed with readNumeric() and readString().
QString QAtResultParser::readNextLine ()
Read the next line of input as literal text, without looking for a prefix. This is for results from commands such as AT+CMGL which place the PDU on a line of its own.
uint QAtResultParser::readNumeric ()
Read a numeric value from the current line.
See also readString() and skip().
QString QAtResultParser::readString ()
Read a string from the current line.
See also readNumeric() and skip().
void QAtResultParser::reset ()
Reset this AT modem result parser to the beginning of the content.
void QAtResultParser::skip ()
Skip the contents of a comma-separated field in the current line.
See also readNumeric() and readString().