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


C++ parse_value函数代码示例

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


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

示例1: SWITCH_DECLARE

/* Parse an object - create a new root, and populate. */
SWITCH_DECLARE(cJSON *)cJSON_Parse(const char *value)
{
	cJSON *c=cJSON_New_Item();
	ep=0;
	if (!c) return 0;       /* memory fail */

	if (!parse_value(c,skip(value))) {cJSON_Delete(c);return 0;}
	return c;
}
开发者ID:bodji,项目名称:freeswitch,代码行数:10,代码来源:switch_json.c

示例2:

/* Parse an object - create a new root, and populate. */
CSON *CSON_Parse(const char *value)
{
	CSON *c=CSON_New_Item();
	ep=0;
	if (!c) return 0;       /* memory fail */

	if (!parse_value(c,skip(value))) {CSON_Delete(c);return 0;}
	return c;
}
开发者ID:AlanZheng,项目名称:cson,代码行数:10,代码来源:cson.c

示例3: CHECK

Status ComplexQuery::parse_expression(const string& exp) {
  static const string OPCHAR = "=!<>";
  CHECK(!exp.empty());

  size_t op_pos = exp.find_first_of(OPCHAR);
  if (op_pos == string::npos) {
    return Status(-1, "Bad expression.");
  }
  size_t value_pos = exp.find_first_not_of(OPCHAR, op_pos);
  if (value_pos == string::npos) {
    return Status(-1, "Bad expression.");
  }
  string field = trim_copy(exp.substr(0, op_pos));
  string opstr = exp.substr(op_pos, value_pos - op_pos);
  string value = trim_copy(exp.substr(value_pos));

  int op = parse_cond_op(opstr);
  if (op < 0) {
    return Status(-1, "Bad operation.");
  }

  string tmp(value);
  Status status = parse_value(field, tmp, &value);
  if (!status.ok()) {
    LOG(ERROR) << status.message() << ":" << tmp;
    return status;
  }

  switch (op) {
    case LE:
      range_query_map_[field].upper = value;
      range_query_map_[field].upper_closed = true;
      break;
    case LT:
      range_query_map_[field].upper = value;
      range_query_map_[field].upper_closed = false;
      break;
    case GE:
      range_query_map_[field].lower = value;
      range_query_map_[field].lower_closed = true;
      break;
    case GT:
      range_query_map_[field].lower = value;
      range_query_map_[field].lower_closed = false;
      break;
    case EQ:
      range_query_map_[field].upper = value;
      range_query_map_[field].upper_closed = true;
      range_query_map_[field].lower = value;
      range_query_map_[field].lower_closed = true;
      break;
    default:
      LOG(ERROR) << "Unknown op code: " << opstr;
      return Status(-1, "Unknown op code.");
  }
  return Status::OK;
}
开发者ID:vsfs,项目名称:vsfs,代码行数:57,代码来源:complex_query.cpp

示例4: next_tag

static const char *parse_field(struct buffer *self, int tag)
{
	if (parse_tag(self) != tag) {
		next_tag(self);
		return NULL;
	}

	return parse_value(self);
}
开发者ID:weixu8,项目名称:libtrading,代码行数:9,代码来源:fix_message.c

示例5:

const nx_json *nx_json_parse(char *text, nx_json_unicode_encoder encoder) {
    nx_json js = { 0 };
    if (!parse_value(&js, 0, text, encoder)) {
        if (js.child)
            nx_json_free(js.child);
        return 0;
    }
    return js.child;
}
开发者ID:debosvi,项目名称:bozHMI,代码行数:9,代码来源:nxjson.c

示例6: json_object

static json_t *parse_dict(stream_t *stream, size_t flags,
                          json_error_t *error)
{
    int c;
    char *key;
    json_t *value;
    json_t *object = json_object();
    if(!object)
        return NULL;

    c = stream_getc(stream);
    assert(c == 'd');

    while (1) {
        c = stream_peek(stream);
        if (c == EOF) {
            error_set(error, stream, "unterminated dictionary");
            goto error;
        }
        if (c == 'e')
            break;

        key = parse_string(stream, flags, error);
        if (!key)
            goto error;

        if(flags & JSON_REJECT_DUPLICATES) {
            if(json_object_get(object, key)) {
                jsonp_free(key);
                error_set(error, stream, "duplicate object key");
                goto error;
            }
        }

        value = parse_value(stream, flags, error);
        if (!value) {
            jsonp_free(key);
            goto error;
        }

        if(json_object_set_nocheck(object, key, value)) {
            jsonp_free(key);
            json_decref(value);
            goto error;
        }

        json_decref(value);
        jsonp_free(key);
    }
    stream_getc(stream);
    return object;

error:
    json_decref(object);
    return NULL;
}
开发者ID:japeq,项目名称:jansson-bencode,代码行数:56,代码来源:bencode.c

示例7: drbd_submit_fields

static int drbd_submit_fields (long int resource,
		char **fields, size_t fields_num)
{
	char plugin_instance[DATA_MAX_NAME_LEN];
	value_t values[fields_num];
	value_list_t vl = VALUE_LIST_INIT;
	size_t i;

	if (resource < 0)
	{
		WARNING ("drbd plugin: Unable to parse resource");
		return (EINVAL);
	}

	if (fields_num != drbd_names_num)
	{
		WARNING ("drbd plugin: Wrong number of fields for "
				 "r%ld statistics. Expected %zu, got %zu.",
				 resource, drbd_names_num, fields_num);
		return (EINVAL);
	}

	ssnprintf (plugin_instance, sizeof (plugin_instance), "r%ld",
			resource);

	for (i = 0; i < drbd_names_num; i++)
	{
		char *data;
		/* skip non numeric wo */
		if (strncmp(fields[i], "wo", 2) == 0)
			continue;
		data = strchr(fields[i], ':');
		if (data == NULL)
			return (EINVAL);
		(void) parse_value (++data, &values[i], DS_TYPE_DERIVE);
	}

	vl.values_len = 1;
	sstrncpy (vl.host, hostname_g, sizeof (vl.host));
	sstrncpy (vl.plugin, "drbd", sizeof (vl.plugin));
	sstrncpy (vl.plugin_instance, plugin_instance,
			sizeof (vl.plugin_instance));
	sstrncpy (vl.type, "drbd_resource", sizeof (vl.type));

	for (i = 0; i < fields_num; i++)
	{
		if (drbd_names[i] == NULL)
			continue;
		vl.values = values + i;
		sstrncpy (vl.type_instance, drbd_names[i],
				sizeof (vl.type_instance));
		plugin_dispatch_values (&vl);
	}

	return (0);
} /* drbd_submit_fields */
开发者ID:Mindera,项目名称:collectd,代码行数:56,代码来源:drbd.c

示例8: parse_struct_sig

Value *Parser::parse_struct() {
    StructSig *sig = parse_struct_sig();
    Struct *value = new Struct(sig);

    for (size_t i = 0; i < sig->num_members; ++i) {
        value->members[i] = parse_value();
    }

    return value;
}
开发者ID:netconstructor,项目名称:apitrace,代码行数:10,代码来源:trace_parser.cpp

示例9: read_uint

void Parser::parse_arg(Call *call, Mode mode) {
    unsigned index = read_uint();
    Value *value = parse_value(mode);
    if (value) {
        if (index >= call->args.size()) {
            call->args.resize(index + 1);
        }
        call->args[index].value = value;
    }
}
开发者ID:netconstructor,项目名称:apitrace,代码行数:10,代码来源:trace_parser.cpp

示例10:

/* Parse an object - create a new root, and populate. */
cJSON *cJSON_Parse(const char *value)
{
	cJSON *c=cJSON_New_Item();
	ep=0;
	if (!c) return 0;       /* memory fail */
	if (!parse_value(c,skip(value))) {cJSON_Delete(c);return 0;}
	
	//printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 264 \n");
	return c;
}
开发者ID:sguotao,项目名称:DVB_F865_JYSX,代码行数:11,代码来源:cJSON.c

示例11: lex_scan

static json_t *parse_json(lex_t *lex, json_error_t *error)
{
    lex_scan(lex, error);
    if(lex->token != '[' && lex->token != '{') {
        error_set(error, lex, "'[' or '{' expected");
        return NULL;
    }

    return parse_value(lex, error);
}
开发者ID:derdewey,项目名称:jansson,代码行数:10,代码来源:load.c

示例12: parse_parameter

// parameter    = attribute "=" value
// attribute    = token
const char* parse_parameter(unsigned char** p)
{
	if (parse_token(p))
		return ERR;
	if (parse_char(p, '='))
		return ERR;
	if (parse_value(p))
		return ERR;
	return NULL;
}
开发者ID:ruslanti,项目名称:rubicon,代码行数:12,代码来源:http_rules.c

示例13: strchr

bool LogFileOutput::parse_options(const char* options, outputStream* errstream) {
  if (options == NULL || strlen(options) == 0) {
    return true;
  }
  bool success = true;
  char* opts = os::strdup_check_oom(options, mtLogging);

  char* comma_pos;
  char* pos = opts;
  do {
    comma_pos = strchr(pos, ',');
    if (comma_pos != NULL) {
      *comma_pos = '\0';
    }

    char* equals_pos = strchr(pos, '=');
    if (equals_pos == NULL) {
      success = false;
      break;
    }
    char* key = pos;
    char* value_str = equals_pos + 1;
    *equals_pos = '\0';

    if (strcmp(FileCountOptionKey, key) == 0) {
      size_t value = parse_value(value_str);
      if (value > MaxRotationFileCount) {
        errstream->print_cr("Invalid option: %s must be in range [0, %u]",
                            FileCountOptionKey,
                            MaxRotationFileCount);
        success = false;
        break;
      }
      _file_count = static_cast<uint>(value);
    } else if (strcmp(FileSizeOptionKey, key) == 0) {
      julong value;
      success = Arguments::atojulong(value_str, &value);
      if (!success || (value > SIZE_MAX)) {
        errstream->print_cr("Invalid option: %s must be in range [0, "
                            SIZE_FORMAT "]", FileSizeOptionKey, SIZE_MAX);
        success = false;
        break;
      }
      _rotate_size = static_cast<size_t>(value);
    } else {
      errstream->print_cr("Invalid option '%s' for log file output.", key);
      success = false;
      break;
    }
    pos = comma_pos + 1;
  } while (comma_pos != NULL);

  os::free(opts);
  return success;
}
开发者ID:netroby,项目名称:jdk9-dev,代码行数:55,代码来源:logFileOutput.cpp

示例14: while

/* Build an array from input text. */
static const char *parse_array(cJSON *item,const char *value) {
    cJSON *child;
    if (*value!='[')	{
        ep=value;    /* not an array! */
        return 0;
    }

    item->type=cJSON_Array;
    value=skip(value+1);
    if (*value==']') {
        return value+1;    /* empty array. */
    }

    item->child=child=cJSON_New_Item();
    if (!item->child) {
        return 0;    /* memory fail */
    }
    value=skip(parse_value(child,skip(value)));	/* skip any spacing, get the value. */
    if (!value) {
        return 0;
    }

    while (*value==',') {
        cJSON *new_item;
        if (!(new_item=cJSON_New_Item())) {
            return 0;    /* memory fail */
        }
        child->next=new_item;
        new_item->prev=child;
        child=new_item;
        value=skip(parse_value(child,skip(value+1)));
        if (!value) {
            return 0;    /* memory fail */
        }
    }

    if (*value==']') {
        return value+1;    /* end of array */
    }
    ep=value;
    return 0;	/* malformed. */
}
开发者ID:JasonYSU,项目名称:VETH3000Switch,代码行数:43,代码来源:cJSON.c

示例15: v_lisu_lisl

static void v_lisu_lisl(char *str, MNEMONIC *mne) {

    unsigned long operand;

    programlabel();
    parse_value(str, &operand);
    if (operand > 7) {
        f8err(ERROR_VALUE_MUST_BE_LT_8, mne->name, str, false);
    }
    emit_opcode1(mne->opcode[0] | (operand & 7));
}
开发者ID:sparkiedk,项目名称:Toyota-PCM-hacking,代码行数:11,代码来源:mnef8.c


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