本文整理汇总了C++中DataTargetRef::getStream方法的典型用法代码示例。如果您正苦于以下问题:C++ DataTargetRef::getStream方法的具体用法?C++ DataTargetRef::getStream怎么用?C++ DataTargetRef::getStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataTargetRef
的用法示例。
在下文中一共展示了DataTargetRef::getStream方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write
void TriMesh::write( DataTargetRef dataTarget ) const
{
OStreamRef out = dataTarget->getStream();
const uint8_t versionNumber = 1;
out->write( versionNumber );
out->writeLittle( static_cast<uint32_t>( mVertices.size() ) );
out->writeLittle( static_cast<uint32_t>( mNormals.size() ) );
out->writeLittle( static_cast<uint32_t>( mTexCoords.size() ) );
out->writeLittle( static_cast<uint32_t>( mIndices.size() ) );
for( vector<Vec3f>::const_iterator it = mVertices.begin(); it != mVertices.end(); ++it ) {
out->writeLittle( it->x ); out->writeLittle( it->y ); out->writeLittle( it->z );
}
for( vector<Vec3f>::const_iterator it = mNormals.begin(); it != mNormals.end(); ++it ) {
out->writeLittle( it->x ); out->writeLittle( it->y ); out->writeLittle( it->z );
}
for( vector<Vec2f>::const_iterator it = mTexCoords.begin(); it != mTexCoords.end(); ++it ) {
out->writeLittle( it->x ); out->writeLittle( it->y );
}
for( vector<size_t>::const_iterator it = mIndices.begin(); it != mIndices.end(); ++it ) {
out->writeLittle( static_cast<uint32_t>( *it) );
}
}
示例2: if
ImageTargetFileQuartz::ImageTargetFileQuartz( DataTargetRef dataTarget, ImageSourceRef imageSource, ImageTarget::Options options, const std::string &extensionData )
: cocoa::ImageTargetCgImage( imageSource, options )
{
cocoa::SafeCfString uti = cocoa::createSafeCfString( extensionData );
mImageDest = NULL;
if( dataTarget->providesFilePath() ) {
cocoa::SafeCfString pathString = cocoa::createSafeCfString( dataTarget->getFilePath().string() );
const std::shared_ptr<__CFURL> urlRef( (__CFURL*)::CFURLCreateWithFileSystemPath( kCFAllocatorDefault, pathString.get(), kCFURLPOSIXPathStyle, false ), cocoa::safeCfRelease );
mImageDest = ::CGImageDestinationCreateWithURL( urlRef.get(), uti.get(), 1, NULL );
}
else if( dataTarget->providesUrl() ) {
std::shared_ptr<__CFURL> urlRef( (__CFURL*)cocoa::createCfUrl( dataTarget->getUrl() ), cocoa::safeCfRelease );
mImageDest = ::CGImageDestinationCreateWithURL( urlRef.get(), uti.get(), 1, NULL );
}
else { // we'll wrap a cinder::OStream in a CGDataConsumer for output
OStreamRef *ostreamRef = new OStreamRef( dataTarget->getStream() );
::CGDataConsumerCallbacks callbacks;
callbacks.putBytes = cgDataConsumerPutBytes;
callbacks.releaseConsumer = cgDataConsumerRelease;
std::shared_ptr<CGDataConsumer> consumer( ::CGDataConsumerCreate( ostreamRef, &callbacks ), ::CGDataConsumerRelease );
mImageDest = ::CGImageDestinationCreateWithDataConsumer( consumer.get(), uti.get(), 1, NULL );
}
if( ! mImageDest )
throw ImageIoExceptionFailedWrite();
setupImageDestOptions( options );
}
示例3: write
void JsonTree::write( DataTargetRef target, bool createDocument )
{
// Declare output string
string jsonString = "";
try {
// Create JsonCpp data to send to parser
Json::Value value = createNativeDoc( createDocument );
// This routine serializes JsonCpp data and formats it
Json::StyledWriter writer;
jsonString = writer.write( value.toStyledString() );
boost::replace_all( jsonString, "\\n", "\r\n" );
boost::replace_all( jsonString, "\\\"", "\"" );
if( jsonString.length() >= 3 ) {
jsonString = jsonString.substr( 1, boost::trim_copy( jsonString ).length() - 2 );
}
jsonString += "\0";
}
catch ( ... ) {
throw ExcJsonParserError( "Unable to serialize JsonTree." );
}
// Save data to file
OStreamRef os = target->getStream();
os->writeData( jsonString.c_str(), jsonString.length() );
}
示例4: write
void XmlTree::write( DataTargetRef target, bool createDocument )
{
// this could do with a more efficient implementation
shared_ptr<rapidxml::xml_document<char> > doc = createRapidXmlDoc( createDocument );
OStreamRef os = target->getStream();
std::ostringstream ss;
ss << *doc;
os->writeData( ss.str().c_str(), ss.str().length() );
}
示例5: write
void SplinePath::write(DataTargetRef target)
{
auto stream = target->getStream();
stream->writeLittle(size());
for (auto &point : points)
{
stream->writeLittle(point.x);
stream->writeLittle(point.y);
}
}