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


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

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


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

示例1: ConfParser_getCategoryKeys

/*#
   @method getCategoryKeys ConfParser
   @brief Get the keys filed under a given category.
   @param category The category of which the key list is required
   @optparam section If provided, the section where the category is defined.
   @return All the keys listed in the given category.

   This method returns a list of all the keys belonging to a certain category.

   See the "Categorized keys" section in @a ConfParser.
*/
FALCON_FUNC  ConfParser_getCategoryKeys( ::Falcon::VMachine *vm )
{
   CoreObject *self = vm->self().asObject();
   ConfigFile *cfile = (ConfigFile *) self->getUserData();
   Item *i_keyMask = vm->param( 0 );
   Item *i_section = vm->param( 1 );

   if ( i_keyMask == 0 || ! i_keyMask->isString() ||
        ( i_section != 0 && ! i_section->isString() && ! i_section->isNil() )
      )
   {
      throw new ParamError( ErrorParam( e_inv_params, __LINE__ ) );
      return;
   }

   String key;
   CoreArray *ret = new CoreArray;
   bool next;

   if ( i_section != 0 && ! i_section->isNil() ) {
      next = cfile->getFirstKey( *i_section->asString(), *i_keyMask->asString(), key );
   }
   else {
      next = cfile->getFirstKey( *i_keyMask->asString(), key );
   }

   while ( next )
   {
      ret->append( new CoreString( String( key, i_keyMask->asString()->length() + 1 ) ) );
      next = cfile->getNextKey( key );
   }

   vm->retval( ret );
}
开发者ID:Klaim,项目名称:falcon,代码行数:45,代码来源:confparser_ext.cpp

示例2: ConfParser_getDictionary

/*#
   @method getDictionary ConfParser
   @brief Retreives keys and values given under a certain category.
   @optparam section If given, the section from which to extract the dictionary.
   @return A dictionary containing a pair of key-values in the given section.

   This method retrieves all the pairs of key and values in the main section, or if
   a non-nil section parameter is provided, from the given section. If the
   requested section cannot be found, or if it doesn't contain any entry, an empty
   dictionary is returned. If a key has multiple values, its element is set to an
   array containing all the values.
*/
FALCON_FUNC  ConfParser_getDictionary( ::Falcon::VMachine *vm )
{
   CoreObject *self = vm->self().asObject();
   ConfigFile *cfile = (ConfigFile *) self->getUserData();
   Item *i_section = vm->param( 0 );

   if ( i_section != 0 && ! i_section->isString() )
   {
      throw new ParamError( ErrorParam( e_inv_params, __LINE__ ) );
   }

   String key;
   LinearDict *ret = new LinearDict();
   LinearDict *current = ret;
   bool next;

   if ( i_section != 0 ) {
      next = cfile->getFirstKey( *i_section->asString(), "", key );
   }
   else {
      next = cfile->getFirstKey( "", key );
   }

   while( next )
   {
      String value;

      // seeking a value won't alter key iterators.
      if( i_section != 0 )
         cfile->getValue( *i_section->asString(), key, value );
      else
         cfile->getValue( key, value );

      // we have at least one value. but do we have more?
      String value1;
      if ( cfile->getNextValue( value1 ) )
      {
         CoreArray *array = new CoreArray( 5 );
         array->append( new CoreString( value ) );
         array->append( new CoreString( value1 ) );

         while( cfile->getNextValue( value1 ) )
            array->append( new CoreString( value1 ) );

         current->put( new CoreString( key ), array );
      }
      else {
         current->put( new CoreString( key ), new CoreString( value ) );
      }

      next = cfile->getNextKey( key );
   }

   vm->retval( new CoreDict(ret) );
}
开发者ID:Klaim,项目名称:falcon,代码行数:67,代码来源:confparser_ext.cpp

示例3: ConfParser_getCategory

/*#
   @method getCategory ConfParser
   @brief Retreives keys and values given under a certain category.
   @param category The category of which the values are required
   @optparam section If provided, the section where the category is defined.
   @return A dictionary containing a pair of key-values in the given category.

   This method returns a dictionary of key-value pairs containing all the keys
   and values in a certain category.

   See the "Categorized keys" section in @a ConfParser.
*/
FALCON_FUNC  ConfParser_getCategory( ::Falcon::VMachine *vm )
{
   CoreObject *self = vm->self().asObject();
   ConfigFile *cfile = (ConfigFile *) self->getUserData();
   Item *i_keyMask = vm->param( 0 );
   Item *i_section = vm->param( 1 );

   if ( i_keyMask == 0 || ! i_keyMask->isString() ||
        ( i_section != 0 && ! i_section->isString() && ! i_section->isNil() )
      )
   {
      throw new ParamError( ErrorParam( e_inv_params, __LINE__ ) );
   }

   if ( i_section != 0 && i_section->isNil() )
      i_section = 0;

   String key, keymask;
   LinearDict *ret = new LinearDict();
   LinearDict *current = ret;
   bool next;

   bool stripNames;
   keymask = *i_keyMask->asString();
   if ( keymask.length() > 0 && keymask.getCharAt(keymask.length() - 1) == '*' )
   {
      stripNames = true;
      keymask.size( keymask.size() - keymask.manipulator()->charSize() );
   }
   else
      stripNames = false;

   if ( keymask.length() > 0 && keymask.getCharAt(keymask.length() - 1) == '.' )
      keymask.size( keymask.size() - keymask.manipulator()->charSize() );

   if ( i_section != 0  ) {
      next = cfile->getFirstKey( *i_section->asString(), keymask, key );
   }
   else {
      next = cfile->getFirstKey( keymask, key );
   }

   while( next )
   {
      String value;

      // seeking a value won't alter key iterators.
      if( i_section != 0  )
         cfile->getValue( *i_section->asString(), key, value );
      else
         cfile->getValue( key, value );


      // we have at least one value. but do we have more?
      String value1;
      if ( cfile->getNextValue( value1 ) )
      {
         CoreArray *array = new CoreArray( 5 );
         array->append( new CoreString( value ) );
         array->append( new CoreString( value1 ) );

         while( cfile->getNextValue( value1 ) )
            array->append( new CoreString( value1 ) );

         // we have used KEY; now what we want to save is just the non-category
         if ( stripNames )
            current->put( new CoreString( key, keymask.length() + 1 ), array );
         else
            current->put( new CoreString( key), array );
      }
      else {
          if ( stripNames )
            current->put( new CoreString( key, keymask.length() + 1 ), new CoreString( value ) );
         else
            current->put(  new CoreString( key) , new CoreString( value ) );
      }

      next = cfile->getNextKey( key );
   }

   vm->retval( new CoreDict(ret) );
}
开发者ID:Klaim,项目名称:falcon,代码行数:94,代码来源:confparser_ext.cpp


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