示例#1
0
static inline void sd_write_aligned_blob(std::ostringstream &buf, void *b, int b_size,
				 const char *name)
{
	sd_write_name(buf, name);
	/* pad calculation MUST come after name is written */
	size_t pad = align64(buf.tellp() + ((std::streamoff) 5l)) - (buf.tellp() + ((std::streamoff) 5l));
	sd_write8(buf, SD_BLOB);
	sd_write32(buf, b_size + pad);
	buf.write(zeros, pad);
	buf.write((const char *) b, b_size);
}
示例#2
0
	inline void add_state_attribute(std::ostringstream &out, bool &first, state st, const char (&name) [N])
	{
		if (m_state & st) {
			if (first)
				first = false;
			else
				out.write("|", 1);

			out.write(name, N - 1);
		}
	}
示例#3
0
void WriteMeshIndicesBinary_Generic(const aiMesh* m, unsigned int offset, std::ostringstream& output)
{
    for (unsigned int i = 0; i < m->mNumFaces; ++i) {
        const aiFace& f = m->mFaces[i];
        NumIndicesType numIndices = static_cast<NumIndicesType>(f.mNumIndices);
        output.write(reinterpret_cast<const char*>(&numIndices), sizeof(NumIndicesType));
        for (unsigned int c = 0; c < f.mNumIndices; ++c) {
            IndexType index = f.mIndices[c] + offset;
            output.write(reinterpret_cast<const char*>(&index), sizeof(IndexType));
        }
    }
}
示例#4
0
static void sd_write_strn(std::ostringstream &buf, char *b, int size, const char *name)
{
	sd_write_name(buf, name);
	sd_write8(buf, SD_STRING);
	sd_write16(buf, size);
	buf.write(b, size);
}
示例#5
0
static inline void sd_write_blob(std::ostringstream &buf, void *b, int buf_size, char *name)
{
	sd_write_name(buf, name);
	sd_write8(buf, SD_BLOB);
	sd_write32(buf, buf_size);
	buf.write((const char *) b, buf_size);
}
示例#6
0
文件: transport.cpp 项目: xandr84/RPC
Variant ClientBase::sendBuffer(char type, RequestID requestID, std::ostringstream &stream)
{	
	unsigned int size = (unsigned int)stream.tellp();
	size -= sizeof(size);
	stream.seekp(0);
	stream.write((const char*)&size, sizeof(size));

	RequestData rd;
	rd.type = MessageType(type);
	rd.id = requestID;
	rd.data = stream.str();

	if(asyncMode())
	{
		rd.writeCompletePtr.reset(new FutureResult);
		bool empty = m_messageQueue.empty();
		m_messageQueue.push(rd);
		if(empty)
		{
			writeData(m_messageQueue.front().data);			
		}
		return rd.writeCompletePtr;
	}
	else
	{
		writeData(rd.data);	
	}
	return Variant();
}
示例#7
0
const std::string& ColorPalette::interpret(
		const sf::Color& color, std::string& str) {

	conv.write("[ ", 2);
	conv << int(color.r);
	conv.write(" ; ", 3);
	conv << int(color.g);
	conv.write(" ; ", 3);
	conv << int(color.b);
	conv.write(" ]", 2);

	str.assign(conv.str());

	conv.str("");

	return str;
}
示例#8
0
static inline void sd_write_name(std::ostringstream &buf, const char *name)
{
	PDEBUG("Writing name '%s'\n", name);
	if (name) {
		sd_write8(buf, SD_NAME);
		sd_write16(buf, strlen(name) + 1);
		buf.write(name, strlen(name) + 1);
	}
}
示例#9
0
 size_t write(const void * data, size_t size)
 {
     stream.write((const char*)data, size);
     return size;
 }
示例#10
0
static inline void sd_write64(std::ostringstream &buf, u64 b)
{
	u64 tmp;
	tmp = cpu_to_le64(b);
	buf.write((const char *) &tmp, 8);
}
示例#11
0
static inline void sd_write32(std::ostringstream &buf, u32 b)
{
	u32 tmp;
	tmp = cpu_to_le32(b);
	buf.write((const char *) &tmp, 4);
}
示例#12
0
static inline void sd_write16(std::ostringstream &buf, u16 b)
{
	u16 tmp;
	tmp = cpu_to_le16(b);
	buf.write((const char *) &tmp, 2);
}
示例#13
0
static inline void sd_write8(std::ostringstream &buf, u8 b)
{
	buf.write((const char *) &b, 1);
}
示例#14
0
void CHeroAddScore::serializeEvent(std::ostringstream& buffer) const
{
	buffer.write((char*)&m_playerId,sizeof(UInt8));
	buffer.write((char*)&m_score,sizeof(UInt32));
}
示例#15
0
//serialize l'objet
void CHeroSyncEvent::serializeEvent(std::ostringstream& buffer) const
{
	buffer.write((char*)&m_dir,sizeof(UInt8));
	buffer.write((char*)&m_coord.x,sizeof(float));
	buffer.write((char*)&m_coord.y,sizeof(float));
}