dillo  3.0.5
About: dillo is a small, fast, extensible Web browser particularly suitable for older or smaller computers and embedded systems (but only limited or no support for frames, CSS, JavaScript, Java).
  Fossies Dox: dillo-3.0.5.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

object.hh
Go to the documentation of this file.
1 #ifndef __LOUT_OBJECT_HH__
2 #define __LOUT_OBJECT_HH__
3 
4 #include <stdlib.h>
5 #include <string.h>
6 
7 #include "misc.hh"
8 
9 namespace lout {
10 
15 namespace object {
16 
24 class Object
25 {
26 public:
27  virtual ~Object();
28  virtual bool equals(Object *other);
29  virtual int hashValue();
30  virtual Object *clone();
31  virtual void intoStringBuffer(misc::StringBuffer *sb);
32  const char *toString();
33  virtual size_t sizeOf();
34 };
35 
41 class Comparable: public Object
42 {
43 public:
57  virtual int compareTo(Comparable *other) = 0;
58 
59  static int compareFun(const void *p1, const void *p2);
60 };
61 
65 class Pointer: public Object
66 {
67 private:
68  void *value;
69 
70 public:
71  Pointer(void *value) { this->value = value; }
72  bool equals(Object *other);
73  int hashValue();
75  inline void *getValue() { return value; }
76 };
77 
81 template <class T> class TypedPointer: public Pointer
82 {
83 public:
84  inline TypedPointer(T *value) : Pointer ((void*)value) { }
85  inline T *getTypedValue() { return (T*)getValue(); }
86 };
87 
88 
92 class Integer: public Comparable
93 {
94  int value;
95 
96 public:
97  Integer(int value) { this->value = value; }
98  bool equals(Object *other);
99  int hashValue();
101  int compareTo(Comparable *other);
102  inline int getValue() { return value; }
103 };
104 
105 
111 class ConstString: public Comparable
112 {
113 protected:
114  const char *str;
115 
116 public:
117  ConstString(const char *str) { this->str = str; }
118  bool equals(Object *other);
119  int hashValue();
120  int compareTo(Comparable *other);
122 
123  inline const char *chars() { return str; }
124 
125  static int hashValue(const char *str);
126 };
127 
128 
134 class String: public ConstString
135 {
136 public:
137  String(const char *str);
138  ~String();
139 };
140 
144 class PairBase: public Object
145 {
146 protected:
148 
149 public:
151  ~PairBase();
152 
153  bool equals(Object *other);
154  int hashValue();
156  size_t sizeOf();
157 };
158 
162 class Pair: public PairBase
163 {
164 public:
166 
167  inline Object *getFirst () { return first; }
168  inline Object *getSecond () { return second; }
169 };
170 
174 template <class F, class S> class TypedPair: public PairBase
175 {
176 public:
178 
179  inline F *getFirst () { return first; }
180  inline S *getSecond () { return second; }
181 };
182 
183 } // namespace object
184 
185 } // namespace lout
186 
187 #endif // __LOUT_OBJECT_HH__
lout::object::ConstString::equals
bool equals(Object *other)
Returns, whether two objects are equal.
Definition: object.cc:201
lout::object::String::String
String(const char *str)
Definition: object.cc:251
lout::object::TypedPointer::TypedPointer
TypedPointer(T *value)
Definition: object.hh:84
lout::object::Integer
An object::Object wrapper for int's.
Definition: object.hh:92
lout::object::PairBase::first
Object * first
Definition: object.hh:147
lout::object::PairBase::PairBase
PairBase(Object *first, Object *second)
Definition: object.cc:265
lout::object::Pointer::getValue
void * getValue()
Definition: object.hh:75
lout::object::PairBase::sizeOf
size_t sizeOf()
Return the number of bytes, this object totally uses.
Definition: object.cc:328
lout::object::TypedPair::getSecond
S * getSecond()
Definition: object.hh:180
lout::object::PairBase::second
Object * second
Definition: object.hh:147
lout::object::ConstString
An object::Object wrapper for constant strings (char*).
Definition: object.hh:111
lout::object::Object::sizeOf
virtual size_t sizeOf()
Return the number of bytes, this object totally uses.
Definition: object.cc:103
lout::object::Pointer::equals
bool equals(Object *other)
Returns, whether two objects are equal.
Definition: object.cc:137
lout::object::TypedPair::getFirst
F * getFirst()
Definition: object.hh:179
lout::object::Integer::hashValue
int hashValue()
Return a hash value for the object.
Definition: object.cc:180
F
#define F(x, y, z)
lout::object::Integer::intoStringBuffer
void intoStringBuffer(misc::StringBuffer *sb)
Store a textual representation of the object in a misc::StringBuffer.
Definition: object.cc:185
lout::object::TypedPointer::getTypedValue
T * getTypedValue()
Definition: object.hh:85
lout::object::PairBase::equals
bool equals(Object *other)
Returns, whether two objects are equal.
Definition: object.cc:279
lout::object::Pointer::intoStringBuffer
void intoStringBuffer(misc::StringBuffer *sb)
Store a textual representation of the object in a misc::StringBuffer.
Definition: object.cc:164
lout::object::Pointer::hashValue
int hashValue()
Return a hash value for the object.
Definition: object.cc:142
lout::object::Object::intoStringBuffer
virtual void intoStringBuffer(misc::StringBuffer *sb)
Store a textual representation of the object in a misc::StringBuffer.
Definition: object.cc:95
lout::object::PairBase::intoStringBuffer
void intoStringBuffer(misc::StringBuffer *sb)
Store a textual representation of the object in a misc::StringBuffer.
Definition: object.cc:309
lout::object::PairBase
Definition: object.hh:144
lout::object::Integer::value
int value
Definition: object.hh:94
lout::object::String
An object::Object wrapper for strings (char*).
Definition: object.hh:134
lout::object::Object::clone
virtual Object * clone()
Return an exact copy of the object.
Definition: object.cc:68
lout::object::Pair::getFirst
Object * getFirst()
Definition: object.hh:167
lout::object::Object::~Object
virtual ~Object()
The destructor is defined as virtual (but not abstract), so that destruction of Object's works proper...
Definition: object.cc:39
lout::object::TypedPair::TypedPair
TypedPair(F *first, S *second)
Definition: object.hh:177
lout::object::Integer::Integer
Integer(int value)
Definition: object.hh:97
lout::misc::StringBuffer
A class for fast concatenation of a large number of strings.
Definition: misc.hh:493
lout::object::Object
This is the base class for many other classes, which defines very common virtual methods.
Definition: object.hh:24
lout::object::Pair::getSecond
Object * getSecond()
Definition: object.hh:168
lout
Definition: container.cc:26
lout::object::Pointer::value
void * value
Definition: object.hh:68
lout::object::Pair
Definition: object.hh:162
lout::object::String::~String
~String()
Definition: object.cc:255
lout::object::Comparable::compareTo
virtual int compareTo(Comparable *other)=0
Compare two objects c1 and c2.
lout::object::ConstString::compareTo
int compareTo(Comparable *other)
Compare two objects c1 and c2.
Definition: object.cc:217
lout::object::Integer::compareTo
int compareTo(Comparable *other)
Compare two objects c1 and c2.
Definition: object.cc:192
lout::object::Pointer
An object::Object wrapper for void pointers.
Definition: object.hh:65
lout::object::TypedPointer
A typed version of object::Pointer.
Definition: object.hh:81
lout::object::Pair::Pair
Pair(Object *first, Object *second)
Definition: object.hh:165
lout::object::Pointer::Pointer
Pointer(void *value)
Definition: object.hh:71
lout::object::Integer::equals
bool equals(Object *other)
Returns, whether two objects are equal.
Definition: object.cc:175
lout::object::ConstString::hashValue
int hashValue()
Return a hash value for the object.
Definition: object.cc:211
lout::object::ConstString::chars
const char * chars()
Definition: object.hh:123
lout::object::Comparable
Instances of a sub class of may be compared (less, greater).
Definition: object.hh:41
lout::object::Object::equals
virtual bool equals(Object *other)
Returns, whether two objects are equal.
Definition: object.cc:50
lout::object::Integer::getValue
int getValue()
Definition: object.hh:102
lout::object::Object::hashValue
virtual int hashValue()
Return a hash value for the object.
Definition: object.cc:59
lout::object::TypedPair
Definition: object.hh:174
lout::object::Comparable::compareFun
static int compareFun(const void *p1, const void *p2)
This static method may be used as compare function for qsort(3) and bsearch(3), for an array of Objec...
Definition: object.cc:118
lout::object::ConstString::ConstString
ConstString(const char *str)
Definition: object.hh:117
lout::object::Object::toString
const char * toString()
Use object::Object::intoStringBuffer to return a textual representation of the object.
Definition: object.cc:81
misc.hh
lout::object::ConstString::intoStringBuffer
void intoStringBuffer(misc::StringBuffer *sb)
Store a textual representation of the object in a misc::StringBuffer.
Definition: object.cc:242
lout::object::PairBase::hashValue
int hashValue()
Return a hash value for the object.
Definition: object.cc:297
lout::object::PairBase::~PairBase
~PairBase()
Definition: object.cc:271
lout::object::ConstString::str
const char * str
Definition: object.hh:114