コード例 #1
0
bool BasePersistenceManager::transfer(const char *name, AnsiStringArray &val) {
	size_t size;

	if (_saving) {
		size = val.size();
		_saveStream->writeUint32LE(size);

		for (AnsiStringArray::iterator it = val.begin(); it != val.end(); ++it) {
			putString((*it).c_str());
		}
	} else {
		val.clear();
		size = _loadStream->readUint32LE();

		for (size_t i = 0; i < size; i++) {
			char *str = getString();
			if (_loadStream->err()) {
				delete[] str;
				return STATUS_FAILED;
			}
			if (str) {
				val.push_back(str);
			}
			delete[] str;
		}
	}

	return STATUS_OK;
}
コード例 #2
0
HRESULT CBPersistMgr::Transfer(const char* Name, AnsiStringArray& Val)
{
	size_t size;

	if (m_Saving)
	{
		size = Val.size();
		PutBytes((BYTE*)&size, sizeof(size_t));

		for (AnsiStringArray::iterator it = Val.begin(); it != Val.end(); ++it)
		{
			PutString((*it).c_str());
		}
	}
	else
	{
		Val.clear();
		GetBytes((BYTE*)&size, sizeof(size_t));

		for (size_t i = 0; i < size; i++)
		{
			char* str = GetString();
			if (str) Val.push_back(str);
		}
	}

	return S_OK;
}