コード例 #1
0
ファイル: MemBuff.cpp プロジェクト: monfort/VecEngine
void CNodedMemoryBuffer::WriteWordField(int iFieldId, WORD wVal)
{
   ASSERT(IsStoring());
   WriteInt(iFieldId);
   WriteDword(sizeof(WORD));
   WriteWord(wVal);
}
コード例 #2
0
ファイル: NodedArchive.cpp プロジェクト: monfort/VecEngine
CNodedArchive::CNodedArchive(const CString& strHeader, CFile* pFile, UINT nMode, int nBufSize, void* lpBuf): 
CArchive(pFile, nMode, nBufSize, lpBuf)
{
   m_iNodeType = ID_END_OF_FIELDS;
   m_iFieldType = ID_END_OF_FIELDS;
   m_iFieldSize = 0;
   m_bNodedFormat = FALSE;  
   if(IsStoring())
   {
      int id = ID_NODED_ARCHIVE;
      *this << id;
      *this << strHeader;
   }
   else if(IsLoading())
   {
      if(pFile->GetLength() > sizeof(int))
      {
         int id;
         *this >> id;
         if(id != ID_NODED_ARCHIVE)
         {
            m_bNodedFormat = FALSE;
            return;
         }
         CString str;
         *this >> str;
         if(str != strHeader)
         {
            m_bNodedFormat = FALSE;
            return;
         }
         m_bNodedFormat = TRUE;
      }
   }
コード例 #3
0
ファイル: MemBuff.cpp プロジェクト: monfort/VecEngine
void CNodedMemoryBuffer::WriteIntField(int iFieldId, INT iVal)
{
   ASSERT(IsStoring());
   WriteInt(iFieldId);
   WriteDword(sizeof(INT));
   WriteInt(iVal);
}
コード例 #4
0
ファイル: MemBuff.cpp プロジェクト: monfort/VecEngine
void CNodedMemoryBuffer::WriteStringField(int iFieldId, CString strVal)
{
   ASSERT(IsStoring());
   WriteInt(iFieldId);
   WriteDword((strVal.GetLength()+1)*sizeof(char));
   WriteString(strVal);
}
コード例 #5
0
ファイル: MemBuff.cpp プロジェクト: monfort/VecEngine
///////////////////////////// Write ///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
void CMemoryBuffer::Write(void* lpvData, DWORD dwSize)
{
   ASSERT(IsStoring());
   CheckIfSizeIsEnoughAndFixIt(dwSize);
   memcpy(m_lpvCurrntPos, lpvData, dwSize);
   m_lpvCurrntPos = (void*) (((DWORD)m_lpvCurrntPos) + dwSize);
}
コード例 #6
0
ファイル: MemBuff.cpp プロジェクト: monfort/VecEngine
void CNodedMemoryBuffer::WriteField(int iFieldId, void* lpvData, DWORD dwSize)
{
   ASSERT(IsStoring());
   WriteInt(iFieldId);
   WriteDword(dwSize);
   Write(lpvData, dwSize);
}
コード例 #7
0
ファイル: MemBuff.cpp プロジェクト: monfort/VecEngine
void CNodedMemoryBuffer::WriteByteField(int iFieldId, BYTE byVal)
{
   ASSERT(IsStoring());
   WriteInt(iFieldId);
   WriteDword(sizeof(BYTE));
   WriteByte(byVal);
}
コード例 #8
0
ファイル: MemBuff.cpp プロジェクト: monfort/VecEngine
void CNodedMemoryBuffer::WriteFloatField(int iFieldId, float fVal)
{
   ASSERT(IsStoring());
   WriteInt(iFieldId);
   WriteDword(sizeof(float));
   WriteFloat(fVal);
}
コード例 #9
0
ファイル: MemBuff.cpp プロジェクト: monfort/VecEngine
void CNodedMemoryBuffer::WriteStringField(int iFieldId, LPSTR lpszVal)
{
   ASSERT(IsStoring());
   WriteInt(iFieldId);
   WriteDword((strlen(lpszVal)+1)*sizeof(char));
   WriteString(lpszVal);
}
コード例 #10
0
ファイル: MemBuff.cpp プロジェクト: monfort/VecEngine
void CNodedMemoryBuffer::WriteDoubleField(int iFieldId, double dVal)
{
   ASSERT(IsStoring());
   WriteInt(iFieldId);
   WriteDword(sizeof(double));
   WriteDouble(dVal);
}
コード例 #11
0
ファイル: MemBuff.cpp プロジェクト: monfort/VecEngine
///////////////////////////// Read ////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
void CMemoryBuffer::Read(void* lpvData, DWORD dwSize)
{
   ASSERT(!IsStoring());
   ASSERT(m_dwSize >= ((DWORD)m_lpvCurrntPos) - ((DWORD)m_lpvMemory) + dwSize);
   memcpy(lpvData, m_lpvCurrntPos, dwSize);
   m_lpvCurrntPos = (void*) (((DWORD)m_lpvCurrntPos) + dwSize);
}
コード例 #12
0
ファイル: MemBuff.cpp プロジェクト: monfort/VecEngine
void CNodedMemoryBuffer::WriteBoolField(int iFieldId, BOOL bVal)
{
   ASSERT(IsStoring());
   WriteInt(iFieldId);
   WriteDword(sizeof(BOOL));
   WriteBool(bVal);
}
コード例 #13
0
ファイル: MemBuff.cpp プロジェクト: monfort/VecEngine
void CNodedMemoryBuffer::WriteLongField(int iFieldId, LONG lVal)
{
   ASSERT(IsStoring());
   WriteInt(iFieldId);
   WriteDword(sizeof(LONG));
   WriteLong(lVal);
}
コード例 #14
0
ファイル: MemBuff.cpp プロジェクト: monfort/VecEngine
void CNodedMemoryBuffer::WriteNodeHeader(int iNodeType)
{
   ASSERT(IsStoring());
   int i = ID_FIELD_IS_NODE;
   WriteInt(i);

   WriteInt(iNodeType);
}
コード例 #15
0
ファイル: CommonDefsQt.cpp プロジェクト: jpoirier/x-gauges
void Serialize(QDataStream& ds, QString& cs)
{
   if(IsStoring(ds)) {
      ds << cs;
   }
   else {
      ds >> cs;
   }
}
コード例 #16
0
ファイル: MemBuff.cpp プロジェクト: monfort/VecEngine
void CMemoryBuffer::CheckIfSizeIsEnoughAndFixIt(DWORD dwSize)
{
   ASSERT(IsStoring());
   DWORD dwSizeWritten = ((DWORD) m_lpvCurrntPos) - ((DWORD) m_lpvMemory);
   DWORD dwSpaceLeft = m_dwSize - dwSizeWritten;
   if(dwSize >= dwSpaceLeft)
   {
      Realloc(dwSize - dwSpaceLeft);
   }
}
コード例 #17
0
ファイル: MemBuff.cpp プロジェクト: monfort/VecEngine
void CMemoryBuffer::Realloc(DWORD dwSize)
{
   ASSERT(IsStoring());
   DWORD dwSizeWritten = ((DWORD) m_lpvCurrntPos) - ((DWORD) m_lpvMemory);

   m_dwSize += ((dwSize / m_dwGrow) + 1) * m_dwGrow;

   m_lpvMemory = realloc(m_lpvMemory, m_dwSize);

   m_lpvCurrntPos = (void*) (((DWORD)m_lpvMemory) + dwSizeWritten);
}
コード例 #18
0
ファイル: MemBuff.cpp プロジェクト: monfort/VecEngine
DWORD CMemoryBuffer::CopyData(void* lpvData, DWORD dwSize)
{
   ASSERT(IsStoring());
   DWORD dwSizeWritten = ((DWORD) m_lpvCurrntPos) - ((DWORD) m_lpvMemory);
   if(lpvData == NULL || dwSizeWritten > dwSize)
   {
      return dwSizeWritten;
   }

   memcpy(lpvData, m_lpvMemory, dwSizeWritten);
   return 0;
}
コード例 #19
0
ファイル: CommonDefsQt.cpp プロジェクト: jpoirier/x-gauges
void Serialize(QDataStream& ds, std::string& ss)
{
   if(IsStoring(ds)) {
      QString qs(ss.c_str());
      ds << qs;
   }
   else {
      QString qs;
      ds >> qs;
      ss = qs.toStdString();
//       ss = qs.toLocal8Bit().data();
   }
}
コード例 #20
0
ファイル: MemBuff.cpp プロジェクト: monfort/VecEngine
int CMemoryBuffer::ReadString(LPSTR lpszVal, int iSize)//return 0 if size was Enough or the size if not (size includes the null termination char)
{
   ASSERT(!IsStoring());
   int iRealSize;
   for(iRealSize = 1; ; iRealSize++)
   {
      ASSERT(m_dwSize >= ((DWORD)m_lpvCurrntPos) - ((DWORD)m_lpvMemory) + iRealSize - 1);
      if(*((char*)((DWORD)m_lpvCurrntPos) + iRealSize - 1) == '\0')
         break;
   }
   if(lpszVal != NULL && iRealSize <= iSize)
   {
      Read(lpszVal, iRealSize);
      return 0;
   }
   else
      return iRealSize;
}
コード例 #21
0
CXMLArchiveNode* CXMLArchive::GetNode(LPCTSTR nodeNameStr)
{
	CString nodeName(nodeNameStr);

	try
	{
#ifdef USE_MSXML
		BSTR nodeNameBSTR = nodeName.AllocSysString();
		MSXML::IXMLDOMNodePtr fatherNodePtr;
#else
		CMarkup* fatherNodePtr;
#endif

		if (m_nodeList.size() == 0)
		{
			fatherNodePtr = m_xmlDocPtr;
		}
		else
		{
			fatherNodePtr = m_nodeList.top()->m_nodePtr;
		}

		if (fatherNodePtr == NULL)
		{
			return NULL;
		}


		if (IsStoring())
		{
#ifdef USE_MSXML
			// Archive is storing
			CXMLArchiveNode* xmlArchiveNodePtr = new CXMLArchiveNode(this, m_xmlDocPtr->createElement(nodeNameBSTR), fatherNodePtr);

			::SysFreeString(nodeNameBSTR);

			m_nodeList.push(xmlArchiveNodePtr);

			return xmlArchiveNodePtr;
#endif
			// Archive is storing
			m_xmlDocPtr->AddChildElem(nodeName);
			CMarkup* childnodep = new CMarkup(m_xmlDocPtr->GetDoc());
			childnodep = m_xmlDocPtr;
			m_xmlDocPtr->ResetChildPos();
			CXMLArchiveNode* xmlArchiveNodePtr = new CXMLArchiveNode(this, 
				childnodep,
				//m_xmlDocPtr->createElement(nodeNameBSTR),
				fatherNodePtr);

			m_nodeList.push(xmlArchiveNodePtr);

			return xmlArchiveNodePtr;
		}


		// Archive is Loading
		//MSXML::IXMLDOMNodeListPtr	nodeListPtr;
		//MSXML::IXMLDOMNodePtr		nodePtr;
		CMarkup*	nodeListPtr;
		CMarkup*		nodePtr;

		// If child node list is not empty, we are loading using the tags to
		// create CObject derived objects or collections (like CArray<Cobject* CObject*>, use child list

#ifdef USE_MSXML
		if (m_nodeList.size() > 0)
		{
			CXMLArchiveNode* xmlNodePtr = m_nodeList.top();
			nodeListPtr = xmlNodePtr->m_childNodeListPtr;

			if (nodeListPtr != NULL && nodeListPtr->length > 0)
			{
				int childIndex = xmlNodePtr->m_childIndex;

				if (childIndex < nodeListPtr->length)
				{
					nodeListPtr->get_item(childIndex, &nodePtr);

					CXMLArchiveNode* xmlArchiveNodePtr = new CXMLArchiveNode(this, nodePtr, m_xmlDocPtr);

					m_nodeList.push(xmlArchiveNodePtr);

					::SysFreeString(nodeNameBSTR);

					return xmlArchiveNodePtr;
				}

				ASSERT(FALSE);
			}
		}
#else
		if (m_nodeList.size() > 0)
		{
			CXMLArchiveNode* xmlNodePtr = m_nodeList.top();
			nodeListPtr = xmlNodePtr->m_childNodeListPtr;

			//Block added to calcule length when using CMarkup
			int length = 0;
			if (nodeListPtr != NULL){
				nodeListPtr->ResetMainPos();
				while (nodeListPtr->FindElem())
				{
					length++;
				}
				nodeListPtr->ResetMainPos();
			}

			if (nodeListPtr != NULL && length > 0)
			{
				int childIndex = xmlNodePtr->m_childIndex;

				if (childIndex < length)
				{
					int index = 0;

					/*if (nodeListPtr->FindChildElem())
					{*/
						while (nodeListPtr->FindElem() && index < childIndex)
						{
							index++;
						}

						nodePtr = new CMarkup();
						nodePtr = nodeListPtr;
						//nodeListPtr->ResetChildPos();
					/*}*/

					CXMLArchiveNode* xmlArchiveNodePtr = new CXMLArchiveNode(this, nodePtr, m_xmlDocPtr);

					m_nodeList.push(xmlArchiveNodePtr);

					return xmlArchiveNodePtr;
				}

				ASSERT(FALSE);
			}
		}
#endif

#ifdef USE_MSXML
		// Get all nodes with this name
		if (MSXML::IXMLDOMDocumentPtr(fatherNodePtr) != NULL)
		{
			// First level node in document
			ASSERT(!nodeName.IsEmpty());
			nodeListPtr = MSXML::IXMLDOMDocumentPtr(fatherNodePtr)->getElementsByTagName(nodeNameBSTR);
		}
		else
		{
			// Get node with desired name
			nodeListPtr = MSXML::IXMLDOMElementPtr(fatherNodePtr)->getElementsByTagName(nodeNameBSTR);
		}

		::SysFreeString(nodeNameBSTR);
#else
		bool bResult=fatherNodePtr->FindElem(nodeName);
		nodeListPtr = new CMarkup();
		nodeListPtr = fatherNodePtr;
#endif
		//Get child index from m_nodeList
		int childIndex = 0;
		if (m_nodeList.size() > 0)
		{
			childIndex = m_nodeList.top()->m_childIndex;
		}

#ifdef USE_MSXML
		if (childIndex < nodeListPtr->length)
		{
			nodeListPtr->get_item(childIndex, &nodePtr);
		}
#else
		//Block added to calcule length when using CMarkup
		int length = 0;
		nodeListPtr->ResetMainPos();
		while (nodeListPtr->FindElem())
		{
			length++;
		}
		nodeListPtr->ResetMainPos();

		if (childIndex < length)
		{
			int index = 0;

			//Check if it has child elements and go inside if so
			if (nodeName.MakeLower()=="svg" && nodeListPtr->FindChildElem())
			{
				while (index < childIndex && nodeListPtr->FindElem())
				{
					index++;
				}

				nodeListPtr->IntoElem();

				nodePtr = new CMarkup();
				nodePtr = nodeListPtr;

				nodeListPtr->ResetMainPos();
			}
			else
			{
				while (index < childIndex && nodeListPtr->FindElem(nodeName))
				{
					index++;
				}

				nodePtr = new CMarkup();
				nodePtr = nodeListPtr;
			}
		}
#endif
		CXMLArchiveNode* xmlArchiveNodePtr = new CXMLArchiveNode(this, nodePtr, m_xmlDocPtr);

		m_nodeList.push(xmlArchiveNodePtr);

		return xmlArchiveNodePtr;
	}

	catch (...)
	{

	}

	return NULL;
}
コード例 #22
0
ファイル: MemBuff.cpp プロジェクト: monfort/VecEngine
CMemoryBuffer::~CMemoryBuffer()
{
   if(IsStoring())
      free(m_lpvMemory);
}
コード例 #23
0
ファイル: MemBuff.cpp プロジェクト: monfort/VecEngine
void CNodedMemoryBuffer::WriteEndOfFields()
{
   ASSERT(IsStoring());
   int i = ID_END_OF_FIELDS;
   WriteInt(i);
}