| 198 | } |
| 199 | |
| 200 | QString ParameterizedCommand::Serialize() |
| 201 | { |
| 202 | const QString escapedId(this->Escape(this->GetId())); |
| 203 | |
| 204 | if (parameterizations.empty()) |
| 205 | { |
| 206 | return escapedId; |
| 207 | } |
| 208 | |
| 209 | QString str; |
| 210 | QTextStream buffer(&str); |
| 211 | buffer << CommandManager::PARAMETER_START_CHAR; |
| 212 | |
| 213 | for (int i = 0; i < parameterizations.size(); i++) |
| 214 | { |
| 215 | |
| 216 | if (i> 0) |
| 217 | { |
| 218 | // insert separator between parameters |
| 219 | buffer << CommandManager::PARAMETER_SEPARATOR_CHAR; |
| 220 | } |
| 221 | |
| 222 | const Parameterization& parameterization = parameterizations[i]; |
| 223 | const QString parameterId(parameterization.GetParameter()->GetId()); |
| 224 | const QString escapedParameterId(this->Escape(parameterId)); |
| 225 | |
| 226 | buffer << escapedParameterId; |
| 227 | |
| 228 | const QString parameterValue(parameterization.GetValue()); |
| 229 | if (!parameterValue.isEmpty()) |
| 230 | { |
| 231 | const QString escapedParameterValue(this->Escape(parameterValue)); |
| 232 | buffer << CommandManager::ID_VALUE_CHAR |
| 233 | << escapedParameterValue; |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | buffer << CommandManager::PARAMETER_END_CHAR; |
| 238 | |
| 239 | return str; |
| 240 | } |
| 241 | |
| 242 | QString ParameterizedCommand::ToString() const |
| 243 | { |