language/duchain
KDevelop::IndexedString Class Reference
This string does "disk reference-counting", which means that reference-counts are maintainted, but only when the string is in a disk-stored location. More...
#include <indexedstring.h>
Public Member Functions | |
| IndexedString (const KUrl &url) | |
| IndexedString (const IndexedString &) | |
| IndexedString (const QByteArray &str) | |
| IndexedString (const QString &str) | |
| IndexedString (char c) | |
| IndexedString (const char *str) | |
| IndexedString (const char *str, unsigned short length, unsigned int hash=0) | |
| QByteArray | byteArray () const |
| unsigned int | hash () const |
| unsigned int | index () const |
| bool | isEmpty () const |
| int | length () const |
| bool | operator!= (const IndexedString &rhs) const |
| bool | operator< (const IndexedString &rhs) const |
| IndexedString & | operator= (const IndexedString &) |
| bool | operator== (const IndexedString &rhs) const |
| QString | str () const |
| KUrl | toUrl () const |
Static Public Member Functions | |
| static IndexedString | fromIndex (unsigned int index) |
| static unsigned int | hashString (const char *str, unsigned short length) |
Detailed Description
This string does "disk reference-counting", which means that reference-counts are maintainted, but only when the string is in a disk-stored location.
The file referencecounting.h is used to manage this condition. Whenever reference-counting is enabled for a range that contains the IndexedString, it will manipulate the reference-counts. The duchain storage mechanisms automatically are about correctly managing that condition, so you don't need to care, and can just use this class in every duchain data type without restrictions.
- Warning:
- Do not use IndexedString after QCoreApplication::aboutToQuit() has been emitted, items that are not disk-referenced will be invalid at that point
Empty strings have an index of zero. Strings of length one are not put into the repository, but are encoded directly within the index: They are encoded like 0xffff00bb where bb is the byte of the character.
Definition at line 43 of file indexedstring.h.
Constructor & Destructor Documentation
| KDevelop::IndexedString::IndexedString | ( | const char * | str, | |
| unsigned short | length, | |||
| unsigned int | hash = 0 | |||
| ) | [explicit] |
- Parameters:
-
str must be a utf8 encoded string, does not need to be 0-terminated. length must be its length in bytes. hash must be a hash as constructed with the here defined hash functions. If it is zero, it will be computed. str must be a utf8 encoded string, does not need to be 0-terminated. length must be its length in bytes.
Definition at line 123 of file indexedstring.cpp.
| KDevelop::IndexedString::IndexedString | ( | const char * | str | ) | [explicit] |
Needs a zero terminated string. When the information is already available, try using the other constructor.
Definition at line 182 of file indexedstring.cpp.
| KDevelop::IndexedString::IndexedString | ( | const QString & | str | ) | [explicit] |
When the information is already available, try using the other constructor. This is expensive.
Definition at line 162 of file indexedstring.cpp.
| KDevelop::IndexedString::IndexedString | ( | const QByteArray & | str | ) | [explicit] |
When the information is already available, try using the other constructor. This is expensive.
Definition at line 197 of file indexedstring.cpp.
| KDevelop::IndexedString::IndexedString | ( | const KUrl & | url | ) | [explicit] |
Creates an indexed string from a KUrl, this is expensive.
Definition at line 142 of file indexedstring.cpp.
Member Function Documentation
| QByteArray KDevelop::IndexedString::byteArray | ( | ) | const |
Convenience function, avoid using it, it's relatively expensive(les expensive then str() though).
Definition at line 278 of file indexedstring.cpp.
| static IndexedString KDevelop::IndexedString::fromIndex | ( | unsigned int | index | ) | [inline, static] |
Returns a not reference-counted IndexedString that represents the given index.
- Warning:
- It is dangerous dealing with indices directly, because it may break the reference counting logic never stay pure indices to disk
Definition at line 66 of file indexedstring.h.
| unsigned int KDevelop::IndexedString::index | ( | ) | const [inline] |
The string is uniquely identified by this index.
You can use it for comparison.
- Warning:
- It is dangerous dealing with indices directly, because it may break the reference counting logic never stay pure indices to disk
Definition at line 90 of file indexedstring.h.
| bool KDevelop::IndexedString::operator< | ( | const IndexedString & | rhs | ) | const [inline] |
Does not compare alphabetically, uses the index for ordering.
Definition at line 118 of file indexedstring.h.
| QString KDevelop::IndexedString::str | ( | ) | const |
Convenience function, avoid using it, it's relatively expensive.
Definition at line 260 of file indexedstring.cpp.
| KUrl KDevelop::IndexedString::toUrl | ( | ) | const |
Re-construct a KUrl from this indexed string, the result can be used with the KUrl-using constructor.
This is expensive.
Definition at line 255 of file indexedstring.cpp.
The documentation for this class was generated from the following files:
KDE 4.4 API Reference