fix logic
[personal-kdelibs.git] / khtml / svg / SVGParserUtilities.h
blob8d3c9b2ace616a75b8265c156ab25b53fdd6a006
1 /*
2 Copyright (C) 2002, 2003 The Karbon Developers
3 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
23 #if ENABLE(SVG)
25 #include "ParserUtilities.h"
27 namespace WebCore {
29 class Path;
30 class SVGPointList;
31 class SVGPathSegList;
33 bool parseNumber(const UChar*& ptr, const UChar* end, float& number, bool skip = true);
34 bool parseNumberOptionalNumber(const String& s, float& h, float& v);
36 // SVG allows several different whitespace characters:
37 // http://www.w3.org/TR/SVG/paths.html#PathDataBNF
38 inline bool isWhitespace(const UChar& c)
40 return (c == ' ' || c == '\t' || c == '\n' || c == '\r');
43 inline bool skipOptionalSpaces(const UChar*& ptr, const UChar* end)
45 while (ptr < end && isWhitespace(*ptr))
46 ptr++;
47 return ptr < end;
50 inline bool skipOptionalSpacesOrDelimiter(const UChar*& ptr, const UChar* end, UChar delimiter = ',')
52 if (ptr < end && !isWhitespace(*ptr) && *ptr != delimiter)
53 return false;
54 if (skipOptionalSpaces(ptr, end)) {
55 if (ptr < end && *ptr == delimiter) {
56 ptr++;
57 skipOptionalSpaces(ptr, end);
60 return ptr < end;
63 bool pointsListFromSVGData(SVGPointList* pointsList, const String& points);
64 bool pathFromSVGData(Path& path, const String& d);
65 bool pathSegListFromSVGData(SVGPathSegList* pathSegList, const String& d, bool process = false);
66 Vector<String> parseDelimitedString(const String& input, const char seperator);
68 } // namespace WebCore
70 #endif // ENABLE(SVG)
71 #endif // SVGParserUtilities_h