Exemplo n.º 1
0
bool Checksum::Compare(const Checksum& inChecksum, StringList& outErrors) const
{
	ChecksumList::const_iterator	theIncomingIter = inChecksum.mChecksumList.begin();
	ChecksumList::const_iterator	theSourceIter = this->mChecksumList.begin();

	string							theErrorString;

	int32							theChecksumCount = 0;

	bool							theReturnCode = true;

	// Only try compare if both checksums are in the same mode 
	if(this->GetIsVerboseMode() == inChecksum.GetIsVerboseMode())
	{
		if(this->mChecksumList.size() == inChecksum.mChecksumList.size())
		{
			for( ; theSourceIter != this->mChecksumList.end(); theSourceIter++, theIncomingIter++)
			{
				if(!(theSourceIter->Compare(*theIncomingIter, theErrorString)))
				{
					outErrors.push_back(theErrorString);
					theReturnCode = false;
				}
				theChecksumCount++;
			}
		}
		else
		{
			sprintf(theErrorString, "Checksum::Compare(): Checksum sizes don't match.  Source size is %d and other size is %d.\n", this->mChecksumList.size(), inChecksum.mChecksumList.size());
			outErrors.push_back(theErrorString);
			theReturnCode = false;
		}
	}
	else
	{
		sprintf(theErrorString, "Checksum::Compare(): One checksum is in verbose mode, the other isn't.\n");
		outErrors.push_back(theErrorString);
		theReturnCode = false;
	}

	return theReturnCode;
}