Changeset 798 in webkit for trunk/JavaScriptCore/kjs/ustring.h
- Timestamp:
- Mar 21, 2002, 4:31:57 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/ustring.h
r6 r798 1 // -*- c-basic-offset: 2 -*- 1 2 /* 2 3 * This file is part of the KDE libraries … … 17 18 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 19 * Boston, MA 02111-1307, USA. 20 * 21 * $Id$ 19 22 */ 20 23 21 #ifndef _KJS_ STRING_H_22 #define _KJS_ STRING_H_24 #ifndef _KJS_USTRING_H_ 25 #define _KJS_USTRING_H_ 23 26 24 27 #ifdef HAVE_CONFIG_H 25 28 #include <config.h> 29 #endif 30 31 #ifdef APPLE_CHANGES 32 #include <KWQDef.h> 26 33 #endif 27 34 … … 36 43 class QConstString; 37 44 38 #if defined(__GNUC__)39 #define KJS_PACKED __attribute__((__packed__))40 #else41 #define KJS_PACKED42 #endif43 44 45 namespace KJS { 45 46 … … 74 75 * @return The higher byte of the character. 75 76 */ 76 unsigned char high() const { return hi; }77 unsigned char high() const { return uc >> 8; } 77 78 /** 78 79 * @return The lower byte of the character. 79 80 */ 80 unsigned char low() const { return lo; }81 unsigned char low() const { return uc & 0xFF; } 81 82 /** 82 83 * @return the 16 bit Unicode value of the character 83 84 */ 84 unsigned short unicode() const { return hi << 8 | lo; }85 unsigned short unicode() const { return uc; } 85 86 public: 86 87 /** … … 102 103 friend bool operator==(const UString& s1, const char *s2); 103 104 friend bool operator<(const UString& s1, const UString& s2); 104 #ifdef KJS_SWAPPED_CHAR 105 unsigned char lo; 106 unsigned char hi; 107 #else 108 unsigned char hi; 109 unsigned char lo; 110 #endif 111 } KJS_PACKED; 112 113 114 #ifdef KJS_SWAPPED_CHAR // to avoid reorder warnings 115 inline UChar::UChar() : lo(0), hi(0) { } 116 inline UChar::UChar(unsigned char h , unsigned char l) : lo(l), hi(h) { } 117 inline UChar::UChar(unsigned short u) : lo(u & 0x00ff), hi(u >> 8) { } 118 #else 119 inline UChar::UChar() : hi(0), lo(0) { } 120 inline UChar::UChar(unsigned char h , unsigned char l) : hi(h), lo(l) { } 121 inline UChar::UChar(unsigned short u) : hi(u >> 8), lo(u & 0x00ff) { } 122 #endif 105 106 ushort uc; 107 }; 108 109 inline UChar::UChar() : uc(0) { } 110 inline UChar::UChar(unsigned char h , unsigned char l) : uc(h << 8 | l) { } 111 inline UChar::UChar(unsigned short u) : uc(u) { } 123 112 124 113 /** … … 155 144 * @return Lower byte. 156 145 */ 157 unsigned char & low() const { return ref().lo; }146 unsigned char low() const { return ref().uc & 0xFF; } 158 147 /** 159 148 * @return Higher byte. 160 149 */ 161 unsigned char & high() const { return ref().hi; }150 unsigned char high() const { return ref().uc >> 8; } 162 151 /** 163 152 * @return Character converted to lower case. … … 365 354 * indicated by a 0x or 0X prefix) and +/- Infinity. 366 355 * Returns NaN if the conversion failed. 367 */ 368 double toDouble() const; 356 * @param tolerant if true, toDouble can tolerate garbage after the number. 357 */ 358 double toDouble(bool tolerant=false) const; 369 359 /** 370 360 * Attempts an conversion to an unsigned long integer. ok will be set … … 398 388 }; 399 389 400 bool operator==(const UChar &c1, const UChar &c2); 390 inline bool operator==(const UChar &c1, const UChar &c2) { 391 return (c1.uc == c2.uc); 392 } 401 393 bool operator==(const UString& s1, const UString& s2); 402 394 inline bool operator!=(const UString& s1, const UString& s2) { … … 408 400 return !KJS::operator==(s1, s2); 409 401 } 410 bool operator==(const char *s1, const UString& s2); 402 inline bool operator==(const char *s1, const UString& s2) { 403 return operator==(s2, s1); 404 } 411 405 inline bool operator!=(const char *s1, const UString& s2) { 412 406 return !KJS::operator==(s1, s2);
Note:
See TracChangeset
for help on using the changeset viewer.