Пример #1
0
	const Utf8* HawkDatabase::QueryResult::GetResult(UInt64 iRow,UInt64 iCol,UInt32* pResLen) const
	{
		if (m_pDBHdl && m_pResHdl && m_iRow && m_iCol)
		{
			A_Exception(iRow >= 0 && iRow < m_iRow);
			A_Exception(iCol >= 0 && iCol < m_iCol);

			return ((HawkDatabase*)m_pDBHdl)->GetResult(this,iRow,iCol,pResLen);
		}
		return 0;
	}
Пример #2
0
	const Utf8* HawkSqlite::QueryResult::GetResult(UInt64 iRow,UInt64 iCol,UInt32* pResLen) const
	{
		if (m_pRes && m_iRow && m_iCol)
		{
			A_Exception(iRow >= 0 && iRow < m_iRow);
			A_Exception(iCol >= 0 && iCol < m_iCol);

			//跳过第一行列名
			Utf8** ppResult = (Utf8**)m_pRes + m_iCol;
			return ppResult[iRow * m_iCol + iCol];
		}
		return 0;
	}
Пример #3
0
	HawkDegree& HawkDegree::operator /= ( Float fScale ) 
	{ 
		A_Exception(!HawkMath::IsZero(fScale));

		Degree /= fScale;
		return *this;
	}
Пример #4
0
	HawkDegree& HawkDegree::operator /= ( const HawkDegree& oDeg ) 
	{ 
		A_Exception(!HawkMath::IsZero(oDeg.Value()));

		Degree /= oDeg.Degree;
		return *this;
	}
Пример #5
0
	HawkVector3D HawkTriangle3D::operator [](Int32 iIdx) const
	{
		A_Exception(iIdx>=0 && iIdx<=2);

		if (iIdx == 0) 
			return Point;
		else
			return Point + Edge[iIdx - 1];
	}
Пример #6
0
	HawkRect2D::HawkRect2D(const HawkRect& oRc)
	{
		A_Exception(oRc.IsValid());

		Point.X	  = oRc.Left;
		Point.Y	  = oRc.Top;
		Edge[0].X = (Float)oRc.Right - (Float)oRc.Left;
		Edge[0].Y = 0;
		Edge[1].X = 0;
		Edge[1].Y = (Float)oRc.Bottom - (Float)oRc.Top;
	}
Пример #7
0
	HawkSegment3D HawkTriangle3D::GetSegment(Int32 iIdx) const
	{
		A_Exception(iIdx>=0 && iIdx<=2);
		if (iIdx == 0)
		{
			return HawkSegment3D(GetPoint(0),GetPoint(1));
		}
		else if (iIdx == 1)
		{
			return HawkSegment3D(GetPoint(1),GetPoint(2));
		}
		return HawkSegment3D(GetPoint(2),GetPoint(0));
	}
Пример #8
0
void HawkRefCounter::Release()
{
    //判断引用计数有效,避免无效对象释放
    A_Exception(m_iRef > 0 && "RefCounter Is Error.");

    DecRef();

    //删除对象
    if (m_iRef <= 0)
    {
        delete this;
    }
}
Пример #9
0
	Bool CApp::PostAppTask(CTask* pTask, Int32 iThreadIdx)
	{
		if(m_bRunning && m_pThreadPool)
		{
			if(iThreadIdx < 0)
			{
				A_Exception(m_pThreadPool->GetThreadNum() > 0);
				iThreadIdx = CRand::RandInt(0, m_pThreadPool->GetThreadNum()-1);
			}

			return m_pThreadPool->AddTask(pTask, iThreadIdx);
		}
		return false;
	}
Пример #10
0
	HawkQuaternion HawkQuaternion::Inverse () const
	{
		Float fLen = Length();
		if ( fLen > 0.0f )
		{
			Float  fInvLen = 1.0f/fLen;
			return HawkQuaternion(W*fInvLen,-X*fInvLen,-Y*fInvLen,-Z*fInvLen);
		}
		else
		{
			A_Exception(false && "Quaternion Length Error.");
		}
		
		return HawkQuaternion(0,0,0,0);
	}
Пример #11
0
	Bool ParseDocument(void* pDoc, const void* pData)
	{
		//数据编码格式检验
		CFile::CodeType eCodeType = CFile::GetCodeType(pData);
		A_Exception(eCodeType != CFile::CODE_UNICODE && "CXmlFile Cannot Parser Unicode.");

		if (eCodeType == CFile::CODE_ASCII)
		{
			xml_document<Char> xmlDoc;
			try
			{
				xmlDoc.parse<0>((Char*)pData);
			}
			catch (rapidxml::parse_error& sExp)
			{
				FmtError("rapidxml parse error, what: %s, where: %s", sExp.what(), sExp.where<Char>());
				return false;
			}

			xml_node<Char>* pRoot = xmlDoc.first_node();
			if (pRoot)
			{
				AXmlElement* pXmlNode = ((AXmlDocument*)pDoc)->GetRoot();
				return ParseXmlNode<AString, Char>(pRoot, pXmlNode);
			}
		}
		else if (eCodeType == CFile::CODE_UTF8)
		{
			xml_document<Utf8> xmlDoc;
			try
			{
				xmlDoc.parse<0>((Utf8*)pData);
			}
			catch (rapidxml::parse_error& sExp)
			{
				FmtError("rapidxml parse error, what: %s, where: %s", sExp.what(), sExp.where<Char>());
				return false;
			}

			xml_node<Utf8>* pRoot = xmlDoc.first_node();
			if (pRoot)
			{
				UXmlElement* pXmlNode = ((UXmlDocument*)pDoc)->GetRoot();
				return ParseXmlNode<UString, Utf8>(pRoot, pXmlNode);
			}
		}
		return false;
	}
Пример #12
0
	HawkSegment2D HawkRect2D::GetSegment(Int32 iIdx) const
	{
		A_Exception(iIdx>= 0 && iIdx<=3);

		if (iIdx == 0) 
		{
			return HawkSegment2D(GetPoint(0),GetPoint(1));
		}
		else if (iIdx == 1) 
		{
			return HawkSegment2D(GetPoint(1),GetPoint(2));
		}
		else if (iIdx == 2)
		{
			return HawkSegment2D(GetPoint(2),GetPoint(3));
		}
		return HawkSegment2D(GetPoint(3),GetPoint(0));
	}
Пример #13
0
	Bool CZmq::Init(Int32 iType)
	{
		A_Exception(m_pHandle == 0);

		m_iType   = iType;
		m_pHandle = zmq_socket(g_ZmqManager->GetZmqCtx(), m_iType);
		if (m_pHandle)
		{
			Int32 iLinger = 0;
			if (!SetOption(ZMQ_LINGER,  &iLinger, sizeof(iLinger)))
				return false;

			Int32 iTimeout = HZMQ_TIMEOUT;
			if (!SetOption(ZMQ_RCVTIMEO, &iTimeout, sizeof(iTimeout)) ||
				!SetOption(ZMQ_SNDTIMEO, &iTimeout, sizeof(iTimeout)) )
				return false;
		}

		return m_pHandle != 0;
	}
Пример #14
0
	HawkVector2D HawkRect2D::operator [](Int32 iIdx) const
	{
		A_Exception(iIdx>= 0 && iIdx<=3);

		if (iIdx == 0) 
		{
			return Point;
		}
		else if (iIdx == 1) 
		{
			return Point + Edge[0];
		}
		else if (iIdx == 2)
		{
			return Point + Edge[0] + Edge[1];
		}
		else if (iIdx == 3)
		{
			return Point + Edge[1];
		}
		return HawkVector2D();
	}
Пример #15
0
	Float HawkRand::RandFloat(Float fLow, Float fHigh)
	{
		A_Exception(fHigh >= fLow && "Random Range Error.");
		return RandFloat(fHigh - fLow) + fLow;
	}
Пример #16
0
	Int32 HawkRand::RandInt(Int32 iLow, Int32 iHigh)
	{
		A_Exception(iHigh >= iLow && "Random Range Error.");
		return RandInt(iHigh - iLow) + iLow;
	}
Пример #17
0
	//获得边
	const HawkVector3D& HawkTriangle3D::GetEdge(Int32 iIdx) const
	{
		A_Exception(iIdx>=0 && iIdx<=1);

		return Edge[iIdx];
	}
Пример #18
0
	HawkDegree HawkDegree::operator / ( const HawkDegree& oDeg ) const
	{
		A_Exception(!HawkMath::IsZero(oDeg.Value()));

		return HawkDegree ( Degree / oDeg.Degree );
	}
Пример #19
0
	//设置边
	void HawkTriangle3D::SetEdge(Int32 iIdx,const HawkVector3D& oEdge)
	{
		A_Exception(iIdx>=0 && iIdx<=1);

		Edge[iIdx] = oEdge[iIdx];
	}
Пример #20
0
	HawkDegree HawkDegree::operator / ( Float fScale ) const
	{
		A_Exception(!HawkMath::IsZero(fScale));

		return HawkDegree ( Degree / fScale );
	}