本文整理汇总了C++中CDatum::value方法的典型用法代码示例。如果您正苦于以下问题:C++ CDatum::value方法的具体用法?C++ CDatum::value怎么用?C++ CDatum::value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDatum
的用法示例。
在下文中一共展示了CDatum::value方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mesage_SaveFieldBinary
int mesage_SaveFieldBinary(lua_State* L) {
int err = 0;
char *b = NULL;
CMessage* msg = cmessage_arg(L, "mesage_AddFieldBinary");
CString fldName = luaL_checkstring(L, 2);
CString path = luaL_checkstring(L, 3);
char *description;
DWORD l;
CDatum *d = msg->GetDatum(fldName);
if (d->GetVarType() != (VT_ARRAY | VT_UI1) ) {
err = -1;
description = "Not Binary Data";
goto err;
}
{
l = d->GetDataSize();
b = new char[l];
SAFEARRAY* pArray = d->value().parray;
ASSERT(pArray->cDims == 1); // check we have 1 dimension array
ASSERT(l == pArray->rgsabound[0].cElements * pArray->cbElements); // get size of array
memcpy(b, (BYTE*)pArray->pvData, l);
int charsLen = ::MultiByteToWideChar(CP_UTF8, 0, path, lstrlen(path), NULL, 0);
std::wstring characters(charsLen, '\0');
::MultiByteToWideChar(CP_UTF8, 0, path, lstrlen(path), &characters[0], charsLen);
int pf;
err = _wsopen_s(&pf, characters.c_str(), _O_BINARY | _O_CREAT | _O_TRUNC | _O_WRONLY, _SH_DENYRW, _S_IWRITE);
if (err) {
description = "Open File Error";
goto err;
}
if (l != _write(pf, (b), l)) {
err = -2;
description = "Write File Error";
goto err;
}
err = _close(pf);
if (err){
description = "Close File Error";
goto err;
}
}
err:
if (b)
delete[]b;
lua_pushinteger(L, err);
if (err)
lua_pushstring(L, description);
else
lua_pushinteger(L, l);
return 2;
}