Enumerations ParseEnumerations( const Lexems& lexems ) { Enumerations result; Lexems::const_iterator it= lexems.begin(); while( it < lexems.end() ) { result.push_back( ParseEnumeration( lexems, it ) ); } return result; }
void SimpleRedmineClient::retrieveEnumerations(QString enumeration, EnumerationsCb callback, QString parameters ) { ENTER()(enumeration)(parameters); auto cb = [=]( QNetworkReply* reply, QJsonDocument* json ) { ENTER(); // Quit on network error if( reply->error() != QNetworkReply::NoError ) { DEBUG() << "Network error:" << reply->errorString(); callback( Enumerations(), RedmineError::ERR_NETWORK, getErrorList(reply, json) ); RETURN(); } Enumerations enumerations; // Iterate over the document for( const auto& j1 : json->object() ) { // Iterate over all enumerations for( const auto& j2 : j1.toArray() ) { QJsonObject obj = j2.toObject(); Enumeration enumeration; // Simple fields enumeration.id = obj.value("id").toInt(); enumeration.name = obj.value("name").toString(); enumeration.isDefault = obj.value("is_default").toBool(); fillDefaultFields( enumeration, &obj ); enumerations.push_back( enumeration ); } } callback( enumerations, RedmineError::NO_ERR, QStringList() ); RETURN(); }; RedmineClient::retrieveEnumerations( enumeration, cb, parameters ); RETURN(); }