Class Account API

download Class Account API

of 67

Transcript of Class Account API

  • 7/30/2019 Class Account API

    1/67

    Cheque management.

    A simple account management system for the

    Lightening Cheque

    application.

    Marc Zonzon

  • 7/30/2019 Class Account API

    2/67

    Cheque management.

    Contents

    1 Date . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.1 BadDate Exception for bad dates. . . . . . . . . . . . . . . . . . . . . . . . 41.2 BadFormat Exception for wrong format. . . . . . . . . . . . . . . . . 41.3 OutputRange Output Range Exception. . . . . . . . . . . . . . . . . . 51.4 now Tag for theDate constructor. . . . . . . . . . . . . . . . . . . . . . . 51.5 constants. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

    1.5.4 DateFmt The known date formats . . . . . . . . . . . . . 61.5.5 YearDigits Year is written on 2 or 4 digits . . . . . 7

    1.6 Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

    1.7 Accessors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91.8 Input-Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101.9 Relational operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131.10 Modifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

    2 Money . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 TransactionData The TransactionData structure . . . . . . . 334 Transaction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

    4.4 Comparison of transactions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374.5 Accessors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384.6 Modifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

    5 Account The account class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425.1 Typedefs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425.2 Constructors and destructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445.3 Transaction management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455.4 Accessors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 495.5 Modifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

    6 SecureInt. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 536.1 SecureInt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

    6.1.1 Overflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 2

  • 7/30/2019 Class Account API

    3/67

    Cheque management.

    This small set of classes is aimed to provide an account management facility.

    The lightening cheque user interface is based on these class. The link betweenthe account level and the UI is done by an account manager layer.

    Two base classes.

    The Transaction class group all data from a transaction.

    An object of the Account class, is a user account. Each user can have asmany account as needed. They are not deemed to be true bank account.

    Four utilities classes:

    The Date class provide the date needed by transaction and account.

    The Money is an arithmetic class appropriate for money operations. (fixedlength, no unexpected rounding, oveflow detection).

    The SecureInt class provides integer with overflow detection, it is used bythe Money class.

    The Test class provides the framework for testing each component.

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 3

  • 7/30/2019 Class Account API

    4/67

    1 Date

    1

    class Date

    Public Members

    1.1 struct BadDate Exception for bad dates. . . . . . . . . 4

    1.2 struct BadFormat Exception for wrong format. . . . 4

    1.3 struct OutputRange Output Range Exception. . . . . . . . 5

    1.4 struct now Tag for theDate constructor. . . 5

    1.5 constants. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

    1.6 Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

    1.7 Accessors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    1.8 Input-Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    1.9 Relational operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

    1.10 Modifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

    1.1

    struct BadDate

    Exception for bad dates.

    Exception for bad dates. Used when the year, month, day do not match anyvalid date.

    1.2

    struct BadFormat

    Exception for wrong format.

    Exception for wrong format. Used when a string cannot be decoded as a date.

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 4

  • 7/30/2019 Class Account API

    5/67

    1 Date

    1.3

    struct OutputRange

    Output Range Exception.

    Output Range Exception. Exception thrown when trying to write on two digitsa date which cannot be safely encoded.

    1.4

    struct now

    Tag for theDate constructor.

    Tag for the Date constructor. Provide a fake type used to ask for the presentdate.

    1.5

    constants.

    Names

    1.5.1 static const intcenturyLim The bound to infer a century from

    a two digits year . . . . . . . . . . . . . . . 6

    1.5.2 static const intlwYear Lower allowed year. . . . . . . . . . . . . 6

    1.5.3 static const inthiYear Higher allowed year. . . . . . . . . . . . 6

    1.5.4 enum DateFmt The known date formats . . . . . . . . 6

    1.5.5 enum YearDigits Year is written on 2 or 4 digits . 7

    1.5.6 static const DateFmtdefaultFmt The default format . . . . . . . . . . . . . 7

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 5

  • 7/30/2019 Class Account API

    6/67

    1 Date

    1.5.1

    static const int centuryLim

    The bound to infer a century from a two digits year

    The bound to infer a century from a two digits year

    1.5.2

    static const int lwYear

    Lower allowed year.

    Lower allowed year. This value is set according to Unix timers length.

    1.5.3

    static const int hiYear

    Higher allowed year.

    Higher allowed year. This value is set according to Unix timers length.

    1.5.4

    enum DateFmt

    The known date formats

    The known date formats

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 6

  • 7/30/2019 Class Account API

    7/67

    1 Date

    1.5.5

    enum YearDigits

    Year is written on 2 or 4 digits

    Year is written on 2 or 4 digits

    1.5.6

    static const DateFmt defaultFmt

    The default format

    The default format

    1.6

    Constructors

    Names

    1.6.1 Date ( int y, int yday) throw( BadDate)Constructor with a day number inthe year. . . . . . . . . . . . . . . . . . . . . . . . 8

    1.6.2 Date (now) Current date. . . . . . . . . . . . . . . . . . . 8

    1.6.3 Date ( int y, int m, int d ) throw( BadDate )year, month, day constructor. 8

    1.6.4 Date ( const Date &)copy constructor . . . . . . . . . . . . . . . 9

    1.6.5 explicit Date ( std::string s, DateFmt fmt=defaultFmt)

    throw( BadFormat, BadDate)Scan a string to extract a date. . 9

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 7

  • 7/30/2019 Class Account API

    8/67

    1 Date

    1.6.1

    Date ( int y, int yday) throw( BadDate)

    Constructor with a day number in the year.

    Constructor with a day number in the year.

    Parameters: y the yearyday day within the year.

    1.6.2

    Date (now)

    Current date.

    Current date. You can initialize a date to the current day by saying Datetoday=now();

    1.6.3

    Date ( int y, int m, int d ) throw( BadDate )

    year, month, day constructor.

    year, month, day constructor. Note that you cannot call Date(2005,09,08)because 09 and 08 are inexistent octal numbers, of course Date(2005,9,8) isfine.

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 8

  • 7/30/2019 Class Account API

    9/67

    1 Date

    1.6.4

    Date ( const Date &)

    copy constructor

    copy constructor

    1.6.5

    explicit Date ( std::string s, DateFmt fmt=defaultFmt)

    throw( BadFormat, BadDate)

    Scan a string to extract a date.

    Scan a string to extract a date. Years lower than 100 are translated tothe current or previous century according how they compare to the constantcenturyLim. Throw a BadFormat exception if the string cannot be decodedand a BadDate exception if it is inexistent.

    Parameters: s The string containing the date.fmt The format used.

    1.7

    Accessors

    Names

    1.7.1 int year () const . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    1.7.2 int month () const . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    1.7.3 int day () const . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    1.7.4 int yDay () const Number of current day in the year. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 9

  • 7/30/2019 Class Account API

    10/67

    1 Date

    1.7.1

    int year () const

    1.7.2

    int month () const

    1.7.3

    int day () const

    1.7.4

    int yDay () const

    Number of current day in the year

    Number of current day in the year

    1.8

    Input-Output

    Names

    1.8.1 std::string strDate (YearDigits ydigits=full,DateFmt fmt=defaultFmt ) const

    String representation of a date. 11

    1.8.2 std::ostream&

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 10

  • 7/30/2019 Class Account API

    11/67

    1 Date

    put (std::ostream& os, YearDigits ydigits=full,DateFmt fmt=defaultFmt) const

    Put the date on the output streamos. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

    1.8.3 std::ostream&put (std::ostream& os, DateFmt fmt) const

    Put the date on the output streamos. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

    1.8.4 std::istream&get (std::istream& is,

    DateFmt fmt=defaultFmt) throw(BadDate)Get the date from input stream. 12

    1.8.1

    std::string strDate (YearDigits ydigits=full, DateFmt

    fmt=defaultFmt ) const

    String representation of a date.

    String representation of a date.

    Return Value: - a string containing the representation ofthe date.

    Parameters: fmt The format used to print the string.ydigits The year is coded on 4 chars ifydigits

    isfull and 2 if it is abridged.

    1.8.2

    std::ostream& put (std::ostream& os, YearDigits ydig-

    its=full, DateFmt fmt=defaultFmt)const

    Put the date on the output streamos.

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 11

  • 7/30/2019 Class Account API

    12/67

    1 Date

    Put the date on the output stream os.

    Parameters: yWidth the number of digits for the year ( 2 or4)

    fmt The format used to print the string.ydigits Year on 4 digits ( full ) or 2 digits (

    abridged )usually called via

  • 7/30/2019 Class Account API

    13/67

  • 7/30/2019 Class Account API

    14/67

    1 Date

    True if current year is a leap year. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

    1.10.1

    Date& operator++ ()

    pre-increment operator

    pre-increment operator

    1.10.2

    Date operator++ ( int )

    post-increment operator

    post-increment operator

    1.10.3

    bool leapYear ( ) const

    True if current year is a leap year

    True if current year is a leap year

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 14

  • 7/30/2019 Class Account API

    15/67

    2 Money

    2

    Money

    Names

    2.1 typedef int SecureInt classMoney Detection of overflows. . . . . . . . . . 15

    2.2 std::ostream&operator> ( std::istream &is,Money &m ) throw(Money::Overflow)Intput operator. . . . . . . . . . . . . . . . . 32

    Money

    2.1

    typedef int SecureInt class Money

    Detection of overflows.

    Names

    2.1.1 exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

    2.1.2 constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

    2.1.3 static inline boolmodule precondition ()

    Precondition to build this class. 19

    2.1.4 Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

    2.1.5 Accessors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

    2.1.6 operations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

    2.1.7 comparison operators. . . . . . . . . . . . . . . . . . . . . . . . . . . 28

    2.1.8 Input-Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30

    2.1.9 Money (SecureInt n) throw()

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 15

  • 7/30/2019 Class Account API

    16/67

    2 Money

    Initialize a money var with theraw value. . . . . . . . . . . . . . . . . . . . . . ??

    Detection of overflows. Use SecureInt to represent the amount in cents as toallow the detection of overflows. The Use of SecureInt is only done at an internallevel and the user of Money dont need to know about it.

    2.1.1

    exceptions

    Names

    2.1.1.1 class Exception base Money::Exception class . . . . 162.1.1.2 class Overflow : public Exception

    Exception for overflows . . . . . . . . 17

    2.1.1.3 class BadFormat : public ExceptionException for error in input of anamount of money . . . . . . . . . . . . . . 17

    2.1.1.1

    class Exception

    base Money::Exception class

    Inheritance

    2.1.1.1

    Exception

    >

    2.1.1.2

    Overflow

    >

    2.1.1.3

    BadFormat

    base Money::Exception class

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 16

  • 7/30/2019 Class Account API

    17/67

    2 Money

    2.1.1.2

    class Overflow : public Exception

    Exception for overflows

    Inheritance

    2.1.1.1

    Exception

    2.1.1.2

    Overflow

    Exception for overflows

    2.1.1.3

    class BadFormat : public Exception

    Exception for error in input of an amount of money

    Inheritance

    2.1.1.1

    Exception

    2.1.1.3

    BadFormat

    Exception for error in input of an amount of money

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 17

  • 7/30/2019 Class Account API

    18/67

    2 Money

    2.1.2

    constants

    Names

    2.1.2.1 typedef long intvalue type An integer type to hold a Money

    value. . . . . . . . . . . . . . . . . . . . . . . . . . . 18

    2.1.2.2 static const Moneymax Maximum for a Money . . . . . . . . . 18

    2.1.2.3 static const Moneymin Minimum for a Money . . . . . . . . . 19

    2.1.2.4 static const intconv multiplicand for cents to units. . 19

    2.1.2.5 static const intdecades The number of decimal positions.

    19

    2.1.2.1

    typedef long int value type

    An integer type to hold a Money value.

    An integer type to hold a Money value. value type is an integer type guaran-teed to be as large as to be able to represent Money::max in cents.

    2.1.2.2

    static const Money max

    Maximum for a Money

    Maximum for a Money

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 18

  • 7/30/2019 Class Account API

    19/67

    2 Money

    2.1.2.3

    static const Money min

    Minimum for a Money

    Minimum for a Money

    2.1.2.4

    static const int conv

    multiplicand for cents to units.

    multiplicand for cents to units. conv== 10**decades

    2.1.2.5

    static const int decades

    The number of decimal positions.

    The number of decimal positions.

    2.1.3

    static inline bool module precondition ()

    Precondition to build this class.

    Precondition to build this class. The following assertion must be verified forthe code to be valid. it is checked at the beginning of the object module. Wecheck than a short int can be safely encoded as Money without taking careof overflows.

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 19

  • 7/30/2019 Class Account API

    20/67

    2 Money

    2.1.4

    Constructors

    Names

    2.1.4.1 Money () throw() A null amount of money . . . . . . . 20

    2.1.4.2 explicit Money (long int n) throw(Overflow)Initializer with a number of cents

    212.1.4.3 explicit Money (int i) throw(Overflow)

    Initializer with a number of cents

    21

    2.1.4.4 explicit Money (short i) throw()Initializer with short number ofcents. . . . . . . . . . . . . . . . . . . . . . . . . . . 21

    2.1.4.5 explicit Money (double d) throw(Overflow)Initializer with a double. . . . . . . . 21

    2.1.4.6 explicit Money (std::string monstring) throw(BadFormat,Overflow )

    Constructor with a formatedstring. . . . . . . . . . . . . . . . . . .. . . . . . . 22

    2.1.4.7 explicit Money (const char* monstring) throw(BadFormat,Overflow )

    Constructor with a formatedstring litteral . . . . . . . . . . . . . . . . . . . 22

    2.1.4.1

    Money () throw()

    A null amount of money

    A null amount of money

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 20

  • 7/30/2019 Class Account API

    21/67

    2 Money

    2.1.4.2

    explicit Money (long int n) throw(Overflow)

    Initializer with a number of cents

    Initializer with a number of cents

    2.1.4.3

    explicit Money (int i) throw(Overflow)

    Initializer with a number of cents

    Initializer with a number of cents

    2.1.4.4

    explicit Money (short i) throw()

    Initializer with short number of cents.

    Initializer with short number of cents. As value type is always larger than ashort no Overflow can be sent by this constructor.

    2.1.4.5

    explicit Money (double d) throw(Overflow)

    Initializer with a double.

    Initializer with a double. Warning: Money(10.4) is 10 cents not 1040 cents.This function round its parameter, it is different from a cast from floatting tointegral type.

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 21

  • 7/30/2019 Class Account API

    22/67

    2 Money

    Return Value: value rounded to the closer number of cents.Parameters: d the double

    2.1.4.6

    explicit Money (std::string monstring) throw(BadFormat,

    Overflow )

    Constructor with a formated string.

    Constructor with a formated string. Money(1.1) 1 unit and 10 cents.

    Parameters: monstring string "xxxxx.xx" for an amount ofmoney.An empty string stand for a nullamount of money.

    2.1.4.7

    explicit Money (const char* monstring) throw(BadFormat,

    Overflow )

    Constructor with a formated string litteral

    Constructor with a formated string litteral

    2.1.5

    Accessors

    Names

    2.1.5.1 value type cents () const throw()Number of cents. . . . . . . . . . . . . . . . 23

    2.1.5.2 value type units () const throw()

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 22

  • 7/30/2019 Class Account API

    23/67

    2 Money

    Integer number of monetary units. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

    2.1.5.3 value type value () const throw()The raw value . . . . . . . . . . . . . . . . . . 23

    2.1.5.1

    value type cents () const throw()

    Number of cents.

    Number of cents. m.cents() < 100

    2.1.5.2

    value type units () const throw()

    Integer number of monetary units

    Integer number of monetary units

    2.1.5.3

    value type value () const throw()

    The raw value

    The raw value

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 23

  • 7/30/2019 Class Account API

    24/67

    2 Money

    2.1.6

    operations.

    Names

    2.1.6.1 Money& operator= ( const Money &) throw()Assignement . . . . . . . . . . . . . . . . . . . 25

    2.1.6.2 Money& operator = (std::string monstring)throw(BadFormat, Overflow)

    Affectation from a string toMoney. . . . . . . . . .. . . . . . . . . . . . . . . 25

    2.1.6.3 Money& operator = (const char* monstring)

    throw(BadFormat, Overflow)Affectation from a string litteral toMoney . . . . . . . . . . . . . . . . . .. . . . . . . 25

    2.1.6.4 Money operator + (const Money &) constthrow(Overflow)

    sum of money . . . . . . . . . . . . . . . . . . 26

    2.1.6.5 Money& operator += (const Money &) throw(Overflow) . . 26

    2.1.6.6 Money operator - (const Money& ) const throw(Overflow)difference of money . . . . . . . . . . . . 26

    2.1.6.7 Money& operator -= (const Money &) throw(Overflow). . . . 26

    2.1.6.8 Money operator - () const throw()

    Opposite amount . . . . . . . . . . . . . . . 27

    2.1.6.9 Money operator* (double) const throw(Overflow)Multiply by a double. . . . . . . . . . . . 27

    2.1.6.10Money& operator*= (double) throw(Overflow).. . . . . .. . . .. . 27

    2.1.6.11double operator/ (const Money& ) const throw()Divide by an other amount ofmoney. . . . . . . . . . . . . . . . . . . . . . . . . 27

    2.1.6.12Money& operator/= (double) throw(Overflow).. . . . . .. . . .. . 28

    2.1.6.13Money operator/ (double) const throw(Overflow)Divide by a real number. . . . . . . . 28

    The additive operations are with Money, the multiplicative operations are withreal numbers i.e. double.

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 24

  • 7/30/2019 Class Account API

    25/67

    2 Money

    2.1.6.1

    Money& operator= ( const Money &) throw()

    Assignement

    Assignement

    2.1.6.2

    Money& operator = (std::string monstring)

    throw(BadFormat, Overflow)

    Affectation from a string to Money.

    Affectation from a string to Money. Money(1.1) 1 unit and 10 cents.

    Parameters: monstring string "xxxxx.xx" for an amount ofmoney.

    2.1.6.3

    Money& operator = (const char* monstring)

    throw(BadFormat, Overflow)

    Affectation from a string litteral to Money

    Affectation from a string litteral to Money

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 25

  • 7/30/2019 Class Account API

    26/67

    2 Money

    2.1.6.4

    Money operator + (const Money &) constthrow(Overflow)

    sum of money

    sum of money

    2.1.6.5

    Money& operator += (const Money &) throw(Overflow)

    2.1.6.6

    Money operator - (const Money& ) const

    throw(Overflow)

    difference of money

    difference of money

    2.1.6.7

    Money& operator -= (const Money &) throw(Overflow)

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 26

  • 7/30/2019 Class Account API

    27/67

    2 Money

    2.1.6.8

    Money operator - () const throw()

    Opposite amount

    Opposite amount

    2.1.6.9

    Money operator* (double) const throw(Overflow)

    Multiply by a double.

    Multiply by a double. You obtain a money amount. It is how you computeinterests.

    2.1.6.10

    Money& operator*= (double) throw(Overflow)

    2.1.6.11

    double operator/ (const Money& ) const throw()

    Divide by an other amount of money.

    Divide by an other amount of money. When you divide to amounts of moneythe result is an abstract real number, not a currency.

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 27

  • 7/30/2019 Class Account API

    28/67

    2 Money

    2.1.6.12

    Money& operator/= (double) throw(Overflow)

    2.1.6.13

    Money operator/ (double) const throw(Overflow)

    Divide by a real number.

    Divide by a real number. And obtain money.

    2.1.7

    comparison operators.

    Names

    2.1.7.1 bool operator== (const Money &) const throw() . . . . . 29

    2.1.7.2 bool operator!= (const Money &) const throw(). . . . . . . 292.1.7.3 bool operator< (const Money &) const throw() . . . . . . . . 29

    2.1.7.4 bool operator> (const Money &) const throw() . . . . . . . . 29

    2.1.7.5 missing comparison operatorsThey are generated by the header from STL. . . . 29

    2.1.7.6 bool isnull () const throw()Shortcut to test against zero . . . . 29

    2.1.7.7 bool iscredit () const throw()True for a positive amount . . . . . 30

    2.1.7.8 bool isdebit () const throw()True for a negative amount . . . . 30

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 28

  • 7/30/2019 Class Account API

    29/67

    2 Money

    2.1.7.1

    bool operator== (const Money &) const throw()

    2.1.7.2

    bool operator!= (const Money &) const throw()

    2.1.7.3

    bool operator< (const Money &) const throw()

    2.1.7.4

    bool operator> (const Money &) const throw()

    2.1.7.5

    missing comparison operators

    They are generated by the header from STL.

    2.1.7.6

    bool isnull () const throw()

    Shortcut to test against zero

    Shortcut to test against zero

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 29

  • 7/30/2019 Class Account API

    30/67

    2 Money

    2.1.7.7

    bool iscredit () const throw()

    True for a positive amount

    True for a positive amount

    2.1.7.8

    bool isdebit () const throw()

    True for a negative amount

    True for a negative amount

    2.1.8

    Input-Output

    Names

    2.1.8.1 std::ostream&put (std::ostream& os, int width=0 ) const throw()

    put the Money on an outputstream. . . . . . . . . . . . . . . . . . . . . . . . . 31

    2.1.8.2 std::string strMoney ( int width) const throw()Convert type Money to a string. 31

    2.1.8.3 std::istream&

    get (std::istream &is) throw(Overflow)Read a Money. . . . . . . . . . . . . . . . . . 31

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 30

  • 7/30/2019 Class Account API

    31/67

    2 Money

    2.1.8.1

    std::ostream& put (std::ostream& os, int width=0 ) constthrow()

    put the Money on an output stream.

    put the Money on an output stream. usually called via

  • 7/30/2019 Class Account API

    32/67

    2 Money

    Parameters: is input stream. The I/O flags of ismustbe inspected with to know the result of

    the input.Exceptions: Overflow if the amount is bigger that thecapacity

    of Money Use the I/O flags to examinethe resultof input.

    2.2

    std::ostream& operator> ( std::istream &is, Money &m )

    throw(Money::Overflow)

    Intput operator.

    Intput operator. operator version of the get method.

    Parameters: is input stream. The I/O flags of ismustbe inspected with to know the result ofthe input.

    m the money variable to get the amounton the stream.

    Exceptions: Overflow if the amount is bigger that thecapacityof Money Use the I/O flags to examinethe resultof input.

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 32

  • 7/30/2019 Class Account API

    33/67

    3 TransactionData

    3

    struct TransactionData

    TheTransactionData structure

    Members

    3.1 string numM The number of the cheque. . . . . 33

    3.2 Date dateM The date of the transaction . . . . . 34

    3.3 string descM The payee . . . . . . . . . . . . . . . . . . . . . . 34

    3.4 string categoryM The category . . . . . . . . . . . . . . . . . . . 34

    3.5 Money amountM The amount of transaction. . . . 34

    3.6 bool recM Reconciled boolean. . . . . . . . . . . . . 35

    3.7 TransactionData ()A new transaction with emptydata . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

    3.8 TransactionData (const TransactionData& dataN)Copy constructor . . . . . . . . . . . . . . . 35

    3.9 TransactionData ( string numN,const Date dateN, string descN,string categoryN,

    Money amountN, bool recN )Build a new TransactionDatawith all fields . . . . . . . . . . . . . . . . . . . 35

    The TransactionData structure contains all transaction fields. It is used togather data from the interface before creating or updating a Transaction

    3.1

    string numM

    The number of the cheque.

    The number of the cheque or any code for an other transaction. Some transac-tion doesnt have a true number. Either because this kind of transaction has no

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 33

  • 7/30/2019 Class Account API

    34/67

    3 TransactionData

    number or more often because we dont know the id number that will be givenby the bank.

    3.2

    Date dateM

    The date of the transaction

    The date of the transaction

    3.3

    string descM

    The payee

    The payee

    3.4

    string categoryM

    The category

    The category

    3.5

    Money amountM

    The amount of transaction.

    The amount is a credit if positive and a debit if negative

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 34

  • 7/30/2019 Class Account API

    35/67

    3 TransactionData

    3.6

    bool recM

    Reconciled boolean.

    rcM is true when the transaction as been reconciled with a bank transaction.

    3.7

    TransactionData ()

    A new transaction with empty data

    A new transaction with empty data

    3.8

    TransactionData (const TransactionData& dataN)

    Copy constructor

    Copy constructor

    3.9

    TransactionData ( string numN, const Date dateN,

    string descN, string categoryN, Money

    amountN, bool recN )

    Build a newTransactionDatawith all fields

    Build a new TransactionData with all fields

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 35

  • 7/30/2019 Class Account API

    36/67

    4 Transaction

    4

    class Transaction : private TransactionData

    Public Members

    4.1 Transaction () An empty transaction. . . . . . . . . . 36

    4.2 Transaction (const TransactionData&)A transaction from its data . . . . 37

    4.3 Transaction ( string numN, const Date dateN,string descN, string categoryN,Money amountN, bool recN )

    Straight constructor without usingTransactionData . . . . . . . . . . . . . . 37

    4.4 Comparison of transactions. . . . . . . . . . . . . . . . . . . . . 37

    4.5 Accessors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

    4.6 Modifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

    A Transaction object an be any kind of transaction on a bank account.

    4.1

    Transaction ()

    An empty transaction.

    An empty transaction. all fields are blank but the date (today).

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 36

  • 7/30/2019 Class Account API

    37/67

    4 Transaction

    4.2

    Transaction (const TransactionData&)

    A transaction from its data

    A transaction from its data

    4.3

    Transaction ( string numN, const Date dateN, string de-scN, string categoryN, Money amountN, bool

    recN )

    Straight constructor without usingTransactionData

    Straight constructor without using TransactionData

    4.4

    Comparison of transactions.

    Names

    4.4.1 bool operator< ( const Transaction & ) const . . . . . . . . . . . 38

    4.4.2 bool operator== ( const Transaction & ) const . . . . . . . . 38

    4.4.3 bool operator> ( const Transaction & ) const . . . . . . .. . . . 38

    Transactions compare by date then by number.

    The missing operators are generated by the STL.

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 37

  • 7/30/2019 Class Account API

    38/67

    4 Transaction

    4.4.1

    bool operator< ( const Transaction & ) const

    4.4.2

    bool operator== ( const Transaction & ) const

    4.4.3

    bool operator> ( const Transaction & ) const

    4.5

    Accessors

    Names4.5.1 string num () const Thenumber. . . . . . . . . . . . . . . . . . . . 39

    4.5.2 string desc () const The payee . . . . . . . . . . . . . . . . . . . . . . 39

    4.5.3 string category () const The category . . . . . . . . . . . . . . . . . . . 39

    4.5.4 bool rec () const True if reconciled . . . . . . . . . . . . . . 39

    4.5.5 Money amount () const amount is a relative number . . . . 40

    4.5.6 Money credit () const . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

    4.5.7 Money debit () const . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

    4.5.8 Money recBalance () const

    The balance after this transaction.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 38

  • 7/30/2019 Class Account API

    39/67

    4 Transaction

    4.5.1

    string num () const

    Thenumber.

    The number. It doesnt need to be numeric.

    4.5.2

    string desc () const

    The payee

    The payee

    4.5.3

    string category () const

    The category

    The category

    4.5.4

    bool rec () const

    True if reconciled

    True if reconciled

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 39

  • 7/30/2019 Class Account API

    40/67

    4 Transaction

    4.5.5

    Money amount () const

    amount is a relative number

    amount is a relative number

    4.5.6

    Money credit () const

    The credit It is equal to amount if amount is positive otherwise credit() is null.

    4.5.7

    Money debit () const

    The debit is equal to -amount If amount is negative, otherwise debit() is null.

    4.5.8

    Money recBalance () const

    The balance after this transaction.

    The balance after this transaction. It depends not only on the amount of thistransaction but also of all the preceding ones.

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 40

  • 7/30/2019 Class Account API

    41/67

    4 Transaction

    4.6

    Modifiers

    Names

    4.6.1 void recBalance (Money m)Set the record-Balance. . . . . . . . . 41

    4.6.2 void rec (bool) Reconcile a transaction. . . . . . . . . 41

    4.6.3 mutable MoneyrecBalanceM Record balance. . . . . . . . . . . . . . . . . ??

    4.6.1

    void recBalance (Money m)

    Set the record-Balance.

    The record-Balance is computed by the account class. As the record balancecan change even if the transaction doesnt it is declared const

    4.6.2

    void rec (bool)

    Reconcile a transaction.

    Reconcile a transaction. It is the only modification you can do without reenter-ing the whole data.

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 41

  • 7/30/2019 Class Account API

    42/67

    5 Account

    5

    class Account

    The account class.

    Public Members

    5.1 Typedefs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

    5.2 Constructors and destructor . . . . . . . . . . . . . . . . . . . . 44

    5.3 Transaction management . . . . . . . . . . . . . . . . . . . . . . . 45

    5.4 Accessors. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

    5.5 Modifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

    Protected Members

    5.6 void adjustBalance (iterator it )Adjust the balance after an update.

    . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

    5.7 void adjustBalance () Adjust the balance after an update.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

    The account class. is used to record the transactions on a specific account. Auser can have many accounts. but in the present application we can supposethat the whole number of accounts is quite low (not more than 10) so the speedof creation and destruction is not our first concern.

    5.1

    Typedefs

    Names

    5.1.1 typedef vectorTransList The container for transactions. 43

    5.1.2 typedef TransList::iteratoriterator Iterator type for transactions . . . 43

    5.1.3 typedef TransList::const iterator

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 42

  • 7/30/2019 Class Account API

    43/67

    5 Account

    const iterator Const iterator type for transac-tions . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

    5.1.4 Blank account . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

    5.1.1

    typedef vector TransList

    The container for transactions.

    The container for transactions.

    We have to choose some convenient type of container the requirements areas follow:

    The container must be accessible by number. It is because the UI returnfrom menus by number of the selected item.

    The container is ordered. Because we want that the transaction list staysorted by date and transaction number. We can suppose that the user willmainly enter transaction sequentially and that sorting is not very oftennecessary. But of course it would need to be checked.

    We can achieve this goal either by inserting transactions at their rightplace or by sorting transactions before to display them.

    When an account is moved by copy-destruction, the container is alsocopied and destroyed, it may be time consuming. The cause of movingaccounts is that they are themselves placed in containers which can needto move them. It happens when they reclaim space because they donthave room to add new accounts.

    5.1.2

    typedef TransList::iterator iterator

    Iterator type for transactions

    Iterator type for transactions

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 43

  • 7/30/2019 Class Account API

    44/67

    5 Account

    5.1.3

    typedef TransList::const iterator const iterator

    Const iterator type for transactions

    Const iterator type for transactions

    5.1.4

    Blank account

    Blank account

    5.2

    Constructors and destructor

    Names

    5.2.1 Account ( string nameN, string descN,string notesN= )

    Account with no transaction . . . . 44

    5.2.2 Account ( const Account & oldAccount)Copy constructor. . . . . . . . . . . . . . . 45

    5.2.3 ~Account () Destructor. . . . . . . . . . . . . . . . . . . . . 45

    5.2.1

    Account ( string nameN, string descN, string notesN= )

    Account with no transaction

    Account with no transaction

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 44

  • 7/30/2019 Class Account API

    45/67

    5 Account

    5.2.2

    Account ( const Account & oldAccount)

    Copy constructor.

    Copy constructor. The transaction container is copied.

    Depending on the container this may imply a copy of each transaction.

    5.2.3

    ~Account ()

    Destructor.

    Destructor. Used during debugging to monitor destructions.

    5.3

    Transaction management

    Names

    5.3.1 void push back ( const Transaction & )Add a new transaction. . . . . . . . . 46

    5.3.2 void erase (iterator) Delete a transaction. . . . . . . . . . . . 46

    5.3.3 void sort () Sort all transactions. . . . . . . . . . . . 47

    5.3.4 void update ( iterator it, const TransactionData &x )Change the data of the transactionit. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

    5.3.5 int size () const the number of transactions . . . . . 47

    5.3.6 iterator begin () First transaction. . . . . . . . . . . . . . . 47

    5.3.7 iterator end () Iterator past the end of transac-tions. . . . . . . . . . . . . . . . . . . . . . . . . . . 48

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 45

  • 7/30/2019 Class Account API

    46/67

    5 Account

    5.3.8 iterator last () Last transaction. . . . . . . . . . . . . . . . 48

    5.3.9 iterator transaction (int i)Iterator on the transaction numb.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

    5.3.10 bool empty () const Predicate true if no transaction. 48

    An account is a transaction container and manager. As we want to keep privatethe base container we import all necessary operations.

    5.3.1

    void push back ( const Transaction & )

    Add a new transaction.

    Add a new transaction.

    The transaction is added at the end of the container.

    The record balance is fixed as the account balance.

    The lastNbr is modified if this transaction is numbered.

    The sorting of transactions is presently done later.

    5.3.2

    void erase (iterator)

    Delete a transaction.

    Delete a transaction. Change the balance an possibly the lastNbr.

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 46

  • 7/30/2019 Class Account API

    47/67

    5 Account

    5.3.3

    void sort ()

    Sort all transactions.

    Sort all transactions. use the operator < on Transaction.

    5.3.4

    void update ( iterator it, const TransactionData &x )

    Change the data of the transactionit.

    Change the data of the transaction it.

    precondition: begin() it < end().

    5.3.5

    int size () const

    the number of transactions

    the number of transactions

    5.3.6

    iterator begin ()

    First transaction.

    First transaction.

    This iterator can be dereferenced only if begin()

  • 7/30/2019 Class Account API

    48/67

    5 Account

    5.3.7

    iterator end ()

    Iterator past the end of transactions.

    Iterator past the end of transactions. It can never be dereferenced.

    5.3.8

    iterator last ()

    Last transaction.

    Last transaction.

    (begin() < end()and + +last() = end())orlast() = end()

    5.3.9

    iterator transaction (int i)

    Iterator on the transaction numb.

    Iterator on the transaction numb. i.

    post: begin() + i = transaction(i)

    5.3.10

    bool empty () const

    Predicate true if no transaction.

    Predicate true if no transaction. empty() size() == 0

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 48

  • 7/30/2019 Class Account API

    49/67

    5 Account

    5.4

    Accessors.

    Names

    5.4.1 string name () const Account name . . . . . . . . . . . . . . . . . . 49

    5.4.2 string desc () const Account description . . . . . . . . . . . . 49

    5.4.3 Money balance () const Balance of the account. . . . . . . . . 50

    5.4.4 Money bankBalance () constBank balance of the account. . . . 50

    5.4.5 int lastNbr () const higher number of a transaction . 50

    5.4.1

    string name () const

    Account name

    Account name

    5.4.2

    string desc () const

    Account description

    Account description

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 49

  • 7/30/2019 Class Account API

    50/67

    5 Account

    5.4.3

    Money balance () const

    Balance of the account.

    Balance of the account. Sum of all transactions amount.

    5.4.4

    Money bankBalance () const

    Bank balance of the account.

    Bank balance of the account. Sum of all reconciled transactions amount.

    5.4.5

    int lastNbr () const

    higher number of a transaction

    higher number of a transaction

    5.5

    Modifiers

    Names

    5.5.1 void name ( string newname )Account name modifier . . . . . . . . . 51

    5.5.2 void desc (string newdesc )

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 50

  • 7/30/2019 Class Account API

    51/67

    5 Account

    Account description modifier . . . 51

    5.5.3 void lastNbr (int n) set the recorded last number . . . . 515.5.4 void lastNbr (string s) Set the last number to the argu-

    ment if numeric. . . . . . . . . . . . . . . . 52

    5.5.1

    void name ( string newname )

    Account name modifier

    Account name modifier

    5.5.2

    void desc (string newdesc )

    Account description modifier

    Account description modifier

    5.5.3

    void lastNbr (int n)

    set the recorded last number

    set the recorded last number

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 51

  • 7/30/2019 Class Account API

    52/67

    5 Account

    5.5.4

    void lastNbr (string s)

    Set the last number to the argument if numeric.

    Set the last number to the argument if numeric.

    The last number is unchanged if s is not numeric.

    Parameters: s any string, when it is a numeric stringit replacesthe last number.

    5.6

    void adjustBalance (iterator it )

    Adjust the balance after an update.

    Adjust the balance after an update.

    Parameters: it is the first modified transaction

    5.7

    void adjustBalance ()

    Adjust the balance after an update.

    Adjust the balance after an update.

    All transactions are inspected to compute the balance.

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 52

  • 7/30/2019 Class Account API

    53/67

    6 SecureInt.

    6

    SecureInt.

    Names

    6.1 class SecureInt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

    6.2 std::ostream&operator > (std::istream & is, SecureInt& i)

    throw(SecureInt::Overflow). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

    SecureInt. A class for a secure integer arithmetic.

    6.1

    class SecureInt

    Public Members

    6.1.1 class Overflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

    6.1.2 typedef longvalue type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

    6.1.3 static inline boolmodule precondition ()

    Precondition to build this class. 56

    6.1.4 static const intbsize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

    6.1.5 static const boolodd word error odd word error. . . . . . . . . . . . . . . . . 56

    6.1.6 static const intbhalf size A half word size . . . . . . . . . . . . . . . . 57

    6.1.7 static const value typemax value Maximum value . . . . . . . . . . . . . . . . 57

    6.1.8 static const value type

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 53

  • 7/30/2019 Class Account API

    54/67

    6 SecureInt.

    min value Minimum value . . . . . . . . . . . . . . . . 57

    6.1.9 static const SecureIntmax Maximum SecureInt . . . . . . . . . . 57

    6.1.10 static const SecureIntmin Minimum SecureInt . . . . . . . . . . . 58

    6.1.11 SecureInt (value type i=0) throw(Overflow). . . . . . . . 58

    6.1.12 explicit SecureInt (int i) throw(Overflow) . . . . . . . . . . . . . . . . . . 58

    6.1.13 explicit SecureInt (short i) throw(Overflow). . .. . . .. . . . . . . . . 58

    6.1.14 explicit SecureInt (double d) throw(Overflow)Floating-integral conversions. . . 58

    6.1.15 SecureInt operator + (SecureInt i) const throw(Overflow) . . 59

    6.1.16 SecureInt operator - (SecureInt i) const throw(Overflow) . . . 59

    6.1.17 SecureInt operator * (SecureInt i) const throw(Overflow) . . . 59

    6.1.18 SecureInt operator / (SecureInt i) const throw(). . . . . . . . . . . . 59

    6.1.19 SecureInt operator% (SecureInt i) const throw(). . . . . . . . . . . . 59

    6.1.20 SecureInt operator + (int i) const throw(Overflow). . . . . . . . . 59

    6.1.21 SecureInt operator - (int i) const throw(Overflow). . . . . . . . . . 60

    6.1.22 SecureInt operator * (int i) const throw(Overflow).. . . . . . . . . 60

    6.1.23 SecureInt operator / (int i) const throw() . . . . . . . . . . . . . . . . . . 60

    6.1.24 SecureInt operator% (int i) const throw() . . . . . . . . . . . . . . . . . . 60

    6.1.25 SecureInt operator - () const throw() . . . . . . . . . . . . . . . . . . . . . . . . 60

    6.1.26 double operator * (double d) const throw()product by a double. . . . . . . . . . . . . 60

    6.1.27 SecureInt& operator = (const SecureInt& i) throw() . . . . . . . . . . 61

    6.1.28 SecureInt& operator = (int i) throw(Overflow)affectation of an int. . . .. . . . . . . . 61

    6.1.29 SecureInt& operator = (short i) throw(Overflow) .. .. . . . . . . . . . 61

    6.1.30 SecureInt& operator = (value type i) throw(Overflow). . . . . . . . 61

    6.1.31 SecureInt& operator = (double d) throw(Overflow) .. . . . . . . . . . 61

    6.1.32 SecureInt& operator += (SecureInt i) throw(Overflow). . . . . . . 626.1.33 SecureInt& operator -= (SecureInt i) throw(Overflow) . . . . . . . . 62

    6.1.34 SecureInt& operator *= (SecureInt i) throw(Overflow). . . . . . . . 62

    6.1.35 SecureInt& operator /= (SecureInt i) throw() . . . . . . . . . . . . . . . . 62

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 54

  • 7/30/2019 Class Account API

    55/67

    6 SecureInt.

    6.1.36 SecureInt& operator += (int i) throw(Overflow).. . . . .. . . . . . . . 62

    6.1.37 SecureInt& operator -= (int i) throw(Overflow). . . . . . . . . . . . .. . 626.1.38 SecureInt& operator *= (int i) throw(Overflow) . . . . . . . . . . . . . . 63

    6.1.39 SecureInt& operator /= (int i) throw() . . . . . . . . . . . . . . . . . . . . . . . 63

    6.1.40 SecureInt& operator *= (double d) throw(Overflow)product of current value by a dou-ble; Equivalent to * then = . . . . . 63

    6.1.41 SecureInt& operator/= (double) throw(Overflow)division of current value by a dou-ble; Equivalent to / then = . . . . . 63

    6.1.42 bool operator == (SecureInt i) const throw() . . . . . . . . . . 63

    6.1.43 bool operator == (value type i) const throw() . . . . . . . . . 646.1.44 bool operator == (int i) const throw() . . . . . . . . . . . . . . . . 64

    6.1.45 bool operator!= (SecureInt i) const throw() . . . . . . . . . . . 64

    6.1.46 bool operator!= (value type i) const throw() . . . . . . . . . . 64

    6.1.47 bool operator!= (int i) const throw() . . . . . . . . . . . . . . . . . . 64

    6.1.48 bool operator< (SecureInt i) const throw(). . . . . . . . . . . . . 64

    6.1.49 bool operator< (value type i) const throw(). . . . . . . . . . .. 65

    6.1.50 bool operator< (int i) const throw() . . . . . . . . . . . . . . . . . . . 65

    6.1.51 bool operator> (SecureInt i) const throw(). . . . . . . . . . . . . 65

    6.1.52 bool operator> (value type i) const throw(). . . . . . . . . . .. 65

    6.1.53 bool operator> (int i) const throw() . . . . . . . . . . . . . . . . . . . 65

    6.1.54 SecureInt operator/ (const SecureInt& ) const throw(). . . . . . 65

    6.1.55 SecureInt operator/ (long i ) const throw() . . . . . . . . . . . . . . . . . 66

    6.1.56 double operator/ (double) const throw(). .. . . . . . . . . . . . . . . 66

    6.1.57 std::ostream&put (std::ostream & os) const throw() . . . . . . . . . . . . . . 66

    6.1.58 std::istream&get (std::istream & is) throw(Overflow) .. . . . . . . . . . . . 66

    6.1.59 template< class Target> Target

    cast to () const throw()cast to an other arithmetic type. 66

    6.1.60 templatestatic boolrangeOK (T i) Range predicate. . . . . . . . . . . . . . . . 67

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 55

  • 7/30/2019 Class Account API

    56/67

    6 SecureInt.

    6.1.1

    class Overflow

    6.1.2

    typedef long value type

    6.1.3

    static inline bool module precondition ()

    Precondition to build this class.

    Precondition to build this class. The following assertion must be verified forthe code to be valid. it is checked at the beginning of the object module.

    6.1.4

    static const int bsize

    6.1.5

    static const bool odd word error

    odd word error.

    odd word error. I suppose that a word has always an even size, so I make sureto fail if some strange CPU is using odd side for a word.

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 56

  • 7/30/2019 Class Account API

    57/67

    6 SecureInt.

    6.1.6

    static const int bhalf size

    A half word size

    A half word size

    6.1.7

    static const value type max value

    Maximum value

    Maximum value

    6.1.8

    static const value type min value

    Minimum value

    Minimum value

    6.1.9

    static const SecureInt max

    Maximum SecureInt

    Maximum SecureInt

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 57

  • 7/30/2019 Class Account API

    58/67

    6 SecureInt.

    6.1.10

    static const SecureInt min

    Minimum SecureInt

    Minimum SecureInt

    6.1.11

    SecureInt (value type i=0) throw(Overflow)

    6.1.12

    explicit SecureInt (int i) throw(Overflow)

    6.1.13

    explicit SecureInt (short i) throw(Overflow)

    6.1.14

    explicit SecureInt (double d) throw(Overflow)

    Floating-integral conversions.

    Floating-integral conversions. In respect to others Floating-integral conversionsThe double d is truncated to produce a SecureInt value.

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 58

  • 7/30/2019 Class Account API

    59/67

    6 SecureInt.

    6.1.15

    SecureInt operator + (SecureInt i) constthrow(Overflow)

    6.1.16

    SecureInt operator - (SecureInt i) const throw(Overflow)

    6.1.17

    SecureInt operator * (SecureInt i) const throw(Overflow)

    6.1.18

    SecureInt operator / (SecureInt i) const throw()

    6.1.19

    SecureInt operator% (SecureInt i) const throw()

    6.1.20

    SecureInt operator + (int i) const throw(Overflow)

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 59

  • 7/30/2019 Class Account API

    60/67

    6 SecureInt.

    6.1.21

    SecureInt operator - (int i) const throw(Overflow)

    6.1.22

    SecureInt operator * (int i) const throw(Overflow)

    6.1.23

    SecureInt operator / (int i) const throw()

    6.1.24

    SecureInt operator% (int i) const throw()

    6.1.25

    SecureInt operator - () const throw()

    6.1.26

    double operator * (double d) const throw()

    product by a double.

    product by a double.

    Return Value: a double value.

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 60

  • 7/30/2019 Class Account API

    61/67

    6 SecureInt.

    6.1.27

    SecureInt& operator = (const SecureInt& i) throw()

    6.1.28

    SecureInt& operator = (int i) throw(Overflow)

    affectation of an int.

    affectation of an int. It is very usefull to have an affectation of a smaller int typebecause it can be down without conversion. We dont know on which machineint and short are smaller than value type; so we cannot exclude an Overflow.

    6.1.29

    SecureInt& operator = (short i) throw(Overflow)

    6.1.30

    SecureInt& operator = (value type i) throw(Overflow)

    6.1.31

    SecureInt& operator = (double d) throw(Overflow)

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 61

  • 7/30/2019 Class Account API

    62/67

    6 SecureInt.

    6.1.32

    SecureInt& operator += (SecureInt i) throw(Overflow)

    6.1.33

    SecureInt& operator -= (SecureInt i) throw(Overflow)

    6.1.34

    SecureInt& operator *= (SecureInt i) throw(Overflow)

    6.1.35

    SecureInt& operator /= (SecureInt i) throw()

    6.1.36

    SecureInt& operator += (int i) throw(Overflow)

    6.1.37

    SecureInt& operator -= (int i) throw(Overflow)

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 62

  • 7/30/2019 Class Account API

    63/67

    6 SecureInt.

    6.1.38

    SecureInt& operator *= (int i) throw(Overflow)

    6.1.39

    SecureInt& operator /= (int i) throw()

    6.1.40

    SecureInt& operator *= (double d) throw(Overflow)

    product of current value by a double; Equivalent to * then =

    product of current value by a double; Equivalent to * then =

    6.1.41

    SecureInt& operator/= (double) throw(Overflow)

    division of current value by a double; Equivalent to / then =

    division of current value by a double; Equivalent to / then =

    6.1.42

    bool operator == (SecureInt i) const throw()

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 63

  • 7/30/2019 Class Account API

    64/67

    6 SecureInt.

    6.1.43

    bool operator == (value type i) const throw()

    6.1.44

    bool operator == (int i) const throw()

    6.1.45

    bool operator!= (SecureInt i) const throw()

    6.1.46

    bool operator!= (value type i) const throw()

    6.1.47

    bool operator!= (int i) const throw()

    6.1.48

    bool operator (SecureInt i) const throw()

    6.1.52

    bool operator> (value type i) const throw()

    6.1.53

    bool operator> (int i) const throw()

    6.1.54

    SecureInt operator/ (const SecureInt& ) const throw()

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 65

  • 7/30/2019 Class Account API

    66/67

    6 SecureInt.

    6.1.55

    SecureInt operator/ (long i ) const throw()

    6.1.56

    double operator/ (double) const throw()

    6.1.57

    std::ostream& put (std::ostream & os) const throw()

    6.1.58

    std::istream& get (std::istream & is) throw(Overflow)

    6.1.59

    template< class Target> Target cast to () const throw()

    cast to an other arithmetic type.

    cast to an other arithmetic type. The cast is done by the standard static castand can cause a truncation if the target type is smaller than value type

    This page was generated with the help of DOC++

    http://docpp.sourceforge.netJuly 1, 2003 66

  • 7/30/2019 Class Account API

    67/67

    6 SecureInt.

    6.1.60

    templatestatic bool rangeOK (T i)

    Range predicate.

    Range predicate. Check if a value from an other numeric type can be safelyencoded as a SecureInt. Allow to try before use instead of using exceptions.

    6.2

    std::ostream& operator > (std::istream & is, SecureInt&

    i) throw(SecureInt::Overflow)