Skip to content
Snippets Groups Projects
user avatar
authored
user avatar
Name Last commit Last update
pkg
src
.gitlab-ci.yml
.hgignore
.hgsigs
.hgtags
CMakeLists.txt
CONTRIBUTING.md
COPYING
CREDITS
ChangeLog
INSTALL
README
********************************************************************************
***  This file is part of Pecunia.                                           ***
***                                                                          ***
***  Copyright (C) 2017, 2018, 2019, 2020, 2021, 2023, 2024                  ***
***  John Schneiderman <Licencing _AT_ Schneiderman _DOT_ me>                ***
***                                                                          ***
***  This program is free software: you can redistribute it and/or modify it ***
***  under the terms of the GNU Lesser General Public License License as     ***
***  published by the Free Software Foundation, either version 3 of the      ***
***  License, or (at your option) any later version.                         ***
***                                                                          ***
***  This program is distributed in the hope that it will be useful, but     ***
***  WITHOUT ANY WARRANTY; without even the implied warranty of              ***
***  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                    ***
***  See the GNU Lesser General Public License License for more details.     ***
***                                                                          ***
***  You should have received a copy of the GNU Lesser General Public License***
***  along with this program. If not, see <http://www.gnu.org/licenses/>.    ***
********************************************************************************

                              DESCRIPTION
Pecunia is a C++ currency library using the ISO-4217 standard. Its three priorities are:
    0) Safe to use, e.g. prevent common money errors from happening.
    1) Simple to use, e.g. reading the code should be clear in its purpose.
    2) Efficient in speed, e.g. adding two of the currencies should be as near to a raw, weak type
         like float or int as possible.
The order of priorities are listed in the order of importance.

Sites:
  * Main website: http://pecunia.schneiderman.me

  * Development website: https://foss.heptapod.net/JohnMS/pecunia

                              BUILD ENVIRONMENT
Pecunia is mainly developed on Mageia and Fedora using just the standard development libraries,
KDE, and QT. It is also tested on Debian, Fedora, and Microsoft Windows.

                              DIRECTORY MAP
All the source code is listed in the src directory. Installation instructions can be found in
the INSTALL file. For a listing of all the contributors to Pecunia you can find that
information in the CREDITS file. All the current news can be be found on the main website.

                              INSTRUCTIONS
Once compiled you can link it into your projects and do some of the examples below.


Add Two Currencies:
     Money pop{Currency::USD, 1, 25u};
     Money candy{Currency::USD, 0, 75u};
     Money sum{pop + candy}; // Sum now holds 2 USD.


Add Two Different Currencies:
     setUpCurrency(&exchangeRates); // The exchangeRates function is user supplied.
     // ...
     Money account1{Currency::USD, 1, 25u};
     Money account2{Currency::PLN, 0, 75u};
     Money sum{account1 + account2};
     // The sum holds 1.42 USD when the exchangeRates function returns the rate of 1 PLN = 0.23 USD.
     // This is because addition is left associative and will use the currency of the "USD" object.


Add Two Different Currencies & Store In a Third:
     setUpCurrency(&exchangeRates);
     // ...
     Money account1{Currency::USD, 1, 25u};
     Money account2{Currency::PLN, 0, 75u};
     Money account3{Currency::EUR};
     account3 = account1 + account2;
     // The account3 holds 1.30 EUR when the exchangeRates function returns the rate of
     // 1 EUR = 0.92 USD. This is because addition is left associative and will use the currency of
     // the "USD" object. The sum is then converted and stored into the "EUR" as the assignment
     // operator is left associative.