Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Doxygen documentation for all files #28

Merged
merged 1 commit into from
Sep 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Doxygen folder
docs/html

# Binaries
bin

Expand Down
2,482 changes: 2,482 additions & 0 deletions docs/Doxyfile

Large diffs are not rendered by default.

18 changes: 11 additions & 7 deletions include/BigInt.hpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
/*
===========================================================================
BigInt
===========================================================================
Definition for the BigInt class.
*/
/**
* @file BigInt.hpp
*
* @brief Contains class declaration for BigInt
*/

#ifndef BIG_INT_HPP
#define BIG_INT_HPP

#include <iostream>

/**
* @brief Class that contains an arbitrarily sized integer.
*/
class BigInt {

std::string value;
char sign;

public:
// Constructors:

// Constructors
BigInt();
BigInt(const BigInt&);
BigInt(const long long&);
Expand Down
50 changes: 27 additions & 23 deletions include/constructors/constructors.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
===========================================================================
Constructors
===========================================================================
/**
* @file constructors/constructors.hpp
*
* @brief contains constructors of BigInt
*/

#ifndef BIG_INT_CONSTRUCTORS_HPP
Expand All @@ -11,32 +11,35 @@
#include "functions/utility.hpp"


/*
Default constructor
-------------------
*/

/**
* @brief Default constructor for BigInt
*
* @return BigInt with value initialized to zero.
*/
BigInt::BigInt() {
value = "0";
sign = '+';
}


/*
Copy constructor
----------------
*/

/**
* @brief Copy constructor for BigInt
*
* @param num a BigInt that is to be copied
* @return BigInt with equal value as `num`
*/
BigInt::BigInt(const BigInt& num) {
value = num.value;
sign = num.sign;
}


/*
Integer to BigInt
-----------------
*/
/**
* @brief Constructor that converts `long long` to BigInt
*
* @param num a `long long` value
* @return BigInt with equal value as `num`
*/

BigInt::BigInt(const long long& num) {
value = std::to_string(num);
Expand All @@ -49,11 +52,12 @@ BigInt::BigInt(const long long& num) {
}


/*
String to BigInt
----------------
*/

/**
* @brief Constructor that converts `std::string` to BigInt
*
* @param num std::string that represents an integer
* @return BigInt with value represented in `num`
*/
BigInt::BigInt(const std::string& num) {
if (num[0] == '+' or num[0] == '-') { // check for sign
std::string magnitude = num.substr(1);
Expand Down
68 changes: 34 additions & 34 deletions include/functions/conversion.hpp
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
/*
===========================================================================
Conversion functions for BigInt
===========================================================================
*/
/**
* @file functions/conversion.hpp
*
* @brief Contains conversion related functions of BigInt
*/

#ifndef BIG_INT_CONVERSION_FUNCTIONS_HPP
#define BIG_INT_CONVERSION_FUNCTIONS_HPP


/*
to_string
---------
Converts a BigInt to a string.
*/

/**
* @brief Converts BigInt into an `std::string` representation
*
* Returns the string representation of the integer with a prefix of
* '-' if negative, and no prefix otherwise.
*
* @return `std::string` representing BigInt value
*/
std::string BigInt::to_string() const {
// prefix with sign if negative
return this->sign == '-' ? "-" + this->value : this->value;
}


/*
to_int
------
Converts a BigInt to an int.
NOTE: If the BigInt is out of range of an int, stoi() will throw an
out_of_range exception.
*/

/**
* @brief Converts BigInt into `int`
*
* @return `int` containing BigInt value.
* \warning If the BigInt range is outside the accepted range of an `int`,
* `out_of_range` exception will be thrown.
*/
int BigInt::to_int() const {
return std::stoi(this->to_string());
}


/*
to_long
-------
Converts a BigInt to a long int.
NOTE: If the BigInt is out of range of a long int, stol() will throw an
out_of_range exception.
*/

/**
* @brief Converts BigInt into `long`
*
* @return `long` containing BigInt value.
* \warning If the BigInt range is outside the accepted range of an `long`,
* `out_of_range` exception will be thrown.
*/
long BigInt::to_long() const {
return std::stol(this->to_string());
}


/*
to_long_long
------------
Converts a BigInt to a long long int.
NOTE: If the BigInt is out of range of a long long int, stoll() will throw
an out_of_range exception.
*/

/**
* @brief Converts BigInt into `long long`
*
* @return `long long` containing BigInt value.
* \warning If the BigInt range is outside the accepted range of an `long long`,
* `out_of_range` exception will be thrown.
*/
long long BigInt::to_long_long() const {
return std::stoll(this->to_string());
}
Expand Down
Loading