• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ NN_ASSERT函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中NN_ASSERT函数的典型用法代码示例。如果您正苦于以下问题:C++ NN_ASSERT函数的具体用法?C++ NN_ASSERT怎么用?C++ NN_ASSERT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NN_ASSERT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: NN_ASSERT

//============================================================================
//		NDBHandlePool::Open : Open the database.
//----------------------------------------------------------------------------
NStatus NDBHandlePool::Open(const NFile &theFile, NDBFlags theFlags, const NString &theVFS)
{	NDBHandlePtr		dbHandle;
	NStatus				theErr;



	// Validate our parameters and state
	NN_ASSERT(theFile.IsValid());
	NN_ASSERT(!IsOpen());
	


	// Update our state
	mFile  = theFile;
	mFlags = theFlags;
	mVFS   = theVFS;



	// Create the initial connection
	//
	// The initial connection allows us to test that we can actually open the
	// database, and may be all that we need if we're only to connect once.
	theErr = CreateConnection(dbHandle);
	NN_ASSERT_NOERR(theErr);

	mIsOpen = (dbHandle != NULL);

	if (mIsOpen)
		mPool.PushBack(dbHandle);

	return(theErr);
}
开发者ID:refnum,项目名称:nano,代码行数:36,代码来源:NDBHandlePool.cpp


示例2: NN_ASSERT

//============================================================================
//		NUnicodeParser::GetChar : Get a character.
//----------------------------------------------------------------------------
utf32_t NUnicodeParser::GetChar(NIndex theIndex, bool toLower) const
{   NStringEncoder		theEncoder;
    NRange				theRange;
    const uint8_t		*srcPtr;
    utf32_t				theChar;



    // Validate our parameters
    NN_ASSERT(theIndex >= 0 && theIndex < GetSize());



    // Get the state we need
    theRange = GetRange(theIndex);
    srcPtr   = mData.GetData(theRange.GetLocation());



    // Convert the character
    theChar = theEncoder.ConvertToUTF32(mEncoding, theRange.GetSize(), srcPtr);
    NN_ASSERT(theChar != 0);

    if (toLower)
        theChar = GetLower(theChar);

    return(theChar);
}
开发者ID:refnum,项目名称:nano,代码行数:31,代码来源:NUnicodeParser.cpp


示例3: switch

//============================================================================
//		TTestClient::ReceivedMessage : The client has received a message.
//----------------------------------------------------------------------------
void TTestClient::ReceivedMessage(const NNetworkMessage &theMsg)
{	NString		theValue;



	// Update our state
	mState += kStateClientReceivedMessage;



	// Handle the message
	switch (theMsg.GetType()) {
		case kTestClientBroadcastMsg:
			// Validate the message
			theValue = theMsg.GetValueString(kTestTokenKey);
			NN_ASSERT(theValue == kTokenClientBroadcast);
			break;


		case kTestServerClientMsg:
			// Validate the message
			theValue = theMsg.GetValueString(kTestTokenKey);
			NN_ASSERT(theValue == kTokenServerClient);
			
			// Update our state
			mIsDone = true;
			break;


		default:
			NMessageClient::ReceivedMessage(theMsg);
			break;
		}
}
开发者ID:x414e54,项目名称:nano,代码行数:37,代码来源:TMessageServer.cpp


示例4: NSocket

//============================================================================
//		TSocketClient::ExecuteCustom : Execute a custom client test.
//----------------------------------------------------------------------------
void TSocketClient::ExecuteCustom(bool *isDone, UInt16 thePort)
{	UInt32		n, theValue;
	NSocket		*theSocket;
	NStatus		theErr;



	// Open the socket
	theSocket = new NSocket(this);
	theSocket->Open("127.0.0.1", thePort);
	
	while (theSocket->GetStatus() != kNSocketOpened)
		NThread::Sleep();



	// Get/set optins
	theErr = theSocket->SetOption(kNSocketNoDelay, (SInt32) true);
	NN_ASSERT_NOERR(theErr);
	
	theValue = theSocket->GetOption(kNSocketNoDelay);
	NN_ASSERT(theValue == (SInt32) true);



	// Write some data
	for (n = 0; n < kTestNumItems; n++)
		{
		theErr = theSocket->WriteUInt32(n);
		NN_ASSERT_NOERR(theErr);
		}



	// Read the response
	for (n = 0; n < kTestNumItems; n++)
		{
		theErr = theSocket->ReadUInt32(theValue);
		NN_ASSERT_NOERR(theErr);
		NN_ASSERT(theValue == (n * n));
		}



	// Clean up
	theSocket->Close();

	while (theSocket->GetStatus() != kNSocketClosed)
		NThread::Sleep();
	
	delete theSocket;



	// Finish off
	*isDone = true;
}
开发者ID:x414e54,项目名称:nano,代码行数:60,代码来源:TSocket.cpp


示例5: NN_ASSERT

//============================================================================
//		NTask::SetCommand : Set the command.
//----------------------------------------------------------------------------
void NTask::SetCommand(const NString &theCmd)
{


	// Validate our parameters and state
	NN_ASSERT(!theCmd.IsEmpty());
	NN_ASSERT(!IsRunning());



	// Set the command
	mCommand = theCmd;
}
开发者ID:x414e54,项目名称:nano,代码行数:16,代码来源:NTask.cpp


示例6: NN_ASSERT

//============================================================================
//		NSocketRequest::ProcessedData : Mark data as having been processed.
//----------------------------------------------------------------------------
void NSocketRequest::ProcessedData(NIndex theSize)
{


	// Validate our state
	NN_ASSERT(!IsFinished());
	
	
	
	// Process the data
	mProcessed += theSize;
	NN_ASSERT(mProcessed <= mData.GetSize());
}
开发者ID:x414e54,项目名称:nano,代码行数:16,代码来源:NSocketRequest.cpp


示例7: acquireLock

//============================================================================
//		NThreadPool::Pause : Pause the pool.
//----------------------------------------------------------------------------
void NThreadPool::Pause(void)
{	StLock	acquireLock(mLock);



	// Validate our state
	NN_ASSERT(!mIsPaused);
	NN_ASSERT(mTasksPending.empty());



	// Update our state
	mIsPaused = true;
}
开发者ID:refnum,项目名称:nano,代码行数:17,代码来源:NThreadPool.cpp


示例8: NN_ASSERT

//============================================================================
//		NMessageServer::SetMaxClients : Set the max clients.
//----------------------------------------------------------------------------
void NMessageServer::SetMaxClients(NIndex maxClients)
{


	// Validate our parameters and state
	NN_ASSERT(maxClients >= 1 && maxClients <= kNEntityClientsMax);

	NN_ASSERT(GetStatus() == kNServerStopped);



	// Set the max clients
	mMaxClients = maxClients;
}
开发者ID:x414e54,项目名称:nano,代码行数:17,代码来源:NMessageServer.cpp


示例9: NN_ASSERT

//============================================================================
//		TTestClient::~TTestClient : Destructor.
//----------------------------------------------------------------------------
TTestClient::~TTestClient(void)
{


	// Validate our state
	NN_ASSERT(GetStatus() == kNClientDisconnected);
}
开发者ID:x414e54,项目名称:nano,代码行数:10,代码来源:TMessageServer.cpp


示例10: acquireLock

//============================================================================
//		NTimer::ResetTimer : Reset a timer.
//----------------------------------------------------------------------------
void NTimer::ResetTimer(NTime fireAfter, NTimerID theTimer)
{	StLock					acquireLock(mLock);
	NTimerMapIterator		theIter;



	// Adjust all timers
	if (theTimer == kNTimerAll)
		{
		for (theIter = mTimers.begin(); theIter != mTimers.end(); theIter++)
			NTargetTime::TimerReset(theIter->first, fireAfter);
		}
	
	
	
	// Adjust a single timer
	else
		{
		theIter = mTimers.find(theTimer);
		NN_ASSERT(theIter != mTimers.end());
		
		if (theIter != mTimers.end())
			NTargetTime::TimerReset(theIter->first, fireAfter);
		}
}
开发者ID:refnum,项目名称:nano,代码行数:28,代码来源:NTimer.cpp


示例11: NN_ASSERT

//=============================================================================
//		NGeometryUtilities::ComparePointToPolygon : Compare a point to a polygon.
//-----------------------------------------------------------------------------
template<class T> NGeometryComparison NGeometryUtilities::ComparePointToPolygon(const NPointT<T> &thePoint, NIndex numPoints, const NPointT<T> *thePoints)
{	bool			p1Above, p2Above;
	SInt32			crossNum;
	NPointT<T>		p1, p2;
 	T				c, w;
    NIndex			n;



	// Validate our parameters
	NN_ASSERT(numPoints >= 3);



	// Test the polygon
	crossNum = 0;
	p1       = thePoints[numPoints-1];
	p1Above  = (p1.y > thePoint.y);
	
	for (n = 0; n < numPoints; n++)
		{
		// Look for a crossing in y
		p2      = thePoints[n];
		p2Above = (p2.y > thePoint.y);

		if (p1Above != p2Above)
			{
			// If the segment is entirely to the left in x, it can't cross
			if (std::max(p1.x, p2.x) < thePoint.x)
				;
			
			
			// If the segment is entirely to the right in x, it must cross
			else if (std::min(p1.x, p2.x) > thePoint.x)
				crossNum++;
			
			
			// Otherwise we need to check the intersection
			else
				{
				w = (thePoint.y - p1.y) / (p2.y - p1.y);
				c = p1.x + (w * (p2.x - p1.x));
				
				if (thePoint.x < c)
					crossNum++;
				}
			}
		
		p1      = p2;
		p1Above = p2Above;
		}



	// Process the result
    if (NMathUtilities::IsOdd(crossNum))
		return(kNGeometryInside);
	else
		return(kNGeometryOutside);
}
开发者ID:x414e54,项目名称:nano,代码行数:63,代码来源:NGeometryUtilities.cpp


示例12: NN_ASSERT

//============================================================================
//		NDate::SetDate : Set the date.
//----------------------------------------------------------------------------
void NDate::SetDate(const NGregorianDate &theDate)
{


    // Validate our parameters
    NN_ASSERT(theDate.month  >= 1   && theDate.month  <= 12);
    NN_ASSERT(theDate.day    >= 1   && theDate.day    <= 31);
    NN_ASSERT(theDate.hour   >= 0   && theDate.hour   <= 23);
    NN_ASSERT(theDate.minute >= 0   && theDate.minute <= 59);
    NN_ASSERT(theDate.second >= 0.0 && theDate.second <= 60.0);



    // Set the time
    mTime = NTargetTime::ConvertDateToTime(theDate);
}
开发者ID:refnum,项目名称:nano,代码行数:19,代码来源:NDate.cpp


示例13: NN_ASSERT

//============================================================================
//		NFileUtilities::GetDirectorySize : Get a directory size.
//----------------------------------------------------------------------------
uint64_t NFileUtilities::GetDirectorySize(const NFile &theDirectory)
{	NFileIterator				fileIterator;
	NFileList					theFiles;
	NFile						theFile;
	uint64_t					theSize;
	NFileListConstIterator		theIter;



	// Validate our parameters
	NN_ASSERT(theDirectory.IsDirectory());



	// Get the state we need
	theFiles = fileIterator.GetFiles(theDirectory);
	theSize  = 0;



	// Get the size
	for (theIter = theFiles.begin(); theIter != theFiles.end(); theIter++)
		{
		theFile = *theIter;

		if (theFile.IsFile())
			theSize += theFile.GetSize();
		}

	return(theSize);
}
开发者ID:refnum,项目名称:nano,代码行数:34,代码来源:NFileUtilities.cpp


示例14: NN_ASSERT

//============================================================================
//		NCGShading::UpdateShading : Update the shading.
//----------------------------------------------------------------------------
void NCGShading::UpdateShading(void) const
{	CGColorSpaceRef		cgColorSpace;



	// Validate our state
	NN_ASSERT(!mShading.IsValid());



	// Create the new shading
	cgColorSpace = NCGColor::GetDeviceRGB();

	switch (mMode) {
		case kShadingNone:
			ResetShading();
			break;

		case kShadingLinear:
			mShading.SetObject(CGShadingCreateAxial( cgColorSpace, ToCG(mStartPoint), ToCG(mEndPoint), mEvaluate, mStartExtend, mEndExtend));
			break;

		case kShadingRadial:
			mShading.SetObject(CGShadingCreateRadial(cgColorSpace, ToCG(mStartPoint), mStartRadius, ToCG(mEndPoint), mEndRadius, mEvaluate, mStartExtend, mEndExtend));
			break;

		default:
			NN_LOG("Unknown shading mode: %d", mMode);
			break;
		}
}
开发者ID:refnum,项目名称:nano,代码行数:34,代码来源:NCGShading.cpp


示例15: NN_ASSERT

//============================================================================
//		NThreadPool::ScheduleTask : Schedule a task for execution.
//----------------------------------------------------------------------------
void NThreadPool::ScheduleTask(NThreadTask *theTask)
{


	// Validate our state
	NN_ASSERT(mLock.IsLocked());
	


	// Add the task
	PushTask(mTasks, theTask);
	mHavePushed = true;



	// Update the workers
	//
	// If we've reached the thread limit then the existing threads will need to
	// process this task, so we signal to let them know there's more work to do.
	//
	// Incrementing the thread count must be done by the main thread, since a large
	// number of tasks may be queued up before any worker thread gets a chance to run. 
	if (mActiveThreads < mThreadLimit)
		NThreadUtilities::DetachFunctor(BindSelf(NThreadPool::ExecuteTasks));

	mSemaphore.Signal();
}
开发者ID:refnum,项目名称:nano,代码行数:30,代码来源:NThreadPool.cpp


示例16: return

//============================================================================
//		NFileUtilities::SetFileData : Set a file to data.
//----------------------------------------------------------------------------
NStatus NFileUtilities::SetFileData(const NFile &theFile, const NData &theData)
{	uint64_t		theSize, numWritten;
	NFile			mutableFile;
	NStatus			theErr;



	// Get the state we need
	mutableFile = theFile;
	theSize     = theData.GetSize();



	// Open the file
	theErr = mutableFile.Open(kNPermissionUpdate, true);
	if (theErr != kNoErr)
		return(theErr);



	// Write the data
	theErr  = mutableFile.SetSize(0);
	theErr |= mutableFile.Write(theSize, theData.GetData(), numWritten);

	NN_ASSERT_NOERR(theErr);
	NN_ASSERT(numWritten == theSize);



	// Clean up
	mutableFile.Close();
	
	return(theErr);
}
开发者ID:refnum,项目名称:nano,代码行数:37,代码来源:NFileUtilities.cpp


示例17: base64_init_encodestate

//============================================================================
//		NDataEncoder::B64_Encode : Encode to Base64.
//----------------------------------------------------------------------------
NString NDataEncoder::B64_Encode(const NData &theValue)
{	NData					theBuffer;
	NString					theString;
	base64_encodestate		theState;
	char					*dataPtr;
	NIndex					dataSize;



	// Get the state we need
	base64_init_encodestate(&theState);

	if (theValue.IsEmpty() || !theBuffer.SetSize(theValue.GetSize() * 2))
		return(theString);



	// Encode the value
	dataPtr   = (char *) theBuffer.GetData();
	dataSize  = base64_encode_block((const char *) theValue.GetData(), theValue.GetSize(), dataPtr, &theState);
	theString = NString(dataPtr, dataSize);

	dataSize = base64_encode_blockend(dataPtr, &theState);
	if (dataSize != 0)
		theString += NString(dataPtr, dataSize);



	// Remove the trailing newline
	NN_ASSERT(theString.GetRight(1) == "\n");
	theString.TrimRight(1);

	return(theString);
}
开发者ID:refnum,项目名称:nano,代码行数:37,代码来源:NDataEncoder.cpp


示例18: GetFileData

//============================================================================
//		NFileUtilities::GetFileText : Get a file as text.
//----------------------------------------------------------------------------
NString NFileUtilities::GetFileText(const NFile &theFile, NStringEncoding theEncoding)
{	NStringEncoder		theEncoder;
	NData				theData;
	NString				theText;



	// Get the state we need
	theData = GetFileData(theFile);
	if (theData.IsEmpty())
		return(theText);
	
	
	
	// Get the text
	if (theEncoding == kNStringEncodingInvalid)
		{
		theEncoding = theEncoder.GetEncoding(theData);
		NN_ASSERT(theEncoding != kNStringEncodingInvalid);
		}

	if (theEncoding != kNStringEncodingInvalid)
		theText = NString(theData, theEncoding);
		
	return(theText);
}
开发者ID:refnum,项目名称:nano,代码行数:29,代码来源:NFileUtilities.cpp


示例19: NN_ASSERT

//============================================================================
//      NTargetNetwork::SocketSetOption : Set a socket option.
//----------------------------------------------------------------------------
NStatus NTargetNetwork::SocketSetOption(NSocketRef theSocket, NSocketOption theOption, int32_t theValue)
{	int			valueInt;
	NStatus		theErr;



	// Validate our parameters
	NN_ASSERT(theSocket->nativeSocket != kSocketHandleInvalid);



	// Get the state we need
	theErr = kNErrNotSupported;



	// Set the option
	switch (theOption) {
		case kNSocketNoDelay:
			valueInt = (theValue != 0) ? 1 : 0;

			if (setsockopt(theSocket->nativeSocket, IPPROTO_TCP, TCP_NODELAY, &valueInt, sizeof(valueInt)) == 0)
				theErr = kNoErr;
			break;

		default:
			NN_LOG("Unknown option: %d", theOption);
			break;
		}
	
	return(theErr);
}
开发者ID:refnum,项目名称:nano,代码行数:35,代码来源:NLinuxNetwork.cpp


示例20: NN_ASSERT

//=============================================================================
//		NBroadcaster::CloneBroadcaster : Clone a broadcaster.
//-----------------------------------------------------------------------------
void NBroadcaster::CloneBroadcaster(const NBroadcaster &theBroadcaster)
{	NListenerMapConstIterator	theIter;



	// Validate our state
	NN_ASSERT(mBroadcasts.empty());



	// Clone the broadcaster
	//
	// An explicit clone is necessary to ensure the pointers between listener and
	// broadcaster are correctly established (the default copy constructor would
	// copy the pointers in this object, but wouldn't update the other).
	//
	// Cloning a broadcaster that's currently broadcasting will clone the listeners
	// so that future broadcasts go to the same place - however we don't clone the
	// list of active broadcasts, since we're not ourselves broadcasting.
	mIsBroadcasting = theBroadcaster.mIsBroadcasting;
	mBroadcasts.clear();

	for (theIter = theBroadcaster.mListeners.begin(); theIter != theBroadcaster.mListeners.end(); theIter++)
		AddListener(theIter->first);
}
开发者ID:refnum,项目名称:nano,代码行数:28,代码来源:NBroadcaster.cpp



注:本文中的NN_ASSERT函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ NODE函数代码示例发布时间:2022-05-30
下一篇:
C++ NN函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap