bogon.cpp

Go to the documentation of this file.
00001 /*****************************************************************************\
00002 *                                                                             *
00003 *  Name   : bogon                                                             *
00004 *  Author : Chris Koeritz                                                     *
00005 *                                                                             *
00006 *  Purpose:                                                                   *
00007 *                                                                             *
00008 *    A simple test object for amorphs.                                        *
00009 *                                                                             *
00010 *******************************************************************************
00011 * Copyright (c) 1996-$now By Author.  This program is free software; you can  *
00012 * redistribute it and/or modify it under the terms of the GNU General Public  *
00013 * License as published by the Free Software Foundation; either version 2 of   *
00014 * the License or (at your option) any later version.  This is online at:      *
00015 *     http://www.fsf.org/copyleft/gpl.html                                    *
00016 * Please send any updates to: fred@gruntose.com                               *
00017 \*****************************************************************************/
00018 
00019 #define DEBUG_ARRAY
00020 #define DEBUG_AMORPH
00021 
00022 #include <basis/istring.h>
00023 #include <data_struct/amorph.h>
00024 
00025 #include <string.h>
00026 
00027 class bogon
00028 {
00029 public:
00030   bogon(byte *to_copy) : my_held(NIL) {
00031     if (to_copy) {
00032       istring t((char *)to_copy);
00033       if (t.length()) {
00034         my_held = new byte[t.length() + 1];
00035         t.stuff((char *)my_held, t.length() + 1);
00036       }
00037     }
00038   }
00039   bogon(const bogon &to_copy) : my_held(NIL) { operator = (to_copy); }
00040   bogon &operator = (const bogon &to_copy) {
00041     if (this == &to_copy) return *this;
00042     istring t((char *)to_copy.my_held);
00043     if (my_held) delete [] my_held;
00044     my_held = new byte[t.length() + 1];
00045     t.stuff((char *)my_held, t.length() + 1);
00046     return *this;
00047   }
00048   ~bogon() { if (my_held) delete [] my_held; }
00049   byte *held() const { return my_held; }
00050   int size() const { return my_held? int(strlen((char *)my_held) + 1) : 0; }
00051 
00052 private:
00053   byte *my_held;
00054 };

Generated on Fri Nov 28 04:29:36 2008 for HOOPLE Libraries by  doxygen 1.5.1