Esempio n. 1
0
int main()
{
	Welcome();
	string sql;			//sql statement
	string line;        //input line
	size_t end;         //end pos
	Interpreter BeetleInterpreter;

	while (true)
	{
		cout << endl << "BeetleDB> ";
		getline(cin, line);
		
		sql = string(line);
		if (sql == "") { continue; } /* Only is an empty input line */

		boost::algorithm::trim(sql);  /* remove blank ahead or behind of the sql */

		if (sql.compare(0,4,"exit") == 0 || sql.compare(0,4,"quit") == 0 || sql.compare(0,2,"\\q") == 0 || sql.compare(0,2,"\\e") == 0)
		{
			BeetleInterpreter.ExecSQL("quit");
			break;
		}

		while ((end = sql.find(";")) == string::npos) /* not end */
		{
			cout <<"       -> ";
			getline(cin, line);
			if (line == "") { continue; } /* Only is an empty input line */
			sql += "\n" + string(line);
		}
		boost::timer ter;
		BeetleInterpreter.ExecSQL(sql);  /* Execute sql statement */
		cout << "(" << ter.elapsed() << " sec)" << endl;
	}
	system("pause");
	return 0;
}