本文整理汇总了C++中CComQIPtr::CreateRowBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ CComQIPtr::CreateRowBuffer方法的具体用法?C++ CComQIPtr::CreateRowBuffer怎么用?C++ CComQIPtr::CreateRowBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComQIPtr
的用法示例。
在下文中一共展示了CComQIPtr::CreateRowBuffer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: R_export2dataset
//.........这里部分代码省略.........
OLECHAR buf[256];
::StringFromGUID2(isShape ? CLSID_Feature : CLSID_Row, buf, 256);
ipUID->put_Value(CComVariant(buf));
}
CComQIPtr<ITable> ipTableNew;
CComBSTR keyword(L"");
hr = E_FAIL;
if (isShape)
{
CComPtr<IFeatureClass> ipFClass;
hr = ipFWKS->CreateFeatureClass(bstrTableName, ipFields, ipUID, 0, esriFTSimple, CComBSTR(L"Shape"), keyword, &ipFClass);
ipTableNew = ipFClass;
}
else
{
hr = ipFWKS->CreateTable(bstrTableName, ipFields, ipUID, 0, keyword, &ipTableNew);
}
if (hr != S_OK)
{
std::wstring err_txt(isShape ? L"Create FeatureClass :" : L"Create Table :");
err_txt += bstrTableName;
err_txt += L" has failed";
return showError<true>(err_txt.c_str()), R_NilValue;
}
CComVariant oid;
CComPtr<ICursor> ipCursor;
CComPtr<IRowBuffer> ipRowBuffer;
hr = ipTableNew->Insert(VARIANT_TRUE, &ipCursor);
if (hr != S_OK)
return showError<true>(L"Insert cursor failed"), R_NilValue;
hr = ipTableNew->CreateRowBuffer(&ipRowBuffer);
if (hr != S_OK)
return showError<true>(L"Insert cursor failed"), R_NilValue;
//re-map fields
CComPtr<IFields> ipRealFields;
ipCursor->get_Fields(&ipRealFields);
for (size_t c = 0; c < cols.c.size(); c++)
{
ipRealFields->FindField(CComBSTR(cols.c[c]->name_ref->c_str()), &(cols.c[c]->pos));
CComPtr<IField> ipField;
ipRealFields->get_Field(cols.c[c]->pos, &ipField);
VARIANT_BOOL b = VARIANT_FALSE;
ipField->get_IsNullable(&b);
if (b == VARIANT_FALSE)
{
esriFieldType ft = esriFieldTypeInteger;
ipField->get_Type(&ft);
switch(ft)
{
case esriFieldTypeInteger:
cols.c[c]->vNULL = 0;//std::numeric_limits<int>::min();
break;
case esriFieldTypeDouble:
cols.c[c]->vNULL = 0.0;//-std::numeric_limits<double>::max();
break;
case esriFieldTypeString:
cols.c[c]->vNULL = L"";
}
}
}
CComQIPtr<IFeatureBuffer> ipFBuffer(ipRowBuffer);
示例2: R_dataframe2dataset
//.........这里部分代码省略.........
if (hr != S_OK)
return showError<true>(L"validate fields failed"), NULL;
if (ipFixedFields)
{
ipFields = ipFixedFields;
for (size_t c = 0; c < cols.c.size(); c++)
{
CComPtr<IField> ipFixedField;
ipFixedFields->get_Field(cols.c[c]->pos, &ipFixedField);
_bstr_t name;
ipFixedField->get_Name(name.GetAddress());
cols.c[c]->name_ref->assign(name);
}
}
}
CComPtr<IUID> ipUID; ipUID.CoCreateInstance(CLSID_UID);
CComQIPtr<ITable> ipTableNew;
CComBSTR keyword(L"");
hr = E_FAIL;
if (isShape)
{
if (ipUID)
{
OLECHAR buf[256];
::StringFromGUID2(CLSID_Feature, buf, 256);
ipUID->put_Value(CComVariant(buf));
}
CComPtr<IFeatureClass> ipFClass;
hr = ipFWKS->CreateFeatureClass(bstrTableName, ipFields, ipUID, 0, esriFTSimple, CComBSTR(L"Shape"), keyword, &ipFClass);
ipTableNew = ipFClass;
}
else
{
if (ipUID)
{
OLECHAR buf[256];
::StringFromGUID2(CLSID_Row, buf, 256);
ipUID->put_Value(CComVariant(buf));
}
hr = ipFWKS->CreateTable(bstrTableName, ipFields, ipUID, 0, keyword, &ipTableNew);
}
if (hr != S_OK)
return showError<true>(L"validate fields failed"), R_NilValue;
CComVariant oid;
CComPtr<ICursor> ipCursor;
CComPtr<IRowBuffer> ipRowBuffer;
hr = ipTableNew->Insert(VARIANT_TRUE, &ipCursor);
if (hr != S_OK)
return showError<true>(L"Insert cursor failed"), R_NilValue;
hr = ipTableNew->CreateRowBuffer(&ipRowBuffer);
if (hr != S_OK)
return showError<true>(L"Insert cursor failed"), R_NilValue;
//re-map fields
for (size_t c = 0; c < cols.c.size(); c++)
ipCursor->FindField(CComBSTR(cols.c[c]->name_ref->c_str()), &(cols.c[c]->pos));
R_len_t n = tools::size(VECTOR_ELT(dtaframe, 0));
for (R_len_t i = 0; i < n; i++)
{
//ATLTRACE("\n");
for (size_t c = 0; c < cols.c.size(); c++)
{
if (cols.c[c]->pos < 0)
continue;
CComVariant val;
cols.c[c]->get(i, val);
hr = ipRowBuffer->put_Value(cols.c[c]->pos, val);
if (hr != S_OK)
return showError<true>(L"insert row value failed"), R_NilValue;
//ATLTRACE(" [%i]=%f",cols[c]->pos, (float)val.dblVal);
}
VARIANT oid;
if (isShape)
{
CComQIPtr<IPoint> ipPoint; ipPoint.CoCreateInstance(CLSID_Point);
CComVariant valX, valY;
cols.shape[0]->get(i, valX);
cols.shape[1]->get(i, valY);
ipPoint->PutCoords(valX.dblVal, valY.dblVal);
CComQIPtr<IFeatureBuffer> ipFBuffer(ipRowBuffer);
ATLASSERT(ipFBuffer);
hr = ipFBuffer->putref_Shape(ipPoint);
if (hr != S_OK)
return showError<true>(L"insert shape failed"), R_NilValue;
}
hr = ipCursor->InsertRow(ipRowBuffer, &oid);
if (hr != S_OK)
return showError<true>(L"insert row failed"), R_NilValue;
}
return R_NilValue;
}