Click here to Skip to main content
15,891,423 members
Articles / Database Development / SQL Server

A scripted SQL query generation framework with IDE: SQLpp (v1.4)

Rate me:
Please Sign up or sign in to vote.
4.98/5 (47 votes)
12 Sep 200311 min read 413.1K   5.4K   133  
A helper framework for generation of SQL queries in C++ and Lua
#include <sqlpp/expressions/numeric_constant.hpp>

namespace sqlpp{
namespace expressions{

	integer_constant::integer_constant(
		int_type i_
		)
	:m_i(i_){};

	string_type integer_constant::get_type_string() const	{	return "INTEGER";};
	std::ostream& integer_constant::get_expression( std::ostream& out_
		, adaptors::database_adaptor_shared_ptr adaptor_) const		
	{
		return out_<<m_i;
	};
integer_constant_shared_ptr to_expression( int i_)
{
	return integer_constant_shared_ptr(
		new integer_constant( i_ ) 
		);
}

	float_constant::float_constant(
		float_type f_
		)
	: m_f(f_)
	{};

	string_type float_constant::get_type_string() const	{	return "FLOAT";};
	std::ostream& float_constant::get_expression( std::ostream& out_ 
		, adaptors::database_adaptor_shared_ptr adaptor_) const		
	{
		return out_<<m_f;
	};

float_constant_shared_ptr to_expression( float f_)
{
	return to_expression( static_cast<double>( f_ ) );
}
float_constant_shared_ptr to_expression( double d_)
{
	return float_constant_shared_ptr(
		new float_constant( d_ ) 
		);
}

/*
class money_constant :
	public numerical_constant
{
public:
	typedef long body_type;
	typedef unsigned long decimal_type;
	money_constant(
		long body_,
		decimal_type decimal_,
		string_const_reference currency_
		)
	: m_body(body_), m_decimal(decimal_), m_currency(currency_)
	{};

	virtual string_type get_type_string() const	{	return "MONEY";};
	virtual std::ostream& get_expression( std::ostream& out_ ) const		
	{
		out_<<m_currency
		   <<m_body;
		if (m_decimal.empty())
			out_<<"."<<m_decimal;

		return out_;
	};
};
typedef boost::shared_ptr< money_constant > money_constant_shared_ptr;


class unique_identifier_constant :
	public constant_expression
{
public:
	typedef string_type guid_type;
	explicit unique_identifier_constant(
		guid_type guid_
		)
		: m_guid(guid_)
	{};

	virtual string_type get_type_string() const	{	return "GUID";};
	virtual std::ostream& get_expression( std::ostream& out_ ) const		
	{
		return out_<<to_sql_string(m_guid);
	};
};
typedef boost::shared_ptr< unique_identifier_constant > unique_identifier_constant_shared_ptr;
*/

}; // expressions
};//sqlpp

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Engineer
United States United States
Jonathan de Halleux is Civil Engineer in Applied Mathematics. He finished his PhD in 2004 in the rainy country of Belgium. After 2 years in the Common Language Runtime (i.e. .net), he is now working at Microsoft Research on Pex (http://research.microsoft.com/pex).

Comments and Discussions