2 * Copyright (C) 2002, 2003 The Karbon Developers
3 * Copyright (C) 2006, 2007 Rob Buis <buis@kde.org>
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., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
21 #ifndef SVGParserUtilities_h
22 #define SVGParserUtilities_h
25 #include "ParserUtilities.h"
26 #include <wtf/HashSet.h>
28 typedef pair<unsigned, unsigned> UnicodeRange;
29 typedef Vector<UnicodeRange> UnicodeRanges;
35 bool parseNumber(const UChar*& ptr, const UChar* end, float& number, bool skip = true);
36 bool parseNumberOptionalNumber(const String& s, float& h, float& v);
37 bool parseArcFlag(const UChar*& ptr, const UChar* end, bool& flag);
39 // SVG allows several different whitespace characters:
40 // http://www.w3.org/TR/SVG/paths.html#PathDataBNF
41 inline bool isWhitespace(const UChar& c)
43 return (c == ' ' || c == '\t' || c == '\n' || c == '\r');
46 inline bool skipOptionalSpaces(const UChar*& ptr, const UChar* end)
48 while (ptr < end && isWhitespace(*ptr))
53 inline bool skipOptionalSpacesOrDelimiter(const UChar*& ptr, const UChar* end, UChar delimiter = ',')
55 if (ptr < end && !isWhitespace(*ptr) && *ptr != delimiter)
57 if (skipOptionalSpaces(ptr, end)) {
58 if (ptr < end && *ptr == delimiter) {
60 skipOptionalSpaces(ptr, end);
66 bool pointsListFromSVGData(SVGPointList& pointsList, const String& points);
67 Vector<String> parseDelimitedString(const String& input, const char seperator);
68 bool parseKerningUnicodeString(const String& input, UnicodeRanges&, HashSet<String>& stringList);
69 bool parseGlyphName(const String& input, HashSet<String>& values);
71 } // namespace WebCore
74 #endif // SVGParserUtilities_h