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


C++ IOStream::Write方法代码示例

本文整理汇总了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 );
    }
}
开发者ID:Samana,项目名称:fastbuild,代码行数:12,代码来源:SLNGenerator.cpp

示例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;
			}
		}
	}
}
开发者ID:scott-nelson,项目名称:fastbuild,代码行数:57,代码来源:Node.cpp

示例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 );
    }
}
开发者ID:dontnod,项目名称:fastbuild,代码行数:14,代码来源:VSProjectGenerator.cpp

示例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() );
	}
}
开发者ID:scott-nelson,项目名称:fastbuild,代码行数:15,代码来源:Node.cpp

示例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 );
}
开发者ID:ClxS,项目名称:fastbuild,代码行数:18,代码来源:Job.cpp

示例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;
}
开发者ID:hatc,项目名称:image-proxy,代码行数:9,代码来源:libxml_util.cpp

示例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 );
}
开发者ID:scott-nelson,项目名称:fastbuild,代码行数:20,代码来源:Node.cpp

示例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 );
	}
}
开发者ID:poppolopoppo,项目名称:fastbuild,代码行数:21,代码来源:Dependencies.cpp

示例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;
	}
}
开发者ID:pkdevbox,项目名称:boxbackup,代码行数:20,代码来源:HTTPRequest.cpp

示例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 );
	}
}
开发者ID:zhangf911,项目名称:fastbuild,代码行数:18,代码来源:ToolManifest.cpp

示例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;
}
开发者ID:pkdevbox,项目名称:boxbackup,代码行数:97,代码来源:HTTPRequest.cpp


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