本文整理汇总了C++中sciErrInit函数的典型用法代码示例。如果您正苦于以下问题:C++ sciErrInit函数的具体用法?C++ sciErrInit怎么用?C++ sciErrInit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sciErrInit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getCommonAllocatedNamedSinglePoly
/*--------------------------------------------------------------------------*/
static int getCommonAllocatedNamedSinglePoly(void* _pvCtx, const char* _pstName, int _iComplex, int* _piNbCoef, double** _pdblReal, double** _pdblImg)
{
SciErr sciErr = sciErrInit();
int iRows = 0;
int iCols = 0;
double* pdblReal = NULL;
double* pdblImg = NULL;
if (isNamedScalar(_pvCtx, _pstName) == 0)
{
addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_SINGLE_POLY, _("%s: Wrong type for input argument \"%s\": A scalar expected.\n"), _iComplex ? "getAllocatedNamedSingleComplexPoly" : "getAllocatedNamedSinglePoly", _pstName);
printError(&sciErr, 0);
return sciErr.iErr;
}
sciErr = readCommonNamedMatrixOfPoly(_pvCtx, _pstName, _iComplex, &iRows, &iCols, _piNbCoef, &pdblReal, &pdblImg);
if (sciErr.iErr)
{
addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_SINGLE_POLY, _("%s: Unable to get argument \"%s\""), _iComplex ? "getAllocatedNamedSingleComplexPoly" : "getAllocatedNamedSinglePoly", _pstName);
printError(&sciErr, 0);
return sciErr.iErr;
}
*_pdblReal = (double*)MALLOC(sizeof(double) **_piNbCoef);
memcpy(*_pdblReal, pdblReal, sizeof(double) **_piNbCoef);
if (_iComplex)
{
*_pdblImg = (double*)MALLOC(sizeof(double) **_piNbCoef);
memcpy(*_pdblImg, pdblImg, sizeof(double) **_piNbCoef);
}
return 0;
}
示例2: getPolyVariableName
SciErr getPolyVariableName(void* _pvCtx, int* _piAddress, char* _pstVarName, int* _piVarNameLen)
{
SciErr sciErr = sciErrInit();
if (_piAddress == NULL)
{
addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), "getPolyVariableName");
return sciErr;
}
if (!((types::InternalType*)_piAddress)->isPoly())
{
addErrorMessage(&sciErr, API_ERROR_INVALID_TYPE, _("%s: Invalid argument type, %s expected"), "getPolyVariableName", _("polynomial matrix"));
return sciErr;
}
if (*_piVarNameLen == 0)
{
*_piVarNameLen = (int)((types::InternalType*)_piAddress)->getAs<types::Polynom>()->getVariableName().size();
//No error
}
if (_pstVarName == NULL)
{
return sciErr;
}
char* pstTemp = wide_string_to_UTF8(((types::InternalType*)_piAddress)->getAs<types::Polynom>()->getVariableName().c_str());
strcpy(_pstVarName, pstTemp);
FREE(pstTemp);
*_piVarNameLen = static_cast<int>(strlen(_pstVarName));
return sciErr;
}
示例3: getHypermatPolyVariableName
SciErr getHypermatPolyVariableName(void* _pvCtx, int* _piAddress, char* _pstVarName, int* _piVarNameLen)
{
SciErr sciErr = sciErrInit();
void * entries = NULL;
int ret = getHypermatEntries(_pvCtx, _piAddress, &entries);
if (ret || entries == NULL || ((types::InternalType*)entries)->isPoly() == false)
{
addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), "getHypermatPolyVariableName");
return sciErr;
}
types::Polynom* p = (types::Polynom*)entries;
std::wstring var = p->getVariableName();
char* varname = wide_string_to_UTF8(var.data());
*_piVarNameLen = static_cast<int>(strlen(varname));
if (_pstVarName)
{
strcpy(_pstVarName, varname);
}
FREE(varname);
return sciErr;
}
示例4: checkInputArgument
int checkInputArgument(void* _pvCtx, int _iMin, int _iMax)
{
SciErr sciErr = sciErrInit();
/*
* store the name in recu array, fname can be a non null terminated char array
* Get_Iname() can be used in other function to get the interface name
*/
int cx0 = 0;
C2F(cvname) (&C2F(recu).ids[(C2F(recu).pt + 1) * nsiz - nsiz], ((StrCtx *) _pvCtx)->pstName, &cx0, (unsigned long int)strlen(((StrCtx *)_pvCtx)->pstName));
if (_iMin <= nbInputArgument(_pvCtx) && _iMax >= nbInputArgument(_pvCtx))
{
return 1;
}
if (_iMax == _iMin)
{
Scierror(77, _("%s: Wrong number of input argument(s): %d expected.\n"), ((StrCtx *) _pvCtx)->pstName, _iMax);
}
else
{
Scierror(77, _("%s: Wrong number of input argument(s): %d to %d expected.\n"), ((StrCtx *) _pvCtx)->pstName, _iMin, _iMax);
}
return 0;
}
示例5: createComplexHypermatOfPoly
SciErr createComplexHypermatOfPoly(void *_pvCtx, int _iVar, char* _pstVarName, int * _dims, int _ndims, const int* _piNbCoef, const double* const* _pdblReal, const double* const* _pdblImg)
{
SciErr sciErr = sciErrInit();
types::GatewayStruct* pStr = (types::GatewayStruct*)_pvCtx;
types::typed_list in = *pStr->m_pIn;
types::InternalType** out = pStr->m_pOut;
int rhs = _iVar - *getNbInputArgument(_pvCtx);
wchar_t* w = to_wide_string(_pstVarName);
types::Polynom* p = new types::Polynom(w, _ndims, _dims, _piNbCoef);
p->setComplex(true);
int size = p->getSize();
if (size == 0)
{
delete p;
out[rhs - 1] = types::Double::Empty();
FREE(w);
return sciErr;
}
types::SinglePoly** s = p->get();
for (int i = 0; i < size; ++i)
{
s[i]->setCoef(_pdblReal[i], _pdblImg[i]);
}
out[rhs - 1] = p;
FREE(w);
return sciErr;
}
示例6: createHypermatOfString
SciErr createHypermatOfString(void *_pvCtx, int _iVar, int * _dims, int _ndims, const char* const* _pstStrings)
{
SciErr sciErr = sciErrInit();
types::GatewayStruct* pStr = (types::GatewayStruct*)_pvCtx;
types::typed_list in = *pStr->m_pIn;
types::InternalType** out = pStr->m_pOut;
int rhs = _iVar - *getNbInputArgument(_pvCtx);
types::String* p = new types::String(_ndims, _dims);
int size = p->getSize();
if (size == 0)
{
delete p;
out[rhs - 1] = types::Double::Empty();
return sciErr;
}
for (int i = 0; i < size; ++i)
{
wchar_t* w = to_wide_string(_pstStrings[i]);
p->set(i, w);
FREE(w);
}
out[rhs - 1] = p;
return sciErr;
}
示例7: getAllocatedSingleString
/*--------------------------------------------------------------------------*/
int getAllocatedSingleString(void* _pvCtx, int* _piAddress, char** _pstData)
{
SciErr sciErr = sciErrInit();
int iRows = 0;
int iCols = 0;
int iLen = 0;
if (isScalar(_pvCtx, _piAddress) == 0 || isStringType(_pvCtx, _piAddress) == 0)
{
addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_SINGLE_STRING, _("%s: Wrong type for input argument #%d: A single string expected.\n"), "getAllocatedSingleString", getRhsFromAddress(_pvCtx, _piAddress));
printError(&sciErr, 0);
return sciErr.iErr;
}
sciErr = getMatrixOfString(_pvCtx, _piAddress, &iRows, &iCols, &iLen, NULL);
if (sciErr.iErr)
{
addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_SINGLE_STRING, _("%s: Unable to get argument data"), "getAllocatedSingleString");
printError(&sciErr, 0);
return sciErr.iErr;
}
*_pstData = (char*)MALLOC(sizeof(char) * (iLen + 1)); //+1 for null termination
sciErr = getMatrixOfString(_pvCtx, _piAddress, &iRows, &iCols, &iLen, _pstData);
if (sciErr.iErr)
{
addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_SINGLE_STRING, _("%s: Unable to get argument data"), "getAllocatedSingleString");
printError(&sciErr, 0);
FREE(*_pstData);
return sciErr.iErr;
}
return 0;
}
示例8: getAllocatedNamedSingleWideString
/*--------------------------------------------------------------------------*/
int getAllocatedNamedSingleWideString(void* _pvCtx, const char* _pstName, wchar_t** _pwstData)
{
SciErr sciErr = sciErrInit();
int iRows = 0;
int iCols = 0;
int iLen = 0;
if (isNamedScalar(_pvCtx, _pstName) == 0 || isNamedStringType(_pvCtx, _pstName) == 0)
{
addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_SINGLE_WIDE_STRING, _("%s: Wrong type for input argument \"%s\": A single string expected.\n"), "getAllocatedNamedSingleWideString", _pstName);
printError(&sciErr, 0);
return sciErr.iErr;
}
sciErr = readNamedMatrixOfWideString(_pvCtx, _pstName, &iRows, &iCols, &iLen, NULL);
if (sciErr.iErr)
{
addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_SINGLE_WIDE_STRING, _("%s: Unable to get argument data"), "getAllocatedNamedSingleWideString");
printError(&sciErr, 0);
return sciErr.iErr;
}
*_pwstData = (wchar_t*)MALLOC(sizeof(wchar_t) * (iLen + 1)); //+1 for null termination
sciErr = readNamedMatrixOfWideString(_pvCtx, _pstName, &iRows, &iCols, &iLen, _pwstData);
if (sciErr.iErr)
{
addErrorMessage(&sciErr, API_ERROR_GET_ALLOC_NAMED_SINGLE_WIDE_STRING, _("%s: Unable to get argument data"), "getAllocatedNamedSingleWideString");
printError(&sciErr, 0);
FREE(*_pwstData);
return sciErr.iErr;
}
return 0;
}
示例9: allocSingleString
int allocSingleString(void* _pvCtx, int _iVar, int _iLen, const char** _pstStrings)
{
SciErr sciErr = sciErrInit();
types::GatewayStruct* pGstr = (types::GatewayStruct*)_pvCtx;
types::typed_list in = *pGstr->m_pIn;
types::InternalType** out = pGstr->m_pOut;
types::String *pStr = NULL;
char* pstStrings = new char[_iLen];
memset(pstStrings, ' ', _iLen);
if (_pstStrings == NULL)
{
addErrorMessage(&sciErr, API_ERROR_NO_MORE_MEMORY, _("%s: No more memory to allocate variable"), "allocSingleString");
return sciErr.iErr;
}
_pstStrings[0] = pstStrings;
pStr = new types::String(pstStrings);
if (pStr == NULL)
{
addErrorMessage(&sciErr, API_ERROR_NO_MORE_MEMORY, _("%s: No more memory to allocate variable"), "allocSingleString");
return sciErr.iErr;
}
int rhs = _iVar - *getNbInputArgument(_pvCtx);
out[rhs - 1] = pStr;
return sciErr.iErr;
}
示例10: createCommonMatrixOfPoly
SciErr createCommonMatrixOfPoly(void* _pvCtx, int _iVar, int _iComplex, char* _pstVarName, int _iRows, int _iCols, const int* _piNbCoef, const double* const* _pdblReal, const double* const* _pdblImg)
{
SciErr sciErr = sciErrInit();
if (_pvCtx == NULL)
{
addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), _iComplex ? "createComplexMatrixOfPoly" : "createMatrixOfPoly");
return sciErr;
}
types::GatewayStruct* pStr = (types::GatewayStruct*)_pvCtx;
types::InternalType** out = pStr->m_pOut;
int rhs = _iVar - *getNbInputArgument(_pvCtx);
//return empty matrix
if (_iRows == 0 && _iCols == 0)
{
types::Double *pDbl = new types::Double(_iRows, _iCols);
if (pDbl == NULL)
{
addErrorMessage(&sciErr, API_ERROR_CREATE_EMPTY_MATRIX, _("%s: Unable to create variable in Scilab memory"), "createEmptyMatrix");
return sciErr;
}
out[rhs - 1] = pDbl;
return sciErr;
}
wchar_t* pstTemp = to_wide_string(_pstVarName);
std::wstring wstTemp(pstTemp);
types::Polynom* pP = new types::Polynom(wstTemp, _iRows, _iCols, _piNbCoef);
FREE(pstTemp);
if (pP == NULL)
{
addErrorMessage(&sciErr, API_ERROR_NO_MORE_MEMORY, _("%s: No more memory to allocated variable"), _iComplex ? "createComplexMatrixOfPoly" : "createMatrixOfPoly");
return sciErr;
}
if (_iComplex)
{
pP->setComplex(true);
}
out[rhs - 1] = pP;
for (int i = 0 ; i < pP->getSize() ; i++)
{
types::Double* pD = new types::Double(_piNbCoef[i], 1, _iComplex == 1);
pD->set(_pdblReal[i]);
if (_iComplex)
{
pD->setImg(_pdblImg[i]);
}
pP->setCoef(i, pD);
delete pD;
}
return sciErr;
}
示例11: checkOutputArgumentAtMost
/*--------------------------------------------------------------------------*/
int checkOutputArgumentAtMost(void* _pvCtx, int _iMax)
{
SciErr sciErr = sciErrInit();
if (_iMax >= nbOutputArgument(_pvCtx))
{
return 1;
}
Scierror(78, _("%s: Wrong number of output argument(s): at most %d expected.\n"), ((StrCtx *) _pvCtx)->pstName, _iMax);
return 0;
}
示例12: checkInputArgumentAtLeast
/*--------------------------------------------------------------------------*/
int checkInputArgumentAtLeast(void* _pvCtx, int _iMin)
{
SciErr sciErr = sciErrInit();
if (_iMin <= nbInputArgument(_pvCtx))
{
return 1;
}
Scierror(77, _("%s: Wrong number of input argument(s): at least %d expected.\n"), ((StrCtx *) _pvCtx)->pstName, _iMin);
return 0;
}
示例13: getHypermatOfString
SciErr getHypermatOfString(void* _pvCtx, int* _piAddress, int **_dims, int *_ndims, int* _piLength, char** _pstStrings)
{
SciErr sciErr = sciErrInit();
void * entries = NULL;
int ret = getHypermatEntries(_pvCtx, _piAddress, &entries);
if (ret || entries == NULL || ((types::InternalType*)entries)->isString() == false)
{
addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), "getHypermatOfString");
return sciErr;
}
types::String* p = (types::String*)entries;
*_dims = p->getDimsArray();
*_ndims = p->getDims();
int size = p->getSize();
if (_piLength == NULL)
{
return sciErr;
}
if (_pstStrings == NULL || *_pstStrings == NULL)
{
wchar_t** s = p->get();
for (int i = 0; i < size; i++)
{
char* c = wide_string_to_UTF8(s[i]);
_piLength[i] = (int)strlen(c);
FREE(c);
}
}
else
{
wchar_t** s = p->get();
for (int i = 0; i < size; i++)
{
if (_pstStrings[i] == NULL)
{
addErrorMessage(&sciErr, API_ERROR_INVALID_SUBSTRING_POINTER, _("%s: Invalid argument address"), "getHypermatOfString");
return sciErr;
}
char* c = wide_string_to_UTF8(s[i]);
strcpy(_pstStrings[i], c);
FREE(c);
}
}
return sciErr;
}
示例14: createNamedMatrixOfString
/*--------------------------------------------------------------------------*/
SciErr createNamedMatrixOfString(void* _pvCtx, const char* _pstName, int _iRows, int _iCols, const char* const* _pstStrings)
{
SciErr sciErr = sciErrInit();
// check variable name
if (checkNamedVarFormat(_pvCtx, _pstName) == 0)
{
addErrorMessage(&sciErr, API_ERROR_CREATE_EMPTY_MATRIX, _("%s: Invalid variable name: %s."), "createNamedMatrixOfString", _pstName);
return sciErr;
}
//return empty matrix
if (_iRows == 0 && _iCols == 0)
{
if (createNamedEmptyMatrix(_pvCtx, _pstName))
{
addErrorMessage(&sciErr, API_ERROR_CREATE_EMPTY_MATRIX, _("%s: Unable to create variable in Scilab memory"), "createEmptyMatrix");
return sciErr;
}
return sciErr;
}
types::String* pS = new types::String(_iRows, _iCols);
if (pS == NULL)
{
addErrorMessage(&sciErr, API_ERROR_INVALID_NAME, _("%s: Invalid variable name: %s."), "createNamedMatrixOfString", _pstName);
return sciErr;
}
for (int i = 0 ; i < pS->getSize() ; i++)
{
wchar_t* pstTemp = to_wide_string(_pstStrings[i]);
pS->set(i, pstTemp);
FREE(pstTemp);
}
wchar_t* pwstName = to_wide_string(_pstName);
symbol::Context* ctx = symbol::Context::getInstance();
symbol::Symbol sym = symbol::Symbol(pwstName);
FREE(pwstName);
if (ctx->isprotected(sym) == false)
{
ctx->put(sym, pS);
}
else
{
delete pS;
addErrorMessage(&sciErr, API_ERROR_REDEFINE_PERMANENT_VAR, _("Redefining permanent variable.\n"));
}
return sciErr;
}
示例15: getVarType
/*--------------------------------------------------------------------------*/
SciErr getVarType(void *_pvCtx, int *_piAddress, int *_piType)
{
SciErr sciErr = sciErrInit();
if (_piAddress == NULL)
{
addErrorMessage(&sciErr, API_ERROR_INVALID_POINTER, _("%s: Invalid argument address"), "getVarType");
return sciErr;
}
*_piType = _piAddress[0];
return sciErr;
}