bool CommandImplementation::SetParameter(const wxString ¶mName, const wxVariant ¶mValue) { wxASSERT(!paramValue.IsType(wxT("null"))); ParamValueMap::iterator iter = mParams.find(paramName); if (iter == mParams.end()) { Error(paramName + wxT(" is not a parameter accepted by ") + GetName()); return false; } Validator &validator = mType.GetSignature().GetValidator(iter->first); if (!validator.Validate(paramValue)) { Error(wxT("Invalid value for parameter '") + paramName + wxT("': should be ") + validator.GetDescription()); return false; } mParams[paramName] = validator.GetConverted(); // (debug) // Status(wxT("Set parameter ") + paramName + wxT(" to type ") + mParams[paramName].GetType() + wxT(", value ") + mParams[paramName].MakeString()); return true; }
void CommandImplementation::TypeCheck(const wxString &typeName, const wxString ¶mName, const wxVariant ¶m) { // this macro is empty if wxWidgets is not compiled in debug mode wxASSERT_MSG(param.IsType(typeName), GetName() + wxT("command tried to get '") + paramName + wxT("' parameter as a ") + typeName + wxT(", but that wasn't enforced by the command signature.")); }
// set value, call ValueChanged() afterwards! bool wxDBase::SetValueByRow(const wxVariant& var, unsigned int row, unsigned int col) { bool ok = true; if (ok) ok = SetPosition(row); if (var.IsType(wxT("datetime"))) { ok = Write(col, var.GetDateTime()); } else { ok = Write(col, var.MakeString()); } if (ok) { ok = PutRecord(row); } return ok; }