KHtml

SVGParserUtilities.h
1 /*
2  Copyright (C) 2002, 2003 The Karbon Developers
3  2006, 2007 Rob Buis <[email protected]>
4 
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.
9 
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.
14 
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.
19 */
20 
21 #ifndef SVGParserUtilities_h
22 #define SVGParserUtilities_h
23 #if ENABLE(SVG)
24 
25 #include "ParserUtilities.h"
26 
27 namespace khtml
28 {
29 class Path;
30 }
31 
32 namespace WebCore
33 {
34 
35 typedef khtml::Path Path;
36 class SVGPointList;
37 class SVGPathSegList;
38 
39 bool parseNumber(const UChar *&ptr, const UChar *end, float &number, bool skip = true);
40 bool parseNumberOptionalNumber(const String &s, float &h, float &v);
41 
42 // SVG allows several different whitespace characters:
43 // https://www.w3.org/TR/SVG/paths.html#PathDataBNF
44 inline bool isWhitespace(const UChar &c)
45 {
46  return (c == ' ' || c == '\t' || c == '\n' || c == '\r');
47 }
48 
49 inline bool skipOptionalSpaces(const UChar *&ptr, const UChar *end)
50 {
51  while (ptr < end && isWhitespace(*ptr)) {
52  ptr++;
53  }
54  return ptr < end;
55 }
56 
57 inline bool skipOptionalSpacesOrDelimiter(const UChar *&ptr, const UChar *end, UChar delimiter = UChar(','))
58 {
59  if (ptr < end && !isWhitespace(*ptr) && *ptr != delimiter) {
60  return false;
61  }
62  if (skipOptionalSpaces(ptr, end)) {
63  if (ptr < end && *ptr == delimiter) {
64  ptr++;
65  skipOptionalSpaces(ptr, end);
66  }
67  }
68  return ptr < end;
69 }
70 
71 bool pointsListFromSVGData(SVGPointList *pointsList, const String &points);
72 bool pathFromSVGData(Path &path, const String &d);
73 bool pathSegListFromSVGData(SVGPathSegList *pathSegList, const String &d, bool process = false);
74 Vector<String> parseDelimitedString(const String &input, const char separator);
75 
76 } // namespace WebCore
77 
78 #endif // ENABLE(SVG)
79 #endif // SVGParserUtilities_h
This file is part of the HTML rendering engine for KDE.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 26 2021 22:48:10 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.