本文整理汇总了C++中IOStream类的典型用法代码示例。如果您正苦于以下问题:C++ IOStream类的具体用法?C++ IOStream怎么用?C++ IOStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IOStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getFileList
void
RemoteHandler::
getFileList(){
string f_list;
DIR* dirp = opendir(curr_dir.c_str());
struct dirent *dp;
while ((dp = readdir(dirp)) != NULL){
struct stat buf;
lstat(dp->d_name, &buf);
string fname(dp->d_name);
if (fname != ".")
add_row(fname, &buf, f_list);
}
f_list += "\n";
//cout << f_list;
int cmd_fd = c_node.command_fd;
IOStream* ioStream;
try{
ioStream->writen(cmd_fd, f_list.c_str(), f_list.length());
}
catch(IOStream::IOException){
cerr << "IOException! Get File List Error!\n" << flush;
return;
}
return;
}
示例2: rcChooseConfig_enc
EGLint rcChooseConfig_enc(void *self , EGLint* attribs, uint32_t attribs_size, uint32_t* configs, uint32_t configs_size)
{
renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
IOStream *stream = ctx->m_stream;
const unsigned int __size_attribs = attribs_size;
const unsigned int __size_configs = ((configs != NULL) ? configs_size*sizeof(uint32_t) : 0);
unsigned char *ptr;
const size_t packetSize = 8 + __size_attribs + 4 + __size_configs + 4 + 2*4;
ptr = stream->alloc(packetSize);
int tmp = OP_rcChooseConfig;memcpy(ptr, &tmp, 4); ptr += 4;
memcpy(ptr, &packetSize, 4); ptr += 4;
*(unsigned int *)(ptr) = __size_attribs; ptr += 4;
memcpy(ptr, attribs, __size_attribs);ptr += __size_attribs;
memcpy(ptr, &attribs_size, 4); ptr += 4;
*(unsigned int *)(ptr) = __size_configs; ptr += 4;
memcpy(ptr, &configs_size, 4); ptr += 4;
if (configs != NULL) stream->readback(configs, __size_configs);
EGLint retval;
stream->readback(&retval, 4);
return retval;
}
示例3: sizeof
// ------------------------------------------------------------------------------------------------
// Imports a texture file.
bool Q3BSPFileImporter::importTextureFromArchive( const Q3BSP::Q3BSPModel *model,
Q3BSP::Q3BSPZipArchive *archive, aiScene*,
aiMaterial *pMatHelper, int textureId ) {
if (nullptr == archive || nullptr == pMatHelper ) {
return false;
}
if ( textureId < 0 || textureId >= static_cast<int>( model->m_Textures.size() ) ) {
return false;
}
bool res = true;
sQ3BSPTexture *pTexture = model->m_Textures[ textureId ];
if ( !pTexture ) {
return false;
}
std::vector<std::string> supportedExtensions;
supportedExtensions.push_back( ".jpg" );
supportedExtensions.push_back( ".png" );
supportedExtensions.push_back( ".tga" );
std::string textureName, ext;
if ( expandFile( archive, pTexture->strName, supportedExtensions, textureName, ext ) ) {
IOStream *pTextureStream = archive->Open( textureName.c_str() );
if ( pTextureStream ) {
size_t texSize = pTextureStream->FileSize();
aiTexture *pTexture = new aiTexture;
pTexture->mHeight = 0;
pTexture->mWidth = static_cast<unsigned int>(texSize);
unsigned char *pData = new unsigned char[ pTexture->mWidth ];
size_t readSize = pTextureStream->Read( pData, sizeof( unsigned char ), pTexture->mWidth );
(void)readSize;
ai_assert( readSize == pTexture->mWidth );
pTexture->pcData = reinterpret_cast<aiTexel*>( pData );
pTexture->achFormatHint[ 0 ] = ext[ 1 ];
pTexture->achFormatHint[ 1 ] = ext[ 2 ];
pTexture->achFormatHint[ 2 ] = ext[ 3 ];
pTexture->achFormatHint[ 3 ] = '\0';
res = true;
aiString name;
name.data[ 0 ] = '*';
name.length = 1 + ASSIMP_itoa10( name.data + 1, static_cast<unsigned int>(MAXLEN-1), static_cast<int32_t>(mTextures.size()) );
archive->Close( pTextureStream );
pMatHelper->AddProperty( &name, AI_MATKEY_TEXTURE_DIFFUSE( 0 ) );
mTextures.push_back( pTexture );
} else {
// If it doesn't exist in the archive, it is probably just a reference to an external file.
// We'll leave it up to the user to figure out which extension the file has.
aiString name;
strncpy( name.data, pTexture->strName, sizeof name.data );
name.length = strlen( name.data );
pMatHelper->AddProperty( &name, AI_MATKEY_TEXTURE_DIFFUSE( 0 ) );
}
}
return res;
}
示例4: _writeCallback
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;
}
示例5: _readCallback
static int XMLCALL _readCallback(void *user_data, char *buffer, int len) {
IOStream *stream = (IOStream*)user_data;
uint32 to_read = (uint32)(len&INT_MAX);
uint32 readed = stream->Read(buffer, to_read);
if (readed != to_read && !(*stream))
return -1;
else
return (int)readed;
}
示例6:
// 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 );
}
}
示例7: 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;
}
}
}
}
示例8:
// 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 );
}
}
示例9: 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() );
}
}
示例10: CanRead
bool AssbinImporter::CanRead( const std::string& pFile, IOSystem* pIOHandler, bool /*checkSig*/ ) const
{
IOStream * in = pIOHandler->Open(pFile);
if (!in)
return false;
char s[32];
in->Read( s, sizeof(char), 32 );
pIOHandler->Close(in);
return strncmp( s, "ASSIMP.binary-dump.", 19 ) == 0;
}
示例11: rcDestroyWindowSurface_enc
void rcDestroyWindowSurface_enc(void *self , uint32_t windowSurface)
{
renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
IOStream *stream = ctx->m_stream;
unsigned char *ptr;
const size_t packetSize = 8 + 4;
ptr = stream->alloc(packetSize);
int tmp = OP_rcDestroyWindowSurface;memcpy(ptr, &tmp, 4); ptr += 4;
memcpy(ptr, &packetSize, 4); ptr += 4;
memcpy(ptr, &windowSurface, 4); ptr += 4;
}
示例12: rcFBSetSwapInterval_enc
void rcFBSetSwapInterval_enc(void *self , EGLint interval)
{
renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
IOStream *stream = ctx->m_stream;
unsigned char *ptr;
const size_t packetSize = 8 + 4;
ptr = stream->alloc(packetSize);
int tmp = OP_rcFBSetSwapInterval;memcpy(ptr, &tmp, 4); ptr += 4;
memcpy(ptr, &packetSize, 4); ptr += 4;
memcpy(ptr, &interval, 4); ptr += 4;
}
示例13: rcBindRenderbuffer_enc
void rcBindRenderbuffer_enc(void *self , uint32_t colorBuffer)
{
renderControl_encoder_context_t *ctx = (renderControl_encoder_context_t *)self;
IOStream *stream = ctx->m_stream;
unsigned char *ptr;
const size_t packetSize = 8 + 4;
ptr = stream->alloc(packetSize);
int tmp = OP_rcBindRenderbuffer;memcpy(ptr, &tmp, 4); ptr += 4;
memcpy(ptr, &packetSize, 4); ptr += 4;
memcpy(ptr, &colorBuffer, 4); ptr += 4;
}
示例14: run
void
RemoteHandler::
run(){
IOStream* ioStream;
for(;;){
char command[256];
int rd = ioStream->readLine(c_node.command_fd, command, 256);
if (rd >0)
dispatch(command);
else {
cout << "client closed" << endl;
exit(0);
}
}
}
示例15:
// LoadNode
//------------------------------------------------------------------------------
/*static*/ bool Node::LoadNode( IOStream & stream, Node * & node )
{
// read the name of the node
AStackString< 512 > nodeName;
if ( stream.Read( nodeName ) == false )
{
node = nullptr;
return false;
}
// empty name means the pointer was null, which is supported
if ( nodeName.IsEmpty() )
{
node = nullptr;
return true;
}
// find the node by name - this should never fail
NodeGraph & ng = FBuild::Get().GetDependencyGraph();
Node * n = ng.FindNode( nodeName );
if ( n == nullptr )
{
node = nullptr;
return false;
}
node = n;
return true;
}