KHTML
SVGParserUtilities.h
Go to the documentation of this file.
00001 /* 00002 Copyright (C) 2002, 2003 The Karbon Developers 00003 2006, 2007 Rob Buis <buis@kde.org> 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00018 Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef SVGParserUtilities_h 00022 #define SVGParserUtilities_h 00023 #if ENABLE(SVG) 00024 00025 #include "ParserUtilities.h" 00026 00027 namespace khtml { 00028 class Path; 00029 } 00030 00031 namespace WebCore { 00032 00033 typedef khtml::Path Path; 00034 class SVGPointList; 00035 class SVGPathSegList; 00036 00037 bool parseNumber(const UChar*& ptr, const UChar* end, float& number, bool skip = true); 00038 bool parseNumberOptionalNumber(const String& s, float& h, float& v); 00039 00040 // SVG allows several different whitespace characters: 00041 // http://www.w3.org/TR/SVG/paths.html#PathDataBNF 00042 inline bool isWhitespace(const UChar& c) 00043 { 00044 return (c == ' ' || c == '\t' || c == '\n' || c == '\r'); 00045 } 00046 00047 inline bool skipOptionalSpaces(const UChar*& ptr, const UChar* end) 00048 { 00049 while (ptr < end && isWhitespace(*ptr)) 00050 ptr++; 00051 return ptr < end; 00052 } 00053 00054 inline bool skipOptionalSpacesOrDelimiter(const UChar*& ptr, const UChar* end, UChar delimiter = ',') 00055 { 00056 if (ptr < end && !isWhitespace(*ptr) && *ptr != delimiter) 00057 return false; 00058 if (skipOptionalSpaces(ptr, end)) { 00059 if (ptr < end && *ptr == delimiter) { 00060 ptr++; 00061 skipOptionalSpaces(ptr, end); 00062 } 00063 } 00064 return ptr < end; 00065 } 00066 00067 bool pointsListFromSVGData(SVGPointList* pointsList, const String& points); 00068 bool pathFromSVGData(Path& path, const String& d); 00069 bool pathSegListFromSVGData(SVGPathSegList* pathSegList, const String& d, bool process = false); 00070 Vector<String> parseDelimitedString(const String& input, const char separator); 00071 00072 } // namespace WebCore 00073 00074 #endif // ENABLE(SVG) 00075 #endif // SVGParserUtilities_h
KDE 4.6 API Reference