• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ MDB_CHECKARG函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中MDB_CHECKARG函数的典型用法代码示例。如果您正苦于以下问题:C++ MDB_CHECKARG函数的具体用法?C++ MDB_CHECKARG怎么用?C++ MDB_CHECKARG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了MDB_CHECKARG函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: mqi_create_table_trigger

int mqi_create_table_trigger(mqi_trigger_cb_t callback, void *user_data)
{
    mqi_db_t         *db;
    mqi_db_functbl_t *ftb;
    int               i;

    MDB_CHECKARG(callback, -1);
    MDB_PREREQUISITE(dbs && ndb > 0, -1);

    for (i = 0;  i < ndb;  i++) {
        db  = dbs + i;
        ftb = db->functbl;

        if (ftb->create_table_trigger(callback, user_data) < 0) {

            for (i--;  i >= 0;  i--) {
                db  = dbs + i;
                ftb = db->functbl;

                ftb->drop_table_trigger(callback, user_data);
            }

            return -1;
        }
    }

    return 0;
}
开发者ID:01org,项目名称:murphy,代码行数:28,代码来源:mqi.c


示例2: HANDLE_USEID

void *mdb_handle_get_data(mdb_handle_map_t *hmap, mdb_handle_t h)
{
    uint32_t          useid = HANDLE_USEID(h);
    int               index = HANDLE_INDEX(h);
    indextbl_t       *indextbl;
    indextbl_entry_t *entry;

    MDB_CHECKARG(hmap && h != MDB_HANDLE_INVALID, NULL);

    indextbl = &hmap->indextbl;

    if (index >= indextbl->nentry) {
        errno = EKEYREJECTED;
        return NULL;
    }

    entry = indextbl->entries + index;

    if (entry->useid != useid) {
        errno = ENOANO;
        return NULL;
    }

    if (!entry->data)
        errno = ENODATA;

    return entry->data;
}
开发者ID:01org,项目名称:murphy,代码行数:28,代码来源:handle.c


示例3: MDB_CHECKARG

static void *index_realloc(indextbl_t *indextbl,
                           uint32_t    useid,
                           int         index,
                           void       *data)
{
    indextbl_entry_t *entry;
    void *old_data;

    MDB_CHECKARG(indextbl, NULL);

    if (index < 0 || index >= indextbl->nentry) {
        errno = EKEYREJECTED;
        return NULL;
    }

    entry = indextbl->entries + index;

    if (entry->useid != useid) {
        errno = ENOKEY;
        return NULL;
    }

    if (!(old_data = entry->data)) {
        errno = ENOENT;
        return NULL;
    }


    entry->data = data;

    return old_data;
}
开发者ID:01org,项目名称:murphy,代码行数:32,代码来源:handle.c


示例4: mql_result_rows_get_floating

double mql_result_rows_get_floating(mql_result_t *r, int colidx, int rowidx)
{
    result_rows_t *rslt = (result_rows_t *)r;
    void *addr;
    double v = 0;

    MDB_CHECKARG(rslt && rslt->type == mql_result_rows &&
                 colidx >= 0 && colidx < rslt->ncol &&
                 rowidx >= 0 && rowidx < rslt->nrow, 0.0);

    if ((addr = get_column_address(rslt, colidx, rowidx))) {
        switch (get_column_type(rslt, colidx)) {
        case mqi_varchar:
            v = strtod(*(char **)addr, NULL);
            break;
        case mqi_integer:
            v = *(int32_t *)addr;
            break;
        case mqi_unsignd:
            v = *(uint32_t *)addr;
            break;
        case mqi_floating:
            v = *(double *)addr;
            break;
        default:
            v = 0;
            break;
        }
    }

    return v;
}
开发者ID:jeeb,项目名称:murphy,代码行数:32,代码来源:result.c


示例5: db_register

static int db_register(const char       *engine,
                       uint32_t          flags,
                       mqi_db_functbl_t *functbl)
{
    mqi_db_t *db;
    int i;

    MDB_CHECKARG(engine && engine[0] && functbl, -1);
    MDB_PREREQUISITE(dbs, -1);

    if (ndb + 1 >= MAX_DB) {
        errno = EOVERFLOW;
        return -1;
    }

    for (i = 0; i < ndb;  i++) {
        if (!strcmp(engine, dbs[i].engine)) {
            errno = EEXIST;
            return -1;
        }
    }

    db = dbs + ndb++;

    db->engine  = strdup(engine);
    db->flags   = flags;
    db->functbl = functbl;

    return 0;
}
开发者ID:01org,项目名称:murphy,代码行数:30,代码来源:mqi.c


示例6: mdb_index_print

int mdb_index_print(mdb_table_t *tbl, char *buf, int len)
{
#define PRINT(args...)  if (e > p) p += snprintf(p, e-p, args)
    mdb_index_t *ix;
    const char  *sep;
    char        *p, *e;
    int          i;

    MDB_CHECKARG(tbl && buf && len > 0, 0);

    ix = &tbl->index;

    MDB_PREREQUISITE(MDB_INDEX_DEFINED(ix), 0);

    e = (p = buf) + len;

    PRINT("index columns: ");

    for (i = 0, sep = "";   i < ix->ncolumn;   i++, sep = ",")
        PRINT("%s%02d", sep, ix->columns[i]);

    PRINT("\n    type    offset length\n    ---------------------"
          "\n    %-7s   %4d   %4d\n",
          mqi_data_type_str(ix->type), ix->offset, ix->length);

    return p - buf;

#undef PRINT
}
开发者ID:klihub,项目名称:murphy,代码行数:29,代码来源:index.c


示例7: mdb_index_delete

int mdb_index_delete(mdb_table_t *tbl, mdb_row_t *row)
{
    mdb_index_t    *ix;
    int             lgh;
    void           *key;
    mdb_hash_t     *hash;
    mdb_sequence_t *seq;

    MDB_CHECKARG(tbl && row, -1);

    ix = &tbl->index;

    if (!MDB_INDEX_DEFINED(ix))
        return 0;

    hash = ix->hash;
    seq  = ix->sequence;
    lgh  = ix->length;
    key  = (void *)row->data + ix->offset;

    if (mdb_hash_delete(hash, lgh,key)    != row ||
        mdb_sequence_delete(seq, lgh,key) != row)
    {
        errno = EIO;
        return -1;
    }

    return 0;
}
开发者ID:klihub,项目名称:murphy,代码行数:29,代码来源:index.c


示例8: mqi_drop_table

int mqi_drop_table(mqi_handle_t h)
{
    mqi_table_t      *tbl;
    mqi_db_functbl_t *ftb;
    char             *name;
    void             *data;
    void             *cursor;
    int               sts;

    MDB_CHECKARG(h != MDB_HANDLE_INVALID, -1);
    MDB_PREREQUISITE(dbs && ndb > 0, -1);

    if (!(tbl = mdb_handle_delete(table_handle, h)))
        return -1;

    ftb = tbl->db->functbl;

    MDB_HASH_TABLE_FOR_EACH_WITH_KEY_SAFE(table_name_hash, data,name, cursor) {
        if ((mqi_handle_t)(data - NULL) == h) {
            mdb_hash_delete(table_name_hash, 0,name);
            sts = ftb->drop_table(tbl->handle);
            free(name);
            free(tbl);
            return sts;
        }
    }

    return -1;
}
开发者ID:01org,项目名称:murphy,代码行数:29,代码来源:mqi.c


示例9: mqi_rollback_transaction

int mqi_rollback_transaction(mqi_handle_t h)
{
    uint32_t           depth = TX_DEPTH(h);
    uint32_t           useid = TX_USEID(h);
    mqi_transaction_t *tx;
    mqi_db_t          *db;
    mqi_db_functbl_t  *ftb;
    int                err;
    int                i;

    MDB_CHECKARG(h != MQI_HANDLE_INVALID && depth < MQI_TXDEPTH_MAX, -1);
    MDB_PREREQUISITE(dbs && ndb > 0, -1);
    MDB_ASSERT(txdepth > 0 && depth == (uint32_t)txdepth - 1, EBADSLT, -1);

    tx = txstack + depth;

    MDB_ASSERT(tx->useid == useid, EBADSLT, -1);

    for (i = 0, err = 0;  i < ndb;  i++) {
        db  = dbs + i;
        ftb = db->functbl;

        if (ftb->rollback_transaction(tx->txid[i]) < 0)
            err = -1;
    }

    txdepth--;

    return err;
}
开发者ID:01org,项目名称:murphy,代码行数:30,代码来源:mqi.c


示例10: mql_result_list_get_floating

double mql_result_list_get_floating(mql_result_t *r, int idx)
{
    result_list_t *rslt = (result_list_t *)r;
    double v = 0;

    MDB_CHECKARG(rslt && rslt->type == mql_result_list &&
                 idx >= 0 && idx < rslt->length, 0);

    switch (rslt->value.type) {
    case mqi_varchar:
        v = strtod(rslt->value.v.varchar[idx], NULL);
        break;
    case mqi_integer:
        v = rslt->value.v.integer[idx];
        break;
    case mqi_unsignd:
        v = rslt->value.v.unsignd[idx];
        break;
    case mqi_floating:
        v = rslt->value.v.floating[idx];
        break;
    default:
        v = 0;
        break;
    }

    return v;
}
开发者ID:jeeb,项目名称:murphy,代码行数:28,代码来源:result.c


示例11: MDB_CHECKARG

mql_result_t *mql_result_string_create_table_change(mqi_event_type_t    event,
        const char         *table)
{
#define EVENT   0
#define TABLE   1
#define FLDS    2

    static const char *hstr[FLDS]  = {" event", "table"};
    static int         hlen[FLDS]  = {    6   ,    5   };

    result_string_t *rslt;

    int              len[FLDS];
    const char      *cstr[FLDS];
    int              cw[FLDS];
    int              linlen;
    char            *p;
    int              i;

    MDB_CHECKARG((event == mqi_table_created || event == mqi_table_dropped) &&
                 table, NULL);

    cstr[EVENT] = (event == mqi_table_created) ?
                  "'table created'" : "'table dropped'";
    cstr[TABLE] = table;

    for (i = 0;  i < FLDS;  i++)
        len[i] = strlen(cstr[i]);

    for (linlen = (FLDS-1) * 2 + 1,  i = 0;   i < FLDS;   i++)
        linlen += (cw[i] = len[i] > hlen[i] ?  len[i] : hlen[i]);


    if (!(rslt = calloc(1, sizeof(result_string_t) + (linlen*3 + 1)))) {
        errno = ENOMEM;
        return NULL;
    }

    p = rslt->string;

    for (i = 0;  i < FLDS;  i++)
        p += sprintf(p, "%-*s%s", cw[i],  hstr[i], i == FLDS-1 ? "\n" : "  ");

    memset(p, '-', linlen-1);
    p[linlen-1] = '\n';
    p += linlen;

    for (i = 0;  i < FLDS;  i++)
        p += sprintf(p, "%-*s%s", cw[i], cstr[i], i == FLDS-1 ? "\n" : "  ");

    rslt->type = mql_result_string;
    rslt->length = p - rslt->string;

    return (mql_result_t *)rslt;

#undef FLDS
#undef TABLE
#undef EVENT
}
开发者ID:jeeb,项目名称:murphy,代码行数:59,代码来源:result.c


示例12: mdb_sequence_add

int mdb_sequence_add(mdb_sequence_t *seq, int klen, void *key, void *data)
{
    sequence_entry_t *entry;
    int               nentry;
    size_t            old_length;
    size_t            length;
    int               cmp;
    int               min, max, i;

    MDB_CHECKARG(seq && key && data, -1);

    nentry = seq->nentry++;

    if ((nentry + 1) > seq->size) {
        old_length = sizeof(sequence_entry_t) * seq->size;
        seq->size += seq->alloc;
        length = sizeof(sequence_entry_t) * seq->size;

        if (!(seq->entries = realloc(seq->entries, length))) {
            seq->nentry = 0;
            errno = ENOMEM;
            return -1;
        }

        memset(seq->entries + old_length, 0, length - old_length);
    }

    for (min = 0,  i = (max = nentry)/2;   ;    i = (min+max)/2) {
        if (!(cmp = seq->scomp(klen, key, seq->entries[i].key)))
            break;

        if (i == min) {
            if (cmp > 0)
                i = max;
            break;
        }

        if (cmp < 0)
            max = i;
        else
            min = i;
    }

    entry = seq->entries + i;

    if (i < nentry) {
        memmove(entry+1, entry, sizeof(sequence_entry_t) * (nentry - i));
    }

    entry->key  = key;
    entry->data = data;

#ifdef SEQUENCE_STATISTICS
    if (seq->nentry > seq->max_entry)
        seq->max_entry = seq->nentry;
#endif

    return 0;
}
开发者ID:sanyaade-mobiledev,项目名称:murphy,代码行数:59,代码来源:sequence.c


示例13: mql_result_columns_get_column_count

int mql_result_columns_get_column_count(mql_result_t *r)
{
    result_columns_t *rslt = (result_columns_t *)r;

    MDB_CHECKARG(rslt && rslt->type == mql_result_columns, -1);

    return rslt->ncol;
}
开发者ID:jeeb,项目名称:murphy,代码行数:8,代码来源:result.c


示例14: mql_result_rows_get_row_count

int mql_result_rows_get_row_count(mql_result_t *r)
{
    result_rows_t *rslt = (result_rows_t *)r;

    MDB_CHECKARG(rslt && rslt->type == mql_result_rows, -1);

    return rslt->nrow;
}
开发者ID:jeeb,项目名称:murphy,代码行数:8,代码来源:result.c


示例15: mql_result_list_get_length

int mql_result_list_get_length(mql_result_t *r)
{
    result_list_t *rslt = (result_list_t *)r;

    MDB_CHECKARG(rslt && rslt->type == mql_result_list, -1);

    return rslt->length;
}
开发者ID:jeeb,项目名称:murphy,代码行数:8,代码来源:result.c


示例16: mdb_sequence_table_destroy

int mdb_sequence_table_destroy(mdb_sequence_t *seq)
{
    MDB_CHECKARG(seq, -1);

    free(seq->entries);
    free(seq);

    return 0;
}
开发者ID:sanyaade-mobiledev,项目名称:murphy,代码行数:9,代码来源:sequence.c


示例17: mql_result_rows_get_row_column_type

mqi_data_type_t mql_result_rows_get_row_column_type(mql_result_t *r, int colidx)
{
    result_rows_t *rslt = (result_rows_t *)r;

    MDB_CHECKARG(rslt && rslt->type == mql_result_rows &&
                 rslt->ncol > colidx, -1);

    return rslt->cols[colidx].type;
}
开发者ID:jeeb,项目名称:murphy,代码行数:9,代码来源:result.c


示例18: mql_result_rows_get_row_column_index

int mql_result_rows_get_row_column_index(mql_result_t *r, int colidx)
{
    result_rows_t *rslt = (result_rows_t *)r;

    MDB_CHECKARG(rslt && rslt->type == mql_result_rows &&
                 rslt->ncol > colidx, -1);

    return rslt->cols[colidx].cindex;
}
开发者ID:01org,项目名称:murphy,代码行数:9,代码来源:result.c


示例19: mql_result_columns_get_flags

uint32_t mql_result_columns_get_flags(mql_result_t *r, int colidx)
{
    result_columns_t *rslt = (result_columns_t *)r;

    MDB_CHECKARG(rslt && rslt->type == mql_result_columns &&
                 colidx >= 0 && colidx < rslt->ncol, -1);

    return rslt->cols[colidx].flags;
}
开发者ID:jeeb,项目名称:murphy,代码行数:9,代码来源:result.c


示例20: mql_result_columns_get_length

int mql_result_columns_get_length(mql_result_t *r, int colidx)
{
    result_columns_t *rslt = (result_columns_t *)r;

    MDB_CHECKARG(rslt && rslt->type == mql_result_columns &&
                 colidx >= 0 && colidx < rslt->ncol, -1);

    return rslt->cols[colidx].length;
}
开发者ID:jeeb,项目名称:murphy,代码行数:9,代码来源:result.c



注:本文中的MDB_CHECKARG函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ MDDI_MSG_ERR函数代码示例发布时间:2022-05-30
下一篇:
C++ MDB函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap