Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members  

value.h

Go to the documentation of this file.
00001 //  -*- c++ -*-
00002 
00003 #ifndef XPATH_VALUE_H
00004 #define XPATH_VALUE_H
00005 
00006 #include <qstring.h>
00007 #include <qcstring.h>
00008 
00009 #include <dom/dom_node.h>
00010 #include <dom/dom_string.h>
00011 
00012 namespace XPath {
00013 
00014 class Exception;
00015 class NodeSet;
00016 class Boolean;
00017 class Number;
00018 class String;
00019 
00027 class Value
00028 {
00029 public:
00030     enum ValueType {
00031         ValueException, ValueNodeSet, ValueBoolean, ValueNumber, ValueString
00032     };
00033 
00034     Value() : tp(ValueException) {}
00035     Value( ValueType t ) : tp(t) {}
00036     Value( const Value &res );
00037 
00038     ValueType type() const { return tp; }
00039 
00040     Exception toException();
00041     NodeSet toNodeSet();
00042     Boolean toBoolean();
00043     Number toNumber();
00044     String toString();
00045 
00046     QString qstring() const;
00047 
00048 private:
00049     ValueType tp;
00050 };
00051 
00055 class Exception : public Value
00056 {
00057 public:
00058     Exception() : Value( ValueException ) {}
00059     Exception( const Exception &x ) : Value(x.type()) {}
00060 };
00061 
00066 class NodeSet : public Value
00067 {
00068 public:
00069     NodeSet();
00070     NodeSet( const NodeSet &ns ) : Value(ns.type()) { this->val = ns.val; }
00071 
00072 private:
00073     DOM::NodeList val;
00074 };
00075 
00080 class Boolean : public Value
00081 {
00082 public:
00083     Boolean();
00084     Boolean( const Boolean &b ) : Value(b.type()) { this->val = b.val; }
00085 
00086 private:
00087     bool val;
00088 };
00089 
00094 class Number : public Value
00095 {
00096 public:
00097     Number();
00098     Number( const Number &n ) : Value(n.type()) { this->val = n.val; }
00099 
00100 private:
00101     double val;
00102 };
00103 
00108 class String : public Value
00109 {
00110 public:
00111     String() : Value(ValueString) {}
00112     String( const String &s ) : Value(ValueString), val(s.val) {}
00113     String( const DOM::DOMString &s ) : Value(ValueString), val(s.string()) {}
00114     String( const QString &s ) : Value(ValueString), val(s) {}
00115     String( const char *s ) : Value(ValueString), val(s) {}
00116 
00117     QString qstring() const { return val; }
00118     QCString cstring() const { return val.local8Bit(); }
00119 
00120 private:
00121     QString val;
00122 };
00123 
00124 }; // namespace XPath
00125 
00126 #endif // XPATH_VALUE_H
00127 
00128 // Local Variables:
00129 // c-basic-offset: 4
00130 // End:

Generated at Sat Feb 8 03:30:01 2003 for XPath by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001