GNU   davin.50webs.com/research
Bringing to you notes for the ages

       Main Menu          Research Projects         Photo Album            Curriculum Vitae      The Greatest Artists
    Email Address       Computer Games          Web Design          Java Training Wheels      The Fly (A Story)   
  Political Activism   Bob Dylan Quotes+       My Life Story          Smoking Cessation          Other Links      
Debugging Macros     String Class I     Linked List System I Java for C Programmers Naming Convention
    String Class II         How I use m4              Strings III                 Symmetrical I/O             Linked Lists II     
Run-Time Type Info   Virtual Methods      An Array System        Science & Religion            Submodes       
  Nested Packages      Memory Leaks    Garbage Collection      Internet & Poverty      What is Knowledge?
Limits of Evolution   Emacs Additions      Function Plotter           Romantic Love        The Next Big Thing
    Science Fiction     Faster Compilation   Theory of Morality           Elisp Scoping               Elisp Advice      
  S.O.G.M. Pattern       Safe Properties         School Bullying          Charisma Control          Life and Death    
     Splitting Java          Multiple Ctors       Religious Beliefs         Conversation 1           Conversation 2    
   J.T.W. Language    Emacs Additions II      Build Counter             Relation Plotter          Lisp++ Language  
  Memory Leaks II   Super Constructors CRUD Implementation Order a Website Form There Is No Afterlife
C to Java Translator


_Integer.hh

    
#ifndef ALREADY_INCLUDED_2006_LIBD_INTEGER_HH
#define ALREADY_INCLUDED_2006_LIBD_INTEGER_HH

#include "libd.hh"

namespace dmp
{
   ///
   /// NOTE: sizeof(Integer) == sizeof(Single) + sizeof(int) == 12 + 4 == 16
   ///
   class Integer : private Single
   {
   public:
      int v;
      POOL1;

   private:
      Integer(int v) : Single(DCODE_INTEGER)
      {
         this->v = v;
      }

   public:
      static ptr<Integer> ctor()
      {
         return new Integer(0);
      }
      static ptr<Integer> ctor(int v)
      {
         return new Integer(v);
      }
      ptr<Integer> clone_shallow()
      {
         return new Integer(this->v);
      }
      ptr<Integer> clone_deep()
      {
         return new Integer(this->v);
      }

   private:
      ///
      /// NOTE: opens up ~Integer() to ptr class
      ///
      friend class ptr<Integer>;
      ~Integer()
      {
         ///
         /// NOTE: do nothing
         ///
      }

      ///
      /// NOTE: disables passing and returning by value
      ///
   private:
      Integer(const Integer&);
      Integer& operator = (const Integer&);

      // public:
      //    operator int ()
      //    {
      //       return v;
      //    }

      ///
      /// USED BY: *_equals methods
      ///
      friend bool operator == (const Integer& i1, const Integer& i2)
      {
         return i1.v == i2.v;
      }
      friend bool operator != (const Integer& i1, const Integer& i2)
      {
         return i1.v != i2.v;
      }

      friend dmp::string_buffer operator + (const dmp::string& s, const Integer&  i)
      {
         dmp::string_buffer sb;
         sb << s;
         sb << i.v;
         return sb;
      }
      friend dmp::string_buffer operator + (const dmp::string_buffer& csb, const Integer& i)
      {
         dmp::string_buffer sb = const_cast<dmp::string_buffer&>(csb);
         sb << i.v;
         return sb;
      }

#ifdef DAVINS_IO_ONLINE
      friend dmp::Writer& operator << (dmp::Writer& w, const Integer& i)
      {
         ASSERT(&w != null);
         ASSERT(&i != null);
         w << i.v;
         // if ((&i == null) || (p.get_ptr() == null))
         // {
         //    w << "null";
         // }
         // else
         // {
         //    w << p.get_ptr()->v;
         // }
         return w;
      }
      friend dmp::Reader& operator >> (dmp::Reader& r, Integer& i)
      {
         //CHECKPOINT;
         ASSERT(&r != null);
         ASSERT(&i != null);
         r >> i.v;
         // if (r.looking_at("null"))
         // {
         //    p = null;
         //    r.next_token();
         // }
         // else
         // {
         //    r >> p->v;
         // }
         //CHECKPOINT;
         return r;
      }
#endif /* DAVINS_IO_ONLINE */
   };
}

#endif /* ALREADY_INCLUDED_2006_LIBD_INTEGER_HH */
Back
| Main Menu | Research Projects | Photo Album | Curriculum Vitae | The Greatest Artists |
| Email Address | Computer Games | Web Design | Java Training Wheels | The Fly (A Story) |
| Political Activism | Bob Dylan Quotes+ | My Life Story | Smoking Cessation | Other Links |
| Debugging Macros | String Class I | Linked List System I | Java for C Programmers | Naming Convention |
| String Class II | How I use m4 | Strings III | Symmetrical I/O | Linked Lists II |
| Run-Time Type Info | Virtual Methods | An Array System | Science & Religion | Submodes |
| Nested Packages | Memory Leaks | Garbage Collection | Internet & Poverty | What is Knowledge? |
| Limits of Evolution | Emacs Additions | Function Plotter | Romantic Love | The Next Big Thing |
| Science Fiction | Faster Compilation | Theory of Morality | Elisp Scoping | Elisp Advice |
| S.O.G.M. Pattern | Safe Properties | School Bullying | Charisma Control | Life and Death |
| Splitting Java | Multiple Ctors | Religious Beliefs | Conversation 1 | Conversation 2 |
| J.T.W. Language | Emacs Additions II | Build Counter | Relation Plotter | Lisp++ Language |
| Memory Leaks II | Super Constructors | CRUD Implementation | Order a Website Form | There Is No Afterlife |
| C to Java Translator |

Last modified: Wed Jun 8 20:52:11 NZST 2016
Best viewed at 800x600 or above resolution.
© Copyright 1999-2016 Davin Pearson.
Please report any broken links to