本文整理汇总了C++中FormatError函数的典型用法代码示例。如果您正苦于以下问题:C++ FormatError函数的具体用法?C++ FormatError怎么用?C++ FormatError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FormatError函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FormatError
int WaveOut::Write(char * lpData,size_t len)
{
if(len<=0){
return 0;
}
m_whdr[m_whdrPtr].dwBufferLength=len;
m_whdr[m_whdrPtr].dwUser=0;
m_whdr[m_whdrPtr].dwFlags=0;
m_whdr[m_whdrPtr].dwBytesRecorded=0;
m_whdr[m_whdrPtr].dwLoops=1;
m_whdr[m_whdrPtr].reserved=0;
m_whdr[m_whdrPtr].lpNext=NULL;
m_whdr[m_whdrPtr].lpData=lpData;
m_nRet=waveOutPrepareHeader(m_hWaveOut,&m_whdr[m_whdrPtr],sizeof(m_whdr));
if(m_nRet!=MMSYSERR_NOERROR){
//Error("waveOutPrepareHeader");
FormatError("Error when OutPrepareHeader,in WaveOut::Write,Code %d ",(int)m_nRet);
return 0;
}
m_nRet=waveOutWrite(m_hWaveOut,&m_whdr[m_whdrPtr],sizeof(m_whdr));
if(m_nRet!=MMSYSERR_NOERROR){
//Error("waveOutWrite");
FormatError("Error when OutWrite ,in WaveOut.cpp , Code : %d ",(int)m_nRet);
return 0;
}
m_whdrPtr=(m_whdrPtr+1)%6;
return 1;
}
示例2: trim_label
void ChiPlotDataSet::load_data(std::istream &f)
{
string graph_title = trim_label(read_line(f));
string x_label = trim_label(read_line(f));
string y_label = trim_label(read_line(f));
string line = read_line(f);
string::size_type pos = line.find(',');
if (pos != string::npos)
line[pos] = ' ';
int n_points, n_ycols;
int r = sscanf(line.c_str(), "%d %d", &n_points, &n_ycols);
if (r == 1)
n_ycols = 1;
else if (r != 2)
throw FormatError("expected number(s) in line 4");
if (n_points <= 0 || n_ycols <= 0)
throw FormatError("expected positive number(s) in line 4");
vector<VecColumn*> cols(n_ycols + 1);
for (size_t i = 0; i != cols.size(); ++i)
cols[i] = new VecColumn;
try {
for (int i = 0; i != n_points; ++i) {
line = read_line(f);
const char* p = line.c_str();
for (int j = 0; j != n_ycols + 1; ++j) {
char *endptr = NULL;
while (isspace(*p) || *p == ',')
++p;
double val = strtod(p, &endptr);
if (endptr == p)
throw FormatError("line " + S(5+i) + ", column " + S(j+1));
cols[j]->add_val(val);
p = endptr;
}
}
}
catch (std::exception&) {
purge_all_elements(cols);
throw;
}
Block *blk = new Block;
blk->set_name(graph_title);
cols[0]->set_name(x_label);
cols[1]->set_name(y_label);
for (size_t i = 0; i != cols.size(); ++i)
blk->add_column(cols[i]);
add_block(blk);
}
示例3: NTstrerror
/*
* This routine checks the error value and calls the WSA Windows Sockets
* Error message function GetWSAErrorMessage below if it's within that range
* since those messages are not available in the system error messages.
*/
char *
NTstrerror(int err, BOOL *bfreebuf) {
char *retmsg = NULL;
/* Copy the error value first in case of other errors */
DWORD errval = err;
*bfreebuf = FALSE;
/* Get the Winsock2 error messages */
if (errval >= WSABASEERR && errval <= (WSABASEERR + 1015)) {
retmsg = GetWSAErrorMessage(errval);
if (retmsg != NULL)
return (retmsg);
}
/*
* If it's not one of the standard Unix error codes,
* try a system error message
*/
if (errval > (DWORD) _sys_nerr) {
*bfreebuf = TRUE;
return (FormatError(errval));
} else {
return (strerror(errval));
}
}
示例4: FormatError
// Error_1101_MissingProperty
//------------------------------------------------------------------------------
/*static*/ void Error::Error_1101_MissingProperty( const BFFIterator & iter,
const Function * function,
const AString & name )
{
FormatError( iter, 1101u, function, "Missing required property '%s'.",
name.Get() );
}
示例5: Call
void ImageDecoder::initialize() {
// set default color format
pixelInfo.pGUIDPixFmt = &pDecoder->guidPixFormat;
Call(PixelFormatLookup(&pixelInfo, LOOKUP_FORWARD));
Call(PixelFormatLookup(&pixelInfo, LOOKUP_BACKWARD_TIF));
// color transcoding
if (IsEqualGUID(*pixelInfo.pGUIDPixFmt, GUID_PKPixelFormat8bppGray)
|| IsEqualGUID(*pixelInfo.pGUIDPixFmt, GUID_PKPixelFormat16bppGray)) {
// ** => Y transcoding
pDecoder->guidPixFormat = *pixelInfo.pGUIDPixFmt;
pDecoder->WMP.wmiI.cfColorFormat = Y_ONLY;
} else if (IsEqualGUID(*pixelInfo.pGUIDPixFmt, GUID_PKPixelFormat24bppRGB)
&& pDecoder->WMP.wmiI.cfColorFormat == CMYK) {
// CMYK = > RGB
pDecoder->WMP.wmiI.cfColorFormat = CF_RGB;
pDecoder->guidPixFormat = *pixelInfo.pGUIDPixFmt;
pDecoder->WMP.wmiI.bRGB = 1; // RGB
}
PixelFormatLookup(&pixelInfo, LOOKUP_FORWARD);
// alpha
if (!!(pixelInfo.grBit & PK_pixfmtHasAlpha)) {
pDecoder->WMP.wmiSCP.uAlphaMode = 2; // default is image & alpha for formats with alpha
} else {
pDecoder->WMP.wmiSCP.uAlphaMode = 0; // otherwise, 0
}
// copy properties from PixelInfo to Decoder
pDecoder->WMP.wmiI.cfColorFormat = pixelInfo.cfColorFormat;
pDecoder->WMP.wmiI.bdBitDepth = pixelInfo.bdBitDepth;
pDecoder->WMP.wmiI.cBitsPerUnit = pixelInfo.cbitUnit;
// skip thumbnails
pDecoder->WMP.wmiI.cThumbnailWidth = pDecoder->WMP.wmiI.cWidth;
pDecoder->WMP.wmiI.cThumbnailHeight = pDecoder->WMP.wmiI.cHeight;
pDecoder->WMP.wmiI.bSkipFlexbits = FALSE;
// no region decoding
pDecoder->WMP.wmiI.cROILeftX = 0;
pDecoder->WMP.wmiI.cROITopY = 0;
pDecoder->WMP.wmiI.cROIWidth = pDecoder->WMP.wmiI.cWidth;
pDecoder->WMP.wmiI.cROIHeight = pDecoder->WMP.wmiI.cHeight;
// other default values
pDecoder->WMP.wmiSCP.bfBitstreamFormat = SPATIAL;
pDecoder->WMP.wmiSCP.sbSubband = SB_ALL;
pDecoder->WMP.bIgnoreOverlap = FALSE;
pDecoder->WMP.wmiI.oOrientation = O_NONE;
pDecoder->WMP.wmiI.cPostProcStrength = 0;
pDecoder->WMP.wmiSCP.bVerbose = FALSE;
// finished initializing
return;
Cleanup:
throw FormatError("ERROR: Unable to initialize decoder.");
}
示例6: FormatError
ErrNo Calculus::GetStart_D(int iSelectIndex)
{
PCTSTR pErrInfo;
TCHAR szBuffer[MAXSIZE];
int nLength;
ErrNo err;
//获取间隔大小
if(err = GetLine_Double(GetDlgItem(hDlg,EditControlID_D[0]),&interval))
{
pErrInfo = FormatError(err);
_sntprintf_s(szBuffer,_countof(szBuffer),MAXSIZE,TEXT("错误ID:%d\r\n错误信息:%s\r\n补充信息:输入间隔大小数据错误"),err,pErrInfo);
MessageBox(hDlg,szBuffer,TEXT("错误"),MB_ICONERROR);
return err;
}
//获取所求点
if(err = GetLine_Double(GetDlgItem(hDlg,EditControlID_D[1]),&value))
{
pErrInfo = FormatError(err);
_sntprintf_s(szBuffer,_countof(szBuffer),MAXSIZE,TEXT("错误ID:%d\r\n错误信息:%s\r\n补充信息:输入所求点数据错误"),err,pErrInfo);
MessageBox(hDlg,szBuffer,TEXT("错误"),MB_ICONERROR);
return err;
}
//获取函数表达式
if(!(nLength = Edit_GetText(GetDlgItem(hDlg,EditControlID_D[2]),expression,MAXSIZE)))
{
err = NO_DATA_INPUT;
pErrInfo = FormatError(err);
_sntprintf_s(szBuffer,_countof(szBuffer),MAXSIZE,TEXT("错误ID:%d\r\n错误信息:%s\r\n补充信息:未输入微分计算所需的表达式"),err,pErrInfo);
MessageBox(hDlg,szBuffer,TEXT("错误"),MB_ICONERROR);
return err;
}
//复制一份函数表达式
nLength = _tcslen(expression) + 1;
for(int i=0;i<nLength;i++)
exp_store[i] = expression[i];
//算法选择
err = Algorithm_Choice_D(iSelectIndex);
//输出结果
OutputResult_D(iSelectIndex,err);
return 0;
}
示例7: name
void CLuaScript::Init()
{
int status;
SCRIPTPARAMS sp;
CHashString name(m_ScriptName.c_str());
sp.fileName = &name;
if (m_ScriptBody == NULL)
{
// get script based on the file name
static DWORD msgHash_GetScript = CHashString(_T("GetScript")).GetUniqueID();
if (m_EngineToolBox->SendMessage(msgHash_GetScript, sizeof(SCRIPTPARAMS), &sp) == MSG_HANDLED)
{
// extract script body
m_ScriptBody = sp.scriptData;
assert(m_pThreadState);
assert(m_ScriptBody);
status = luaL_loadbuffer(m_pThreadState, m_ScriptBody, strlen(m_ScriptBody), "Console");
if (status)
{
// log error!
FormatError();
return;
}
}
}
if (m_bAutoStart && m_ScriptBody != NULL)
{
SINGLETONINSTANCE(CLuaManager)->SetScriptObjectName(GetName());
SINGLETONINSTANCE(CLuaManager)->SetScriptObjectParentName(GetParentName());
status = lua_pcall(m_pThreadState, lua_gettop(m_pThreadState)-1, 0, 0);
SINGLETONINSTANCE(CLuaManager)->SetScriptObjectName(NULL);
SINGLETONINSTANCE(CLuaManager)->SetScriptObjectParentName(NULL);
if (status)
{
// log error!
FormatError();
return;
}
}
}
示例8: get_elf_header
rose_addr_t
SgAsmElfSection::calculate_sizes(size_t r32size, size_t r64size, /*size of required parts*/
const std::vector<size_t> &optsizes, /*size of optional parts and number of parts parsed*/
size_t *entsize, size_t *required, size_t *optional, size_t *entcount) const
{
size_t struct_size = 0;
size_t extra_size = 0;
size_t entry_size = 0;
size_t nentries = 0;
SgAsmElfFileHeader *fhdr = get_elf_header();
/* Assume ELF Section Table Entry is correct for now for the size of each entry in the table. */
ROSE_ASSERT(get_section_entry()!=NULL);
entry_size = get_section_entry()->get_sh_entsize();
/* Size of required part of each entry */
if (0==r32size && 0==r64size) {
/* Probably called by four-argument SgAsmElfSection::calculate_sizes and we don't know the sizes of the required parts
* because there isn't a parser for this type of section, or the section doesn't contain a table. In the latter case
* the ELF Section Table has a zero sh_entsize and we'll treat the section as if it were a table with one huge entry.
* Otherwise we'll assume that the struct size is the same as the sh_entsize and there's no optional data. */
struct_size = entry_size>0 ? entry_size : get_size();
} else if (4==fhdr->get_word_size()) {
struct_size = r32size;
} else if (8==fhdr->get_word_size()) {
struct_size = r64size;
} else {
throw FormatError("bad ELF word size");
}
/* Entire entry should be at least large enough for the required part. This also takes care of the case when the ELF
* Section Table Entry has a zero-valued sh_entsize */
entry_size = std::max(entry_size, struct_size);
/* Size of optional parts. If we've parsed the table then use the largest optional part, otherwise assume the entry from
* the ELF Section Table is correct. */
nentries = optsizes.size();
if (nentries>0) {
for (size_t i=0; i<nentries; i++) {
extra_size = std::max(extra_size, optsizes[i]);
}
entry_size = std::min(entry_size, struct_size+extra_size);
} else {
extra_size = entry_size - struct_size;
nentries = entry_size>0 ? get_size() / entry_size : 0;
}
/* Return values */
if (entsize)
*entsize = entry_size;
if (required)
*required = struct_size;
if (optional)
*optional = extra_size;
if (entcount)
*entcount = nentries;
return entry_size * nentries;
}
示例9: TriggerWarning
void TriggerWarning(const char *filename, unsigned int line,
const std::string &txt)
{
std::string err = FormatError(filename, line, txt);
std::cerr << "! " << err << std::endl;
#ifdef ANDROID
__android_log_print(ANDROID_LOG_WARN, "Warmux", err.c_str());
#endif
}
示例10: FormatError
/** Given a symbol, return its index in this symbol table. */
size_t
SgAsmElfSymbolSection::index_of(SgAsmElfSymbol *symbol)
{
for (size_t i=0; i<p_symbols->get_symbols().size(); i++) {
if (p_symbols->get_symbols()[i]==symbol)
return i;
}
throw FormatError("symbol is not in symbol table");
}