/*
 * bigint.hpp
 *
 * Interface definition for the BigInt class, which represents aribitrary
 * sized integers.
 *
 */

#ifndef BIGINT_HPP_INCLUDED		// Usual C++ include guard for header
#define BIGINT_HPP_INCLUDED 1

#include <vector>			
#include <string>
#include <iostream>
using namespace std;                    // Necessary incantation in ISO C++.

class BigInt {
public:

    /* BigInt [constructor]:
     *      Inputs:  int value		Initial value for the BigInt	
     * 
     * Creates a new BigInt object with value.  Defaults to zero.
     */

    explicit BigInt(int value = 0);

    /* The compiler's default copy constructor, assignment operator and
     * destructor are okay.  (A shallow copy is fine because the class
     * has no pointer members.)
     */


    /* += [member function and overloaded operator]:
     * -= [member function and overloaded operator]:
     * *= [member function and overloaded operator]:
     * /= [member function and overloaded operator]:
     *      Inputs:  BigInt* this		LHS argument to operator
     * 		     BigInt rhs		RHS argument to operator
     *	    Returns: BigInt&		LHS argument
     * 
     * Updates the LHS operand to add/subtract/multiply by/divide by
     * the RHS operand.  Returns a reference to the LHS argument.
     */

    BigInt& operator+= (const BigInt& rhs);
    BigInt& operator-= (const BigInt& rhs);
    BigInt& operator*= (const BigInt& rhs);
    BigInt& operator/= (const BigInt& rhs);


    /* == [member function and overloaded operator]:
     * != [member function and overloaded operator]:
     *      Inputs:  BigInt* this	LHS argument to operator [implicit]
     * 		     const BigInt& rhs	RHS argument to operator
     *	    Returns: bool
     * 
     * == returns true when LHS is equal to RHS, false otherwise
     * != returns true when LHS is is not equal to RHS, false otherwise
     */

    bool operator==(const BigInt& rhs) const;
    bool operator!=(const BigInt& rhs) const;

    /* print [member function]:
     * 
     *      Inputs:  const BigInt* this	BigInt to print [implicit]
     *		     ostream& out	The output stream.
     *	    Returns: ostream&		The output stream.
     */

    ostream& print(ostream& out) const;


private:
    /*
     * Private data.
     *
     * If CHUNK_SIZE = 100, the number 123456789 is stored in the chunks_
     * vector as follows:
     *     chunks_[0] = 89
     *     chunks_[1] = 67
     *     chunks_[2] = 45
     *     chunks_[3] = 23
     *     chunks_[4] = 1
     */
    static const int CHUNK_SIZE = 100; 
				// Deliberately small during testing.

    vector<int> chunks_;	// Value of the BigInt.
};

/* << [global function and overloaded operator]:
 *	Inputs:  ostream& out		output stream (LHS argument of <<)
 *		 const BigInt& value	value to print (RHS argument of <<)
 *      Returns: ostream&		out
 * 
 * Output function for BigNum.  Calls the print() method.
 */
ostream& operator<<(ostream& out, const BigInt& value);

#endif // BIGINT_HPP_INCLUDED


/* Junk to make emacs use the right C++ style when editing this code:
 *   Local Variables:
 *   c-file-style: "stroustrup"
 *   End:
 */
