本文整理汇总了C++中FATALERROR函数的典型用法代码示例。如果您正苦于以下问题:C++ FATALERROR函数的具体用法?C++ FATALERROR怎么用?C++ FATALERROR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FATALERROR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test
void Image::import(const SimulationItem *item, QString filename, QString directory)
{
// Cache a pointer to the logger
Log* log = item->find<Log>();
// Store a pointer to the units system
_units = item->find<Units>();
// Determine the path of the input FITS file
QString filepath;
filename = filename.endsWith(".fits") ? filename : filename + ".fits";
if (directory.isNull())
{
filepath = item->find<FilePaths>()->input(filename);
}
else
{
QFileInfo test(directory);
if (!test.isDir()) throw FATALERROR("Import directory does not exist: " + directory);
filepath = directory + "/" + filename;
}
// Read the input image and store it
log->info("Reading FITS file " + filepath);
FITSInOut::read(filepath, _data, _xsize, _ysize, _nframes);
// Verify that the FITS file contains only one frame
if (_nframes != 1) throw FATALERROR("FITS image contains multiple frames");
// Log the dimensions of the image
log->info("Frame dimensions: " + QString::number(_xsize) + " x " + QString::number(_ysize));
}
示例2: extract2fs
/*
* extract from the archive
* and copy to the filesystem
* relative to the directory the archive's in
*/
int extract2fs(TOC *ptoc)
{
#ifdef WIN32
char *p;
#endif
FILE *out;
unsigned char *data = extract(ptoc);
if (!f_workpath) {
getTempPath(f_temppath);
#ifdef WIN32
strcpy(f_temppathraw, f_temppath);
for ( p=f_temppath; *p; p++ )
if (*p == '\\')
*p = '/';
#endif
f_workpath = f_temppath;
}
out = openTarget(f_workpath, ptoc->name);
if (out == NULL) {
FATALERROR(ptoc->name);
FATALERROR(" could not be extracted!\n");
}
else {
fwrite(data, ntohl(ptoc->ulen), 1, out);
#ifndef WIN32
fchmod(fileno(out), S_IRUSR | S_IWUSR | S_IXUSR);
#endif
fclose(out);
}
free(data);
return 0;
}
示例3: loadPython
/*
* Load the Python DLL, and get all of the necessary entry points
* Windows only (dynamic load)
*/
int loadPython()
{
#ifdef WIN32
HINSTANCE dll;
char dllpath[_MAX_PATH + 1];
/* Determine the path */
sprintf(dllpath, "%spython%02d.dll", f_homepathraw, ntohl(f_cookie.pyvers));
/* Load the DLL */
dll = LoadLibraryEx(dllpath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
if (dll) {
VS(dllpath);
VS("\n");
}
else {
sprintf(dllpath, "%spython%02d.dll", f_temppathraw, ntohl(f_cookie.pyvers));
dll = LoadLibraryEx(dllpath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH );
if (dll) {
VS(dllpath);
VS("\n");
}
}
if (dll == 0) {
FATALERROR("Error loading Python DLL: ");
FATALERROR(dllpath);
FATALERROR("\n");
return -1;
}
mapNames(dll);
#endif
return 0;
}
示例4: setupSelfBefore
void LogNormalGrainSizeDistribution::setupSelfBefore()
{
RangeGrainSizeDistribution::setupSelfBefore();
// verify the attributes
if (_a0 <= 0) throw FATALERROR("The centroid of the log-normal law must be positive");
if (_sigma <= 0) throw FATALERROR("The width of the log-normal law must be positive");
}
示例5:
void
YDustCompNormalization::setupSelfBefore()
{
DustCompNormalization::setupSelfBefore();
// verify that we have some wavelength and optical depth
if (_wavelength <= 0) throw FATALERROR("Wavelength was not set");
if (_tau <= 0) throw FATALERROR("Optical depth was not set");
}
示例6:
void
TriaxialGeometry::setupSelfBefore()
{
GenGeometry::setupSelfBefore();
// verify property values
if (_p <= 0 || _p > 1.0) throw FATALERROR("the flattening parameter p should be between 0 and 1");
if (_q <= 0 || _q > 1.0) throw FATALERROR("the flattening parameter q should be between 0 and 1");
}
示例7: GMC_DCL
GMC_DCL(tp_Nod, Nod)
{
tp_FilHdr FilHdr;
tp_Nod RootNod, OprNod;
tp_Key Key;
if (Nod == ERROR) return ERROR;
switch (Nod_NodTyp(Nod)) {
case NSTDEF: case FILDEF: case SEGDEF: {
SystemError("Syntax error: Unexpected target.\n");
return ERROR; }/*case*/;
case WORD: {
FilHdr = Str_FilHdr(Sym_Str(Nod_Sym(Nod)), NullPrmTyp);
return New_PrmFHdr(FilHdr, RootFilPrm); }/*case*/;
case DRVFIL: {
break; }/*case*/;
default: {
FATALERROR("Unexpected node type.\n"); };}/*switch*/;
RootNod = Nod_Son(1, Nod);
OprNod = Nod_Brother(RootNod);
switch (Nod_NodTyp(RootNod)) {
case EMPFIL: {
FilHdr = Copy_FilHdr(EmptyFilHdr);
break; }/*case*/;
case ARTFIL: {
FilHdr = Copy_FilHdr(RootFilHdr);
break; }/*case*/;
case OBJTID: {
FilHdr = LocHdr_FilHdr
((tp_LocHdr)Str_PosInt(Sym_Str(Nod_Sym(RootNod))));
break; }/*case*/;
case WORD: {
FilHdr = HostFN_FilHdr(Sym_Str(Nod_Sym(RootNod)));
break; }/*case*/;
case ABSFIL: {
Key = Sym_Str(Nod_Sym(Nod_Son(1, RootNod)));
FilHdr = Do_Keys(Copy_FilHdr(RootFilHdr), Key);
break; }/*case*/;
case SEGOPR: {
FilHdr = Get_BaseVTgtFilHdr(Top_ContextFilHdr());
OprNod = RootNod;
break; }/*case*/;
case DRVOPR: {
FilHdr = Top_ContextFilHdr();
OprNod = RootNod;
break; }/*case*/;
case STRING: {
FilHdr = Str_FilHdr(Sym_Str(Nod_Sym(Nod_Son(1, RootNod))), NullPrmTyp);
break; }/*case*/;
default: {
FATALERROR("Unexpected node type.\n"); };}/*switch*/;
return Apply_OprNods(FilHdr, RootFilPrm, OprNod);
}/*Nod_PrmFHdr*/
示例8: _MGL_destroyDisplayDC
/****************************************************************************
PARAMETERS:
dc - Device context to destroy
RETURNS:
True if the context was destroyed, false on error.
REMARKS:
Searches for the display device context in the list of currently allocated
contexts, and destroys it if it exists. If this is the last display device
context, then we also shut down the graphics mode and restore the original
graphics mode.
{secret}
****************************************************************************/
ibool _MGL_destroyDisplayDC(
MGLDC *dc)
{
MGLDC *prev;
PM_HWND hwndConsole;
if (!dc) {
FATALERROR(grInvalidDC);
return false;
}
if (DEV.dispDCList->count == 1) {
/* There is only one active display context left, so restore
* the original display mode and destroy the entire display
* device context list
*/
if (dc != _LST_first(DEV.dispDCList)) {
FATALERROR(grInvalidDC);
return false;
}
/* Save the console window handle for later as the DC structure
* is destroyed before we close the console itself.
*/
hwndConsole = (PM_HWND)dc->v->d.hwnd;
dc->v->d.restoreTextMode(dc);
_MGL_freeInternalDCVars(dc);
dc->v->d.destroy(dc);
_LST_destroy(DEV.dispDCList,_LST_freeNode);
DEV.dispDCList = NULL;
/* Restore the console state and close it */
if (DEV.stateBuf) {
PM_restoreConsoleState(DEV.stateBuf,hwndConsole);
PM_free(DEV.stateBuf);
DEV.stateBuf = NULL;
PM_closeConsole(hwndConsole);
}
/* We are no longer in Windows full screen mode but on the desktop */
if (_MGL_consoleSupport)
_MS_setDisplayDC(NULL);
}
else {
/* There is more than one active display context, so simply
* remove the current one from the list and destroy it.
*/
if ((prev = _LST_findNode(DEV.dispDCList,dc)) == NULL) {
FATALERROR(grInvalidDC);
return false;
}
_MGL_freeInternalDCVars(dc);
dc->v->d.destroy(dc);
_LST_removeNext(DEV.dispDCList,prev);
_LST_freeNode(dc);
}
return true;
}
示例9: openArchive
/*
* Open the archive
* Sets f_archiveFile, f_pkgstart, f_tocbuff and f_cookie.
*/
int openArchive()
{
int filelen;
/* Physically open the file */
f_fp = fopen(f_archivename, "rb");
if (f_fp == NULL) {
VS("Cannot open archive: ");
VS(f_archivename);
VS("\n");
return -1;
}
/* Seek to the Cookie at the end of the file. */
fseek(f_fp, 0, SEEK_END);
filelen = ftell(f_fp);
if (fseek(f_fp, -(int)sizeof(COOKIE), SEEK_END))
{
VS(f_archivename);
VS(" appears to be an invalid archive\n");
return -1;
}
/* Read the Cookie, and check its MAGIC bytes */
fread(&f_cookie, sizeof(COOKIE), 1, f_fp);
if (strncmp(f_cookie.magic, MAGIC, strlen(MAGIC)))
{
VS(f_archivename);
VS(" has bad magic!\n");
return -1;
}
/* From the cookie, calculate the archive start */
f_pkgstart = filelen - ntohl(f_cookie.len);
/* Read in in the table of contents */
fseek(f_fp, f_pkgstart + ntohl(f_cookie.TOC), SEEK_SET);
f_tocbuff = (TOC *) malloc(ntohl(f_cookie.TOClen));
if (f_tocbuff == NULL)
{
FATALERROR("Could not allocate buffer for TOC.");
return -1;
}
fread(f_tocbuff, ntohl(f_cookie.TOClen), 1, f_fp);
f_tocend = (TOC *) (((char *)f_tocbuff) + ntohl(f_cookie.TOClen));
/* Check input file is still ok (should be). */
if (ferror(f_fp))
{
FATALERROR("Error on file");
return -1;
}
return 0;
}
示例10: value
double AdaptiveMeshAsciiFile::value(int g) const
{
// verify index range
if (g < 0) throw FATALERROR("Field index out of range");
if (g >= _columns.size()) throw FATALERROR("Insufficient number of field values in mesh data");
// get the appropriate column value
bool ok;
double value = _columns.value(g).toDouble(&ok);
if (!ok) throw FATALERROR("Invalid leaf line in mesh data");
return value;
}
示例11: buildFontEnumCache
/****************************************************************************
PARAMETERS:
dcache - local cache for one directory
cache - pointer to variable that holds list of found families
REMARKS:
Extracts information from dcache and translates it to cache.
This involves finding fonts with same family name and merging them into
one entry in cache.
Called exclusively by enumFontsInDir.
{secret}
****************************************************************************/
static void buildFontEnumCache(
dirCache *dcache,
fontEnumCache **cache)
{
fontEnumCache *ecache, *tail;
size_t i;
fileCache *f;
if (dcache->filesCnt == 0)
return;
qsort(dcache->files, dcache->filesCnt, sizeof(fileCache),
comparFileCacheByFamily);
tail = ecache = NULL;
for (i = 0, f = dcache->files; i < dcache->filesCnt; i++, f++) {
/* new family: */
if (tail == NULL ||
strcmp(tail->info.familyName, f->familyName) != 0) {
if (tail == NULL) {
if ((tail = ecache = PM_malloc(sizeof(fontEnumCache))) == NULL)
FATALERROR(grNoMem);
}
else {
if ((tail->next = PM_malloc(sizeof(fontEnumCache))) == NULL)
FATALERROR(grNoMem);
tail = tail->next;
}
tail->next = NULL;
strcpy(tail->info.familyName, f->familyName);
tail->info.fontLibType = f->fontLibType;
tail->info.isFixed = f->isFixed;
tail->info.regularFace[0] = '\0';
tail->info.boldFace[0] = '\0';
tail->info.italicFace[0] = '\0';
tail->info.boldItalicFace[0] = '\0';
}
/* faces lookup: */
if (!f->isBold && !f->isItalic)
strcpy(tail->info.regularFace, f->fileName);
else if (f->isBold && !f->isItalic)
strcpy(tail->info.boldFace, f->fileName);
else if (!f->isBold && f->isItalic)
strcpy(tail->info.italicFace, f->fileName);
else if (f->isBold && f->isItalic)
strcpy(tail->info.boldItalicFace, f->fileName);
}
tail->next = *cache;
*cache = ecache;
}
示例12: Init_Env
void
Init_Env(GMC_ARG_VOID)
{
tps_FileName FileName;
boolean Abort;
size_t sz;
OdinDirName = GetEnv("ODINCACHE");
FORBIDDEN(OdinDirName == NIL);
if (!IsDirectory_FileName(OdinDirName)) {
SystemError("Odin root <%s> does not exist.\n", OdinDirName);
FATALERROR("");}/*if*/;
if (OdinDirName[0] != '/') {
SystemError("Odin cache pathname <%s> must be absolute.\n", OdinDirName);
FATALERROR("");}/*if*/;
Set_ModeMask(OdinDirName);
sz = snprintf(FileName, MAX_FileName, "%s/FILES", OdinDirName);
if (sz >= MAX_FileName) {
(void)fprintf(stderr, "File name too long (MAX_FileName=%d): %s/FILES\n",
MAX_FileName, OdinDirName);
exit(1); }/*if*/;
CacheDirName = Malloc_Str(FileName);
MakeDirFile(&Abort, CacheDirName);
if (Abort) FATALERROR("cannot create odin FILES directory");
sz = snprintf(FileName, MAX_FileName, "%s/JOBS", OdinDirName);
if (sz >= MAX_FileName) {
(void)fprintf(stderr, "File name too long (MAX_FileName=%d): %s/JOBS\n",
MAX_FileName, OdinDirName);
exit(1); }/*if*/;
JobsDirName = Malloc_Str(FileName);
MakeDirFile(&Abort, JobsDirName);
if (Abort) FATALERROR("cannot create odin JOBS directory");
sz = snprintf(FileName, MAX_FileName, "%s/ENV", OdinDirName);
if (sz >= MAX_FileName) {
(void)fprintf(stderr, "File name too long (MAX_FileName=%d): %s/ENV\n",
MAX_FileName, OdinDirName);
exit(1); }/*if*/;
Read_Env(FileName);
DumpCore = (GetEnv("DUMPCORE") != NIL);
RBS_Cmd = GetEnv("ODIN_RBSCMD");
FORBIDDEN(RBS_Cmd == NIL);
ShortCacheNameFlag = (GetEnv("ODIN_SHORTNAMES") != NIL);
LocalIPCFlag = (GetEnv("ODIN_LOCALIPC") != NIL);
}/*Init_Env*/
示例13: _MGL_destroyWindowedDC
/****************************************************************************
PARAMETERS:
dc - Device context to destroy
RETURNS:
True if the context was destroyed, false on error.
REMARKS:
Searches for the windowed device context in the list of currently allocated
contexts, and destroys it if it exists.
{secret}
****************************************************************************/
ibool _MGL_destroyWindowedDC(
MGLDC *dc)
{
MGLDC *prev;
PM_HWND hwndConsole;
/* Remove the DC from the list of allocated memory DC's */
if (!dc) {
FATALERROR(grInvalidDC);
return false;
}
if ((prev = _LST_findNode(_MGL_winDCList,dc)) == NULL) {
__MGL_result = grInvalidDC;
return false;
}
/* Unhook any window procedures that are hooked */
_MGL_unhookWindowProc(dc);
/* Free up all memory occupied by the DC */
if (_MGL_winDCList->count == 1) {
/* This is the last windowed device context, so destroy the list */
if (dc != _LST_first(_MGL_winDCList)) {
FATALERROR(grInvalidDC);
return false;
}
hwndConsole = (PM_HWND)dc->v->d.hwnd;
dc->v->d.restoreTextMode(dc);
_MGL_freeInternalDCVars(dc);
dc->v->w.destroy(dc);
_LST_destroy(_MGL_winDCList,_LST_freeNode);
_MGL_winDCList = NULL;
/* Restore the console state and close it */
PM_closeConsole(hwndConsole);
/* We are no longer in Windows full screen mode but on the desktop */
if (_MGL_consoleSupport)
_MS_setDisplayDC(NULL);
}
else {
_MGL_freeInternalDCVars(dc);
dc->v->w.destroy(dc);
_LST_removeNext(_MGL_winDCList,prev);
_LST_freeNode(dc);
}
return true;
}
示例14: FATALERROR
void BinTreeDustGridStructure::setupSelfBefore()
{
TreeDustGridStructure::setupSelfBefore();
if (searchMethod() == TreeDustGridStructure::Bookkeeping)
throw FATALERROR("Bookkeeping method is not compatible with binary tree");
}
示例15: extract2fs
/*
* extract from the archive
* and copy to the filesystem
* relative to the directory the archive's in
*/
int extract2fs(ARCHIVE_STATUS *status, TOC *ptoc)
{
FILE *out;
unsigned char *data = extract(status, ptoc);
if (createTempPath(status) == -1){
return -1;
}
out = openTarget(status->temppath, ptoc->name);
if (out == NULL) {
FATALERROR("%s could not be extracted!\n", ptoc->name);
return -1;
}
else {
fwrite(data, ntohl(ptoc->ulen), 1, out);
#ifndef WIN32
fchmod(fileno(out), S_IRUSR | S_IWUSR | S_IXUSR);
#endif
fclose(out);
}
free(data);
return 0;
}