stringit.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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) { 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.4.