Click here to Skip to main content
11,922,641 members (57,790 online)
Click here to Skip to main content
Articles » Database » Database » General » Downloads


35 bookmarked

PostgreSQL/libpqxx Class Generator

, 18 Aug 2006
Automated generation of PostgreSQL data transfer classes.
#ifndef __ATLCURR_H__
#define __ATLCURR_H__

#pragma once

namespace ATL

class COleCurrency
	// Constructors

	COleCurrency(CURRENCY cySrc);
	COleCurrency(const COleCurrency& curSrc);
	COleCurrency(const VARIANT& varSrc);
	COleCurrency(long nUnits, long nFractionalUnits);

	// Attributes
	enum CurrencyStatus
		valid = 0,
		invalid = 1,    // Invalid currency (overflow, div 0, etc.)
		null = 2,       // Literally has no value

	CURRENCY m_cur;
	CurrencyStatus m_status;
	static const COleCurrency zero;

	void SetStatus(CurrencyStatus status);
	CurrencyStatus GetStatus() const;

	// Operations
	const COleCurrency& operator=(CURRENCY cySrc);
	const COleCurrency& operator=(const COleCurrency& curSrc);
	const COleCurrency& operator=(const VARIANT& varSrc);

	BOOL operator==(const COleCurrency& cur) const;
	BOOL operator!=(const COleCurrency& cur) const;
	BOOL operator<(const COleCurrency& cur) const;
	BOOL operator>(const COleCurrency& cur) const;
	BOOL operator<=(const COleCurrency& cur) const;
	BOOL operator>=(const COleCurrency& cur) const;

	// Currency math
	COleCurrency operator+(const COleCurrency& cur) const;
	COleCurrency operator-(const COleCurrency& cur) const;
	const COleCurrency& operator+=(const COleCurrency& cur);
	const COleCurrency& operator-=(const COleCurrency& cur);
	COleCurrency operator-() const;

	COleCurrency operator*(long nOperand) const;
	COleCurrency operator/(long nOperand) const;
	const COleCurrency& operator*=(long nOperand);
	const COleCurrency& operator/=(long nOperand);

	operator CURRENCY() const;

	// Currency definition
	void SetCurrency(long nUnits, long nFractionalUnits);
	BOOL ParseCurrency(LPCTSTR lpszCurrency, DWORD dwFlags = 0,

	// formatting
	CString Format(DWORD dwFlags = 0, LCID lcid = LANG_USER_DEFAULT) const;
	CString Format(LPCTSTR lpszMask) const;
inline COleCurrency::COleCurrency()
	m_cur.Hi = 0;
	m_cur.Lo = 0; 
inline COleCurrency::COleCurrency(CURRENCY cySrc)
	m_cur = cySrc;
inline COleCurrency::COleCurrency(const COleCurrency& curSrc)
	m_cur = curSrc.m_cur;
	m_status = curSrc.m_status;
inline COleCurrency::COleCurrency(const VARIANT& varSrc)
	*this = varSrc;
inline COleCurrency::CurrencyStatus COleCurrency::GetStatus() const
	return m_status;
inline void COleCurrency::SetStatus(CurrencyStatus status)
	m_status = status;
inline const COleCurrency& COleCurrency::operator+=(const COleCurrency& cur)
	*this = *this + cur;
	return *this;
inline const COleCurrency& COleCurrency::operator-=(const COleCurrency& cur)
	*this = *this - cur;
	return *this;
inline const COleCurrency& COleCurrency::operator*=(long nOperand)
	*this = *this * nOperand;
	return *this;
inline const COleCurrency& COleCurrency::operator/=(long nOperand)
	*this = *this / nOperand;
	return *this;
inline BOOL COleCurrency::operator==(const COleCurrency& cur) const
	return (m_status == cur.m_status
		&& m_cur.Hi == cur.m_cur.Hi
		&& m_cur.Lo == cur.m_cur.Lo);
inline BOOL COleCurrency::operator!=(const COleCurrency& cur) const
	return(m_status != cur.m_status
		|| m_cur.Hi != cur.m_cur.Hi
		|| m_cur.Lo != cur.m_cur.Lo);
inline COleCurrency::operator CURRENCY() const
	return m_cur;

}	// namespace ATL

#endif // __ATLCURR_H__

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.


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


About the Author

Australia Australia
No Biography provided

You may also be interested in...

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