00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef OTATTRIBUTE_H
00013 #define OTATTRIBUTE_H
00014
00015 #include <stdio.h>
00016 #include <qstring.h>
00017 #include <qarray.h>
00018 #include <qvector.h>
00019 #include <bluezlib.h>
00020 #include <OTUUID.h>
00021
00022 namespace Opietooth2 {
00023
00024 class OTSDPAttribute;
00025 class OTUUID;
00026
00027 typedef QVector<OTSDPAttribute> AttributeVector;
00028
00032 class OTSDPAttribute {
00033
00034 public:
00035
00036 enum AttrType {
00037 INVALID = 0,
00038 NIL = 1,
00039 UINT = 2,
00040 INT = 3,
00041 UUID = 4,
00042 BOOLEAN = 5,
00043 STRING = 6,
00044 SEQUENCE = 7,
00045 ALTERNATIVE = 8,
00046 URL = 9,
00047 UNKNOWN = 10
00048 };
00049
00050 class int128_t {
00051 public :
00052 int128_t(int64_t l=0, int64_t h=0) {
00053 hi = h;
00054 lo = l;
00055 }
00056 int128_t(const OTSDPAttribute::int128_t & l) {
00057 hi = l.hi;
00058 lo = l.lo;
00059 }
00060 QString toString() const {
00061 char Buf[50];
00062 sprintf( Buf, "%lld%lld", hi, lo );
00063 return QString( Buf );
00064 }
00065 int64_t hi;
00066 int64_t lo;
00067 };
00068
00069 class uint128_t {
00070 public :
00071 uint128_t( uint64_t l=0, uint64_t h=0) {
00072 hi = h;
00073 lo = l;
00074 }
00075 uint128_t( const OTSDPAttribute::uint128_t & l) {
00076 hi = l.hi;
00077 lo = l.lo;
00078 }
00079 QString toString() const {
00080 char Buf[50];
00081 sprintf( Buf, "%llu%llu", hi, lo );
00082 return QString( Buf );
00083 }
00084 uint64_t hi;
00085 uint64_t lo;
00086 };
00087
00088 public:
00089
00090 OTSDPAttribute();
00091 OTSDPAttribute( sdp_data_t * D );
00092 ~OTSDPAttribute();
00093
00094 QString toString( void );
00095
00096 void setNil();
00097 void setInt(const OTSDPAttribute::int128_t & val);
00098 void setUInt(const OTSDPAttribute::uint128_t & val);
00099 void setUUID( const OTUUID & val);
00100 void setBool(bool val);
00101 void setString(const QString & val);
00102 void setURL(const QString & val);
00103 void setSequence(const AttributeVector& val);
00104 void setAlternative(const AttributeVector& val);
00105
00106 QString getString();
00107 QString getURL();
00108 const OTSDPAttribute::int128_t & getInt();
00109 const OTSDPAttribute::uint128_t & getUInt();
00110 const OTUUID & getUUID();
00111 bool getBool();
00112 AttributeVector * getSequence();
00113 AttributeVector * getAlternative();
00114
00115 UUIDVector getAllUUIDs();
00116
00117 inline AttrType getType()
00118 { return type; }
00119
00120
00121 const char * getTypeString();
00122
00123 private:
00124
00125 AttrType type;
00126
00127 union {
00128 OTSDPAttribute::int128_t * intVal;
00129 OTSDPAttribute::uint128_t * uintVal;
00130 OTUUID * uuidVal;
00131 bool boolVal;
00132 QString * stringVal;
00133 AttributeVector * sequenceVal;
00134 } Value;
00135
00136 };
00137
00138 }
00139
00140 #endif