University of Sheffield   

    The Simons
    Component Library

Introduction   Class Hierarchy   Class Listing   Index of Classes   Index of Methods   Header Files  

String.h

00001 
00002 //
00003 //  SCL : Simons Component Library
00004 //
00006 //
00007 //  Filename:   String.h
00008 //  Contents:   String class
00009 //  Author:     Anthony J H Simons
00010 //  Revised:    17 November 2005
00011 
00012 // This software is distributed free in the hope that others will
00013 // find it useful.  However, it comes WITHOUT ANY WARRANTY.  No
00014 // liability can be accepted for software failure, merchantability
00015 // or fitness for a particular purpose.  You can redistribute this
00016 // software in its original form, or in a modified form, provided
00017 // that this disclaimer is retained in the file banner.
00018 
00019 #ifndef STRING
00020 #define STRING
00021 
00022 #include "Sequence.h"           // Include my superclass type
00023 #include "StringID.h"           // Include my pointer type
00024 
00025 #include "ReaderID.h"           // Depends on the pointer types
00026 #include "WriterID.h"
00027 
00040 
00041 class String : public Sequence {
00042 private:
00043         Natural alloc;
00044         Natural items;
00045         Character* block;
00046         static Character dummyString[1];
00047         enum Constants { INITIAL = 15, MAXDIGITS = 20 };
00048 protected:
00049         String(const String&);
00050         String(const String&, Natural);
00051 public:
00052         String();
00053         virtual ~String();
00054         String(const Character*);
00055         String(CollectionID);
00056         String(Boolean);
00057         String(Character);
00058         String(Natural);
00059         String(Integer);
00060         String(Decimal, Natural=5);
00061         virtual ObjectID clone() const;
00062         virtual Natural hash() const;
00063         virtual Order compare(ObjectID) const;
00064         Order compare(StringID) const;
00065         virtual Void readOn(ReaderID);
00066         virtual Void writeOn(WriterID) const;
00067         virtual Natural size() const;
00068         virtual ObjectID getAt(Integer) const;
00069         virtual Void putAt(Integer, ObjectID);
00070         virtual Void addAt(Integer, ObjectID);
00071         virtual Void removeAt(Integer);
00072         Boolean has(Character) const;
00073         virtual Boolean has(ObjectID) const;
00074         Void addAll(StringID);  
00075         virtual Void addAll(CollectionID);      
00076         Character getValue(Integer) const;
00077         Void putValue(Integer, Character);
00078         Integer indexOf(Character, Integer = 0) const;
00079         Integer indexOfString(StringID, Integer = 0) const;
00080         Integer indexOfBag(StringID, Integer = 0) const;
00081         StringID subString(Integer) const;
00082         StringID subString(Integer, Natural) const;
00083         Boolean toBoolean() const;
00084         Character toCharacter() const;
00085         Natural toNatural() const;
00086         Integer toInteger() const;
00087         Decimal toDecimal() const;
00088         const Character* value() const;
00089 };
00090 
00092 
00095 inline StringID::StringID() {}
00096 
00098 inline StringID::~StringID() {}
00099 
00103 inline StringID::StringID(const Null* null) :
00104         SequenceID(null) {}
00105         
00109 inline StringID::StringID(const String* string) :
00110         SequenceID(string) {}
00111         
00115 inline StringID::StringID(const StringID& pointer) :
00116         SequenceID(pointer) {}
00117         
00122 inline StringID::StringID(const Character* literal) : 
00123         SequenceID(new String(literal)) {}
00124 
00128 inline StringID& StringID::operator=(const String* string) {
00129         assign(string);
00130         return *this;
00131 }
00132 
00137 inline StringID& StringID::operator=(const StringID& pointer) {
00138         assign(pointer);
00139         return *this;
00140 }
00141 
00142 
00143 #endif
00144 

Generated on Fri May 5 17:17:15 2006 for The Simons Component Library by doxygen1.3