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


C++ ConfigFile::errorMessage方法代码示例

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


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

示例1: ConfParser_read

FALCON_FUNC  ConfParser_read( ::Falcon::VMachine *vm )
{
   CoreObject *self = vm->self().asObject();
   ConfigFile *cfile = (ConfigFile *) self->getUserData();
   Item *i_stream = vm->param(0);

   bool bRes;

   if( i_stream == 0 )
   {
      vm->idle();
      bRes = cfile->load();
      vm->unidle();
   }
   else {
      bool bValid = false;
      if ( i_stream->isObject() )
      {
         CoreObject *streamObj = i_stream->asObject();
         if ( streamObj->derivedFrom( "Stream" ) )
         {
            Stream *base = (Stream *) streamObj->getUserData();
            bRes = cfile->load( base );
            bValid = true;
         }
      }

      if ( ! bValid )
      {
         throw new ParamError( ErrorParam( e_inv_params, __LINE__ ).extra( "Stream" ) );
         return;
      }
   }

   if ( ! bRes )
   {
      // is this an I/O or a parsing error?
      if ( cfile->fsError() != 0 )
      {
         throw new IoError( ErrorParam( e_loaderror, __LINE__ ).
            sysError( cfile->fsError() ).
            extra( cfile->errorMessage() ) );
      }
      else {
         String msg = cfile->errorMessage() + " at ";
         msg.writeNumber( (int64) cfile->errorLine() );
         self->setProperty( "error", cfile->errorMessage() );
         self->setProperty( "errorLine", (int64) cfile->errorLine() );
         throw new ParseError( ErrorParam( FALCP_ERR_INVFORMAT, __LINE__ )
            .desc( FAL_STR(cp_msg_invformat) )
            .extra( msg ) );
      }
   }

}
开发者ID:Klaim,项目名称:falcon,代码行数:55,代码来源:confparser_ext.cpp

示例2: ConfParser_write

/*#
   @method write ConfParser
   @brief Write the INI file.
   @optparam stream An optional output stream on which to write the configuration file.
   @raise IoError on write error.

   Writes the content of a modified or entirely generated configuration file on the
   given stream, that must be a valid Falcon stream opened for output. If a stream
   is not given, then the file name provided to the ConfParser constructor is
   opened for writing. In case the name has not been given in the constructor, the
   method raises an error.

*/
FALCON_FUNC  ConfParser_write( ::Falcon::VMachine *vm )
{
   CoreObject *self = vm->self().asObject();
   ConfigFile *cfile = (ConfigFile *) self->getUserData();

   Item *i_stream = vm->param(0);

   bool bRes;

   if( i_stream == 0 )
   {
      bRes = cfile->save();
   }
   else {
      bool bValid = false;
      if ( i_stream->isObject() )
      {
         CoreObject *streamObj = i_stream->asObject();
         if ( streamObj->derivedFrom( "Stream" ) )
         {
            Stream *base = (Stream *) streamObj->getUserData();
            bRes = cfile->save( base );
            bValid = true;
         }
      }

      if ( ! bValid )
      {
         throw new ParamError( ErrorParam( e_inv_params, __LINE__ ).extra( "Stream" ) );
         return;
      }
   }

   if ( ! bRes )
   {
      // is this a file error?
      if ( cfile->fsError() )
      {
         throw new IoError( ErrorParam( e_file_output, __LINE__ ).
            sysError( cfile->fsError() ).
            extra( cfile->errorMessage() ) );
      }
      else
      {
         // no -- it's a configuration file.d
         self->setProperty( "error", cfile->errorMessage() );
         self->setProperty( "errorLine", (int64) cfile->errorLine() );
         throw new ParseError( ErrorParam( FALCP_ERR_STORE, __LINE__ ).
            desc( FAL_STR(cp_msg_errstore)  ).extra( cfile->errorMessage() ) );
      }
   }
}
开发者ID:Klaim,项目名称:falcon,代码行数:65,代码来源:confparser_ext.cpp


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