00001 /* 00002 * Character.h 00003 * 00004 * Smalltalk like class library for C++ 00005 * Character wrapper. Header. 00006 * 00007 * Copyright (c) 2003 Milan Cermak 00008 */ 00009 /* 00010 * This library is free software; you can redistribute it and/or 00011 * modify it under the terms of the GNU Lesser General Public 00012 * License as published by the Free Software Foundation; either 00013 * version 2.1 of the License, or (at your option) any later version. 00014 * 00015 * This library is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * Lesser General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU Lesser General Public 00021 * License along with this library; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00023 */ 00024 #ifndef __CHARACTER_H 00025 #define __CHARACTER_H 00026 00027 #include <stlib/Object.h> 00028 00029 namespace Core { 00030 00031 class Dictionary; 00032 class Integer; 00033 class String; 00034 class Stream; 00035 class Visitor; 00036 00038 class Character : public Object // : public Magnitude 00039 { 00040 protected: 00041 unsigned long _value; 00042 static Dictionary *character_store; 00043 00044 protected: 00045 Character(unsigned long val); 00046 00047 public: 00048 /* Class-accessing protocol */ 00049 virtual String *className(void) const; 00050 static Dictionary *characterStore(void); 00051 00052 /* Class-constants protocol */ 00053 static Character *cr(void); 00054 static Character *lf(void); 00055 static Character *space(void); 00056 static Character *tab(void); 00057 00058 /* Instance creation protocol */ 00059 static Character *value(unsigned long val); 00060 static Character *value(Integer *val); 00061 00062 /* Accessing protocol */ 00063 virtual int byteSize(void); 00064 virtual int digitValue(void); 00065 00066 /* Comparing protocol */ 00067 virtual long hash(void) const; 00068 virtual bool isEqual(const Object *object) const; 00069 virtual bool isEqual(const Object &object) const 00070 { return Object::isEqual(object); } 00071 virtual bool isEqual(char cChar) const; 00072 00073 /* Converting protocol */ 00074 virtual unsigned long asInteger(void); 00076 virtual Character *asLowercase(void); 00078 virtual Character *asUppercase(void); 00079 00080 /* Printing protocol */ 00081 virtual void printOn(Stream *stream) const; 00082 00083 /* Testing protocol */ 00084 virtual bool isCharacter(void) const; 00085 virtual bool isDigit(void) const; 00086 virtual bool isLowercase(void) const; 00087 virtual bool isSeparator(void) const; 00088 virtual bool isUppercase(void) const; 00089 virtual bool isVowel(void) const; 00090 00091 /* Visiting protocol */ 00092 virtual void visitBy(Visitor *visitor); 00093 }; 00094 00095 }; 00096 00097 #endif /* __CHARACTER_H */