00001 00002 // 00003 // This file is part of the MADELINE 2 program 00004 // written by Edward H. Trager, Ritu Khanna and Adrian Marrs 00005 // Copyright (c) 2005 by the 00006 // Regents of the University of Michigan. 00007 // All Rights Reserved. 00008 // 00009 // The latest version of this program is available from: 00010 // 00011 // http://eyegene.ophthy.med.umich.edu/madeline/ 00012 // 00013 // Released under the GNU General Public License. 00014 // A copy of the GPL is included in the distribution 00015 // package of this software, or see: 00016 // 00017 // http://www.gnu.org/copyleft/ 00018 // 00019 // ... for licensing details. 00020 // 00022 // 00023 // 2005.03.31.ET.RK 00024 // 00025 00026 // 00027 // String.h 00028 // 00029 #ifndef STRING_INCLUDED 00030 #define STRING_INCLUDED 00031 00032 #include "Data.h" 00033 #include <string> 00034 #include <iostream> 00036 00037 class String : public Data{ 00038 private: 00039 00040 static std::set<std::string> _stringMissingValue; 00041 00042 protected: 00043 00044 // 00045 // These are protected so that the derived Affected class 00046 // can have direct access: 00047 // 00048 std::string _value; 00049 bool _isMissing; 00050 00051 public: 00052 // 00053 // Constructors: 00054 // 00055 String() { _isMissing=true;_value="."; } 00056 String( const std::string value ){ set(value); } 00057 String( const char* value ){ set(value); } 00058 00059 // 00060 // Static Methods: 00061 // 00062 static void addStringMissingValue(std::string value){ _stringMissingValue.insert(value); } 00063 static bool isMissingValue(std::string value); 00064 00065 // 00066 // Methods required by Variable virtual base class: 00067 // 00068 bool isMissing( void ) const { return _isMissing; } 00069 void setMissing( void ) { _isMissing=true; _value="."; } 00070 void set( const std::string &value); 00071 void set( const char* value); 00072 const std::string get( void ) const { if(_isMissing) return "."; return _value; } 00073 // 00074 // Operators: 00075 // 00076 String operator+( const String& b) const; 00077 String& operator+=(const String& b); 00078 bool operator==(const Data& b) const; 00079 bool operator<(const Data& b) const; 00080 bool operator!=(const String& b) const; 00081 bool operator<=(const String& b) const; 00082 bool operator>=(const String& b) const; 00083 bool operator>(const String& b) const; 00084 00085 // Added on 2005-07-17 00086 const DATATYPE getDataType( void ) const { return STRING; } 00087 virtual String* clone() const; 00088 00089 char operator[](unsigned int n); 00090 00091 00092 }; 00093 std::ostream& operator<<(std::ostream& s,const String& n); 00094 #endif