Logo Search packages:      
Sourcecode: akonadi version File versions  Download package

int ImapParser::parseParenthesizedList ( const QByteArray &  data,
QList< QByteArray > &  result,
int  start = 0 
) [static]

Parses the next parenthesized list in data starting from start and puts the result into result. The number of used characters is returned. This does not recurse into sub-lists.

Parameters:
data Source data.
result The parsed list.
start Start parsing at this index.

Definition at line 63 of file imapparser.cpp.

References parseString().

Referenced by Akonadi::Store::handleLine(), Akonadi::Status::handleLine(), Akonadi::Modify::handleLine(), Akonadi::Create::handleLine(), Akonadi::Append::handleLine(), Akonadi::AkList::handleLine(), Akonadi::AkAppend::handleLine(), and Akonadi::HandlerHelper::parseCachePolicy().

{
  result.clear();
  if ( start >= data.length() )
    return data.length();

  int begin = data.indexOf( '(', start );
  if ( begin < 0 )
    return start;

  int count = 0;
  int sublistbegin = start;
  for ( int i = begin + 1; i < data.length(); ++i ) {
    if ( data[i] == '(' ) {
      ++count;
      if ( count == 1 )
        sublistbegin = i;
      continue;
    }
    if ( data[i] == ')' ) {
      if ( count <= 0 )
        return i + 1;
      if ( count == 1 )
        result.append( data.mid( sublistbegin, i - sublistbegin + 1 ) );
      --count;
      continue;
    }
    if ( data[i] == ' ' )
      continue;
    if ( count == 0 ) {
      QByteArray ba;
      i = parseString( data, ba, i ) - 1; // compensate the increment
      result.append( ba );
    }
  }
  return data.length();
}


Generated by  Doxygen 1.6.0   Back to index