Click here to Skip to main content
15,892,005 members
Articles / Web Development / HTML

A C++ Embedded Web Server

Rate me:
Please Sign up or sign in to vote.
4.76/5 (47 votes)
23 Jun 2014BSD7 min read 451.1K   8.5K   209  
Give a C++ application its own web page
/*
  SQLiteDatabase.h - CSQLiteDatabase interface, a wrapper for the SQLite database
*/
#pragma once

#include "sqlite3.h"

#include <string>
using std::string;
using std::wstring;

#include <vector>
using std::vector;

/// Access to SQLite databases
class CSQLiteDatabase
{
public:

/// the name of the file used to store the database on disk
	wstring myDBFName;

/// the number of rows returned by the last query on this database
	int myRowCount;				

/// the index number of the last row added
	int myLastID;		

/// the values returned by the last query
	vector<string> myRows;
	vector<wstring> myRows16;

/// if not null, points to last error message
	char * myError;

	CSQLiteDatabase(const wchar_t* dbfname );		// constructor
	~CSQLiteDatabase(void);

/// Query - apply SQL query ( null terminated character string ) to database 
	int Query( const char* szQ ) { return Query( string( szQ ) ); }

///  Query - apply SQL query ( string ) to database.
	int Query( string & sQ );

/// Query - apply SQL query ( unicode CString ) to database
	int Query16( wstring const & q );

///  Enable speed optimization ( synchronous off ).
	void setFast();

protected:

	void Open();
	void Close();

/// sqlite's pointer to the database
	sqlite3 *db;						


private:


	static int RowCount;			// the rows returned by current query on any database

	// callback function used by SQLite each time it returns one row
	static int callback(void *myRows, int argc, char **argv, char **azColName);

};
/**************************************************************************

//   Designed and coded by James Bremner, Raven's Point Consulting,
//   james@ravenspoint.com

  This file is under cvs version control

  If it has been released, the release name will be here: $Name: tip $

  Below is more detailed information describing the precise version

  $Header: C:\Documents and Settings\james\My Documents\code\webem\kenai/src/sqlite/sqlitedatabase.h,v 380e7e273298 2008/09/09 21:28:57 james $

*/

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The BSD License


Written By
Founder Raven's Point Consulting
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions