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


C++ config_setting_create函数代码示例

本文整理汇总了C++中config_setting_create函数的典型用法代码示例。如果您正苦于以下问题:C++ config_setting_create函数的具体用法?C++ config_setting_create怎么用?C++ config_setting_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: return

config_setting_t *config_setting_set_string_elem(config_setting_t *vector,
                                                 int idx, const char *value)
{
  config_setting_t *element = NULL;

  if((vector->type != CONFIG_TYPE_ARRAY) && (vector->type != CONFIG_TYPE_LIST))
    return(NULL);

  if(idx < 0)
  {
    if(! __config_vector_checktype(vector, CONFIG_TYPE_STRING))
      return(NULL);

    element = config_setting_create(vector, NULL, CONFIG_TYPE_STRING);
  }
  else
    element = config_setting_get_elem(vector, idx);

  if(! element)
    return(NULL);

  if(! config_setting_set_string(element, value))
    return(NULL);

  return(element);
}
开发者ID:mlafeldt,项目名称:ps2rd,代码行数:26,代码来源:libconfig.c

示例2: return

config_setting_t *config_setting_add(config_setting_t *parent,
                                     const char *name, int type)
{
  if((type < CONFIG_TYPE_NONE) || (type > CONFIG_TYPE_LIST))
    return(NULL);

  if(! parent)
    return(NULL);

  if((parent->type == CONFIG_TYPE_ARRAY) || (parent->type == CONFIG_TYPE_LIST))
    name = NULL;

  if(name)
  {
    if(! __config_validate_name(name))
      return(NULL);
  }

  config_setting_t *setting = config_setting_get_member(parent, name);
  if (setting != NULL)
  {
    if ((setting->type != type && type != CONFIG_TYPE_NONE) ||
        (setting->type != CONFIG_TYPE_GROUP &&
         setting->type != CONFIG_TYPE_ARRAY &&
         setting->type != CONFIG_TYPE_LIST))
      return(NULL); /* already exists */
    else
      return setting; /* merge with existing config */
  }

  return(config_setting_create(parent, name, type));
}
开发者ID:krin-san,项目名称:libconfig,代码行数:32,代码来源:libconfig.c

示例3: return

config_setting_t *config_setting_add(config_setting_t *parent,
                                     const char *name, int type)
{
  if((type < CONFIG_TYPE_NONE) || (type > CONFIG_TYPE_LIST))
    return(NULL);

  if(! parent)
    return(NULL);

  if((parent->type == CONFIG_TYPE_ARRAY) || (parent->type == CONFIG_TYPE_LIST))
    name = NULL;

  if(name)
  {
    if(! __config_validate_name(name))
      return(NULL);
  }

#if 0
  /* https://github.com/HerculesWS/Hercules/pull/136#discussion_r6363319
   * With this code, accidental duplicate keys would cause the file parsing to fail
   * (would cause several issues during runtime on file reloads), while libconfig's code
   * has no problems with duplicate members so it was ducked out -- TODO: looking now though
   * I'd think it could be useful to have it display a warning or error message when finding
   * duplicate keys instead of silently moving on. [Ind]
   */
  if(config_setting_get_member(parent, name) != NULL)
    return(NULL); /* already exists */
#endif

  return(config_setting_create(parent, name, type));
}
开发者ID:AchcarLucas,项目名称:Cronus,代码行数:32,代码来源:libconfig.c

示例4: return

LIBCONFIG_API config_setting_t *config_setting_set_bool_elem(
  config_setting_t *vector, int index, int value)
{
  config_setting_t *element = NULL;

  if((vector->type != CONFIG_TYPE_ARRAY) && (vector->type != CONFIG_TYPE_LIST))
    return(NULL);

  if(index < 0)
  {
    if(! __config_vector_checktype(vector, CONFIG_TYPE_BOOL))
      return(NULL);
    
    element = config_setting_create(vector, NULL, CONFIG_TYPE_BOOL);
  }
  else
    element = config_setting_get_elem(vector, index);

  if(! element)
    return(NULL);

  if(! config_setting_set_bool(element, value))
    return(NULL);
  
  return(element);
}
开发者ID:aveek0218,项目名称:ImpalaPythia,代码行数:26,代码来源:libconfig.c

示例5: return

config_setting_t *config_setting_add(config_setting_t *parent,
                                     const char *name, int type)
{
  if((type < CONFIG_TYPE_NONE) || (type > CONFIG_TYPE_LIST))
    return(NULL);

  if(! parent)
    return(NULL);

  if((parent->type == CONFIG_TYPE_ARRAY) || (parent->type == CONFIG_TYPE_LIST))
    name = NULL;

  if(name)
  {
    if(! __config_validate_name(name))
      return(NULL);
  }

  if(((name && *name != '$') || (!name)) && config_setting_get_member(parent, name) != NULL)
    return(NULL); /* already exists */

  return(config_setting_create(parent, name, type));
}
开发者ID:NeotericUK,项目名称:Pancake2,代码行数:23,代码来源:PancakeConfigurationParser.c


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