Пример #1
0
void CNReporter::loadBuffer(char* pBuffer, int& iIndex, AffxString& str, int iLength)
{
  if (iLength == -1) {
    iLength = str.length();
  }
  unsigned int ui = htonl(iLength);
  memcpy((void*)(pBuffer + iIndex), (void*)&ui, sizeof(unsigned int));
  iIndex += sizeof(unsigned int);
  memcpy((void*)(pBuffer + iIndex), str.c_str(), iLength); iIndex += iLength;
}
int AffxByteArray::append(const AffxString& srcIn)
{
	AffxString src = srcIn;

	int nOldSize = m_nSize;
	setSize(m_nSize + (int)src.length());

	memcpy(m_pData + nOldSize, src.c_str(), src.length() * sizeof(char));

	return nOldSize;
}
bool AffxBinaryFile::open(const AffxString& strFileName, m_enumOpenOptions enumOpenOption)
{
	std::fstream fstrm;
	switch (enumOpenOption)
	{
	case LOAD:
		fstrm.open(strFileName.c_str(), std::fstream::in | std::fstream::binary);
		if (fstrm.is_open()) {fstrm.close();} else {return false;}
		m_pistrm = new std::ifstream(strFileName.c_str(), std::ios::in | std::ios::binary);
		if (m_pistrm == NULL) {return false;}
		break;
	case SAVE:
		m_postrm = new std::ofstream(strFileName.c_str(), std::ios::out | std::ios::binary);
		if (m_postrm == NULL) {return false;}
		break;
	case APPEND:
		m_postrm = new std::ofstream(strFileName.c_str(), std::ios::out | std::ios::binary | std::ios::app);
		if (m_postrm == NULL) {return false;}
		break;
	default:
		return false;
	}
	return true;
}