Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60954 - in sandbox/xint: boost/xint libs/xint/example
From: pbristow_at_[hidden]
Date: 2010-03-30 12:57:40


Author: pbristow
Date: 2010-03-30 12:57:40 EDT (Tue, 30 Mar 2010)
New Revision: 60954
URL: http://svn.boost.org/trac/boost/changeset/60954

Log:
Doxygen commented files
Text files modified:
   sandbox/xint/boost/xint/xint.hpp | 43 +++++++++++++++++++++------------------
   sandbox/xint/libs/xint/example/xint_fibonacci.cpp | 24 ++++++++++++++++++---
   sandbox/xint/libs/xint/example/xint_simple.cpp | 35 +++++++++++++++++--------------
   3 files changed, 62 insertions(+), 40 deletions(-)

Modified: sandbox/xint/boost/xint/xint.hpp
==============================================================================
--- sandbox/xint/boost/xint/xint.hpp (original)
+++ sandbox/xint/boost/xint/xint.hpp 2010-03-30 12:57:40 EDT (Tue, 30 Mar 2010)
@@ -28,8 +28,10 @@
 It has the Boost Software License, Version 1.0. at
 http://www.boost.org/LICENSE_1_0.txt
 
-Documentation is at https://svn.boost.org/svn/boost/sandbox/xint/libs/xint/doc/html/index/html
+Documentation in full as html is at
+https://svn.boost.org/svn/boost/sandbox/xint/libs/xint/doc/html/index/html
 
+and a pdf version is also available.
 
 */
 // Copyright 2010 by Chad Nelson
@@ -52,14 +54,14 @@
 #include <boost/function.hpp>
 #include <boost/static_assert.hpp>
 
+//! \namespace xint namespace for all extended integer classes and functions.
 namespace xint
-{ //! xint namespace for all extended integer classes and functions.
-
+{
 ////////////////////////////////////////////////////////////////////////////////
 // The boring-but-necessary preliminary stuff
 
 namespace detail
-{ //! xint implementation details, normal users should not need to use these.
+{ //! \namespace xint::detail implementation details, normal users should not need to use these.
     typedef boost::uintmax_t doubledigit_t;
     typedef boost::uint_t<std::numeric_limits<doubledigit_t>::digits / 2>::fast
         digit_t;
@@ -89,21 +91,23 @@
 // The integer class
 
 class integer
-{ //! \brief the extended integer class.
+{ //! \brief The extended integer class.
+ //! \details
     public:
- integer();
- integer(const integer& b);
- template <typename T> integer(const T& n);
- explicit integer(const std::string& str, size_t base=10);
+ integer(); //!< Constructs a default integer, value zero. (Can throw std::overflow_error if not enough memory to construct a new integer).
+ integer(const integer& b); //!< Copy constructs a integer from another integer.
+ //!< (Can throw std::overflow_error if not enough memory to construct a new integer).
+ template <typename T> integer(const T& n);
+ explicit integer(const std::string& str, size_t base=10); //!< Copy constructs a integer from a digits string (decimal by default).
     explicit integer(const not_a_number&); //!< Constructs an extended integer with the NotANumber value;
     ~integer();
 
- bool odd() const; //! \returns true if extended integer is odd.
- bool even() const; //! \returns true if extended integer is even.
- int sign() const; //! \returns -1 if extended integer is < 0.
- bool nan() const; //! \returns true if extended integer is Not-a-Number.
+ bool odd() const; //!< \returns true if extended integer is odd.
+ bool even() const; //!< \returns true if extended integer is even.
+ int sign() const; //!< \returns -1 if extended integer is < 0.
+ bool nan() const; //!< \returns true if extended integer is Not-a-Number.
 
- size_t hex_digits() const;
+ size_t hex_digits() const; //!< \returns the number of hex digits to show the integer.
 
     integer& operator=(const integer &c);
 
@@ -126,8 +130,8 @@
     integer& operator<<=(size_t shift);
     integer& operator>>=(size_t shift);
 
- static const integer& zero();
- static const integer& one();
+ static const integer& zero(); //!< Extended integer holding zero.
+ static const integer& one(); //!< Extended integer holding one.
 
     // These are used internally, they're probably not useful outside of the
     // library's functions.
@@ -149,10 +153,9 @@
     void _attach();
     void _detach();
 
- static const integer *cZero; //!< Plain integer holding zero.
- static const integer *cOne; //!< Plain integer holding one.
-
- detail::data_t *data; //!< raw data representing an extended integer.
+ static const integer *cZero;
+ static const integer *cOne;
+ detail::data_t *data; //!< Raw data representing an extended integer.
 };
 
 ////////////////////////////////////////////////////////////////////////////////

Modified: sandbox/xint/libs/xint/example/xint_fibonacci.cpp
==============================================================================
--- sandbox/xint/libs/xint/example/xint_fibonacci.cpp (original)
+++ sandbox/xint/libs/xint/example/xint_fibonacci.cpp 2010-03-30 12:57:40 EDT (Tue, 30 Mar 2010)
@@ -11,6 +11,12 @@
 \brief Simple demo of xint sending the fibonacci sequence to stream output.
 \details
 
+Fibonacci numbers are a sequence of numbers, starting with the numbers 0 and 1, where each successive number is the sum of the previous two. The first few Fibonacci numbers are:
+
+ 0 1 1 2 3 5 8 13 21 34 55 89 144...
+
+You might be curious what the first Fibonacci number is that's too big to calculate using the standard C++ unsigned long type. A brute-force method of calculating this would be problematic, since it might not be possible to tell when it overflows. But with the XInt library, it's child's play.
+
 If you're not intimately familiar with the Fibonacci sequence,
 and how fast the numbers in it grow, the answer might shock you.
 
@@ -32,7 +38,7 @@
 
 //[xint_fibonacci_snippet_1
 
-// Select the limit, in this case the largest number
+// Select our limit, in this case the largest number
 // that will fit into an unsigned long:
   integer limit=(std::numeric_limits<unsigned long>::max)();
 
@@ -40,8 +46,8 @@
   integer n, n1=0, n2=1;
 //] [xint_fibonacci_snippet_1]
 
- // Now count the items in the sequence as we iterate over them, until we
- // come to the first one greater than the limit we've set.
+ // Now count the items in the sequence as we iterate over them,
+ // until we come to the first one greater than the limit we've set.
     size_t counter=0;
     cout << counter++ << ": " << n1 << endl;
     cout << counter++ << ": " << n2 << endl;
@@ -57,4 +63,14 @@
     }
 
     cout << "The answer is " << counter << " (" << n << ")." << endl;
-}
+} // int main()
+
+
+/*
+//[xint_fibonacci_output_1
+
+
+
+//] [xint_fibonacci_output_1]
+*/
+

Modified: sandbox/xint/libs/xint/example/xint_simple.cpp
==============================================================================
--- sandbox/xint/libs/xint/example/xint_simple.cpp (original)
+++ sandbox/xint/libs/xint/example/xint_simple.cpp 2010-03-30 12:57:40 EDT (Tue, 30 Mar 2010)
@@ -15,40 +15,43 @@
 
 #include <boost/xint/xint.hpp>
 
-#include <iostream>
-using std::cout;
-using std::endl;
-#include <iomanip>
-using std::setprecision;
-using std::setw;
-#include <limits>
+//#include <iostream>
+//using std::cout;
+//using std::endl;
+//#include <iomanip>
+//using std::setprecision;
+//using std::setw;
+//#include <limits>
 
 int main()
 {
   // TODO I think you should get this into the boost namespace now or there will be zillions of places to change.
   //using namespace boost::xint
 
- using namespace xint;
- using xint::integer;
+ //using namespace xint;
+ //using xint::integer;
 
 //[xint_simple_snippet_1
 
- integer a(2);
- integer b = 3;
-
- cout << a << ", b = " << b << ", a + b = " << a + b << endl;
-
-//] [xint_simple_snippet_1]
+ xint::integer a;
+ //integer b = 3;
 
+ //integer c = a + b;
 
+ //cout << a << ", b = " << b << ", a + b = " << a + b << endl;
 
+//] [xint_simple_snippet_1]
       return 0;
 } // int(main)
 
 /*
 
-Output
 
+//[xint_simple_output
+Output:
+
+
+//] [xint_simple_output]
 */
 
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk