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

C++ descriptor_table类代码示例

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

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



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

示例1: cli_close_fdb

int cli_close_fdb(int session)
{
    statement_desc *stmt, *next;
    session_desc* s = sessions.get(session);
    if (s == NULL) { 
        return cli_bad_descriptor;
    }
    cli_request req;
    req.length = sizeof(req);
    req.cmd = cli_cmd_close_session;
    req.pack();
    int result = cli_ok;
    if (!s->sock->write(&req, sizeof req)) { 
        result = cli_network_error;
    }
    delete s->sock;
    s->sock = NULL;     
    for (stmt = s->stmts; stmt != NULL; stmt = next) {  
        next = stmt->next;
        stmt->deallocate();
        statements.deallocate(stmt);
    }
    sessions.deallocate(s);
    return result;
}
开发者ID:jiajw0426,项目名称:easyscada,代码行数:25,代码来源:cli_fastdb.cpp


示例2: cli_insert_fdb

int cli_insert_fdb(int statement, cli_oid_t* oid)
{
    int rc = cli_send_columns_fdb(statement, cli_cmd_insert);
    if (rc == cli_ok) { 
        char buf[sizeof(cli_oid_t) + 8];
        statement_desc* s = statements.get(statement);
        if (!s->session->sock->read(buf, sizeof buf)) { 
            rc = cli_network_error;
        } else { 
            rc = unpack4(buf);
            s->prepared = true;
            s->oid = unpack_oid(buf + 8);
            if (oid != NULL) { 
                *oid = s->oid;
            }
           if (s->autoincrement) {
               int4 rowid = unpack4(buf + 4);
               for (column_binding* cb = s->columns; cb != NULL; cb = cb->next) {
                   if (cb->var_type == cli_autoincrement) {
                       *(int4*)cb->var_ptr = rowid;
                   }
               }
           }
        }
    }
    return rc;
}
开发者ID:jiajw0426,项目名称:easyscada,代码行数:27,代码来源:cli_fastdb.cpp


示例3: cli_array_column_ex_fdb

int cli_array_column_ex_fdb(int               statement,
                        char const*       column_name, 
                        int               var_type,
                        void*             var_ptr,
                        cli_column_set_ex set,
                        cli_column_get_ex get,
                        void*             user_data)
{
    statement_desc* s = statements.get(statement);
    if (s == NULL) { 
        return cli_bad_descriptor;
    }
    if (!((var_type >= cli_asciiz && var_type <= cli_array_of_string) 
          || (var_type >= cli_wstring && var_type <= cli_array_of_wstring))) 
    {
        return cli_unsupported_type;
    }
    s->prepared = false;
    column_binding* cb = new column_binding;
    int len = strlen(column_name) + 1;
    cb->name = new char[len];
    s->columns_len += len;
    cb->next = s->columns;
    s->columns = cb;
    s->n_columns += 1;
    strcpy(cb->name, column_name);
    cb->var_type = var_type;
    cb->var_len = NULL;
    cb->var_ptr = var_ptr;
    cb->set_fnc = set;
    cb->get_fnc = get;
    cb->user_data = user_data;
    return cli_ok;
}
开发者ID:jiajw0426,项目名称:easyscada,代码行数:34,代码来源:cli_fastdb.cpp


示例4: cli_parameter_fdb

int cli_parameter_fdb(int         statement,
                  char const* param_name, 
                  int         var_type,
                  void*       var_ptr)
{
    if (var_type != cli_rectangle 
        && var_type != cli_wstring
        && var_type != cli_pwstring
        && ((unsigned)var_type >= cli_array_of_oid || var_type == cli_decimal)) 
    {
        return cli_unsupported_type;
    }
    statement_desc* s = statements.get(statement);
    if (s == NULL) { 
        return cli_bad_descriptor;
    }
    s->prepared = false;
    for (parameter_binding* pb = s->params; pb != NULL; pb = pb->next) { 
        if (strcmp(pb->name, param_name) == 0) { 
            pb->var_ptr  = var_ptr;
            pb->var_type = var_type;
            return cli_ok;
        }
    }
    return cli_parameter_not_found;
}
开发者ID:jiajw0426,项目名称:easyscada,代码行数:26,代码来源:cli_fastdb.cpp


示例5: cli_alter_index_fdb

int cli_alter_index_fdb(int session, char const* tableName, char const* fieldName, int newFlags)
{
    session_desc* s = sessions.get(session);
    if (s == NULL) {
        return cli_bad_descriptor;
    }
    int size = sizeof(cli_request) + 1 + strlen(tableName)+strlen(fieldName)+2;
    dbSmallBuffer buf(size);
    cli_request* req = (cli_request*)buf.base();
    req->length  = size;
    req->cmd     = cli_cmd_alter_index;
    req->stmt_id = 0;
    char* dst = (char*)(req + 1);
    strcpy(dst, tableName);
    dst += strlen(dst) + 1;
    strcpy(dst, fieldName);
    dst += strlen(dst) + 1;
    *dst++ = newFlags;
    req->pack();
    if (!s->sock->write(buf, size)) {
        return cli_network_error;
    }
    int4 response;
    if (!s->sock->read(&response, sizeof response)) {
        return cli_network_error;
    }
    unpack4(response);
    return response;
}
开发者ID:jiajw0426,项目名称:easyscada,代码行数:29,代码来源:cli_fastdb.cpp


示例6: put_db_online_fdb

int put_db_online_fdb(int session, const char_t* filename)
{
    int4 response;

	session_desc* s = sessions.get(session);
    if (s == NULL) {
        return cli_bad_descriptor;
    }

	int len = sizeof(cli_request);

    dbSmallBuffer buf(len);
    cli_request* req = (cli_request*)buf.base();
    req->length = len;
    req->cmd    = cli_cmd_is_db_online;
    req->stmt_id = 0;
        
	req->pack();
    if (!s->sock->write(buf, len)) 
	{
		return cli_network_error;
    }
    	
    if (!s->sock->read(&response, sizeof response)) 
	{
		return cli_network_error;
    }
    unpack4(response);

	if(response == cli_database_is_offline)
	{
		int len = sizeof(cli_request) + (strlen(filename)+ 1)*sizeof(char_t);
		dbSmallBuffer buf(len);
		char_t* p = (char_t*)buf.base();
		cli_request* req = (cli_request*)p;
		req->length = len;
		req->cmd    = cli_cmd_put_db_online;
		req->stmt_id = 0;
		p += sizeof(cli_request);
		p = pack_str(p, filename);
    
		req->pack();
		if (!s->sock->write(buf, len)) 
		{
			return cli_network_error;
		}
    
		if (!s->sock->read(&response, sizeof response)) 
		{
			return cli_network_error;
		}
		unpack4(response);
	}

	return response;
}
开发者ID:jiajw0426,项目名称:easyscada,代码行数:56,代码来源:cli_fastdb.cpp


示例7: cli_update_table

static int cli_update_table(int cmd, int session, char const* tableName, int nColumns, 
                            cli_field_descriptor* columns)
{
    int i;
    session_desc* s = sessions.get(session);
    if (s == NULL) {
        return cli_bad_descriptor;
    }
    int size = sizeof(cli_request) + 4 + strlen(tableName)+1;
    for (i = 0; i < nColumns; i++) { 
        size += 2 + (strlen(columns[i].name)+3);
        if (columns[i].refTableName != NULL) { 
            size += strlen(columns[i].refTableName);
        }
        if (columns[i].inverseRefFieldName != NULL) { 
            size += strlen(columns[i].inverseRefFieldName);
        }
    }
    dbSmallBuffer buf(size);
    cli_request* req = (cli_request*)buf.base();
    req->length  = size;
    req->cmd     = cmd;
    req->stmt_id = 0;
    char* dst = (char*)(req + 1);
    strcpy(dst, tableName);
    dst += strlen(dst) + 1;
    *dst++ = (char)nColumns;
    for (i = 0; i < nColumns; i++) { 
        *dst++ = (char)columns[i].type;
        *dst++ = (char)columns[i].flags;
        strcpy(dst, columns[i].name);
        dst += strlen(dst) + 1;
        if (columns[i].refTableName != NULL) { 
            strcpy(dst, columns[i].refTableName);
            dst += strlen(dst) + 1;        
        } else { 
            *dst++ = 0;
        }
        if (columns[i].inverseRefFieldName != NULL) { 
            strcpy(dst, columns[i].inverseRefFieldName);
            dst += strlen(dst) + 1;
        } else { 
            *dst++ = 0;
        }
    }
    req->pack();
    if (!s->sock->write(buf, size)) {
        return cli_network_error;
    }
    int4 response;
    if (!s->sock->read(&response, sizeof response)) {
        return cli_network_error;
    }
    unpack4(response);
    return response;
}
开发者ID:jiajw0426,项目名称:easyscada,代码行数:56,代码来源:cli_fastdb.cpp


示例8: cli_open_fdb

END_FASTDB_NAMESPACE
USE_FASTDB_NAMESPACE

int cli_open_fdb(char const* server_url, 
             int         max_connect_attempts,
             int         reconnect_timeout_sec)
{
    socket_t* sock;
    int n_addresses = 1;
    char const* start = server_url;
    char const* end;
    while ((end = strchr(start, ',')) != NULL) { 
        start = end + 1;
        n_addresses += 1;
    }
    if (n_addresses == 1) { 
        sock = socket_t::connect(server_url,
                                 socket_t::sock_any_domain,
                                 max_connect_attempts,
                                 reconnect_timeout_sec);
    } else { 
        char** addresses = new char*[n_addresses];
        start = server_url;
        for (int i = 0; i < n_addresses; i++) { 
            end = strchr(start, ',');
            if (end == NULL) { 
                end = start + strlen(start);
            }
            int len = end - start;
            char* addr = new char[len+1];
            memcpy(addr, start, len);
            addr[len] = '\0';
            start = end + 1;
            addresses[i] = addr;
        }
        sock = replication_socket_t::connect((char const**)addresses,
                                             n_addresses, 
                                             max_connect_attempts,
                                             reconnect_timeout_sec);
        while (--n_addresses >= 0) { 
            delete[] addresses[n_addresses];
        }
        delete[] addresses;
    }
    if (!sock->is_ok()) { 
        delete sock;
        return cli_connection_refused;
    }
    session_desc* session = sessions.allocate();
    session->sock = sock;
    session->stmts = NULL;
    return session->id;
}
开发者ID:jiajw0426,项目名称:easyscada,代码行数:53,代码来源:cli_fastdb.cpp


示例9: cli_show_tables_fdb

int cli_show_tables_fdb(int session, cli_table_descriptor** tables)
{
    session_desc* s = sessions.get(session);
    if (s == NULL) {
        return cli_bad_descriptor;
    }
    cli_request req;
    req.length  = sizeof(cli_request);
    req.cmd     = cli_cmd_show_tables;
    req.stmt_id = 0;
    req.pack();
    if (!s->sock->write(&req, sizeof req)) {
        return cli_network_error;
    }
    int4 response[2];
    if (!s->sock->read(&response, sizeof response)) {
        return cli_network_error;
    }
    unpack4(response[0]);
    unpack4(response[1]);
    int len = response[0];
    int nTables = response[1];

	//01-11-09
	if(nTables > 10000)
	{
		return cli_network_error;		
	}

    if (nTables == -1) {
        return cli_table_not_found;
    }
    char* p = (char*)malloc(nTables*sizeof(cli_table_descriptor) + len);
    cli_table_descriptor* fp = (cli_table_descriptor*)p;
    p += nTables*sizeof(cli_table_descriptor);
    if (!s->sock->read(p, len)) {
        free(p);
        return cli_network_error;
    }
    *tables = fp;
    for (int i = nTables; --i >= 0; fp++) {
        fp->name = (char*)p;
        p += strlen((char*)p)+1;
    }
    return nTables;
}
开发者ID:jiajw0426,项目名称:easyscada,代码行数:46,代码来源:cli_fastdb.cpp


示例10: send_receive

static int send_receive(int statement, int cmd)
{
    statement_desc* s = statements.get(statement);
    if (s == NULL) { 
        return cli_bad_descriptor;
    }
    if (!s->prepared) { 
        return cli_not_fetched;
    }
    cli_request req;
    req.length = sizeof(req);
    req.cmd = cmd;
    req.stmt_id = statement;
    req.pack();
    int4 response = cli_ok;
    if (!s->session->sock->write(&req, sizeof req)) { 
        return cli_network_error;
    } 
    if (!s->session->sock->read(&response, sizeof response)) { 
        return cli_network_error;
    }
    unpack4(response);
    return response;
}
开发者ID:jiajw0426,项目名称:easyscada,代码行数:24,代码来源:cli_fastdb.cpp


示例11: cli_drop_table_fdb

int cli_drop_table_fdb(int session, char const* tableName)
{
    session_desc* s = sessions.get(session);
    if (s == NULL) {
        return cli_bad_descriptor;
    }
    int size = sizeof(cli_request) + strlen(tableName) + 1;
    dbSmallBuffer buf(size);
    cli_request* req = (cli_request*)buf.base();
    req->length  = size;
    req->cmd     = cli_cmd_drop_table;
    req->stmt_id = 0;
    strcpy((char*)(req + 1), tableName);
    req->pack();
    if (!s->sock->write(buf, size)) {
        return cli_network_error;
    }
    int4 response;
    if (!s->sock->read(&response, sizeof response)) {
        return cli_network_error;
    }
    unpack4(response);
    return response;
}
开发者ID:jiajw0426,项目名称:easyscada,代码行数:24,代码来源:cli_fastdb.cpp


示例12: cli_send_columns_fdb

static int cli_send_columns_fdb(int statement, int cmd)
{
    statement_desc* s = statements.get(statement);
    column_binding* cb;
    if (s == NULL) { 
        return cli_bad_descriptor;
    }
    long msg_size = sizeof(cli_request);
    if (cmd == cli_cmd_update) { 
        if (!s->prepared) { 
            return cli_not_fetched;
        }
        if (s->oid == 0) { 
            return cli_not_found;
        }
        if (s->updated) {
            return cli_already_updated;
        } 
        if (!s->for_update) { 
            return cli_not_update_mode;
        }
    } else { 
        if (!s->prepared) { 
            cmd = cli_cmd_prepare_and_insert;
            msg_size += 1 + s->stmt_len + s->n_columns + s->columns_len;
        }
    }
    s->autoincrement = false;
    for (cb = s->columns; cb != NULL; cb = cb->next) { 
        if (cb->get_fnc != NULL) { 
            cb->arr_ptr = cb->get_fnc(cb->var_type, cb->var_ptr, &cb->arr_len, 
                                      cb->name, statement, cb->user_data);
            int len = cb->arr_len;
            msg_size += 4;
            if (cb->var_type == cli_array_of_string) {
                char** p = (char**)cb->arr_ptr;
                while (--len >= 0) { 
                    msg_size += strlen(*p++) + 1;
                }
            } else if (cb->var_type == cli_array_of_wstring) {
                wchar_t** p = (wchar_t**)cb->arr_ptr;
                while (--len >= 0) { 
                    msg_size += (wcslen(*p++) + 1)*sizeof(wchar_t);
                }
            } else if (cb->var_type == cli_wstring || cb->var_type == cli_pwstring) {
                msg_size += len * sizeof(wchar_t);
            } else if (cb->var_type >= cli_array_of_oid) {
                msg_size += len * sizeof_type[cb->var_type - cli_array_of_oid];
            } else { 
                msg_size += len;
            }
        } else { 
            switch (cb->var_type) { 
              case cli_autoincrement:
                s->autoincrement = true;
                break;
              case cli_asciiz:
                msg_size += 4 + (strlen((char*)cb->var_ptr) + 1);
                break;
              case cli_pasciiz:
                msg_size += 4 + (strlen(*(char**)cb->var_ptr) + 1);
                break;
              case cli_wstring:
                msg_size += 4 + (wcslen((wchar_t*)cb->var_ptr) + 1)*sizeof(wchar_t);
                break;
              case cli_pwstring:
                msg_size += 4 + (wcslen(*(wchar_t**)cb->var_ptr) + 1)*sizeof(wchar_t);
                break;
              case cli_array_of_string:
              { 
                char** p = (char**)cb->var_ptr;
                int len;
                msg_size += 4;
                for (len = *cb->var_len; --len >= 0;) { 
                    msg_size += (strlen(*p++) + 1);
                }
                break;
              }
              case cli_array_of_wstring:
              { 
                wchar_t** p = (wchar_t**)cb->var_ptr;
                int len;
                msg_size += 4;
                for (len = *cb->var_len; --len >= 0;) { 
                    msg_size += (wcslen(*p++) + 1)*sizeof(wchar_t);
                }
                break;
              }
              default:
                if (cb->var_type >= cli_array_of_oid && cb->var_type < cli_array_of_string) {
                    msg_size += 4 + *cb->var_len * sizeof_type[cb->var_type-cli_array_of_oid];
                } else { 
                    msg_size += sizeof_type[cb->var_type];
                }
            }
        }
    }
    dbSmallBuffer buf(msg_size);
    char* p = buf;
    cli_request* req = (cli_request*)p;
//.........这里部分代码省略.........
开发者ID:jiajw0426,项目名称:easyscada,代码行数:101,代码来源:cli_fastdb.cpp


示例13: cli_get_fdb

static int cli_get_fdb(int statement, int cmd, cli_oid_t value = 0)
{
    statement_desc* s = statements.get(statement);
    if (s == NULL) { 
        return cli_bad_descriptor;
    }
    if (!s->prepared) { 
        return cli_not_fetched;
    }
    struct get_req { 
        cli_request req;
        cli_oid_t   value;
    } get;
    int length = sizeof(cli_request);
    if (cmd == cli_cmd_skip) { 
        length += 4;
        pack4((char*)(&get.req+1), (int)value);
    } else if (cmd == cli_cmd_seek) { 
        length += sizeof(cli_oid_t);
        pack_oid((char*)(&get.req+1), value);
    }
    get.req.length  = length;
    get.req.cmd     = cmd;
    get.req.stmt_id = statement;
    get.req.pack();
    if (!s->session->sock->write(&get.req, length)) { 
        return cli_network_error;
    }   
    int4 response;
    if (!s->session->sock->read(&response, sizeof response)) { 
        return cli_network_error;
    }
    unpack4(response);
    if (response <= 0) { 
        return response;
    }
    if (s->buf_size < (size_t)response-4) { 
        delete[] s->buf;
        s->buf_size = response-4 < DEFAULT_BUF_SIZE ? DEFAULT_BUF_SIZE : response-4;
        s->buf = new char[s->buf_size];
    }
    char* buf = s->buf;
    if (!s->session->sock->read(buf, response-4)) { 
        return cli_network_error;
    }
    char* p = buf;
    int result = cli_ok;
    if (cmd == cli_cmd_seek) { 
        s->oid = value;
        result = unpack_oid(p);
    } else { 
        s->oid = unpack_oid(p);
        if (s->oid == 0) { 
            return cli_not_found;
        }
    }
    p += sizeof(cli_oid_t);
    for (column_binding* cb = s->columns; cb != NULL; cb = cb->next) { 
        int type = *p++;
        if (cb->var_type == cli_any) { 
            cb->var_type = type;
        } else { 
            assert(cb->var_type == type);
        }
        if (cb->set_fnc != NULL) { 
            int len = unpack4(p);
            p += 4;
            char* dst = (char*)cb->set_fnc(cb->var_type, cb->var_ptr, len, 
                                           cb->name, statement, p, cb->user_data);
            if (dst == NULL) {
                continue;
            }
            if (cb->var_type == cli_array_of_string) { 
                char** s = (char**)dst;
                while (--len >= 0) {
                    *s++ = p;
                    p += strlen(p) + 1;
                }
            } else if (cb->var_type == cli_array_of_wstring) { 
                wchar_t** s = (wchar_t**)dst;
                while (--len >= 0) {
                    *s++ = (wchar_t*)p;
                    p += (wcslen((wchar_t*)p) + 1)*sizeof(wchar_t);
                }
            } else if (cb->var_type >= cli_array_of_oid && cb->var_type < cli_array_of_string) { 
                switch (sizeof_type[cb->var_type-cli_array_of_oid]) { 
                  case 2:                   
                    while (--len >= 0) { 
                        p = unpack2(dst, p);
                        dst += 2;
                    }
                    break;
                  case 4:
                    while (--len >= 0) { 
                        p = unpack4(dst, p);
                        dst += 4;
                    }
                    break;
                  case 8:
                    while (--len >= 0) { 
//.........这里部分代码省略.........
开发者ID:jiajw0426,项目名称:easyscada,代码行数:101,代码来源:cli_fastdb.cpp


示例14: cli_describe_fdb

int cli_describe_fdb(int session, char const* table, cli_field_descriptor** fields)
{
    int len = sizeof(cli_request) + strlen(table) + 1;
    dbSmallBuffer buf(len);
    cli_request* req = (cli_request*)buf.base();
    req->length = len;
    req->cmd    = cli_cmd_describe_table;
    req->stmt_id = 0;
    strcpy((char*)(req+1), table);
    session_desc* s = sessions.get(session);
    if (s == NULL) {
        return cli_bad_descriptor;
    }
    req->pack();
    if (!s->sock->write(buf, len)) {
        return cli_network_error;
    }
    int4 response[2];
    if (!s->sock->read(&response, sizeof response)) {
        return cli_network_error;
    }
    unpack4(response[0]);
    unpack4(response[1]);
    len = response[0];
    int nFields = response[1];
    if (nFields == -1) { 
        return cli_table_not_found;
    }

	if(nFields > 256)
	{
		return cli_network_error;
	}

    char* p = (char*)malloc(nFields*sizeof(cli_field_descriptor) + len);
    cli_field_descriptor* fp = (cli_field_descriptor*)p;
    p += nFields*sizeof(cli_field_descriptor);
    if (!s->sock->read(p, len)) {
        return cli_network_error;
    }
    *fields = fp;
    for (int i = nFields; --i >= 0; fp++) {
        fp->type = (enum cli_var_type)*p++;
        fp->flags = *p++ & 0xFF;
        fp->name = p;
        p += strlen(p) + 1;
        if (*p != 0) { 
            fp->refTableName = p;
        } else { 
            fp->refTableName = NULL;
        }
        p += strlen(p) + 1;
        if (*p != 0) { 
            fp->inverseRefFieldName = p;
        } else { 
            fp->inverseRefFieldName = NULL;
        }
        p += strlen(p) + 1;
    }
    return nFields;
}
开发者ID:jiajw0426,项目名称:easyscada,代码行数:61,代码来源:cli_fastdb.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ detail类代码示例发布时间:2022-05-31
下一篇:
C++ deque类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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