00001 // -*- c++ -*- 00002 00003 /* 00004 * This file is part of the KDE libraries 00005 * Copyright (C) 2004 Richard Moore, rich@kde.org 00006 * Copyright (C) 2004 Zack Rusin, zack@kde.org 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2 of the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 * 00022 */ 00023 00024 #ifndef XPATH_VALUE_H 00025 #define XPATH_VALUE_H 00026 00027 #include "xpath_valueimpl.h" 00028 00029 namespace XPath { 00030 00031 class NodeSet; 00032 class Boolean; 00033 class Number; 00034 class String; 00035 00039 class Value 00040 { 00041 public: 00042 enum ValueType { 00043 ValueNodeSet, ValueBoolean, ValueNumber, ValueString 00044 }; 00045 00046 Value( const Value &res ); 00047 virtual ~Value(); 00048 Value &operator=( const Value &other ); 00049 00050 unsigned short type() const { return impl->type(); } 00051 bool isString() const { return (impl->type() == ValueString); } 00052 bool isBoolean() const { return (impl->type() == ValueBoolean); } 00053 bool isNumber() const { return (impl->type() == ValueNumber); } 00054 bool isNodeSet() const { return (impl->type() == ValueNodeSet); } 00055 00056 virtual String toString() const; 00057 virtual Boolean toBoolean() const; 00058 virtual Number toNumber() const; 00059 00060 protected: 00061 Value( ValueImpl *impl ); 00062 protected: 00063 ValueImpl *impl; 00064 }; 00065 00070 class NodeSet : public Value 00071 { 00072 public: 00073 NodeSet(); 00074 ~NodeSet(); 00075 NodeSet &operator=( const NodeSet &other ); 00076 00077 DOM::NodeList value() const; 00078 public: 00079 NodeSet( ValueImpl *impl ); 00080 }; 00081 00086 class Boolean : public Value 00087 { 00088 public: 00089 Boolean(); 00090 Boolean( ValueImpl * ); 00091 Boolean( const Boolean &src ); 00092 Boolean( bool value ); 00093 ~Boolean(); 00094 Boolean &operator=( const Boolean &other ); 00095 00096 bool value() const; 00097 00102 String toString() const; 00103 00105 Boolean toBoolean() const; 00106 }; 00107 00112 class Number : public Value 00113 { 00114 public: 00115 Number(); 00116 Number( ValueImpl* ); 00117 Number( const Number &number ); 00118 Number( int value ); 00119 Number( uint value ); 00120 Number( double value ); 00121 00122 ~Number(); 00123 00124 Number &operator=( const Number &other ); 00125 00126 double value() const; 00127 int intValue() const; 00128 00133 virtual String toString() const; 00134 00139 virtual Boolean toBoolean() const; 00140 }; 00141 00146 class String : public Value 00147 { 00148 public: 00149 String(); 00150 String( ValueImpl* ); 00151 String( const String &string ); 00152 String( const char *value ); 00153 String( const DOM::DOMString &value ); 00154 ~String(); 00155 00156 String &operator=( const String &other ); 00157 00158 DOM::DOMString value() const; 00159 QString qstring() const; 00160 }; 00161 00162 } // namespace XPath 00163 00164 #endif // XPATH_VALUE_H 00165 00166 // Local Variables: 00167 // c-basic-offset: 4 00168 // End: