Click here to Skip to main content
15,886,806 members
Articles / Database Development / SQL Server

PostgreSQL/libpqxx Class Generator

Rate me:
Please Sign up or sign in to vote.
4.87/5 (15 votes)
18 Aug 200627 min read 82.7K   1.9K   37  
Automated generation of PostgreSQL data transfer classes.
// $Id: articlesrs.h 2080 2006-08-18 01:53:19Z phil $
// articlesrs.h: Declaration of the CArticle and CArticlesRS classes

// Generated by pgpqgen 17/08/2006 4:02:29 PM

#pragma once

#include "pqxxTransfer.h"

namespace Database
{
	class CArticle
	{
	public:
		CArticle()
			: archived(false)
			, id(NULLINT)
			, numwords(NULLINT)
			, weight(NULLDBL)
		{
			submitted.SetStatus(COleDateTime::invalid);
		}

		bool operator==(const CArticle& other)
		{
			return archived == other.archived
				&& author == other.author
				&& content == other.content
				&& id == other.id
				&& numwords == other.numwords
				&& price == other.price
				&& submitted == other.submitted
				&& title == other.title
				&& weight == other.weight;
		}

	public:
		bool archived;
		std::string author;
		std::string content;
		int id;
		int numwords;
		COleCurrency price;
		COleDateTime submitted;
		std::string title;
		double weight;

	};

	class CArticlesRS
		: public CPqxxTransfer<CArticlesRS>
		, public CArticle
	{
		typedef CPqxxTransfer<CArticlesRS> baseClass;

	public:
		CArticlesRS() : baseClass("articles") { initColDescs(); }
		CArticlesRS(const pqxx::result::const_iterator& src) : baseClass("articles") { initColDescs(); xferValues(src); }

		static const std::string defaultQuery()
		{
			return "SELECT "
				"archived"
				", author"
				", content"
				", id"
				", numwords"
				", price"
				", submitted"
				", title"
				", weight"
				" FROM public.articles";
		}

		CArticlesRS& operator=(const CArticle& other)
		{
			initColDescs();

			archived = other.archived;
			author = other.author;
			content = other.content;
			numwords = other.numwords;
			price = other.price;
			submitted = other.submitted;
			title = other.title;
			weight = other.weight;

			return *this;
		}

		BEGIN_DB_MAP(CArticlesRS, 9)
			DB_BOOL_ENTRY(0, archived)
			DB_STRING_ENTRY(1, author)
			DB_STRING_ENTRY(2, content)
			DB_INT_INDEX(3, id)
			DB_INT_ENTRY(4, numwords)
			DB_CURR_ENTRY(5, price)
			DB_DATE_ENTRY(6, submitted)
			DB_STRING_ENTRY(7, title)
			DB_DOUBLE_ENTRY(8, weight)
		END_DB_MAP()
	};
}

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
Australia Australia
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions