Changeset 798 in webkit for trunk/JavaScriptCore/kjs/ustring.h


Ignore:
Timestamp:
Mar 21, 2002, 4:31:57 PM (23 years ago)
Author:
mjs
Message:

Merged changes from LABYRINTH_KDE_3_MERGE branch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/ustring.h

    r6 r798  
     1// -*- c-basic-offset: 2 -*-
    12/*
    23 *  This file is part of the KDE libraries
     
    1718 *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    1819 *  Boston, MA 02111-1307, USA.
     20 *
     21 *  $Id$
    1922 */
    2023
    21 #ifndef _KJS_STRING_H_
    22 #define _KJS_STRING_H_
     24#ifndef _KJS_USTRING_H_
     25#define _KJS_USTRING_H_
    2326
    2427#ifdef HAVE_CONFIG_H
    2528#include <config.h>
     29#endif
     30
     31#ifdef APPLE_CHANGES
     32#include <KWQDef.h>
    2633#endif
    2734
     
    3643class QConstString;
    3744
    38 #if defined(__GNUC__)
    39 #define KJS_PACKED __attribute__((__packed__))
    40 #else
    41 #define KJS_PACKED
    42 #endif
    43 
    4445namespace KJS {
    4546
     
    7475     * @return The higher byte of the character.
    7576     */
    76     unsigned char high() const { return hi; }
     77    unsigned char high() const { return uc >> 8; }
    7778    /**
    7879     * @return The lower byte of the character.
    7980     */
    80     unsigned char low() const { return lo; }
     81    unsigned char low() const { return uc & 0xFF; }
    8182    /**
    8283     * @return the 16 bit Unicode value of the character
    8384     */
    84     unsigned short unicode() const { return hi << 8 | lo; }
     85    unsigned short unicode() const { return uc; }
    8586  public:
    8687    /**
     
    102103    friend bool operator==(const UString& s1, const char *s2);
    103104    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) { }
    123112
    124113  /**
     
    155144     * @return Lower byte.
    156145     */
    157     unsigned char& low() const { return ref().lo; }
     146    unsigned char low() const { return ref().uc & 0xFF; }
    158147    /**
    159148     * @return Higher byte.
    160149     */
    161     unsigned char& high() const { return ref().hi; }
     150    unsigned char high() const { return ref().uc >> 8; }
    162151    /**
    163152     * @return Character converted to lower case.
     
    365354     * indicated by a 0x or 0X prefix) and +/- Infinity.
    366355     * 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;
    369359    /**
    370360     * Attempts an conversion to an unsigned long integer. ok will be set
     
    398388  };
    399389
    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  }
    401393  bool operator==(const UString& s1, const UString& s2);
    402394  inline bool operator!=(const UString& s1, const UString& s2) {
     
    408400    return !KJS::operator==(s1, s2);
    409401  }
    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  }
    411405  inline bool operator!=(const char *s1, const UString& s2) {
    412406    return !KJS::operator==(s1, s2);
Note: See TracChangeset for help on using the changeset viewer.