summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/opietooth2/OTUUID.h
blob: aebd9b9bb54bec2d119d8048abfcce9c0a534b89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//-*-c++-*-
/***************************************************************************
 *   Copyright (C) 2003 by Fred Schaettgen                                 *
 *   kdebluetooth@schaettgen.de                                            *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 ***************************************************************************/

#ifndef OTUUID_H
#define OTUUID_H

#include <qstring.h>
#include <qarray.h>
#include <bluezlib.h>

namespace Opietooth2 {

class OTUUID;

typedef QArray<OTUUID> UUIDVector;

class OTUUID {

public :

    OTUUID( QString s );
    OTUUID( uint64_t l=0, uint64_t h=0);
    OTUUID( const OTUUID & O );

    bool fromString(QString s);

    void setUUID128(uint64_t hi, uint64_t lo);

    void setUUID32(uint32_t v);

    uint16_t toShort()
      { return ((hi>>32) & 0xffff); }
    uint32_t toLong()
      { return ((hi>>32) & 0xffffffff); }
    uint64_t toLongLong()
      { return hi; }

    QString toString() const ;
    operator QString() const;
    operator ::uuid_t() const;

    OTUUID & operator=( const OTUUID & other ) ;
    bool operator<( const OTUUID & other ) const;
    bool operator==(const OTUUID & uuid) const;

    uint64_t hi;
    uint64_t lo;
};
}
#endif