Source Code (Use browser search to find items of interest.)

Class Index

kdelibs'DOMString (./kdelibs/khtml/dom/dom_string.h:44)

class DOMString
{
    friend class CharacterDataImpl;
    friend class Attribute;

public:
    /** default constructor. Gives an empty DOMString */
    DOMString();
    /* constructs an empty DOMString. Like this assignment to 0 works */
    DOMString(int);
    /** if copy == false, takes over the QChar * array. It'll get deleted,
     * when the string gets deleted...
     */
    DOMString(QChar *str, uint len, bool copy = true);
    DOMString(const QChar *str, uint len);
    DOMString(const QString &);
    DOMString(const char *str);
    DOMString(DOMStringImpl *i);
    virtual ~DOMString();

    // assign and copy
    DOMString(const DOMString &str);
    DOMString &operator =(const DOMString &str);

    /**
     * append str to this string
     */
    DOMString &operator += (const DOMString &str);
    /**
     * add two DOMString's
     */
    DOMString operator + (const DOMString &str);

    void insert(DOMString str, uint pos);

    /**
     * The character at position i of the DOMString. If i > length(), the
     * character returned will be 0.
     */
    const QChar &operator [](unsigned int i) const;

    int find(const QChar c, int start = 0);

    uint length() const;
    void truncate( unsigned int len );
    void remove(unsigned int pos, int len=1);
    /**
     * Splits the string into two. The original string gets truncated to pos, and the rest is returned.
     */
    DOMString split(unsigned int pos);
    
    QChar *unicode() const;
    QString string() const;

    int toInt() const;
    bool percentage(int &_percentage) const;

    DOMString copy() const;

    bool isNull() { return (impl == 0); }
    bool isEmpty();

    /**
     * @internal get a handle to the imlementation of the DOMString
     * Use at own risk!!!
     */
    DOMStringImpl *implementation() const { return impl; }

    /**
     * @internal get a pointer to start of the string
     * Needed by kBackpage
     */
    const QChar *stringPtr() const;
    
protected:
    DOMStringImpl *impl;
};


kdelibs'DOMString::DOMString() (./kdelibs/khtml/dom/dom_string.cpp:30)

DOMString::DOMString()
{
    impl = 0;
}


kdelibs'DOMString::DOMString() (./kdelibs/khtml/dom/dom_string.cpp:35)

DOMString::DOMString(int)
{
    impl = 0;
}


kdelibs'DOMString::DOMString() (./kdelibs/khtml/dom/dom_string.cpp:40)

DOMString::DOMString(QChar *str, uint len, bool copy)
{
    QChar *c;
    if(copy)
    {
	c = new QChar[len];
	memcpy(c, str, len*sizeof(QChar));
    }
    else
    {
	c = str;
    }
    impl = new DOMStringImpl( c, len );
    impl->ref();
}


kdelibs'DOMString::DOMString() (./kdelibs/khtml/dom/dom_string.cpp:56)

DOMString::DOMString(const QChar *str, uint len)
{
    QChar *c;
    c = new QChar[len];
    memcpy(c, str, len*sizeof(QChar));
    impl = new DOMStringImpl( c, len );
    impl->ref();
}


kdelibs'DOMString::DOMString() (./kdelibs/khtml/dom/dom_string.cpp:65)

DOMString::DOMString(const QString &str)
{
    QChar *c;
    c = new QChar[str.length()];
    memcpy(c, str.unicode(), str.length()*sizeof(QChar));
    impl = new DOMStringImpl( c, str.length() );
    impl->ref();
}


kdelibs'DOMString::DOMString() (./kdelibs/khtml/dom/dom_string.cpp:74)

DOMString::DOMString(const char *str)
{
    int len = 0;
    const char *p = str;
    while(*p != '\0') p++, len++;
    QChar *m_str = new QChar[len];
    int i = 0;
    while(i<len)
    {
	m_str[i] = str[i];
	i++;
    }
    impl = new DOMStringImpl( m_str, len );
    impl->ref();
}


kdelibs'DOMString::DOMString() (./kdelibs/khtml/dom/dom_string.cpp:90)

DOMString::DOMString(DOMStringImpl *i)
{
    impl = i;
    if(impl) impl->ref();
}


kdelibs'DOMString::DOMString() (./kdelibs/khtml/dom/dom_string.cpp:96)

DOMString::DOMString(const DOMString &other)
{
    impl = other.impl;
    if(impl) impl->ref();
}


kdelibs'DOMString::~DOMString() (./kdelibs/khtml/dom/dom_string.cpp:102)

DOMString::~DOMString()
{
    if(impl) impl->deref();
}


kdelibs'DOMString::insert() (./kdelibs/khtml/dom/dom_string.cpp:148)

void DOMString::insert(DOMString str, uint pos)
{
    if(!impl)
    {
	impl = str.impl->copy();
	impl->ref();
    }
    else
	impl->insert(str.impl, pos);
}



kdelibs'DOMString::find() (./kdelibs/khtml/dom/dom_string.cpp:169)

int DOMString::find(const QChar c, int start)
{
    unsigned int l = start;
    if(!impl) return -1;
    if( l > impl->l ) return -1;
    while( l < impl->l )
    {
	if( *(impl->s+l) == c ) return l;
	l++;
    }
    return -1;
}


kdelibs'DOMString::length() (./kdelibs/khtml/dom/dom_string.cpp:182)

uint DOMString::length() const
{
    if(!impl) return 0;
    return impl->l;
}


kdelibs'DOMString::truncate() (./kdelibs/khtml/dom/dom_string.cpp:188)

void DOMString::truncate( unsigned int len )
{
    if(impl) impl->truncate(len);
}


kdelibs'DOMString::remove() (./kdelibs/khtml/dom/dom_string.cpp:193)

void DOMString::remove(unsigned int pos, int len)
{
  if(impl) impl->remove(pos, len);
}


kdelibs'DOMString::split() (./kdelibs/khtml/dom/dom_string.cpp:198)

DOMString DOMString::split(unsigned int pos)
{
  if(!impl) return 0;
  return impl->split(pos);
}



kdelibs'DOMString::percentage() (./kdelibs/khtml/dom/dom_string.cpp:205)

bool DOMString::percentage(int &_percentage) const
{
    if ( *(impl->s+impl->l-1) != QChar('%'))
       return false;

    _percentage = QConstString(impl->s, impl->l-1).string().toInt();
    return true;
}


kdelibs'DOMString::unicode() (./kdelibs/khtml/dom/dom_string.cpp:214)

QChar *DOMString::unicode() const
{
    if(!impl) return 0;
    return impl->s;
}


kdelibs'DOMString::string() (./kdelibs/khtml/dom/dom_string.cpp:220)

QString DOMString::string() const
{
    if(!impl) return QConstString(0, 0).string();

    return QConstString(impl->s, impl->l).string();
}


kdelibs'DOMString::toInt() (./kdelibs/khtml/dom/dom_string.cpp:227)

int DOMString::toInt() const
{
    if(!impl) return 0;

    return QConstString(impl->s, impl->l).string().toInt();
}


kdelibs'DOMString::copy() (./kdelibs/khtml/dom/dom_string.cpp:234)

DOMString DOMString::copy() const
{
    if(!impl) return 0;
    return impl->copy();
}

// ------------------------------------------------------------------------


kdelibs'DOMString::isEmpty() (./kdelibs/khtml/dom/dom_string.cpp:280)

bool DOMString::isEmpty()
{
    if (impl == 0) return true;
    return (impl->l == 0);
}


kdelibs'DOMString::stringPtr() (./kdelibs/khtml/dom/dom_string.cpp:286)

const QChar *DOMString::stringPtr() const
{
    if (impl) return impl->s;
    return 0;
}

//-----------------------------------------------------------------------------