/*---------------------------------------------------------------------------* Copyright (C) Nintendo. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. *---------------------------------------------------------------------------*/ #ifndef NN_EC_MONEY_H_ #define NN_EC_MONEY_H_ #include namespace nn { namespace ec { //! @addtogroup nn_ec_class //! @{ /*! @brief Class for handling money. */ class Money : public RootObject { public: /*! @brief Specifies the maximum length of the amount string. */ static const size_t AMOUNT_LENGTH_MAX = 43; /*! @brief Specifies the size of the amount string. */ static const size_t AMOUNT_SIZE = AMOUNT_LENGTH_MAX + 1; /*! @brief Specifies the maximum length of an unformatted amount string. */ static const size_t VALUE_LENGTH_MAX = 15; /*! @brief Specifies the size of an unformatted amount string. */ static const size_t VALUE_SIZE = VALUE_LENGTH_MAX + 1; /*! @brief Specifies the length of the currency code. */ static const size_t CURRENCY_LENGTH = 3; /*! @brief Specifies the size of the currency code. */ static const size_t CURRENCY_SIZE = CURRENCY_LENGTH + 1; /*! @brief Specifies the maximum digits of the integer part. */ static const size_t INTEGER_LENGTH_MAX = 10; /*! @brief Specifies the maximum digits of the fractional part. */ static const size_t DECIMAL_LENGTH_MAX = 2; /*! @brief Specifies the invalid amount string that is set when an incorrect amount is specified or an overflow occurs. */ static const char* INVALID_AMOUNT; // "##########.##" public: /*! @brief Instantiates an object. @param[in] pValue Specifies an unformatted amount string. @param[in] pCurrency Specifies the currency code. @param[in] pAmount Specifies the amount string. */ Money(const char* pValue = NULL, const char* pCurrency = NULL, const char* pAmount = NULL); /*! @brief Gets the unformatted amount string. @return Returns the unformatted amount string. */ const char* GetValue() const; /*! @brief Gets the currency code. @return Returns the currency code. */ const char* GetCurrency() const; /*! @brief Gets the amount string. The amount string is "##########.##" for @ref Money objects created using calculations or integer multiples before @ref Login. @n This is because there is no local information before @ref Login, so amount strings cannot be generated. @return Returns the amount string. */ const char* GetAmount() const; /*! @brief Determines whether the amount is valid. @return Returns true if the amount is valid, or false otherwise. */ bool IsValid() const; /*! @brief Determines whether the amount is 0. @return Returns true if the amount is 0, or false otherwise. */ bool IsZero() const; /*! @brief Adds the amounts in two Money objects. @param[in] money Specifies the Money to add. @return Returns a Money object. */ const Money operator+(const Money& money) const; /*! @brief Subtracts the amount in one Money object from the amount in another Money object. @param[in] money Specifies the Money to subtract. @return Returns a Money object. */ const Money operator-(const Money& money) const; /*! @brief Gets the amount multiplied by an integer. @param[in] quantity Specifies the quantity. @return Returns a Money object. */ const Money operator*(u32 quantity) const; /*! @brief Calculates the Money object quotient. This function returns 0 if the denominator is 0. @param[in] money The amount that will serve as the denominator. @return The quotient. */ f64 operator/(const Money& money) const; /*! @brief Adds the amounts in two Money objects. @param[in] money Specifies the Money to add. @return Returns a Money object. */ Money& operator+=(const Money& money); /*! @brief Subtracts the amount in one Money object from the amount in another Money object. @param[in] money Specifies the Money to subtract. @return Returns a Money object. */ Money& operator-=(const Money& money); /*! @brief Gets the amount multiplied by an integer. @param[in] quantity Specifies the quantity. @return Returns a Money object. */ Money& operator*=(u32 quantity); /*! @brief Compares the amount in one Money object to the amount in another Money object. @param[in] money Specifies the Money to compare. @return Returns the result of an equality (==) operation. */ bool operator==(const Money& money) const; /*! @brief Compares the amount in one Money object to the amount in another Money object. @param[in] money Specifies the Money to compare. @return Returns the result of an inequality (!=) operation. */ bool operator!=(const Money& money) const; /*! @brief Compares the amount in one Money object to the amount in another Money object. @param[in] money Specifies the Money to compare. @return Returns the result of a greater than (>) operation. */ bool operator>(const Money& money) const; /*! @brief Compares the amount in one Money object to the amount in another Money object. @param[in] money Specifies the Money to compare. @return Returns the result of a less than (<) operation. */ bool operator<(const Money& money) const; /*! @brief Compares the amount in one Money object to the amount in another Money object. @param[in] money Specifies the Money to compare. @return Returns the result of a greater-than-or-equal-to (>=) operation. */ bool operator>=(const Money& money) const; /*! @brief Compares the amount in one Money object to the amount in another Money object. @param[in] money Specifies the Money to compare. @return Returns the result of a less-than-or-equal-to (<=) operation. */ bool operator<=(const Money& money) const; /*! @brief Creates a Money object from an unformatted money string. The money string and currency code are not set when the user is not logged in. @param[in] pValue Specifies an unformatted amount string. @return Returns a Money object. */ static Money Make(const char* pValue); private: // char m_amount[AMOUNT_SIZE]; // char m_value[VALUE_SIZE]; // u32 m_currency; }; //! @} }} // namespace nn::ec #endif // NN_EC_MONEY_H_