时间:2021-07-01 10:21:17 帮助过:35人阅读
相关类部分代码2:
switch (nType) { case FIELD_TYPE_TINY: { mI64Val = pszValue ? atol(pszValue) : 0; memcpy(&m_arrRowBuff[m_nBuffBegin], &mI64Val, 1); m_nBuffBegin += 1; } break; case FIELD_TYPE_SHORT: { mI64Val = pszValue ? atol(pszValue) : 0; memcpy(&m_arrRowBuff[m_nBuffBegin], &mI64Val, 2); m_nBuffBegin += 2; } break; case FIELD_TYPE_LONG: { mI64Val = pszValue ? atol(pszValue) : 0; memcpy(&m_arrRowBuff[m_nBuffBegin], &mI64Val, 4); m_nBuffBegin += 4; } break; case FIELD_TYPE_FLOAT: { mF64Val = pszValue ? atof(pszValue) : 0; memcpy(&m_arrRowBuff[m_nBuffBegin], &mF64Val, 4); m_nBuffBegin += 4; } break; case FIELD_TYPE_LONGLONG: { mI64Val = pszValue ? atol(pszValue) : 0; memcpy(&m_arrRowBuff[m_nBuffBegin], &mI64Val, 8); m_nBuffBegin += 8; } break; case FIELD_TYPE_DOUBLE: { mF64Val = pszValue ? atof(pszValue) : 0; memcpy(&m_arrRowBuff[m_nBuffBegin], &mF64Val, 8); m_nBuffBegin += 8; } break; case FIELD_TYPE_STRING:// char case FIELD_TYPE_VAR_STRING:// var_char { memcpy(&m_arrRowBuff[m_nBuffBegin], pszValue, nLen / 3); // mysql char 定义大小会按最大长底去计算长度,这里限制按字节大小去截断 m_nBuffBegin += nLen / 3; } break; case MYSQL_TYPE_TINY_BLOB: case MYSQL_TYPE_MEDIUM_BLOB: case MYSQL_TYPE_LONG_BLOB: case MYSQL_TYPE_BLOB: { memcpy(&m_arrRowBuff[m_nBuffBegin], pszValue, nLen); m_nBuffBegin += nLen; } break;
目前这个DyNetMysql.dll还不完善,如果是直接select 则可以创建结构体与它对应则可直接转结构体,如果是其它如update,delete乖等,则建议设置不使用回调或使用存储过程。
测试代码中也用到了最近封装一个异步Socket的dll,如果大家感兴趣,请留言和推荐吧,我才会有动力跟园友一起分享!如果有问题,可以留言或qq296464231问我
项目源码下载
分享封装好的异步Mysql动态的库(DyNetMysql.dll) + 项目源码
标签: