1
/***************************************************************************
2
Copyright 2007 David Nolden <david.nolden.kdevelop@art-master.de>
3
***************************************************************************/
5
/***************************************************************************
7
* This program is free software; you can redistribute it and/or modify *
8
* it under the terms of the GNU General Public License as published by *
9
* the Free Software Foundation; either version 2 of the License, or *
10
* (at your option) any later version. *
12
***************************************************************************/
14
#ifndef HASHED_STRING_H
15
#define HASHED_STRING_H
17
//krazy:excludeall=dpointer,inline
19
#include <QtCore/QString>
20
#include "../languageexport.h"
28
KDEVPLATFORMLANGUAGE_EXPORT QDataStream& operator << ( QDataStream& stream, const KDevelop::HashedString& str );
30
KDEVPLATFORMLANGUAGE_EXPORT QDataStream& operator >> ( QDataStream& stream, KDevelop::HashedString& str );
34
typedef uint HashType; ///@todo use at least 64 bit hash
37
* A simple class that stores a string together with it's appropriate hash-key
39
* The difference to a normal QString is that the hash is stored, used for sorting, and for equality-comparison.
41
* Since most of the member-functions boil down to a simply integer-comparison in the most common case, they are inlined for performance-reasons.
43
class KDEVPLATFORMLANGUAGE_EXPORT HashedString {
47
HashedString( const QString& str );
49
HashedString( const char* str );
51
inline HashType hash() const {
57
HashedString& operator= ( const QString& str );
59
HashedString& operator +=( const QString& str );
61
HashedString& operator +=( const char* str );
63
bool operator == ( const HashedString& rhs ) const;
65
bool operator != ( const HashedString& rhs ) const;
67
///Does not compare alphabetically, uses the hash-key for ordering.
68
bool operator < ( const HashedString& rhs ) const;
70
static HashType hashString( const QString& str );
78
friend QDataStream& ::operator << ( QDataStream& stream, const HashedString& str );
79
friend QDataStream& ::operator >> ( QDataStream& stream, HashedString& str );
82
KDEVPLATFORMLANGUAGE_EXPORT inline uint qHash( const KDevelop::HashedString& str ) {