static void hash_set_cstr(ParseInfo pi, const char *key, size_t klen, const char *str, size_t len, const char *orig) { Val parent = stack_peek(&pi->stack); if (0 != pi->options.create_id && *pi->options.create_id == *key && pi->options.create_id_len == klen && 0 == strncmp(pi->options.create_id, key, klen)) { if (str < pi->json || pi->cur < str) { parent->classname = oj_strndup(str, len); } else { parent->classname = str; } parent->clen = len; } else { volatile VALUE rstr = rb_str_new(str, len); volatile VALUE rkey = rb_str_new(key, klen); rstr = oj_encode(rstr); rkey = oj_encode(rkey); if (Yes == pi->options.sym_key) { rkey = rb_str_intern(rkey); } rb_hash_aset(parent->val, rkey, rstr); } }
static void add_cstr(ParseInfo pi, const char *str, size_t len, const char *orig) { volatile VALUE rstr = rb_str_new(str, len); rstr = oj_encode(rstr); pi->stack.head->val = rstr; }
static void hash_set_cstr(ParseInfo pi, Val parent, const char *str, size_t len, const char *orig) { volatile VALUE rstr = rb_str_new(str, len); rstr = oj_encode(rstr); rb_hash_aset(stack_peek(&pi->stack)->val, calc_hash_key(pi, parent), rstr); }
static void array_append_cstr(ParseInfo pi, const char *str, size_t len, const char *orig) { volatile VALUE rstr = rb_str_new(str, len); rstr = oj_encode(rstr); rb_ary_push(stack_peek(&pi->stack)->val, rstr); }
static void hash_set_cstr(ParseInfo pi, Val parent, const char *str, size_t len, const char *orig) { volatile VALUE rstr = rb_str_new(str, len); rstr = oj_encode(rstr); rb_hash_aset(stack_peek(&pi->stack)->val, calc_hash_key(pi, parent), rstr); if (Yes == pi->options.trace) { oj_trace_parse_call("set_string", pi, __FILE__, __LINE__, rstr); } }
static void add_cstr(ParseInfo pi, const char *str, size_t len, const char *orig) { volatile VALUE rstr = rb_str_new(str, len); rstr = oj_encode(rstr); pi->stack.head->val = rstr; if (Yes == pi->options.trace) { oj_trace_parse_call("add_string", pi, __FILE__, __LINE__, rstr); } }
static void array_append_cstr(ParseInfo pi, const char *str, size_t len, const char *orig) { volatile VALUE rstr = rb_str_new(str, len); rstr = oj_encode(rstr); rb_ary_push(stack_peek(&pi->stack)->val, rstr); if (Yes == pi->options.trace) { oj_trace_parse_call("append_string", pi, __FILE__, __LINE__, rstr); } }
static VALUE calc_hash_key(ParseInfo pi, Val parent) { volatile VALUE rkey = parent->key_val; if (Qundef == rkey) { rkey = rb_str_new(parent->key, parent->klen); } rkey = oj_encode(rkey); if (Yes == pi->options.sym_key) { rkey = rb_str_intern(rkey); } return rkey; }