How do I use MySQL C++ Connector for storing binary data?
2009-07-27 15:28
555 查看
http://stackoverflow.com/questions/1071120/how-do-i-use-mysql-c-connector-for-storing-binary-data
You have to subclass streambuf e.g. like this:
Then you can instantiate an istream object which uses a DataBuf as buffer, which itself uses your block of binary data. Supposing that binarySize specifies the size of your binary data in bytes (sizeof(char) should be one byte), you could do this like so:
That istream object you can now pass to setBlob().
Regards, Elrohir
You have to subclass streambuf e.g. like this:
class DataBuf : public streambuf { public: DataBuf(char * d, size_t s) { setg(d, d, d + s); } };
Then you can instantiate an istream object which uses a DataBuf as buffer, which itself uses your block of binary data. Supposing that binarySize specifies the size of your binary data in bytes (sizeof(char) should be one byte), you could do this like so:
DataBuf buffer((char*)address, binarySize); istream stream(&buffer);
That istream object you can now pass to setBlob().
Regards, Elrohir
相关文章推荐
- How to use the System Restore API to save and to restore system data in Visual C++
- How to use Connector to sync data between AX and CRM
- How to use data analysis for machine learning (example, part 1)
- How to use binary mode for stdin/stdout in VC
- Tip18:Don't use GridFS for small binary data
- How to use Microsoft Dynamics Connector to sync data between different crm organizations
- How to create a hex dump from binary data in C++
- How to save data in ASCII format in ADS for use in MATLAB
- MySQL Connector for C++ linux (ubuntu ) 安装
- C_C++随机数据生成(is how to use but not how it work)
- MySQL Connector/C++入门教程(上)
- How to use udev for Oracle ASM in Oracle Linux 5
- How to use "for/" batch command in Dos extention
- FTP 150 Opening BINARY mode data connection for MLSD 读取目录列表失败
- PHP + MySql + Stored Procedures, how do I get access an "out" value?
- 在CentOS里使用MySQL Connector/C++
- C++--How to configure Visual Studio for compiling drivers
- 【架构】How To Use HAProxy to Set Up MySQL Load Balancing
- 使用MySQL connector/C++链接MySQL数据库
- How to use the Erase Data and Disable Handheld command