当前位置: 首页>>代码示例>>C++>>正文


C++ MemoryStream::GetData方法代码示例

本文整理汇总了C++中MemoryStream::GetData方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryStream::GetData方法的具体用法?C++ MemoryStream::GetData怎么用?C++ MemoryStream::GetData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MemoryStream的用法示例。


在下文中一共展示了MemoryStream::GetData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ASSERT

// IMessage::Send (with payload)
//------------------------------------------------------------------------------
bool Protocol::IMessage::Send( const ConnectionInfo * connection, const MemoryStream & payload ) const
{
    ASSERT( connection );
    ASSERT( m_HasPayload == true ); // must NOT use Send with payload

    TCPConnectionPool & pool = connection->GetTCPConnectionPool();
    return pool.Send( connection, this, m_MsgSize, payload.GetData(), payload.GetSize() );
}
开发者ID:liamkf,项目名称:fastbuild,代码行数:10,代码来源:Protocol.cpp

示例2: Write

void Pipe::Write(MemoryStream& stream)
{
	const uint32_t position = stream.GetPosition();
	const uint32_t size = stream.GetSize();

	const uint8_t* pData = stream.GetData() + position;
	const uint32_t status = Write(size - position, pData);
	stream.SetPosition(position + status);
}
开发者ID:marmysh,项目名称:FX-Lib,代码行数:9,代码来源:Pipe.cpp

示例3: tw

	/*static*/ bool ReflectionInfo::WriteDefinitions()
	{
		uint32_t numProblems = 0;

		const ReflectionInfo * ri = s_FirstReflectionInfo;
		for ( ; ri != nullptr; ri = ri->m_Next )
		{
			// ignore abstract classes
			if ( ri->IsAbstract() )
			{
				continue;
			}

			// Serialize a default instance to a MemoryStream 
			MemoryStream ms;
			{
				// Create and serialize default instance
				if ( ri->IsObject() )
				{
					RefObject * object = ri->CreateObject();
					{
						TextWriter tw( ms );
						tw.Write( object );
					}
					FDELETE( object );
				}
				else
				{
					ASSERT( ri->IsStruct() )
					Struct * str = ri->CreateStruct();
					{
						TextWriter tw( ms );
						tw.Write( str, ri );
					}
					FDELETE( str );
				}
			}

			AStackString<> fileName; 
			fileName.Format( "..\\Data\\Reflection\\.Definitions\\%s.definition", ri->GetTypeName() );

			// avoid writing file if not changed

			// Try to open existing file
			FileStream f;
			if ( f.Open( fileName.Get(), FileStream::READ_ONLY ) )
			{
				// read content
				const uint64_t fileSize = f.GetFileSize();
				if ( fileSize == ms.GetSize() )
				{
					AutoPtr< char > mem( (char *)Alloc( (size_t)fileSize ) );
					if ( f.Read( mem.Get(), (size_t)fileSize ) == fileSize )
					{
						if ( memcmp( mem.Get(), ms.GetData(), (size_t)fileSize ) == 0 )
						{
							continue; // definition has not changed
						}
					}
				}
				f.Close();
			}

			// Definition changed - try to save it

			int result = 0;
			AutoPtr< char > memOut;
			AutoPtr< char > memErr;
			uint32_t memOutSize;
			uint32_t memErrSize;

			// existing definition?
			if ( FileIO::FileExists( fileName.Get() ) )
			{
				// existing - need to open for edit?
				if ( FileIO::GetReadOnly( fileName ) )
				{
					AStackString<> args( "edit " );
					args += fileName;
					Process p;
					if ( p.Spawn( "p4", args.Get(), nullptr, nullptr ) )
					{
						p.ReadAllData( memOut, &memOutSize, memErr, &memErrSize );
						result = p.WaitForExit();
					}
				}
			}
			else
			{
				// new - open for add
				AStackString<> args( "add " );
				args += fileName;
				Process p;
				if ( p.Spawn( "p4", args.Get(), nullptr, nullptr ) )
				{
					p.ReadAllData( memOut, &memOutSize, memErr, &memErrSize );
					result = p.WaitForExit();
				}
			}

//.........这里部分代码省略.........
开发者ID:ClxS,项目名称:fastbuild,代码行数:101,代码来源:ReflectionInfo.cpp


注:本文中的MemoryStream::GetData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。