Click here to Skip to main content
Click here to Skip to main content
Articles » Database » Database » General » Downloads
 
Add your own
alternative version

PostgreSQL/libpqxx Class Generator

, 18 Aug 2006
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

Share

About the Author

_oti

Australia Australia
No Biography provided

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150327.1 | Last Updated 18 Aug 2006
Article Copyright 2005 by _oti
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid