00001
00002
00003
00004
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef STRING
00020 #define STRING
00021
00022 #include "Sequence.h"
00023 #include "StringID.h"
00024
00025 #include "ReaderID.h"
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