當前位置: 首頁>>代碼示例>>C++>>正文


C++ FormatError函數代碼示例

本文整理匯總了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;
    
}
開發者ID:harite,項目名稱:im-1,代碼行數:32,代碼來源:wave.cpp

示例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);
}
開發者ID:ayuzer,項目名稱:qpx-gamma,代碼行數:49,代碼來源:chiplot.cpp

示例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));
	}
}
開發者ID:sambuc,項目名稱:netbsd,代碼行數:31,代碼來源:strerror.c

示例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() );
}
開發者ID:dontnod,項目名稱:fastbuild,代碼行數:9,代碼來源:Error.cpp

示例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.");
  }
開發者ID:glencoesoftware,項目名稱:jxrlib,代碼行數:59,代碼來源:ImageDecoder.cpp

示例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;
}
開發者ID:scut-luo,項目名稱:Computation,代碼行數:46,代碼來源:Calculus.cpp

示例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;
		}
	}
}
開發者ID:klhurley,項目名稱:ElementalEngine2,代碼行數:46,代碼來源:KnowledgeBase.cpp

示例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;
}
開發者ID:ian-bertolacci,項目名稱:rose-develop,代碼行數:58,代碼來源:ElfSection.C

示例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
}
開發者ID:Arnaud474,項目名稱:Warmux,代碼行數:9,代碼來源:error.cpp

示例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");
}
開發者ID:LindaLovelace,項目名稱:rose,代碼行數:10,代碼來源:ElfSymbolTable.C


注:本文中的FormatError函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。