void LogVariant(const wxString& prefix, const wxVariant& v)
{
    const wxString type = v.GetType();

    wxString info;
    const wxString& name = v.GetName();
    if (type == wxS("arrstring")) {
        wxArrayString as = v.GetArrayString();
        info.Printf(wxS("%svariant type: \"%s\", element count: %zu, name: \"%s\"."),
            prefix, type, as.size(), name);        
        wxLogTrace(wxTRACE_AutoExcel, wxS("%s"), info);
        for (size_t i = 0; i < as.size(); i++) 
        {
            info.Printf(wxS("   string #%zu value: \"%s\""), i, as[i]);
            if ( i == LogVariantMaxItemsInList )
            {
                wxLogTrace(wxTRACE_AutoExcel, wxS("And %zu more strings"), as.size() - i);
                break;
            }
            else            
                wxLogTrace(wxTRACE_AutoExcel, wxS("%s"), info);
        }
        return;
    }
    if (type == wxS("list")) {
        info.Printf(wxS("%sVariant type: \"%s\", element count: %zu, name: \"%s\"."),
            prefix, type, v.GetCount(), name);
        wxLogTrace(wxTRACE_AutoExcel, wxS("%s"), info);
        for (size_t i = 0; i < v.GetCount(); i++)
        {
            if ( i == LogVariantMaxItemsInList )
            {
                wxLogTrace(wxTRACE_AutoExcel, wxS("And %zu more variants"), v.GetCount() - i);
                break;
            } else            
            {
                const wxVariant& vTmp = v[i];
                info.Printf(wxS("   variant #%zu type: \"%s\", value: \"%s\", name: \"%s\"."),
                    i, vTmp.GetType(), vTmp.MakeString(), vTmp.GetName());        
                wxLogTrace(wxTRACE_AutoExcel, wxS("%s"), info);
            }
        }
        return;
    }
    if (type == wxS("void*") && v.GetVoidPtr() != NULL) {
        wxString automationName;
        wxExcelObject object;
        IDispatch* dispatch = (IDispatch*)v.GetVoidPtr();
        dispatch->AddRef();
        object.GetAutomationObject_()->SetDispatchPtr(dispatch);
        info.Printf(wxS("%svariant type: \"IDispatch - %s\", value: \"%s\", name: \"%s\"."),
            prefix, object.GetAutomationObjectName_(false), v.MakeString(), name);    
    } else {
        info.Printf(wxS("%svariant type: \"%s\", value: \"%s\", name: \"%s\"."),
            prefix, type, v.MakeString(), name);        
    }
    wxLogTrace(wxTRACE_AutoExcel, wxS("%s"), info);
}
void CommandSignature::AddParameter(const wxString &name,
      const wxVariant &dft,
      std::unique_ptr<Validator> &&valid)
{
   wxASSERT_MSG(valid->Validate(dft),
         wxT("Invalid command signature: the default value of '")
         + dft.MakeString()
         + wxT("' for the '")
         + name
         + wxT("' parameter doesn't satisfy the provided validator.")
         + wxT(" It should be ")
         + valid->GetDescription()
         + wxT("."));
   mDefaults.insert(std::pair<wxString, wxVariant>(name, dft));
   mValidators.insert(ValidatorMap::value_type(name, std::move(valid)));
}
Beispiel #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;
}
Beispiel #4
0
 static std::string convert(const wxVariant& v)
 {
     return v.MakeString().ToStdString(wxConvUTF8);
 }