本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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 */
示例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;
}
示例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;
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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. */
}
示例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));
}