KHtml

ClassNames.h
1 /*
2  * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3  *
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.
8  *
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.
13  *
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.
18  *
19  */
20 
21 #ifndef ClassNames_h
22 #define ClassNames_h
23 
24 #include "misc/AtomicString.h"
25 #include <wtf/Vector.h>
26 #include <wtf/OwnPtr.h>
27 
28 using khtml::AtomicString;
29 
30 namespace DOM
31 {
32 
33 class ClassNames
34 {
35  typedef Vector<khtml::AtomicString, 8> ClassNameVector;
36 public:
37  ClassNames()
38  {
39  }
40 
41  bool contains(const khtml::AtomicString &str) const
42  {
43  if (!m_nameVector) {
44  return false;
45  }
46 
47  size_t size = m_nameVector->size();
48  for (size_t i = 0; i < size; ++i) {
49  if (m_nameVector->at(i) == str) {
50  return true;
51  }
52  }
53 
54  return false;
55  }
56 
57  void parseClassAttribute(const DOMString &, bool inCompatMode);
58 
59  size_t size() const
60  {
61  return m_nameVector ? m_nameVector->size() : 0;
62  }
63  void clear()
64  {
65  if (m_nameVector) {
66  m_nameVector->clear();
67  }
68  }
69  const khtml::AtomicString &operator[](size_t i) const
70  {
71  ASSERT(m_nameVector);
72  return m_nameVector->at(i);
73  }
74 
75 private:
76  OwnPtr<ClassNameVector> m_nameVector;
77 };
78 
79 inline static bool isClassWhitespace(const QChar &c)
80 {
81  unsigned short u = c.unicode();
82  if (u > 0x20) {
83  return false;
84  }
85  return u == ' ' || u == '\r' || u == '\n' || u == '\t' || u == '\f';
86 }
87 
88 } // namespace DOM
89 
90 #endif // ClassNames_h
This class implements the basic string we use in the DOM.
Definition: dom_string.h:44
ushort unicode() const const
This library provides a full-featured HTML parser and widget.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Oct 25 2021 22:48:11 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.