本文整理匯總了C++中GRN_TEXT_PUTS函數的典型用法代碼示例。如果您正苦於以下問題:C++ GRN_TEXT_PUTS函數的具體用法?C++ GRN_TEXT_PUTS怎麽用?C++ GRN_TEXT_PUTS使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GRN_TEXT_PUTS函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: grn_expr_inspect
grn_rc
grn_expr_inspect(grn_ctx *ctx, grn_obj *buffer, grn_obj *expr)
{
grn_expr *e = (grn_expr *)expr;
GRN_TEXT_PUTS(ctx, buffer, "#<expr\n");
{
int i = 0;
grn_obj *value;
const char *name;
uint32_t name_len;
unsigned int n_vars;
grn_hash *vars = grn_expr_get_vars(ctx, expr, &n_vars);
GRN_TEXT_PUTS(ctx, buffer, " vars:{");
GRN_HASH_EACH(ctx, vars, id, &name, &name_len, &value, {
if (i++) {
GRN_TEXT_PUTC(ctx, buffer, ',');
}
GRN_TEXT_PUTS(ctx, buffer, "\n ");
GRN_TEXT_PUT(ctx, buffer, name, name_len);
GRN_TEXT_PUTC(ctx, buffer, ':');
grn_inspect_indented(ctx, buffer, value, " ");
});
GRN_TEXT_PUTS(ctx, buffer, "\n },");
}
示例2: ngx_http_groonga_handler_validate_post_command
static ngx_int_t
ngx_http_groonga_handler_validate_post_command(ngx_http_request_t *r,
ngx_str_t *command_path,
ngx_http_groonga_handler_data_t *data)
{
grn_ctx *context;
ngx_str_t command;
command.data = command_path->data;
if (r->args.len == 0) {
command.len = command_path->len;
} else {
command.len = command_path->len - r->args.len - strlen("?");
}
if (ngx_str_equal_c_string(&command, "load")) {
return NGX_OK;
}
context = &(data->context);
ngx_http_groonga_handler_set_content_type(r, "text/plain");
GRN_TEXT_PUTS(context, &(data->body), "command for POST must be <load>: <");
GRN_TEXT_PUT(context, &(data->body), command.data, command.len);
GRN_TEXT_PUTS(context, &(data->body), ">");
return NGX_HTTP_BAD_REQUEST;
}
示例3: rb_grn_expression_inspect
/*
* call-seq:
* _expression_.inspect -> String
*
* _expression_の中身を人に見やすい文字列で返す。
*/
static VALUE
rb_grn_expression_inspect (VALUE self)
{
grn_ctx *context = NULL;
grn_obj inspected;
grn_obj *expression;
VALUE rb_inspected;
rb_grn_expression_deconstruct(SELF(self), &expression, &context,
NULL, NULL,
NULL, NULL, NULL);
GRN_TEXT_INIT(&inspected, 0);
GRN_TEXT_PUTS(context, &inspected, "#<Groonga::Expression ");
#ifdef WIN32
GRN_TEXT_PUTS(context, &inspected, "(not supported on Windows)");
#else
grn_expr_inspect(context, &inspected, expression);
#endif
GRN_TEXT_PUTS(context, &inspected, ">");
rb_inspected = rb_grn_context_rb_string_new(context,
GRN_TEXT_VALUE(&inspected),
GRN_TEXT_LEN(&inspected));
GRN_OBJ_FIN(context, &inspected);
return rb_inspected;
}
示例4: grn_output_array_open
void
grn_output_array_open(grn_ctx *ctx, grn_obj *outbuf, grn_content_type output_type,
const char *name, int nelements)
{
put_delimiter(ctx, outbuf, output_type);
switch (output_type) {
case GRN_CONTENT_JSON:
GRN_TEXT_PUTC(ctx, outbuf, '[');
break;
case GRN_CONTENT_XML:
GRN_TEXT_PUTC(ctx, outbuf, '<');
GRN_TEXT_PUTS(ctx, outbuf, name);
GRN_TEXT_PUTC(ctx, outbuf, '>');
grn_vector_add_element(ctx, &ctx->impl->names, name, strlen(name), 0, GRN_DB_SHORT_TEXT);
break;
case GRN_CONTENT_TSV:
if (DEPTH > 2) { GRN_TEXT_PUTS(ctx, outbuf, "[\t"); }
break;
case GRN_CONTENT_MSGPACK :
#ifdef HAVE_MESSAGE_PACK
if (nelements < 0) {
GRN_LOG(ctx, GRN_LOG_DEBUG,
"grn_output_array_open nelements (%d) for <%s>",
nelements,
name);
}
msgpack_pack_array(&ctx->impl->msgpacker, nelements);
#endif
break;
case GRN_CONTENT_NONE:
break;
}
INCR_DEPTH(0);
}
示例5: proc_status
static grn_obj *
proc_status(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
{
uint32_t nvars;
grn_obj *outbuf = args[0];
grn_expr_var *vars;
grn_proc_get_info(ctx, user_data, &vars, &nvars, NULL);
if (nvars == 1) {
grn_timeval now;
grn_content_type otype = GET_OTYPE(&vars[0].value);
grn_timeval_now(ctx, &now);
switch (otype) {
case GRN_CONTENT_TSV:
/* TODO: implement */
break;
case GRN_CONTENT_JSON:
GRN_TEXT_PUTS(ctx, outbuf, "{\"starttime\":");
grn_text_itoa(ctx, outbuf, grn_starttime.tv_sec);
GRN_TEXT_PUTS(ctx, outbuf, ",\"uptime\":");
grn_text_itoa(ctx, outbuf, now.tv_sec - grn_starttime.tv_sec);
GRN_TEXT_PUTC(ctx, outbuf, '}');
break;
}
}
return outbuf;
}
示例6: grn_output_time
void
grn_output_time(grn_ctx *ctx, grn_obj *outbuf, grn_content_type output_type, int64_t value)
{
double dv = value;
dv /= 1000000.0;
put_delimiter(ctx, outbuf, output_type);
switch (output_type) {
case GRN_CONTENT_JSON:
grn_text_ftoa(ctx, outbuf, dv);
break;
case GRN_CONTENT_TSV:
grn_text_ftoa(ctx, outbuf, dv);
break;
case GRN_CONTENT_XML:
GRN_TEXT_PUTS(ctx, outbuf, "<DATE>");
grn_text_ftoa(ctx, outbuf, dv);
GRN_TEXT_PUTS(ctx, outbuf, "</DATE>");
break;
case GRN_CONTENT_MSGPACK :
#ifdef HAVE_MESSAGE_PACK
msgpack_pack_double(&ctx->impl->msgpacker, dv);
#endif
break;
case GRN_CONTENT_NONE:
break;
}
INCR_LENGTH;
}
示例7: grn_output_geo_point
void
grn_output_geo_point(grn_ctx *ctx, grn_obj *outbuf, grn_content_type output_type,
grn_geo_point *value)
{
put_delimiter(ctx, outbuf, output_type);
switch (output_type) {
case GRN_CONTENT_JSON:
if (value) {
GRN_TEXT_PUTC(ctx, outbuf, '"');
grn_text_itoa(ctx, outbuf, value->latitude);
GRN_TEXT_PUTC(ctx, outbuf, 'x');
grn_text_itoa(ctx, outbuf, value->longitude);
GRN_TEXT_PUTC(ctx, outbuf, '"');
} else {
GRN_TEXT_PUTS(ctx, outbuf, "null");
}
break;
case GRN_CONTENT_TSV:
if (value) {
GRN_TEXT_PUTC(ctx, outbuf, '"');
grn_text_itoa(ctx, outbuf, value->latitude);
GRN_TEXT_PUTC(ctx, outbuf, 'x');
grn_text_itoa(ctx, outbuf, value->longitude);
GRN_TEXT_PUTC(ctx, outbuf, '"');
} else {
GRN_TEXT_PUTS(ctx, outbuf, "\"\"");
}
break;
case GRN_CONTENT_XML:
GRN_TEXT_PUTS(ctx, outbuf, "<GEO_POINT>");
if (value) {
grn_text_itoa(ctx, outbuf, value->latitude);
GRN_TEXT_PUTC(ctx, outbuf, 'x');
grn_text_itoa(ctx, outbuf, value->longitude);
}
GRN_TEXT_PUTS(ctx, outbuf, "</GEO_POINT>");
break;
case GRN_CONTENT_MSGPACK :
#ifdef HAVE_MESSAGE_PACK
if (value) {
grn_obj buf;
GRN_TEXT_INIT(&buf, 0);
grn_text_itoa(ctx, &buf, value->latitude);
GRN_TEXT_PUTC(ctx, &buf, 'x');
grn_text_itoa(ctx, &buf, value->longitude);
msgpack_pack_raw(&ctx->impl->msgpacker, GRN_TEXT_LEN(&buf));
msgpack_pack_raw_body(&ctx->impl->msgpacker,
GRN_TEXT_VALUE(&buf),
GRN_TEXT_LEN(&buf));
grn_obj_close(ctx, &buf);
} else {
msgpack_pack_nil(&ctx->impl->msgpacker);
}
#endif
break;
case GRN_CONTENT_NONE:
break;
}
INCR_LENGTH;
}
示例8: grn_output_bool
void
grn_output_bool(grn_ctx *ctx, grn_obj *outbuf, grn_content_type output_type, char value)
{
put_delimiter(ctx, outbuf, output_type);
switch (output_type) {
case GRN_CONTENT_JSON:
GRN_TEXT_PUTS(ctx, outbuf, value ? "true" : "false");
break;
case GRN_CONTENT_TSV:
GRN_TEXT_PUTS(ctx, outbuf, value ? "true" : "false");
break;
case GRN_CONTENT_XML:
GRN_TEXT_PUTS(ctx, outbuf, "<BOOL>");
GRN_TEXT_PUTS(ctx, outbuf, value ? "true" : "false");
GRN_TEXT_PUTS(ctx, outbuf, "</BOOL>");
break;
case GRN_CONTENT_MSGPACK :
#ifdef HAVE_MESSAGE_PACK
if (value) {
msgpack_pack_true(&ctx->impl->msgpacker);
} else {
msgpack_pack_false(&ctx->impl->msgpacker);
}
#endif
break;
case GRN_CONTENT_NONE:
break;
}
INCR_LENGTH;
}
示例9: grn_output_void
void
grn_output_void(grn_ctx *ctx, grn_obj *outbuf, grn_content_type output_type,
const char *value, size_t value_len)
{
if (value_len == sizeof(grn_id) && *(grn_id *)value == GRN_ID_NIL) {
put_delimiter(ctx, outbuf, output_type);
switch (output_type) {
case GRN_CONTENT_JSON:
GRN_TEXT_PUTS(ctx, outbuf, "null");
break;
case GRN_CONTENT_TSV:
break;
case GRN_CONTENT_XML:
GRN_TEXT_PUTS(ctx, outbuf, "<NULL/>");
break;
case GRN_CONTENT_MSGPACK :
#ifdef HAVE_MESSAGE_PACK
msgpack_pack_nil(&ctx->impl->msgpacker);
#endif
break;
case GRN_CONTENT_NONE:
break;
}
INCR_LENGTH;
} else {
grn_output_str(ctx, outbuf, output_type, value, value_len);
}
}
示例10: grn_output_str
void
grn_output_str(grn_ctx *ctx, grn_obj *outbuf, grn_content_type output_type,
const char *value, size_t value_len)
{
put_delimiter(ctx, outbuf, output_type);
switch (output_type) {
case GRN_CONTENT_JSON:
grn_text_esc(ctx, outbuf, value, value_len);
break;
case GRN_CONTENT_TSV:
grn_text_esc(ctx, outbuf, value, value_len);
break;
case GRN_CONTENT_XML:
GRN_TEXT_PUTS(ctx, outbuf, "<TEXT>");
grn_text_escape_xml(ctx, outbuf, value, value_len);
GRN_TEXT_PUTS(ctx, outbuf, "</TEXT>");
break;
case GRN_CONTENT_MSGPACK :
#ifdef HAVE_MESSAGE_PACK
msgpack_pack_raw(&ctx->impl->msgpacker, value_len);
msgpack_pack_raw_body(&ctx->impl->msgpacker, value, value_len);
#endif
break;
case GRN_CONTENT_NONE:
break;
}
INCR_LENGTH;
}
示例11: grn_output_float
void
grn_output_float(grn_ctx *ctx, grn_obj *outbuf, grn_content_type output_type, double value)
{
put_delimiter(ctx, outbuf, output_type);
switch (output_type) {
case GRN_CONTENT_JSON:
grn_text_ftoa(ctx, outbuf, value);
break;
case GRN_CONTENT_TSV:
grn_text_ftoa(ctx, outbuf, value);
break;
case GRN_CONTENT_XML:
GRN_TEXT_PUTS(ctx, outbuf, "<FLOAT>");
grn_text_ftoa(ctx, outbuf, value);
GRN_TEXT_PUTS(ctx, outbuf, "</FLOAT>");
break;
case GRN_CONTENT_MSGPACK :
#ifdef HAVE_MESSAGE_PACK
msgpack_pack_double(&ctx->impl->msgpacker, value);
#endif
break;
case GRN_CONTENT_NONE:
break;
}
INCR_LENGTH;
}
示例12: grn_output_map_close
void
grn_output_map_close(grn_ctx *ctx, grn_obj *outbuf, grn_content_type output_type)
{
switch (output_type) {
case GRN_CONTENT_JSON:
GRN_TEXT_PUTS(ctx, outbuf, "}");
break;
case GRN_CONTENT_TSV:
if (DEPTH > 3) {
if (CURR_LEVEL >= 2) { GRN_TEXT_PUTC(ctx, outbuf, '\t'); }
GRN_TEXT_PUTC(ctx, outbuf, '}');
}
break;
case GRN_CONTENT_XML:
{
const char *name;
unsigned int name_len = grn_vector_pop_element(ctx, &ctx->impl->names, &name, NULL, NULL);
GRN_TEXT_PUTS(ctx, outbuf, "</");
GRN_TEXT_PUT(ctx, outbuf, name, name_len);
GRN_TEXT_PUTC(ctx, outbuf, '>');
}
break;
case GRN_CONTENT_MSGPACK :
// do nothing
break;
case GRN_CONTENT_NONE:
break;
}
DECR_DEPTH;
INCR_LENGTH;
}
示例13: suggest_result
static int
suggest_result(struct evbuffer *res_buf, const char *types, const char *query,
const char *target_name, int threshold, int limit,
grn_obj *cmd_buf, grn_ctx *ctx)
{
if (target_name && types && query) {
GRN_BULK_REWIND(cmd_buf);
GRN_TEXT_PUTS(ctx, cmd_buf, "/d/suggest?table=item_");
grn_text_urlenc(ctx, cmd_buf, target_name, strlen(target_name));
GRN_TEXT_PUTS(ctx, cmd_buf, "&column=kana&types=");
grn_text_urlenc(ctx, cmd_buf, types, strlen(types));
GRN_TEXT_PUTS(ctx, cmd_buf, "&query=");
grn_text_urlenc(ctx, cmd_buf, query, strlen(query));
GRN_TEXT_PUTS(ctx, cmd_buf, "&threshold=");
grn_text_itoa(ctx, cmd_buf, threshold);
GRN_TEXT_PUTS(ctx, cmd_buf, "&limit=");
grn_text_itoa(ctx, cmd_buf, limit);
{
char *res;
int flags;
unsigned int res_len;
grn_ctx_send(ctx, GRN_TEXT_VALUE(cmd_buf), GRN_TEXT_LEN(cmd_buf), 0);
grn_ctx_recv(ctx, &res, &res_len, &flags);
evbuffer_add(res_buf, res, res_len);
return res_len;
}
} else {
evbuffer_add(res_buf, "{}", 2);
return 2;
}
}
示例14: grn_ja_inspect
static grn_rc
grn_ja_inspect(grn_ctx *ctx, grn_obj *buf, grn_obj *obj)
{
GRN_TEXT_PUTS(ctx, buf, "#<column:var_size ");
grn_store_inspect_body(ctx, buf, obj);
GRN_TEXT_PUTS(ctx, buf, ">");
return GRN_SUCCESS;
}
示例15: parse_synonyms_file_line
static void
parse_synonyms_file_line(grn_ctx *ctx, const char *line, size_t line_length,
grn_obj *key, grn_obj *value)
{
size_t i = 0;
if (is_comment_mark(line[i])) {
return;
}
while (i < line_length) {
char character = line[i];
i++;
if (character == '\t') {
break;
}
GRN_TEXT_PUTC(ctx, key, character);
}
if (i == line_length) {
return;
}
GRN_TEXT_PUTS(ctx, value, "((");
while (i < line_length) {
char character = line[i];
i++;
if (character == '\t') {
GRN_TEXT_PUTS(ctx, value, ") OR (");
} else {
GRN_TEXT_PUTC(ctx, value, character);
}
}
GRN_TEXT_PUTS(ctx, value, "))");
{
grn_id id;
void *value_location = NULL;
id = grn_hash_add(ctx, synonyms, GRN_TEXT_VALUE(key), GRN_TEXT_LEN(key),
&value_location, NULL);
if (id == GRN_ID_NIL) {
GRN_PLUGIN_LOG(ctx, GRN_LOG_WARNING,
"[plugin][query-expander][tsv] "
"failed to register key: <%.*s>",
(int)GRN_TEXT_LEN(key), GRN_TEXT_VALUE(key));
return;
}
if (GRN_TEXT_LEN(value) <= MAX_SYNONYM_BYTES - 1) {
GRN_TEXT_PUTC(ctx, value, '\0');
} else {
grn_bulk_truncate(ctx, value, MAX_SYNONYM_BYTES - 1);
GRN_TEXT_PUTC(ctx, value, '\0');
}
grn_memcpy(value_location, GRN_TEXT_VALUE(value), GRN_TEXT_LEN(value));
}
}