本文整理匯總了C++中AssertWarn函數的典型用法代碼示例。如果您正苦於以下問題:C++ AssertWarn函數的具體用法?C++ AssertWarn怎麽用?C++ AssertWarn使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了AssertWarn函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: AssertWarn
//-----------------------------------------------------------------------------
// Get the size of the file in bytes.
// It is an error to query the file size for a Closed file, or for one with an
// error status.
//-----------------------------------------------------------------------------
U32 File::getSize() const
{
if (handle != NULL)
{
AssertWarn(Closed != currentStatus, "File::getSize: file closed");
AssertFatal(handle != NULL, "File::getSize: invalid file handle");
if (Ok == currentStatus || EOS == currentStatus)
{
struct stat statData;
if(fstat(fileno((FILE*)handle), &statData) != 0)
return 0;
// return the size in bytes
return statData.st_size;
}
return 0;
}
AssertWarn(Closed != currentStatus, "File::getSize: file closed");
AssertFatal(buffer != NULL, "File::getSize: invalid file buffer");
if (Ok == currentStatus || EOS == currentStatus)
{
return size;
}
return 0;
}
示例2: CreateFile
Bool GFXFont::read( const char *in_name )
{
Bool success;
HANDLE fileHandle; // handle of opened file
fileHandle = CreateFile(in_name,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL
);
if ( fileHandle == INVALID_HANDLE_VALUE )
{
AssertWarn(0, avar("GFXFont::load: Unable to load font %s, CreateFile for reading failed.", in_name));
return FALSE;
}
FileRStream frs(fileHandle);
success = read( &frs );
frs.close();
CloseHandle( fileHandle );
if ( success )
return TRUE;
else
{
AssertWarn(0, avar("GFXFont::load: Unable to load font %s, StreamIO for reading failed.", in_name));
return FALSE;
}
}
示例3: GetDateFormat
String Platform::localTimeToString( const LocalTime < )
{
// Converting a LocalTime to SYSTEMTIME
// requires a few annoying adjustments.
SYSTEMTIME st;
st.wMilliseconds = 0;
st.wSecond = lt.sec;
st.wMinute = lt.min;
st.wHour = lt.hour;
st.wDay = lt.monthday;
st.wDayOfWeek = lt.weekday;
st.wMonth = lt.month + 1;
st.wYear = lt.year + 1900;
TCHAR buffer[1024] = {0};
S32 result = 0;
String outStr;
// Note: The 'Ex' version of GetDateFormat and GetTimeFormat are preferred
// and have better support for supplemental locales but are not supported
// for version of windows prior to Vista.
//
// Would be nice if Torque was more aware of the OS version and
// take full advantage of it.
result = GetDateFormat( LOCALE_USER_DEFAULT,
DATE_SHORTDATE,
&st,
NULL,
(LPTSTR)buffer,
1024 );
// Also would be nice to have a standard system for torque to
// retrieve and display windows level errors using GetLastError and
// FormatMessage...
AssertWarn( result != 0, "Platform::getLocalTime" );
outStr += buffer;
outStr += "\t";
result = GetTimeFormat( LOCALE_USER_DEFAULT,
0,
&st,
NULL,
(LPTSTR)buffer,
1024 );
AssertWarn( result != 0, "Platform::localTimeToString, error occured!" );
outStr += buffer;
return outStr;
}
示例4: AssertWarn
ResourceOld<AtlasFile> AtlasFile::load(const char *filename)
{
ResourceOld<AtlasFile> af;
af = gResourceManager->load(filename);
// If we didn't get something back from the resman or we fail to open it,
// then clean up and error out.
if(af.isNull())
{
Con::errorf("AtlasFile::load - cannot open atlas file '%s'.", filename);
return af;
}
if(!af->hasStream())
{
Con::printf("AtlasFile::load - loading Atlas resource %x with %s", (AtlasFile*)af, filename);
if(!af->open(filename))
Con::errorf("AtlasFile::load - cannot open atlas file '%s'.", filename);
}
AssertWarn(!af.isNull() && af->getTOCCount(), "AtlasFile::load - loaded empty atlas file!?");
return af;
}
示例5: CreateFile
//================================================================
// NAME
// GFXBitmapArray::read
//
// DESCRIPTION
//
//
// ARGUMENTS
//
//
// RETURNS
//
//
// NOTES
//
//================================================================
Bool GFXBitmapArray::read(const char *in_filename, DWORD in_flags)
{
Bool result;
HANDLE fileHandle;
fileHandle = CreateFile(in_filename,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL
);
if (fileHandle == INVALID_HANDLE_VALUE)
{
AssertWarn(0, avar("GFXBitmapArray::load: Unable to open file %s, CreateFile for reading failed.", in_filename));
return (FALSE);
}
FileRStream frs(fileHandle);
result = read(&frs, in_flags);
frs.close();
CloseHandle(fileHandle);
return(result);
}
示例6: m_mul
Point2F& m_mul( const Point2F& a, const TMat2F& m, Point2F* r )
{
AssertWarn( &a != r, "m_mul: dest should not be same as source" );
r->x = a.x * m.m[0][0] + a.y * m.m[1][0] + m.p.x;
r->y = a.x * m.m[0][1] + a.y * m.m[1][1] + m.p.y;
return *r;
}
示例7: FileStream
void Journal::Record(const char * file)
{
if (_State == DisabledState)
{
Con::errorf("//---------------------------------------------//");
Con::errorf("Journal::Record() - Cannot record a journal after GuiCanvas or NetConnection creation!");
Con::errorf("To record before canvas/netConnection creation, run %s with the following arguments: -jSave %s",
Platform::getExecutableName(), file);
Con::errorf("//---------------------------------------------//");
return;
}
if (_State == StopState)
{
_Count = 0;
mFile = new FileStream();
if( ((FileStream*)mFile)->open(file, Torque::FS::File::Write) )
{
mFile->write(_Count);
_State = RecordState;
}
else
{
AssertWarn(false,"Journal: Could not create journal file");
Con::errorf("Journal: Could not create journal file '%s'", file);
}
}
}
示例8: read
/// Reads "size" bytes from the file, and dumps data into "dst".
/// The number of actual bytes read is returned in bytesRead
/// @returns The status of the file
File::Status read(U32 size, char *dst, U32 *bytesRead)
{
#ifdef DEBUG
// fprintf(stdout,"reading %d bytes\n",size);fflush(stdout);
#endif
AssertFatal(Closed != currentStatus, "File::read: file closed");
AssertFatal(NULL != handle, "File::read: invalid file handle");
AssertFatal(NULL != dst, "File::read: NULL destination pointer");
AssertFatal(true == hasCapability(FileRead), "File::read: file lacks capability");
AssertWarn(0 != size, "File::read: size of zero");
/* show stats for this file */
#ifdef DEBUG
//struct stat st;
//fstat(*((int *)handle), &st);
//fprintf(stdout,"file size = %d\n", st.st_size);
#endif
/****************************/
long lastBytes=0;
File::Status lastStatus = File::Ok;
if (Ok != currentStatus || 0 == size) {
lastStatus = currentStatus;
} else
{
long *bytes = &lastBytes;
if ( (*((U32 *)bytes) = x86UNIXRead(*((int *)handle), dst, size)) == -1)
{
#ifdef DEBUG
// fprintf(stdout,"unsuccessful: %d\n", *((U32 *)bytes));fflush(stdout);
#endif
setStatus(); // unsuccessful
lastStatus = currentStatus;
} else {
// dst[*((U32 *)bytes)] = '\0';
if (*((U32 *)bytes) != size || *((U32 *)bytes) == 0) {
#ifdef DEBUG
// fprintf(stdout,"end of stream: %d\n", *((U32 *)bytes));fflush(stdout);
#endif
currentStatus = EOS; // end of stream
lastStatus = currentStatus;
}
}
}
// dst[*bytesRead] = '\0';
#ifdef DEBUG
//fprintf(stdout, "We read:\n");
//fprintf(stdout, "====================================================\n");
//fprintf(stdout, "%s\n",dst);
//fprintf(stdout, "====================================================\n");
//fprintf(stdout,"read ok: %d\n", *bytesRead);fflush(stdout);
#endif
// if bytesRead is a valid pointer, put number of bytes read there.
if(bytesRead)
*bytesRead = lastBytes;
currentStatus = lastStatus;
return currentStatus; // successfully read size bytes
}
示例9: AssertWarn
//-----------------------------------------------------------------------------
bool FileStream::flush()
{
AssertWarn(0 != mStreamCaps, "FileStream::flush: the stream isn't open");
AssertFatal(false == mDirty || BUFFER_INVALID != mBuffHead, "FileStream::flush: buffer must be valid if its dirty");
// if the buffer is dirty
if (mDirty)
{
AssertFatal(hasCapability(StreamWrite), "FileStream::flush: a buffer without write-capability should never be dirty");
// align the file pointer to the buffer head
if (mBuffHead != mFile->getPosition())
{
mFile->setPosition(mBuffHead, Torque::FS::File::Begin);
if (mFile->getStatus() != Torque::FS::FileNode::Open && mFile->getStatus() != Torque::FS::FileNode::EndOfFile)
return(false);
}
// write contents of the buffer to disk
U32 blockHead;
calcBlockHead(mBuffHead, &blockHead);
mFile->write((char *)mBuffer + (mBuffHead - blockHead), mBuffTail - mBuffHead + 1);
// and update the file stream's state
setStatus();
if (EOS == getStatus())
mEOF = true;
if (Ok == getStatus() || EOS == getStatus())
// and update the status of the buffer
mDirty = false;
else
return(false);
}
return(true);
}
示例10: AssertFatal
//-----------------------------------------------------------------------------
// Write to a file.
// The number of bytes to write is passed in size, the data is passed in src.
// The number of bytes written is available in bytesWritten if a non-Null
// pointer is provided.
//-----------------------------------------------------------------------------
File::Status File::write(U32 size, const char *src, U32 *bytesWritten)
{
if (handle != NULL)
{
AssertFatal(Closed != currentStatus, "File::write: file closed");
AssertFatal(handle != NULL, "File::write: invalid file handle");
AssertFatal(NULL != src, "File::write: NULL source pointer");
AssertFatal(true == hasCapability(FileWrite), "File::write: file lacks capability");
AssertWarn(0 != size, "File::write: size of zero");
if ((Ok != currentStatus && EOS != currentStatus) || 0 == size)
return currentStatus;
// write bytes to the stream
U32 nBytes = fwrite(src, 1, size,(FILE*)handle);
// if we couldn't write everything, we've got a problem. set error status.
if(nBytes != size)
setStatus();
// if bytesWritten is a valid pointer, put number of bytes read there.
if(bytesWritten)
*bytesWritten = nBytes;
// return current File status, whether good or ill.
return currentStatus;
}
AssertFatal(0, "File::write: Not supported on Android.");
return setStatus();
}
示例11: SAFE_DELETE
void Journal::Play(const char * file)
{
if (_State == DisabledState)
{
Con::errorf("//---------------------------------------------//");
Con::errorf("Journal::Play() - Cannot playback a journal after GuiCanvas or NetConnection creation!");
Con::errorf("To playback before canvas/netConnection creation, run %s with the following arguments: -jPlay %s",
Platform::getExecutableName(), file);
Con::errorf("//---------------------------------------------//");
return;
}
if (_State == StopState)
{
SAFE_DELETE(mFile);
mFile = new FileStream();
if( ((FileStream*)mFile)->open(file, Torque::FS::File::Read) )
{
mFile->read(&_Count);
_State = PlayState;
}
else
{
AssertWarn(false,"Journal: Could not open journal file");
Con::errorf("Journal: Could not open journal file '%s'", file);
}
}
}
示例12: setMaskBits
//------------------------------------------------------------------------------
void Sky::load()
{
if (manager->isServer()) {
// don't load sky resources in server
setMaskBits(Modified);
return;
}
unload();
if ( dmlName[0] ) {
ResourceManager &rm = *SimResource::get(manager);
// const char *filename = SimTagDictionary::getString(manager, matListTag);
// load the material list from file
hMaterialList = rm.load(dmlName);
// don't want to bring down the mission editor, so if an invalid
// dml is given, set the color to ugly
AssertWarn((bool)hMaterialList, avar("Error reading materialList file \"%s\"", dmlName));
if ((bool)hMaterialList && hMaterialList->getMaterialsCount() > 0)
{
loaded = true;
hMaterialList->load(rm, true);
if (initialize() == false)
addToSet(SimTimerSetId);
}
else
// set ugly color if dml wasn't found
set(ColorF(1.0f, 0.0f, 0.0f));
}
setMaskBits(Modified);
}
示例13: AssertWarn
//------------------------------------------------------------------------------
// NAME
// void
// Surface::drawSurface(GFXSurface* /*lpSourceSurface*/,
// const RectI* /*in_subRegion*/,
// const Point2I* /*in_at*/)
//
// DESCRIPTION
// Not implemented for hardware cards...
//
//------------------------------------------------------------------------------
void
Surface::drawSurface(GFXSurface* /*lpSourceSurface*/,
const RectI* /*in_subRegion*/,
const Point2I* /*in_at*/)
{
AssertWarn(0, "DrawSurface not implemented in hardware");
}
示例14: AssertWarn
void SimGroup::popObject()
{
MutexHandle handle;
handle.lock( mMutex );
if( objectList.empty() )
{
AssertWarn( false, "SimGroup::popObject - Stack underflow" );
return;
}
SimObject* object = objectList.last();
objectList.pop_back();
object->onGroupRemove();
object->mGroup = NULL;
clearNotify( object );
mNameDictionary.remove( object );
getSetModificationSignal().trigger( SetObjectAdded, this, object );
if( object->isProperlyAdded() )
onObjectRemoved_callback( object );
object->decRefCount();
}
示例15: while
void StdMoveList::clientReadMovePacket(BitStream * bstream)
{
#ifdef TORQUE_DEBUG_NET_MOVES
Con::printf("pre move ack: %i", mLastMoveAck);
#endif
mLastMoveAck = bstream->readInt(32);
#ifdef TORQUE_DEBUG_NET_MOVES
Con::printf("post move ack %i, first move %i, last move %i", mLastMoveAck, mFirstMoveIndex, mLastClientMove);
#endif
if (mLastMoveAck < mFirstMoveIndex)
mLastMoveAck = mFirstMoveIndex;
if(mLastMoveAck > mLastClientMove)
mLastClientMove = mLastMoveAck;
while(mFirstMoveIndex < mLastMoveAck)
{
if (mMoveVec.size())
{
mMoveVec.pop_front();
mFirstMoveIndex++;
}
else
{
AssertWarn(1, "Popping off too many moves!");
mFirstMoveIndex = mLastMoveAck;
}
}
}