KHTML
functions.h
Go to the documentation of this file.
00001 /* 00002 * functions.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 FUNCTIONS_H 00026 #define FUNCTIONS_H 00027 00028 #include "expression.h" 00029 00030 #include <QHash> 00031 #include <QList> 00032 00033 #include "dom/dom_string.h" 00034 #include "xml/dom_stringimpl.h" 00035 00036 namespace khtml { 00037 namespace XPath { 00038 00039 class Function : public Expression 00040 { 00041 public: 00042 void setArguments( const QList<Expression *> &args ); 00043 void setName( const DOM::DOMString &name ); 00044 00045 virtual QString dump() const; 00046 00047 protected: 00048 Expression *arg( int pos ); 00049 const Expression *arg( int pos ) const; 00050 unsigned int argCount() const; 00051 DOM::DOMString name() const; 00052 00053 private: 00054 DOM::DOMString m_name; 00055 }; 00056 00057 class FunctionLibrary 00058 { 00059 friend struct FunctionMapping; 00060 public: 00061 static FunctionLibrary &self(); 00062 00063 Function *getFunction( const DOM::DOMString& name, 00064 const QList<Expression *> &args = QList<Expression *>() ) const; 00065 00066 private: 00067 struct FunctionRec; 00068 00069 FunctionLibrary(); 00070 FunctionLibrary( const FunctionLibrary &rhs ); 00071 FunctionLibrary &operator=( const FunctionLibrary &rhs ); 00072 00073 QHash<DOM::DOMString, FunctionRec> m_functionDict; 00074 }; 00075 00076 } // namespace XPath 00077 00078 } // namespace khtml 00079 00080 #endif // FUNCTIONS_H 00081
KDE 4.6 API Reference