filters
aielement.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef AIELEMENT_H
00021 #define AIELEMENT_H
00022
00023
00024 #include <qvaluevector.h>
00025
00026 class QString;
00027 class QCString;
00028
00033 class AIElement {
00034 public:
00035 enum Type {
00036 Invalid,
00037
00038 String,
00039 Int,
00040 UInt,
00041 Double,
00042 CString,
00043
00044 Operator,
00045 Reference,
00046 ElementArray,
00047 Block,
00048 ByteArray,
00049 Byte
00050 };
00051
00052 AIElement();
00053 ~AIElement();
00054 AIElement( const AIElement& );
00055 AIElement( const QString&, Type type = String );
00056 AIElement( const QCString& );
00057 AIElement( const char* );
00058
00059 AIElement( const QValueVector<AIElement>&, Type type = ElementArray);
00060 AIElement( int );
00061 AIElement( uint );
00062 AIElement( double );
00063 AIElement( const QByteArray& );
00064 AIElement( uchar );
00065
00066 AIElement& operator= ( const AIElement& );
00067 bool operator==( const AIElement& ) const;
00068 bool operator!=( const AIElement& ) const;
00069
00070 Type type() const;
00071 const char* typeName() const;
00072
00073 bool canCast( Type ) const;
00074 bool cast( Type );
00075
00076 bool isValid() const;
00077
00078 void clear();
00079
00080 const QString toString() const;
00081 const QCString toCString() const;
00082 int toInt( bool * ok=0 ) const;
00083 uint toUInt( bool * ok=0 ) const;
00084 double toDouble( bool * ok=0 ) const;
00085
00086 const QValueVector<AIElement> toElementArray() const;
00087 const QValueVector<AIElement> toBlock() const;
00088
00089
00090 const QString toReference() const;
00091 const QString toOperator() const;
00092 const QByteArray toByteArray() const;
00093 uchar toByte( bool * ok=0 ) const;
00094
00095
00096
00097 QString& asString();
00098 QCString& asCString();
00099 int& asInt();
00100 uint& asUInt();
00101 double& asDouble();
00102
00103 QValueVector<AIElement>& asElementArray();
00104 QValueVector<AIElement>& asBlock();
00105
00106
00107 QString& asReference();
00108 QString& asToken();
00109 QByteArray& asByteArray();
00110 uchar& asByte();
00111
00112 static const char* typeToName( Type typ );
00113 static Type nameToType( const char* name );
00114
00115 private:
00116 void detach();
00117
00118 class Private : public QShared
00119 {
00120 public:
00121 Private();
00122 Private( Private* );
00123 ~Private();
00124
00125 void clear();
00126
00127 Type typ;
00128 union
00129 {
00130 uint u;
00131 int i;
00132 double d;
00133 uchar b;
00134 void *ptr;
00135 } value;
00136 };
00137
00138 Private* d;
00139 };
00140
00141 inline AIElement::Type AIElement::type() const
00142 {
00143 return d->typ;
00144 }
00145
00146 inline bool AIElement::isValid() const
00147 {
00148 return (d->typ != Invalid);
00149 }
00150
00151 #endif
|