本文整理匯總了C++中Err函數的典型用法代碼示例。如果您正苦於以下問題:C++ Err函數的具體用法?C++ Err怎麽用?C++ Err使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Err函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: GetChar
char GetChar (DynChar Char)
{
switch (Char)
{
case SPACE: return ' ';
case DASH: return '-';
case DOT: return '.';
case SLASH: return '/';
case BACKSLASH: return '\\';
default: throw Err ("Unknown DynChar");
}
}//GetChar
示例2: GetImageDirsFromShapeFile
static void
GetImageDirsFromShapeFile (char sImageDirs[], // out
const char sShapeFile[], // in
FILE *pShapeFile) // in
{
char s[SLEN];
Fgets(s, SLEN-1, pShapeFile); // this skips blank lines and comments, if any
const char *sWhiteSpace = " \t\n\r";
char *sToken = strtok(s, sWhiteSpace);
if (!sToken || 0 != strcmp(sToken, "Directories"))
Err("expected \"Directories\" in line %d of %s",
nGetLineNbr(pShapeFile), sShapeFile);
sToken = strtok(NULL, sWhiteSpace);
if (!sToken)
Err("can't read image directories in line %d of %s",
nGetLineNbr(pShapeFile), sShapeFile);
strcpy(sImageDirs, sToken);
}
示例3: EnsureGlContext
void Shader::SetParameter(const std::string& name, CurrentTextureType)
{
if (myShaderProgram)
{
EnsureGlContext();
// Find the location of the variable in the shader
myCurrentTexture = glGetUniformLocationARB(myShaderProgram, name.c_str());
if (myCurrentTexture == -1)
Err() << "Texture \"" << name << "\" not found in shader" << std::endl;
}
}
示例4: Err
bool Shader::LoadFromStream(InputStream& vertexShaderStream, InputStream& fragmentShaderStream)
{
// Read the vertex shader code from the stream
std::vector<char> vertexShader;
if (!GetStreamContents(vertexShaderStream, vertexShader))
{
Err() << "Failed to read vertex shader from stream" << std::endl;
return false;
}
// Read the fragment shader code from the stream
std::vector<char> fragmentShader;
if (!GetStreamContents(fragmentShaderStream, fragmentShader))
{
Err() << "Failed to read fragment shader from stream" << std::endl;
return false;
}
// Compile the shader program
return Compile(&vertexShader[0], &fragmentShader[0]);
}
示例5: Err
void Assembler::macro()
{
char *sptr, *eptr;
char nbuf[NAME_MAX+1];
int idlen, xx;
Macro *fmac;
gNargs = 0;
macrobuf = "";
idlen = ibuf->getIdentifier(&sptr, &eptr);
if (idlen == 0)
{
//printf("aaa:%.20s|\r\n", sptr);
Err(E_MACRONAME);
return;
}
if (pass < 2)
{
memset(nbuf, '\0', sizeof(nbuf));
memcpy(nbuf, sptr, min(idlen, NAME_MAX));
gMacro.setName(nbuf);
fmac = (Macro *)macroTbl->find(&gMacro);
if (fmac)
{
Err(E_DEFINED, nbuf);
return;
}
}
// Free parameter list (if not already freed)
for (xx = 0; xx < MAX_MACRO_PARMS; xx++)
if (parmlist[xx]) {
delete parmlist[xx];
parmlist[xx] = NULL;
}
xx = gNargs = ibuf->getParmList(parmlist);
gMacro.setArgCount(xx);
gMacro.setFileLine(CurFileNum, File[CurFileNum].LastLine);
CollectingMacro = true;
}
示例6: WriteShapeMod
static void WriteShapeMod( // write a shape model to a .mh file as C++ code
const char* modname, // in
const Shape& meanshape, // in: n x 2
const VEC& eigvals, // in: 2n x 1
const MAT& eigvecs, // in: 2n x 2n, inverse of eigs of cov mat
const char* outdir, // in: output directory
const char* comment) // in
{
char path[SLEN];
sprintf(path, "%s/mh/%s_shapemodel.mh", outdir, modname);
lprintf("Generating %s\n", path);
FILE *file = fopen(path, "wb");
if (!file)
Err("Cannot open %s", path);
char s[SLEN];
Fprintf(file, "// %s.mh: machine generated shape model\n", path);
Fprintf(file, "//\n");
Fprintf(file, "// Command: %s\n//\n\n", comment);
char path1[SLEN]; sprintf(path1, "stasm_%s_shapemodel_mh", modname);
ToUpper(path1);
Fprintf(file, "#ifndef %s\n", path1);
Fprintf(file, "#define %s\n\n", path1);
Fprintf(file, "namespace stasm {\n\n");
sprintf(s, "%s_meanshapedata", modname);
WriteMatAsArray(meanshape, s, "mean shape", file);
Fprintf(file,
"\nstatic const cv::Mat %s_meanshape(%d, %d, CV_64FC1, "
"(double *)%s_meanshapedata);\n\n",
modname, meanshape.rows, meanshape.cols, modname);
sprintf(s, "%s_eigvalsdata", modname);
WriteMatAsArray(eigvals, s, "eigen values", file);
Fprintf(file,
"\nstatic const cv::Mat %s_eigvals(%d, %d, CV_64FC1, "
"(double *)%s_eigvalsdata);\n\n",
modname, eigvals.rows, eigvals.cols, modname);
sprintf(s, "%s_eigvecsdata", modname);
WriteMatAsArray(eigvecs, s, "eigen vectors", file);
Fprintf(file,
"\nstatic const cv::Mat %s_eigvecs(%d, %d, CV_64FC1, "
"(double *)%s_eigvecsdata);\n\n",
modname, eigvecs.rows, eigvecs.cols, modname);
Fprintf(file, "} // namespace stasm\n", path1);
Fprintf(file, "#endif // %s\n", path1);
fclose(file);
}
示例7: reader
Result<Ok, nsresult>
SinfParser::ParseSchm(Box& aBox)
{
BoxReader reader(aBox);
if (reader->Remaining() < 8) {
return Err(NS_ERROR_FAILURE);
}
MOZ_TRY(reader->ReadU32()); // flags -- ignore
MOZ_TRY_VAR(mSinf.mDefaultEncryptionType, reader->ReadU32());
return Ok();
}
示例8: Err
/*
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
*/
void CExPolicy_ServerSession::KillProcessL(const RMessage2& aMessage)
{
TInt Err(KErrNone);
TBuf8<255> Hjelpper;
// TRAP(Err,
aMessage.ReadL(0,Hjelpper,0);
Server().KillProcess(Hjelpper);
aMessage.Complete(Err);
}
示例9: json_object
// input/output operators for options
std::ostream & operator<< (std::ostream & s, const Opts & o){
json_error_t e;
json_t *J = json_object();
for (auto i: o){
json_object_set(J, i.first.c_str(), json_string(i.second.c_str()));
}
char *ret = json_dumps(J, JSON_SORT_KEYS);
json_decref(J);
if (!ret) throw Err() << "can't write Opts";
s<<ret;
free(ret);
return s;
}
示例10: if
//////////////////////////////
// FromString
// check the string ...Is it cash we are talking about?
// if so exchange. Take from this monehy add add to other
// The remove functions through a CError if not enough cash.
// written by: Demetrius Comes
void sMoney::FromString(CString & strMoney, sMoney & ToAdd, int nCoins)
{
if(strMoney.Compare(m_strPlat.Left(strMoney.GetLength())))
{
ToAdd.AddPlat(RemovePlat(nCoins));
throw "platinum";
}
else if(strMoney.Compare(m_strGold.Left(strMoney.GetLength())))
{
ToAdd.AddGold(RemoveGold(nCoins));
throw "gold";
}
else if(strMoney.Compare(m_strSilver.Left(strMoney.GetLength())))
{
ToAdd.AddSilver(RemoveSilver(nCoins));
throw "silver";
}
else if(strMoney.Compare(m_strCopper.Left(strMoney.GetLength())))
{
ToAdd.AddCopper(RemoveCopper(nCoins));
throw "copper";
}
else if(strMoney.Compare("coins"))
{
if(nCoins!=-1 && nCoins!=1)
{
CError Err(MESSAGE_ONLY,"You can't specify coins without type!\r\n");
throw &Err;
}
if(IsEmpty())
{
CError Err(MESSAGE_ONLY,"You can't find any coins.\r\n");
throw &Err;
}
ToAdd+=*this;
*this=0;
throw "coins";
}
}
示例11: GetCurrentProcess
Result<Ok, nsresult> MemMapSnapshot::Freeze(AutoMemMap& aMem) {
auto orig = mFile.ref().ClonePlatformHandle();
mFile.reset();
HANDLE handle;
if (!::DuplicateHandle(
GetCurrentProcess(), orig.release(), GetCurrentProcess(), &handle,
GENERIC_READ | FILE_MAP_READ, false, DUPLICATE_CLOSE_SOURCE)) {
return Err(NS_ERROR_FAILURE);
}
return aMem.initWithHandle(FileDescriptor(handle), mMem.size());
}
示例12: Err
void LSH::WordHashing(TQuoteBase* QuoteBase, THashSet<TMd5Sig>& Shingles) {
Err("Hashing shingles using words...\n");
TIntV QuoteIds;
QuoteBase->GetAllQuoteIds(QuoteIds);
for (int qt = 0; qt < QuoteIds.Len(); qt++) {
if (qt % 1000 == 0) {
Err("%d out of %d completed\n", qt, QuoteIds.Len());
}
TQuote Q;
QuoteBase->GetQuote(QuoteIds[qt], Q);
TStrV Content;
Q.GetParsedContent(Content);
int ContentLen = Content.Len();
for (int i = 0; i < ContentLen; i++) {
const TMd5Sig ShingleMd5(Content[i]);
Shingles.AddKey(ShingleMd5);
}
}
Err("Done with word hashing! Number of shingles: %d\n", Shingles.Len());
}
示例13: FilePatchError
void FilePatchError( int format, ... )
{
va_list args;
int err;
va_start( args, format );
err = errno;
Err( format, args );
printf( ": %s\n", strerror( err ) );
va_end( args );
MsgFini();
exit( EXIT_FAILURE );
}
示例14: LogToFile
static void LogToFile(int16_t x, int16_t y, int16_t z) {
uint8_t write_buf[48];
UINT bw;
TIMEREC time;
/* open file */
if (FAT1_open(&fp, "./log.txt", FA_OPEN_ALWAYS|FA_WRITE)!=FR_OK) {
Err();
}
/* move to the end of the file */
if (FAT1_lseek(&fp, fp.fsize) != FR_OK || fp.fptr != fp.fsize) {
Err();
}
/* get time */
if (TmDt1_GetTime(&time)!=ERR_OK) {
Err();
}
/* write data */
write_buf[0] = '\0';
UTIL1_strcatNum8u(write_buf, sizeof(write_buf), time.Hour);
UTIL1_chcat(write_buf, sizeof(write_buf), ':');
UTIL1_strcatNum8u(write_buf, sizeof(write_buf), time.Min);
UTIL1_chcat(write_buf, sizeof(write_buf), ':');
UTIL1_strcatNum8u(write_buf, sizeof(write_buf), time.Sec);
UTIL1_chcat(write_buf, sizeof(write_buf), '\t');
UTIL1_strcatNum16s(write_buf, sizeof(write_buf), x);
UTIL1_chcat(write_buf, sizeof(write_buf), '\t');
UTIL1_strcatNum16s(write_buf, sizeof(write_buf), y);
UTIL1_chcat(write_buf, sizeof(write_buf), '\t');
UTIL1_strcatNum16s(write_buf, sizeof(write_buf), z);
UTIL1_strcat(write_buf, sizeof(write_buf), (unsigned char*)"\r\n");
if (FAT1_write(&fp, write_buf, UTIL1_strlen((char*)write_buf), &bw)!=FR_OK) {
(void)FAT1_close(&fp);
Err();
}
/* closing file */
(void)FAT1_close(&fp);
}
示例15: ImgDirs
static void ImgDirs(
char* dirs, // out
const char* shapepath, // in: shape file path
FILE* file) // in
{
char s[SLEN];
Fgets(s, SLEN-1, file); // will skip blank lines and comments, if any
static const char* const whitespace = " \t\n\r";
char* token = strtok(s, whitespace);
if (!token || 0 != strcmp(token, "Directories"))
Err("Expected \"Directories\" in line %d of %s",
LineNbr(file), shapepath);
token = strtok(NULL, whitespace);
if (!token)
Err("Cannot read image directories in line %d of %s",
LineNbr(file), shapepath);
strncpy_(dirs, token, SLEN);
ConvertBackslashesToForwardAndStripFinalSlash(dirs);
}