fix logic
[personal-kdelibs.git] / khtml / xml / ClassNames.h
blob6650fb0a6a709219c871d73f3d81ba5702936637
1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 #ifndef ClassNames_h
22 #define ClassNames_h
24 #include "misc/AtomicString.h"
25 #include <wtf/Vector.h>
26 #include <wtf/OwnPtr.h>
28 using khtml::AtomicString;
30 namespace DOM {
32 class ClassNames {
33 typedef Vector<khtml::AtomicString, 8> ClassNameVector;
34 public:
35 ClassNames()
39 bool contains(const khtml::AtomicString& str) const
41 if (!m_nameVector)
42 return false;
44 size_t size = m_nameVector->size();
45 for (size_t i = 0; i < size; ++i) {
46 if (m_nameVector->at(i) == str)
47 return true;
50 return false;
53 void parseClassAttribute(const DOMString&, bool inCompatMode);
55 size_t size() const { return m_nameVector ? m_nameVector->size() : 0; }
56 void clear() { if (m_nameVector) m_nameVector->clear(); }
57 const khtml::AtomicString& operator[](size_t i) const { ASSERT(m_nameVector); return m_nameVector->at(i); }
59 private:
60 OwnPtr<ClassNameVector> m_nameVector;
63 inline static bool isClassWhitespace(QChar c)
65 return c == ' ' || c == '\r' || c == '\n' || c == '\t' || c == '\f';
68 } // namespace DOM
70 #endif // ClassNames_h