本文整理汇总了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() );
}
示例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);
}
示例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();
}
}
//.........这里部分代码省略.........