const range worksheet::named_range(const std::string &name) const { if (!workbook().has_named_range(name)) { throw key_not_found(); } if (!has_named_range(name)) { throw key_not_found(); } return range(d_->named_ranges_[name].targets()[0].second); }
void worksheet::remove_named_range(const std::string &name) { if (!has_named_range(name)) { throw key_not_found(); } d_->named_ranges_.erase(name); }
static ngx_int_t ngx_restfull_redis_handler(ngx_http_request_t *r) { //TODO: deal with allocation problem - return 500 ngx_chain_t out; out.buf = create_response_buffer(r);; out.next = NULL; dd("command => %s", command(r)); char* redis_command = command(r); define_content_type(r, "application/json; charset=utf-8"); redisContext *c = redisConnect("127.0.0.1", 6379); if (c->err) { dd("Error: %s\n", c->errstr); write_to_buffer(out.buf, (u_char*) "Can't connect to redis", strlen("Can't connect to redis")); } Hash* params = get_params(r); redisReply *reply; if(!strcmp(redis_command, "get")) { reply = redisCommand(c,"GET %s", params->get(params, "key")); dd("Redis reply status: %d", reply->type); if(key_not_found(reply)) { not_found(r, out.buf, (u_char*)"not found"); return ngx_http_output_filter(r, &out); } dd("reply: %s", reply->str); u_char * result = copy(r->pool, reply->str, reply->len); write_to_buffer(out.buf, result, reply->len); write_header(r, NGX_HTTP_OK, reply->len); } else if (!strcmp(redis_command, "set")) { reply = redisCommand(c,"SET %s %s", params->get(params, "key"), params->get(params, "value")); dd("Redis reply status: %d", reply->type); if(key_not_found(reply)) { not_found(r, out.buf, (u_char*)"not found"); return ngx_http_output_filter(r, &out); } dd("Reply set %s -- %d", reply->str, reply->len); write_to_buffer(out.buf, (u_char*) reply->str, reply->len); write_header(r, NGX_HTTP_OK, reply->len); } else if(!strcmp(redis_command, "incr")) { reply = redisCommand(c,"INCR %s", params->get(params, "key")); dd("Redis reply status: %d", reply->type); int len = number_of_digits(reply->integer); dd("Reply INCR -- %d - len %d", (int)reply->integer, len); u_char* result = ngx_pcalloc(r->pool, sizeof(char)*len); sprintf((char*)result,"%d",(int)reply->integer); write_to_buffer(out.buf, result, len); write_header(r, NGX_HTTP_OK, len); } freeReplyObject(reply); redisFree(c); ngx_free(params); return ngx_http_output_filter(r, &out); }
/** * @short Try to get a key, if not existant, throws an key_not_found exception. */ std::string operator[](const std::string &k) const{ const char *ret=onion_dict_get(ptr, k.c_str()); if (!ret) throw(key_not_found(k)); return onion_dict_get(ptr, k.c_str()); }