示例#1
0
bool CommandImplementation::SetParameter(const wxString &paramName, const wxVariant &paramValue)
{
   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;
}
示例#2
0
void CommandImplementation::TypeCheck(const wxString &typeName,
                                      const wxString &paramName,
                                      const wxVariant &param)
{
   // 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."));
}
示例#3
0
// 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;
}