本文整理汇总了C++中IOStream::Write方法的典型用法代码示例。如果您正苦于以下问题:C++ IOStream::Write方法的具体用法?C++ IOStream::Write怎么用?C++ IOStream::Write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IOStream
的用法示例。
在下文中一共展示了IOStream::Write方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// Save (SLNDependency)
//------------------------------------------------------------------------------
/*static*/ void SLNDependency::Save( IOStream & stream, const Array< SLNDependency > & slnDeps )
{
const uint32_t num = (uint32_t)slnDeps.GetSize();
stream.Write( num );
for ( const SLNDependency & deps : slnDeps )
{
stream.Write( deps.m_Projects );
stream.Write( deps.m_Dependencies );
}
}
示例2: Serialize
// Serialize
//------------------------------------------------------------------------------
void Node::Serialize( IOStream & stream ) const
{
// Deps
NODE_SAVE_DEPS( m_PreBuildDependencies );
NODE_SAVE_DEPS( m_StaticDependencies );
NODE_SAVE_DEPS( m_DynamicDependencies );
// Properties
const ReflectionInfo * const ri = GetReflectionInfoV();
const ReflectionIter end = ri->End();
for ( ReflectionIter it = ri->Begin(); it != end; ++it )
{
const ReflectedProperty & property = *it;
const PropertyType pt = property.GetType();
switch ( pt )
{
case PT_ASTRING:
{
if ( property.IsArray() )
{
const Array< AString > * arrayOfStrings( nullptr );
property.GetProperty( this, arrayOfStrings );
VERIFY( stream.Write( *arrayOfStrings ) );
}
else
{
AString string; // TODO:C remove this copy
property.GetProperty( this, &string );
VERIFY( stream.Write( string ) );
}
break;
}
case PT_BOOL:
{
bool b( false );
property.GetProperty( this, &b );
VERIFY( stream.Write( b ) );
break;
}
case PT_UINT32:
{
uint32_t u32( 0 );
property.GetProperty( this, &u32 );
VERIFY( stream.Write( u32 ) );
break;
}
default:
{
ASSERT( false ); // Unsupported type
break;
}
}
}
}
示例3:
// VSProjectFileType::Save
//------------------------------------------------------------------------------
/*static*/ void VSProjectFileType::Save( IOStream & stream, const Array< VSProjectFileType > & fileTypes )
{
uint32_t numFileTypes = (uint32_t)fileTypes.GetSize();
stream.Write( numFileTypes );
for ( uint32_t i=0; i<numFileTypes; ++i )
{
const VSProjectFileType & ft = fileTypes[ i ];
stream.Write( ft.m_FileType );
stream.Write( ft.m_Pattern );
}
}
示例4: SaveNode
// SaveNode
//------------------------------------------------------------------------------
void Node::SaveNode( IOStream & fileStream, const Node * node ) const
{
// for null pointer, write an empty string
if ( node == nullptr )
{
fileStream.Write( AString::GetEmpty() );
}
else
{
// for valid nodes, write the node name
fileStream.Write( node->GetName() );
}
}
示例5: Serialize
// Serialize
//------------------------------------------------------------------------------
void Job::Serialize( IOStream & stream )
{
PROFILE_FUNCTION
// write jobid
stream.Write( m_JobId );
stream.Write( m_Node->GetName() );
// write properties of node
Node::SaveRemote( stream, m_Node );
stream.Write( IsDataCompressed() );
stream.Write( m_DataSize );
stream.Write( m_Data, m_DataSize );
}
示例6: return
static int XMLCALL _writeCallback(void *user_data, char const *buffer, int len) {
IOStream *stream = (IOStream*)user_data;
uint32 to_write = (uint32)(len&INT_MAX);
uint32 written = stream->Write(buffer, to_write);
if (written != to_write && !(*stream))
return -1;
else
return (int)written;
}
示例7:
//
//------------------------------------------------------------------------------
/*static*/ void Node::Save( IOStream & stream, const Node * node )
{
ASSERT( node );
// save type
uint32_t nodeType = (uint32_t)node->GetType();
stream.Write( nodeType );
// save stamp (but not for file nodes)
if ( nodeType != Node::FILE_NODE )
{
uint64_t stamp = node->GetStamp();
stream.Write( stamp );
}
// save contents
node->Save( stream );
}
示例8: Save
// Save
//------------------------------------------------------------------------------
void Dependencies::Save( IOStream & stream ) const
{
size_t numDeps = GetSize();
stream.Write( (uint32_t)numDeps );
Iter end = End();
for ( Iter it = Begin(); it != end; ++it )
{
const Dependency & dep = *it;
// Nodes are saved by index to simplify deserialization
uint32_t index = dep.GetNode()->GetIndex();
stream.Write( index );
// Save weak flag
bool isWeak = dep.IsWeak();
stream.Write( isWeak );
}
}
示例9: ReadContent
void HTTPRequest::ReadContent(IOStream& rStreamToWriteTo)
{
Seek(0, SeekType_Absolute);
CopyStreamTo(rStreamToWriteTo);
IOStream::pos_type bytesCopied = GetSize();
while (bytesCopied < mContentLength)
{
char buffer[1024];
IOStream::pos_type bytesToCopy = sizeof(buffer);
if (bytesToCopy > mContentLength - bytesCopied)
{
bytesToCopy = mContentLength - bytesCopied;
}
bytesToCopy = mpStreamToReadFrom->Read(buffer, bytesToCopy);
rStreamToWriteTo.Write(buffer, bytesToCopy);
bytesCopied += bytesToCopy;
}
}
示例10: Serialize
// Serialize
//------------------------------------------------------------------------------
void ToolManifest::Serialize( IOStream & ms ) const
{
ms.Write( m_ToolId );
const uint32_t numItems( (uint32_t)m_Files.GetSize() );
ms.Write( numItems );
const size_t numFiles( m_Files.GetSize() );
for ( size_t i=0; i<numFiles; ++i )
{
const File & f = m_Files[ i ];
ms.Write( f.m_Name );
ms.Write( f.m_TimeStamp );
ms.Write( f.m_Hash );
ms.Write( f.m_ContentSize );
}
}
示例11: Send
// --------------------------------------------------------------------------
//
// Function
// Name: HTTPRequest::Send(IOStream &, int)
// Purpose: Write the request to an IOStream using HTTP.
// Created: 03/01/09
//
// --------------------------------------------------------------------------
bool HTTPRequest::Send(IOStream &rStream, int Timeout, bool ExpectContinue)
{
switch (mMethod)
{
case Method_UNINITIALISED:
THROW_EXCEPTION(HTTPException, RequestNotInitialised); break;
case Method_UNKNOWN:
THROW_EXCEPTION(HTTPException, BadRequest); break;
case Method_GET:
rStream.Write("GET"); break;
case Method_HEAD:
rStream.Write("HEAD"); break;
case Method_POST:
rStream.Write("POST"); break;
case Method_PUT:
rStream.Write("PUT"); break;
}
rStream.Write(" ");
rStream.Write(mRequestURI.c_str());
rStream.Write(" ");
switch (mHTTPVersion)
{
case HTTPVersion_0_9: rStream.Write("HTTP/0.9"); break;
case HTTPVersion_1_0: rStream.Write("HTTP/1.0"); break;
case HTTPVersion_1_1: rStream.Write("HTTP/1.1"); break;
default:
THROW_EXCEPTION_MESSAGE(HTTPException, NotImplemented,
"Unsupported HTTP version: " << mHTTPVersion);
}
rStream.Write("\n");
std::ostringstream oss;
if (mContentLength != -1)
{
oss << "Content-Length: " << mContentLength << "\n";
}
if (mContentType != "")
{
oss << "Content-Type: " << mContentType << "\n";
}
if (mHostName != "")
{
if (mHostPort != 80)
{
oss << "Host: " << mHostName << ":" << mHostPort <<
"\n";
}
else
{
oss << "Host: " << mHostName << "\n";
}
}
if (mpCookies)
{
THROW_EXCEPTION_MESSAGE(HTTPException, NotImplemented,
"Cookie support not implemented yet");
}
if (mClientKeepAliveRequested)
{
oss << "Connection: keep-alive\n";
}
else
{
oss << "Connection: close\n";
}
for (std::vector<Header>::iterator i = mExtraHeaders.begin();
i != mExtraHeaders.end(); i++)
{
oss << i->first << ": " << i->second << "\n";
}
if (ExpectContinue)
{
oss << "Expect: 100-continue\n";
}
rStream.Write(oss.str().c_str());
rStream.Write("\n");
return true;
}