00001 /* 00002 * This file is part of the KDE libraries 00003 * Copyright (C) 2004 Richard Moore, rich@kde.org 00004 * Copyright (C) 2004 Zack Rusin, zack@kde.org 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 * 00020 */ 00021 00022 #ifndef XPATH_VALUEIMPL_H 00023 #define XPATH_VALUEIMPL_H 00024 00025 #include "dom/dom_node.h" 00026 #include "dom/dom_string.h" 00027 #include "misc/shared.h" 00028 00029 namespace XPath { 00030 00031 class NodeSetImpl; 00032 class BooleanImpl; 00033 class NumberImpl; 00034 class StringImpl; 00035 00036 class ValueImpl : public khtml::Shared<ValueImpl> 00037 { 00038 public: 00039 ValueImpl( unsigned short type ) : m_type( type ) { } 00040 virtual ~ValueImpl() {} 00041 00042 unsigned short type() const { return m_type; } 00043 00044 virtual StringImpl *toString() { return 0; } 00045 virtual BooleanImpl *toBoolean() { return 0; } 00046 virtual NumberImpl *toNumber() { return 0; } 00047 00048 private: 00049 unsigned short m_type; 00050 }; 00051 00052 class NodeSetImpl : public ValueImpl 00053 { 00054 public: 00055 NodeSetImpl(); 00056 ~NodeSetImpl(); 00057 DOM::NodeList value() const { return m_value; } 00058 private: 00059 DOM::NodeList m_value; 00060 }; 00061 00062 class BooleanImpl : public ValueImpl 00063 { 00064 public: 00065 BooleanImpl(); 00066 BooleanImpl( bool value ); 00067 ~BooleanImpl(); 00068 00073 StringImpl *toString(); 00074 00076 BooleanImpl *toBoolean(); 00077 00078 bool value() const { return m_value; } 00079 private: 00080 bool m_value; 00081 }; 00082 00087 class NumberImpl : public ValueImpl 00088 { 00089 public: 00090 NumberImpl(); 00091 NumberImpl( int value ); 00092 NumberImpl( uint value ); 00093 NumberImpl( double value ); 00094 00095 ~NumberImpl(); 00096 00097 double value() const { return m_value; } 00098 int intValue() const; 00099 00104 virtual StringImpl *toString(); 00105 00110 virtual BooleanImpl *toBoolean(); 00111 private: 00112 double m_value; 00113 }; 00114 00119 class StringImpl : public ValueImpl 00120 { 00121 public: 00122 StringImpl(); 00123 StringImpl( const char *value ); 00124 StringImpl( const DOM::DOMString &value ); 00125 ~StringImpl(); 00126 00127 DOM::DOMString value() const { return m_value; } 00128 QString qstring() const; 00129 00131 virtual StringImpl *toString(); 00132 private: 00133 DOM::DOMString m_value; 00134 }; 00135 00136 } 00137 00138 #endif 00139 00140 // Local Variables: 00141 // c-basic-offset: 4 00142 // End: