OSCL_EXPORT_REF void BitStreamParser::WriteUInt16(uint16 data) { uint16 be = data; host_to_big_endian((char*)&be, sizeof(be)); WriteUInt8(((uint8*)&be)[0]); WriteUInt8(((uint8*)&be)[1]); }
void CFileDataIO::WriteTag(const CTag& tag) { try { WriteUInt8(tag.GetType()); if (!tag.GetName().IsEmpty()) { WriteString(tag.GetName(),utf8strNone); } else { WriteUInt16(1); WriteUInt8(tag.GetNameID()); } switch (tag.GetType()) { case TAGTYPE_HASH16: // Do NOT use this to transfer any tags for at least half a year!! WriteHash(CMD4Hash(tag.GetHash())); break; case TAGTYPE_STRING: WriteString(tag.GetStr(), utf8strRaw); // Always UTF8 break; case TAGTYPE_UINT64: WriteUInt64(tag.GetInt()); break; case TAGTYPE_UINT32: WriteUInt32(tag.GetInt()); break; case TAGTYPE_FLOAT32: WriteFloat(tag.GetFloat()); break; case TAGTYPE_BSOB: WriteBsob(tag.GetBsob(), tag.GetBsobSize()); break; case TAGTYPE_UINT16: WriteUInt16(tag.GetInt()); break; case TAGTYPE_UINT8: WriteUInt8(tag.GetInt()); break; case TAGTYPE_BLOB: // NOTE: This will break backward compatibility with met files for eMule versions prior to 0.44a // and any aMule prior to SVN 26/02/2005 WriteUInt32(tag.GetBlobSize()); Write(tag.GetBlob(), tag.GetBlobSize()); break; default: //TODO: Support more tag types // With the if above, this should NEVER happen. AddLogLineNS(CFormat(wxT("CFileDataIO::WriteTag: Unknown tag: type=0x%02X")) % tag.GetType()); wxFAIL; break; } } catch (...) { AddLogLineNS(wxT("Exception in CDataIO:WriteTag")); throw; } }
void WriteUInt8Array(const std::vector<unsigned __int8>& arg, MemoryBuffer& buffer) { WriteUInt32((unsigned __int32)arg.size(), buffer); for each(const auto element in arg) { WriteUInt8(element, buffer); }
void CBitWriter::DoFlush() { assert(cDataSize == m_position); WriteUInt8(m_data, m_buffer); m_data = 0; m_position = 0; }
void CFileDataIO::WriteTagPtrList(const TagPtrList& tagList) { uint32 count = tagList.size(); wxASSERT( count <= 0xFF ); WriteUInt8(count); TagPtrList::const_iterator it; for (it = tagList.begin(); it != tagList.end(); it++) { WriteTag(**it); } }
void BinaryStream::WriteSmallString(std::string what) { if(mySetPos > myBuffer.size()) mySetPos = myBuffer.size(); WriteUInt8((uint8_t)what.size()); for(uint8_t i = 0; i < (uint8_t)what.size(); i++) { myBuffer.insert(myBuffer.begin()+mySetPos, what[i]); mySetPos++; } myBuffer.insert(myBuffer.begin()+mySetPos, 0); mySetPos++; }
void CFileDataIO::WriteBsob(const unsigned char* value, uint8 size) { WriteUInt8(size); Write(value, size); }
void WriteInt8(int8_t what) { WriteUInt8((uint8_t)what); }
void BinaryStream::WriteData(void* what, uint32_t size) { uint8_t* data = (uint8_t*)what; for(uint32_t i = 0; i < size; i++) WriteUInt8(data[i]); }