# khtml Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# stringit.h

    00001 /*
    00002     This file is part of the KDE libraries
    00003
    00004     Copyright (C) 1999 Lars Knoll (knoll@mpi-hd.mpg.de)
    00005
    00006     This library is free software; you can redistribute it and/or
    00007     modify it under the terms of the GNU Library General Public
    00008     License as published by the Free Software Foundation; either
    00009     version 2 of the License, or (at your option) any later version.
    00010
    00011     This library is distributed in the hope that it will be useful,
    00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00014     Library General Public License for more details.
    00015
    00016     You should have received a copy of the GNU Library General Public License
    00017     along with this library; see the file COPYING.LIB.  If not, write to
    00018     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00019     Boston, MA 02111-1307, USA.
    00020 */
    00021 //----------------------------------------------------------------------------
    00022 //
    00023 // KDE HTML Widget -- String class
    00024 // $Id: stringit.h,v 1.13.4.1 2003/05/18 12:34:39 mueller Exp $
    00025
    00026 #ifndef KHTMLSTRING_H
    00027 #define KHTMLSTRING_H
    00028
    00029 #include "dom/dom_string.h"
    00030
    00031 #include <qstring.h>
    00032
    00033 using namespace DOM;
    00034
    00035 namespace khtml
    00036 {
    00037
    00038 class DOMStringIt
    00039 {
    00040 public:
    00041     DOMStringIt()
    00042         { s = 0, l = 0; lines = 0; }
    00043     DOMStringIt(QChar *str, uint len)
    00044         { s = str, l = len; lines = 0; }
    00045     DOMStringIt(const QString &str)
    00046         { s = str.unicode(); l = str.length(); lines = 0; }
    00047     DOMStringIt(const DOMString &str)
    00048         { s = str.unicode(); l = str.length(); lines = 0; }
    00049
    00050     DOMStringIt *operator++()
    00051     {
    00052         if(!pushedChar.isNull())
    00053             pushedChar=0;
    00054         else if(l > 0 ) {
    00055             if (*s == '\n')
    00056                 lines++;
    00057             s++, l--;
    00058         }
    00059         return this;
    00060     }
    00061 public:
    00062     void push(const QChar& c) { /* assert(pushedChar.isNull());*/  pushedChar = c; }
    00063
    00064     const QChar& operator*() const  { return pushedChar.isNull() ? *s : pushedChar; }
    00065     const QChar* operator->() const { return pushedChar.isNull() ? s : &pushedChar; }
    00066
    00067     bool escaped() const { return !pushedChar.isNull(); }
    00068     uint length() const { return l+(!pushedChar.isNull()); }
    00069
    00070     const QChar *current() const { return pushedChar.isNull() ? s : &pushedChar; }
    00071     int lineCount() const { return lines; }
    00072
    00073 protected:
    00074     QChar pushedChar;
    00075     const QChar *s;
    00076     int l;
    00077     int lines;
    00078 };
    00079
    00080
    00081 }
    00082
    00083 #endif

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:34:44 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001