本文整理汇总了C++中GRN_API_RETURN函数的典型用法代码示例。如果您正苦于以下问题:C++ GRN_API_RETURN函数的具体用法?C++ GRN_API_RETURN怎么用?C++ GRN_API_RETURN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GRN_API_RETURN函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: grn_tokenizer_query_set_raw_string
grn_rc
grn_tokenizer_query_set_raw_string(grn_ctx *ctx,
grn_tokenizer_query *query,
const char *string,
size_t string_length)
{
GRN_API_ENTER;
if (query->query_buf) {
GRN_PLUGIN_FREE(ctx, query->query_buf);
}
if (string_length == 0) {
query->query_buf = NULL;
query->ptr = NULL;
query->length = 0;
query->need_normalize = GRN_TRUE;
} else {
query->query_buf = (char *)GRN_PLUGIN_MALLOC(ctx, string_length + 1);
if (!query->query_buf) {
GRN_PLUGIN_ERROR(ctx, GRN_TOKENIZER_ERROR,
"[tokenizer][query] failed to duplicate query");
GRN_API_RETURN(ctx->rc);
}
grn_memcpy(query->query_buf, string, string_length);
query->query_buf[string_length] = '\0';
query->ptr = query->query_buf;
query->length = string_length;
}
GRN_API_RETURN(ctx->rc);
}
示例2: grn_type_create
grn_obj *
grn_type_create(grn_ctx *ctx, const char *name, unsigned int name_size,
grn_obj_flags flags, unsigned int size)
{
grn_id id;
struct _grn_type *res = NULL;
grn_obj *db;
if (!ctx || !ctx->impl || !(db = ctx->impl->db)) {
ERR(GRN_INVALID_ARGUMENT, "db not initialized");
return NULL;
}
GRN_API_ENTER;
if (grn_db_check_name(ctx, name, name_size)) {
GRN_DB_CHECK_NAME_ERR("[type][create]", name, name_size);
GRN_API_RETURN(NULL);
}
if (!GRN_DB_P(db)) {
ERR(GRN_INVALID_ARGUMENT, "invalid db assigned");
GRN_API_RETURN(NULL);
}
id = grn_obj_register(ctx, db, name, name_size);
if (id && (res = GRN_MALLOC(sizeof(grn_db_obj)))) {
GRN_DB_OBJ_SET_TYPE(res, GRN_TYPE);
res->obj.header.flags = flags;
res->obj.header.domain = GRN_ID_NIL;
GRN_TYPE_SIZE(&res->obj) = size;
if (grn_db_obj_init(ctx, db, id, DB_OBJ(res))) {
// grn_obj_delete(ctx, db, id);
GRN_FREE(res);
GRN_API_RETURN(NULL);
}
}
GRN_API_RETURN((grn_obj *)res);
}
示例3: grn_token_get_data
grn_obj *
grn_token_get_data(grn_ctx *ctx, grn_token *token)
{
GRN_API_ENTER;
if (!token) {
ERR(GRN_INVALID_ARGUMENT, "token must not be NULL");
GRN_API_RETURN(NULL);
}
GRN_API_RETURN(&(token->data));
}
示例4: grn_token_get_status
grn_token_status
grn_token_get_status(grn_ctx *ctx, grn_token *token)
{
GRN_API_ENTER;
if (!token) {
ERR(GRN_INVALID_ARGUMENT, "token must not be NULL");
GRN_API_RETURN(GRN_TOKEN_CONTINUE);
}
GRN_API_RETURN(token->status);
}
示例5: grn_token_get_source_offset
uint64_t
grn_token_get_source_offset(grn_ctx *ctx, grn_token *token)
{
GRN_API_ENTER;
if (!token) {
ERR(GRN_INVALID_ARGUMENT,
"[token][source-offset][get] token must not be NULL");
GRN_API_RETURN(0);
}
GRN_API_RETURN(token->source_offset);
}
示例6: grn_token_have_overlap
grn_bool
grn_token_have_overlap(grn_ctx *ctx, grn_token *token)
{
GRN_API_ENTER;
if (!token) {
ERR(GRN_INVALID_ARGUMENT,
"[token][overlap][have] token must not be NULL");
GRN_API_RETURN(0);
}
GRN_API_RETURN(token->have_overlap);
}
示例7: grn_token_get_force_prefix_search
grn_bool
grn_token_get_force_prefix_search(grn_ctx *ctx, grn_token *token)
{
GRN_API_ENTER;
if (!token) {
ERR(GRN_INVALID_ARGUMENT,
"[token][force-prefix-search][get] token must not be NULL");
GRN_API_RETURN(GRN_FALSE);
}
GRN_API_RETURN(token->force_prefix_search);
}
示例8: grn_token_get_position
uint32_t
grn_token_get_position(grn_ctx *ctx, grn_token *token)
{
GRN_API_ENTER;
if (!token) {
ERR(GRN_INVALID_ARGUMENT,
"[token][position][get] token must not be NULL");
GRN_API_RETURN(0);
}
GRN_API_RETURN(token->position);
}
示例9: grn_token_get_source_first_character_length
uint32_t
grn_token_get_source_first_character_length(grn_ctx *ctx, grn_token *token)
{
GRN_API_ENTER;
if (!token) {
ERR(GRN_INVALID_ARGUMENT,
"[token][source-first-character-length][get] token must not be NULL");
GRN_API_RETURN(0);
}
GRN_API_RETURN(token->source_first_character_length);
}
示例10: grn_tokenizer_query_open
grn_tokenizer_query *
grn_tokenizer_query_open(grn_ctx *ctx, int num_args, grn_obj **args,
unsigned int normalize_flags)
{
grn_obj *flags;
grn_obj *query_str;
grn_obj *tokenize_mode;
GRN_API_ENTER;
flags = grn_ctx_pop(ctx);
query_str = grn_ctx_pop(ctx);
tokenize_mode = grn_ctx_pop(ctx);
if (query_str == NULL) {
GRN_PLUGIN_ERROR(ctx, GRN_INVALID_ARGUMENT, "missing argument");
GRN_API_RETURN(NULL);
}
if ((num_args < 1) || (args == NULL) || (args[0] == NULL)) {
GRN_PLUGIN_ERROR(ctx, GRN_INVALID_ARGUMENT, "invalid NULL pointer");
GRN_API_RETURN(NULL);
}
{
grn_tokenizer_query * const query =
GRN_PLUGIN_MALLOC(ctx, sizeof(grn_tokenizer_query));
if (!query) {
GRN_API_RETURN(NULL);
}
grn_tokenizer_query_init(ctx, query);
grn_tokenizer_query_set_raw_string(ctx,
query,
GRN_TEXT_VALUE(query_str),
GRN_TEXT_LEN(query_str));
if (ctx->rc != GRN_SUCCESS) {
GRN_PLUGIN_FREE(ctx, query);
GRN_API_RETURN(NULL);
}
if (flags) {
grn_tokenizer_query_set_flags(ctx, query, GRN_UINT32_VALUE(flags));
}
if (tokenize_mode) {
grn_tokenizer_query_set_mode(ctx, query, GRN_UINT32_VALUE(tokenize_mode));
}
grn_tokenizer_query_set_normalize_flags(ctx, query, normalize_flags);
grn_tokenizer_query_set_lexicon(ctx, query, args[0]);
grn_tokenizer_query_ensure_have_tokenized_delimiter(ctx, query);
GRN_API_RETURN(query);
}
}
示例11: grn_token_set_position
grn_rc
grn_token_set_position(grn_ctx *ctx, grn_token *token, uint32_t position)
{
GRN_API_ENTER;
if (!token) {
ERR(GRN_INVALID_ARGUMENT,
"[token][position][set] token must not be NULL");
GRN_API_RETURN(ctx->rc);
}
token->position = position;
GRN_API_RETURN(ctx->rc);
}
示例12: grn_token_set_force_prefix_search
grn_rc
grn_token_set_force_prefix_search(grn_ctx *ctx, grn_token *token, grn_bool force)
{
GRN_API_ENTER;
if (!token) {
ERR(GRN_INVALID_ARGUMENT,
"[token][force-prefix-search][set] token must not be NULL");
GRN_API_RETURN(ctx->rc);
}
token->force_prefix_search = force;
GRN_API_RETURN(ctx->rc);
}
示例13: grn_type_size
uint32_t
grn_type_size(grn_ctx *ctx, grn_obj *type)
{
uint32_t size;
GRN_API_ENTER;
if (!type) {
ERR(GRN_INVALID_ARGUMENT, "[type][size] type is NULL");
GRN_API_RETURN(0);
}
size = GRN_TYPE_SIZE(DB_OBJ(type));
GRN_API_RETURN(size);
}
示例14: grn_windows_event_logger_set
grn_rc
grn_windows_event_logger_set(grn_ctx *ctx, const char *event_source_name)
{
#ifdef WIN32
grn_rc rc;
grn_logger windows_event_logger;
grn_windows_event_logger_data *data;
if (ctx) {
GRN_API_ENTER;
}
data = malloc(sizeof(grn_windows_event_logger_data));
if (!data) {
if (ctx) {
ERR(GRN_NO_MEMORY_AVAILABLE,
"failed to allocate user data for Windows event logger");
GRN_API_RETURN(ctx->rc);
} else {
return GRN_NO_MEMORY_AVAILABLE;
}
}
if (event_source_name) {
data->event_source_name = grn_strdup_raw(event_source_name);
} else {
data->event_source_name = grn_strdup_raw("libgroonga");
}
data->event_source = INVALID_HANDLE_VALUE;
windows_event_logger.max_level = GRN_LOG_DEFAULT_LEVEL;
windows_event_logger.flags = GRN_LOG_TIME | GRN_LOG_MESSAGE;
windows_event_logger.user_data = data;
windows_event_logger.log = windows_event_logger_log;
windows_event_logger.reopen = windows_event_logger_reopen;
windows_event_logger.fin = windows_event_logger_fin;
rc = grn_logger_set(ctx, &windows_event_logger);
if (rc != GRN_SUCCESS) {
windows_event_logger.fin(ctx, windows_event_logger.user_data);
}
if (ctx) {
GRN_API_RETURN(rc);
} else {
return rc;
}
#else /* WIN32 */
return GRN_FUNCTION_NOT_IMPLEMENTED;
#endif /* WIN32 */
}
示例15: grn_command_input_get_arguments
grn_obj *
grn_command_input_get_arguments(grn_ctx *ctx,
grn_command_input *input)
{
GRN_API_ENTER;
GRN_API_RETURN((grn_obj *)(input->arguments));
}