number_long Class Reference

#include <number_impl.hpp>

Inheritance diagram for number_long:

number_impl

List of all members.

Public Member Functions

 number_long (long value)
long value () const
virtual number_implpromote_to_void ()
virtual number_implpromote_to_rational ()
virtual number_implpromote_to_double ()

Private Member Functions

virtual std::string do_to_string () const
virtual void do_save (std::ostream &stream) const
virtual bool do_equals (number_impl const &rhs) const
virtual bool do_less (number_impl const &rhs) const
virtual number_impldo_add (number_impl const &rhs)
virtual number_impldo_subtract (number_impl const &rhs)
virtual number_impldo_multiply (number_impl const &rhs)
virtual number_impldo_divide (number_impl const &rhs)
virtual number_impldo_promote (number_impl &rhs) const

Private Attributes

long value_


Detailed Description

Represent an integer. For the greatest range, always use long to represent integers.

Definition at line 95 of file number_impl.hpp.


Constructor & Destructor Documentation

number_long::number_long ( long  value  )  [inline]

Definition at line 97 of file number_impl.hpp.

Referenced by do_add(), do_multiply(), and do_subtract().

00097 : number_impl(), value_(value) {}


Member Function Documentation

long number_long::value (  )  const [inline]

Definition at line 98 of file number_impl.hpp.

References value_.

Referenced by do_add(), do_divide(), do_equals(), do_less(), do_multiply(), do_save(), do_subtract(), do_to_string(), promote_to_double(), and promote_to_rational().

00098 { return value_; }

number_impl * number_long::promote_to_void (  )  [virtual]

Reimplemented from number_impl.

Definition at line 249 of file number_impl.cpp.

00250 {
00251   return new number_void();
00252 }

number_impl * number_long::promote_to_rational (  )  [virtual]

Reimplemented from number_impl.

Definition at line 254 of file number_impl.cpp.

References value().

00255 {
00256   return new number_rational(value());
00257 }

number_impl * number_long::promote_to_double (  )  [virtual]

Reimplemented from number_impl.

Definition at line 259 of file number_impl.cpp.

References value().

00260 {
00261   return new number_double(value());
00262 }

std::string number_long::do_to_string (  )  const [private, virtual]

Implements number_impl.

Definition at line 194 of file number_impl.cpp.

References value().

00196 {
00197   std::ostringstream stream;
00198   stream << value();
00199   return stream.str();
00200 }

void number_long::do_save ( std::ostream &  stream  )  const [private, virtual]

Implements number_impl.

Definition at line 202 of file number_impl.cpp.

References value().

00204 {
00205   stream << "long " << value() << ' ';
00206 }

bool number_long::do_equals ( number_impl const &  rhs  )  const [private, virtual]

Implements number_impl.

Definition at line 208 of file number_impl.cpp.

References value().

00210 {
00211   return value() == dynamic_cast<number_long const&>(rhs).value();
00212 }

bool number_long::do_less ( number_impl const &  rhs  )  const [private, virtual]

Implements number_impl.

Definition at line 214 of file number_impl.cpp.

References value().

00216 {
00217   return value() < dynamic_cast<number_long const&>(rhs).value();
00218 }

number_impl * number_long::do_add ( number_impl const &  rhs  )  [private, virtual]

Implements number_impl.

Definition at line 220 of file number_impl.cpp.

References number_long(), value(), and value_.

00221 {
00222   return new number_long(value_ + dynamic_cast<number_long const&>(rhs).value());
00223 }

number_impl * number_long::do_subtract ( number_impl const &  rhs  )  [private, virtual]

Implements number_impl.

Definition at line 225 of file number_impl.cpp.

References number_long(), value(), and value_.

00226 {
00227   return new number_long(value_ - dynamic_cast<number_long const&>(rhs).value());
00228 }

number_impl * number_long::do_multiply ( number_impl const &  rhs  )  [private, virtual]

Implements number_impl.

Definition at line 230 of file number_impl.cpp.

References number_long(), value(), and value_.

00231 {
00232   return new number_long(value_ * dynamic_cast<number_long const&>(rhs).value());
00233 }

number_impl * number_long::do_divide ( number_impl const &  rhs  )  [private, virtual]

Implements number_impl.

Definition at line 235 of file number_impl.cpp.

References value(), and value_.

00236 {
00237   long right = dynamic_cast<number_long const&>(rhs).value();
00238   if (right == 0)
00239     throw calc_error("division by zero");
00240   return new number_rational(value_, right);
00241 }

number_impl * number_long::do_promote ( number_impl rhs  )  const [private, virtual]

Implements number_impl.

Definition at line 243 of file number_impl.cpp.

References number_impl::promote_to_long().

00245 {
00246   return rhs.promote_to_long();
00247 }


Member Data Documentation

long number_long::value_ [private]

Definition at line 113 of file number_impl.hpp.

Referenced by do_add(), do_divide(), do_multiply(), do_subtract(), and value().


The documentation for this class was generated from the following files:
Generated on Sun Nov 30 10:06:54 2008 for Calculator by  doxygen 1.5.3