Vault  4.1
vchar.h
Go to the documentation of this file.
00001 /*
00002 Copyright c1997-2014 Trygve Isaacson. All rights reserved.
00003 This file is part of the Code Vault version 4.1
00004 http://www.bombaydigital.com/
00005 License: MIT. See LICENSE.md in the Vault top level directory.
00006 */
00007 
00008 #ifndef vchar_h
00009 #define vchar_h
00010 
00013 #include "vtypes.h"
00014 
00016 #define VCHAR_NULL_TERMINATOR '\0'
00017 
00035 class VChar {
00036     public:
00037 
00041         static const VChar& NULL_CHAR();
00042 
00046         VChar();
00051         VChar(char c);
00057         VChar(int i);
00058 
00063         VChar& operator=(char c);
00068         VChar& operator=(int i);
00069 
00074         bool isLowerCase() const;
00079         VChar lowerCase() const;
00083         void toLowerCase();
00088         bool isUpperCase() const;
00093         VChar upperCase() const;
00097         void toUpperCase();
00102         char charValue() const;
00107         int intValue() const;
00112         void set(char c);
00117         void set(int i);
00122         operator char() const;
00123 
00124         // These utilities only make sense for simple ASCII parsing purposes;
00125         // they only look at values in the base ASCII range below 128.
00126         bool isAlpha() const;           
00127         bool isNumeric() const;         
00128         bool isAlphaNumeric() const;    
00129         bool isWhitespace() const;      
00130         bool isHexadecimal() const;     
00131 
00132         static bool equalsIgnoreCase(const VChar& c1, const VChar& c2); 
00133         static bool equalsIgnoreCase(const VChar& c1, char c2);         
00134         static bool equalsIgnoreCase(char c1, const VChar& c2);         
00135         static bool equalsIgnoreCase(char c1, char c2);                 
00136 
00137         friend inline bool operator==(const VChar& lhs, const VChar& rhs);
00138 #ifndef VPLATFORM_DISALLOW_VCHAR_OPERATOR_EQUALS_CHAR
00139         friend inline bool operator==(const VChar& lhs, char rhs);
00140         friend inline bool operator==(char lhs, const VChar& rhs);
00141 #endif
00142 
00143         friend inline bool operator!=(const VChar& lhs, const VChar& rhs);
00144 #ifndef VPLATFORM_DISALLOW_VCHAR_OPERATOR_EQUALS_CHAR
00145         friend inline bool operator!=(const VChar& lhs, char rhs);
00146         friend inline bool operator!=(char lhs, const VChar& rhs);
00147 #endif
00148 
00149         friend inline bool operator<(const VChar& lhs, const VChar& rhs);
00150         friend inline bool operator<(const VChar& lhs, char rhs);
00151         friend inline bool operator<(char lhs, const VChar& rhs);
00152 
00153         friend inline bool operator<=(const VChar& lhs, const VChar& rhs);
00154         friend inline bool operator<=(const VChar& lhs, char rhs);
00155         friend inline bool operator<=(char lhs, const VChar& rhs);
00156 
00157         friend inline bool operator>=(const VChar& lhs, const VChar& rhs);
00158         friend inline bool operator>=(const VChar& lhs, char rhs);
00159         friend inline bool operator>=(char lhs, const VChar& rhs);
00160 
00161         friend inline bool operator>(const VChar& lhs, const VChar& rhs);
00162         friend inline bool operator>(const VChar& lhs, char rhs);
00163         friend inline bool operator>(char lhs, const VChar& rhs);
00164 
00165     private:
00166 
00167         char mValue;    
00168 };
00169 
00170 inline bool operator==(const VChar& lhs, const VChar& rhs) { return lhs.mValue == rhs.mValue; } 
00171 #ifndef VPLATFORM_DISALLOW_VCHAR_OPERATOR_EQUALS_CHAR
00172 inline bool operator==(const VChar& lhs, char rhs) { return lhs.mValue == rhs; }                
00173 inline bool operator==(char lhs, const VChar& rhs) { return lhs == rhs.mValue; }                
00174 #endif
00175 
00176 inline bool operator!=(const VChar& lhs, const VChar& rhs) { return !operator==(lhs, rhs); }    
00177 #ifndef VPLATFORM_DISALLOW_VCHAR_OPERATOR_EQUALS_CHAR
00178 inline bool operator!=(const VChar& lhs, char rhs) { return !operator==(lhs, rhs); }            
00179 inline bool operator!=(char lhs, const VChar& rhs) { return !operator==(lhs, rhs); }            
00180 #endif
00181 
00182 inline bool operator<(const VChar& lhs, const VChar& rhs) { return lhs.mValue < rhs.mValue; }   
00183 inline bool operator<(const VChar& lhs, char rhs) { return lhs.mValue < rhs; }                  
00184 inline bool operator<(char lhs, const VChar& rhs) { return lhs < rhs.mValue; }                  
00185 
00186 inline bool operator<=(const VChar& lhs, const VChar& rhs) { return !operator>(lhs, rhs); }     
00187 inline bool operator<=(const VChar& lhs, char rhs) { return !operator>(lhs, rhs); }             
00188 inline bool operator<=(char lhs, const VChar& rhs) { return !operator>(lhs, rhs); }             
00189 
00190 inline bool operator>=(const VChar& lhs, const VChar& rhs) { return !operator<(lhs, rhs); }     
00191 inline bool operator>=(const VChar& lhs, char rhs) { return !operator<(lhs, rhs); }             
00192 inline bool operator>=(char lhs, const VChar& rhs) { return !operator<(lhs, rhs); }             
00193 
00194 inline bool operator>(const VChar& lhs, const VChar& rhs) { return operator<(rhs, lhs); }       
00195 inline bool operator>(const VChar& lhs, char rhs) { return operator<(rhs, lhs); }               
00196 inline bool operator>(char lhs, const VChar& rhs) { return operator<(rhs, lhs); }               
00197 
00198 #endif /* vchar_h */

Copyright ©1997-2014 Trygve Isaacson. All rights reserved. This documentation was generated with Doxygen.