//  -*- c++ -*-

#ifndef XPATH_VALUE_H
#define XPATH_VALUE_H

#include <qstring.h>
#include <qcstring.h>

#include <dom/dom_node.h>
#include <dom/dom_string.h>

namespace XPath {

class Exception;
class NodeSet;
class Boolean;
class Number;
class String;

/**
 * An XPath value.
 * See REC-xpath-19991116 1.0 Section 1.
 *
 * @version $Id: xmldemo.h,v 1.3 2002/02/18 00:45:47 rich Exp $
 * @author Richard Moore, rich@kde.org 
 */
class Value
{
public:
    enum ValueType {
	ValueException, ValueNodeSet, ValueBoolean, ValueNumber, ValueString
    };

    Value() : tp(ValueException) {}
    Value( const Value &res );
    virtual ~Value() {}

    ValueType type() const { return tp; }

#if 0
    virtual Exception toException();
    virtual NodeSet toNodeSet();
    virtual Boolean toBoolean();
    virtual Number toNumber();
#endif
    virtual String toString();

    virtual QString qstring() const;

protected:
    Value( ValueType t ) : tp(t) {}

private:
    ValueType tp;
};


/**
 * An XPath String value.
 * See REC-xpath-19991116 1.0 Section 1.
 */
class String : public Value
{
public:
    String() : Value(ValueString) {}
    String( const String &s ) : Value(ValueString), val(s.val) {}
    String( const QString &s ) : Value(ValueString), val(s) {}
    String( const char *s ) : Value(ValueString), val(s) {}
    virtual ~String() {}

    virtual String toString();
    virtual QString qstring() const;

private:
    QString val;
};

/**
 * An error value returned by the XPath engine.
 */
class Exception : public Value
{
public:
    Exception() : Value(ValueException) {}
    Exception( const Exception & ) : Value(ValueException) {}
    ~Exception();
};

/**
 * An XPath node-set value.
 * See REC-xpath-19991116 1.0 Section 1.
 */
class NodeSet : public Value
{
public:
    NodeSet();
    NodeSet( const NodeSet &ns ) : Value(ns.type()) { this->val = ns.val; }
    ~NodeSet();

private:
    DOM::NodeList val;
};

/**
 * An XPath Boolean value.
 * See REC-xpath-19991116 1.0 Section 1.
 */
class Boolean : public Value
{
public:
    Boolean();
    Boolean( const Boolean &b ) : Value(b.type()) { this->val = b.val; }

private:
    bool val;
};

/**
 * An XPath Number value.
 * See REC-xpath-19991116 1.0 Section 1.
 */
class Number : public Value
{
public:
    Number();
    Number( const Number &n ) : Value(n.type()) { this->val = n.val; }

private:
    double val;
};

}; // namespace XPath

#endif // XPATH_VALUE_H

// Local Variables:
// c-basic-offset: 4
// End:
