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


C++ StringStream::tell方法代码示例

本文整理汇总了C++中StringStream::tell方法的典型用法代码示例。如果您正苦于以下问题:C++ StringStream::tell方法的具体用法?C++ StringStream::tell怎么用?C++ StringStream::tell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringStream的用法示例。


在下文中一共展示了StringStream::tell方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: inner_readData

void Wopi::inner_readData( SharedMem* shmem, Item& data )
{
   StringStream target;
   shmem->read( &target, true );

   if ( target.tell() == 0 )
   {
      // nothing to be deserialized.
      data.setNil();
      return;
   }

   target.seekBegin(0);
   Item::e_sercode sc = data.deserialize( &target, VMachine::getCurrent() );
   if( sc != Item::sc_ok )
   {
      throw new WopiError( ErrorParam( FALCON_ERROR_WOPI_APPDATA_DESER, __LINE__ )
            .desc( "Error during de-serialization of application data")
            .extra( String("type ").N( (int) sc ) )
            );
   }
}
开发者ID:Klaim,项目名称:falcon,代码行数:22,代码来源:wopi.cpp

示例2: setData

bool Wopi::setData( Item& data, const String& appName, bool atomicUpdate )
{
   SharedMem* pAppMem = 0;

   // do we have the required appname data?
   m_mtx.lock();
   AppDataMap::const_iterator pos = m_admap.find( appName );
   if( pos == m_admap.end() )
   {
      m_mtx.unlock();
      pAppMem = inner_create_appData( appName );
   }
   else
   {

      pAppMem = pos->second;
      m_mtx.unlock();
   }

   // we can deal with the shared memory in an unlocked region, of course.
   if ( pAppMem->currentVersion() != pAppMem->lastVersion() )
   {
      // we already know we're out of sync.
      if( atomicUpdate )
         inner_readData( pAppMem, data );

      return false;
   }

   // ok, try and serialize the data.
   StringStream source;
   Item::e_sercode sc = data.serialize( &source, false );
   if( sc != Item::sc_ok )
   {
      throw new WopiError( ErrorParam( FALCON_ERROR_WOPI_APPDATA_SER, __LINE__ )
                  .desc( "Error during Serialization of application data")
                  .extra( String("type ").N( (int) sc ) )
                  );
   }

   // great, the data is serialized; try to get it out of the door.
   int32 datalen = (int32) source.tell();
   source.seekBegin(0);
   bool bSuccess = pAppMem->commit( &source, datalen, atomicUpdate );

   // did we succeed?
   if( ! bSuccess )
   {
      // No; we wasted the serialization. However, are now required to
      // deserialize the item?
      if( atomicUpdate )
      {
         // ... and, is there anything to be de-serialized?
         if( source.tell() != 0 )
         {
            source.seekBegin(0);
            Item::e_sercode sc = data.deserialize( &source, VMachine::getCurrent() );
            if( sc != Item::sc_ok )
            {
               throw new WopiError( ErrorParam( FALCON_ERROR_WOPI_APPDATA_DESER, __LINE__ )
                     .desc( "Error during de-serialization of application data")
                     .extra( String("type ").N( (int) sc ) )
                     );
            }
         }
         else
         {
            data.setNil();
         }
      }
   }

   return bSuccess;
}
开发者ID:Klaim,项目名称:falcon,代码行数:74,代码来源:wopi.cpp


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