KHTML
util.h
Go to the documentation of this file.
00001 /* 00002 * util.h - Copyright 2005 Frerich Raabe <raabe@kde.org> 00003 * 00004 * Redistribution and use in source and binary forms, with or without 00005 * modification, are permitted provided that the following conditions 00006 * are met: 00007 * 00008 * 1. Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * 00014 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00015 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00016 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00017 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 00018 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 00019 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00020 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00021 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00022 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00023 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00024 */ 00025 #ifndef UTIL_H 00026 #define UTIL_H 00027 00028 #include <QList> 00029 #include <misc/shared.h> 00030 #include <dom/dom_string.h> 00031 00032 namespace DOM { 00033 class NodeImpl; 00034 class StaticNodeListImpl; 00035 } 00036 00037 namespace khtml { 00038 namespace XPath { 00039 00040 // ### removeme 00041 typedef SharedPtr<DOM::StaticNodeListImpl> DomNodeList; 00042 00043 00044 /* @return whether the given node is the root node. 00045 */ 00046 bool isRootDomNode( DOM::NodeImpl *node ); 00047 00048 /* @return the 'string-value' of the given node as specified by 00049 http://www.w3.org/TR/xpath 00050 */ 00051 DOM::DOMString stringValue( DOM::NodeImpl *node ); 00052 00053 /* @return append all descendant nodes of the given node, in document order, 00054 to the given set 00055 */ 00056 void collectChildrenRecursively( SharedPtr<DOM::StaticNodeListImpl> out, 00057 DOM::NodeImpl *root ); 00058 00059 /* this one is in reverse order */ 00060 void collectChildrenReverse( SharedPtr<DOM::StaticNodeListImpl> out, 00061 DOM::NodeImpl *root ); 00062 00063 /* @return whether the given node is a valid context node 00064 */ 00065 bool isValidContextNode( DOM::NodeImpl *node ); 00066 00067 /* @returns the parent node of the given node under the XPath model 00068 (which has some additional links that DOM doesn't 00069 */ 00070 DOM::NodeImpl *xpathParentNode( DOM::NodeImpl *node ); 00071 00072 /* @returns the first/last kid of the given node under the XPath model, 00073 which doesn't have text nodes or the likes under attributes 00074 */ 00075 DOM::NodeImpl *xpathFirstChild( DOM::NodeImpl *node ); 00076 DOM::NodeImpl *xpathLastChild( DOM::NodeImpl *node ); 00077 00078 /* @returns a slightly generalized notion of a sibling needed to implement 00079 the following axis. Essentially, for that axis, and only that axis, 00080 if we have something like this: 00081 <node attr1 attr2><kid></node> 00082 the <kid> is considered to be the next thing following attr1 00083 */ 00084 DOM::NodeImpl *nextSiblingForFollowing( DOM::NodeImpl *node ); 00085 00086 // Enable for some low debug output. 00087 // #define XPATH_VERBOSE 00088 00089 00090 } // namespace XPath 00091 00092 } // namespace khtml 00093 00094 00095 #endif // UTIL_H 00096
KDE 4.6 API Reference