Here is another wrapper for the famous SQLite3 database engine. While there are several other wrappers available here at Code Project, I don't believe they support MFC/Unicode or have the results tested on a Pocket PC.
The wrapper source code is based on the SQLiteWrapper source produced by rene.nyffenegger@adp-gmbh.ch. I altered the original source while packaging it for use with Microsoft MFC. My primary objective in this exercise was to make the wrapper suitable for both MCBS and Unicode because Unicode is native to the Pocket PC. There are four key differences between this wrapper and the author's original source.
- First, all the instances of
std::string were converted to Microsoft's generic string pointers using LPCTSTR. This should be familiar to developer's accustomed to working with MFC. This also means that you should rely heavily on the Microsoft TEXT or _T macros for hard-coded character strings should you wish to maintain portability between the desktop and the Pocket PC.
- Second, I have changed the class
SQLiteStatement to CSqlStatement and SQLiteWrapper to CDbSQLite. This was primarily a matter of preference since most MFC developer's recognize Microsoft's conventions for the "Cx" nomenclature.
- Third, I removed exception handling from the wrapper. Windows CE does not support the traditional
try, catch and throw paradigm so you are basically on your own with respect to error handling.
- Finally, I have added the header SQLite3i.h with
typedefs to the various sqlite3.h functions. These type definitions are "internal" accessors to the sqlite3 functions conditionally utilizing either the UTF-8 or UTF-16 variation during compilation. For your entertainment, I incorporated a pragma in the header to inform you when you are compiling Unicode or MCBS.
(阅读次数:)