2 * Copyright (C) 2007 David Smith (catfish.man@gmail.com)
3 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
22 #include "SpaceSplitString.h"
24 #include <wtf/ASCIICType.h>
30 static bool hasNonASCIIOrUpper(const String
& string
)
32 const UChar
* characters
= string
.characters();
33 unsigned length
= string
.length();
34 bool hasUpper
= false;
36 for (unsigned i
= 0; i
< length
; i
++) {
37 UChar c
= characters
[i
];
38 hasUpper
|= isASCIIUpper(c
);
41 return hasUpper
|| (ored
& ~0x7F);
44 void SpaceSplitStringData::createVector()
46 ASSERT(!m_createdVector
);
47 ASSERT(m_vector
.isEmpty());
49 if (m_shouldFoldCase
&& hasNonASCIIOrUpper(m_string
))
50 m_string
= m_string
.foldCase();
52 const UChar
* characters
= m_string
.characters();
53 unsigned length
= m_string
.length();
56 while (start
< length
&& isClassWhitespace(characters
[start
]))
60 unsigned end
= start
+ 1;
61 while (end
< length
&& !isClassWhitespace(characters
[end
]))
64 m_vector
.append(AtomicString(characters
+ start
, end
- start
));
70 m_createdVector
= true;
73 bool SpaceSplitStringData::containsAll(SpaceSplitStringData
& other
)
77 size_t thisSize
= m_vector
.size();
78 size_t otherSize
= other
.m_vector
.size();
79 for (size_t i
= 0; i
< otherSize
; ++i
) {
80 const AtomicString
& name
= other
.m_vector
[i
];
82 for (j
= 0; j
< thisSize
; ++j
) {
83 if (m_vector
[j
] == name
)
92 } // namespace WebCore