deCONZ C++ API v2.6.1
Loading...
Searching...
No Matches
ustring.h
1/*
2 * Copyright (c) 2023 dresden elektronik ingenieurtechnik gmbh.
3 * All rights reserved.
4 *
5 * The software in this package is published under the terms of the BSD
6 * style license a copy of which has been included with this distribution in
7 * the LICENSE.txt file.
8 *
9 */
10
11#ifndef U_STRING_H
12#define U_STRING_H
13
14#include "deconz/atom.h"
15#include "deconz/declspec.h"
16
17#ifndef USTRING_NO_QSTRING
18#include <QString>
19#endif
20
21typedef unsigned long long US_WordType;
22
23
33class DECONZ_DLLSPEC UString
34{
35public:
37 UString();
39 UString(const char *str);
41 UString(const UString &other);
43 UString(UString &&other) noexcept;
45 UString& operator=(const UString &other);
47 UString& operator=(UString &&other) noexcept;
49 ~UString();
50
51 bool operator==(const UString &) const;
52 bool operator!=(const UString &rhs) const { return !(*this == rhs); }
53
54 bool operator==(const char*) const;
55 bool operator!=(const char *rhs) const { return !(*this == rhs); }
56
61 const char *c_str() const;
67 unsigned size() const;
69 bool empty() const;
70
71 static UString number(int, int base=10);
72 static UString number(unsigned int, int base=10);
73 static UString number(long, int base=10);
74 static UString number(unsigned long, int base=10);
75 static UString number(long long, int base=10);
76 static UString number(unsigned long long, int base=10);
77 static UString number(double, char f='f', int prec=6);
78
84 static UString fromAtom(AT_Atom);
90 static UString fromAtom(AT_AtomIndex);
91
92private:
96 US_WordType d_word = 0;
97};
98
99#ifndef USTRING_NO_QSTRING
101inline QLatin1String toQLatin1String(UString str)
102{
103 return QLatin1String(str.c_str(), int(str.size()));
104}
105
107inline QString toQString(UString str)
108{
109 return QString::fromUtf8(str.c_str(), int(str.size()));
110}
111#endif
112
113#endif /* U_STRING_H */
String class to replace QString (work in progress).
Definition ustring.h:34
unsigned size() const
Returns the byte size of the string.
Definition ustring.cpp:336
const char * c_str() const
Returns the zero terminated C-String.
Definition ustring.cpp:306
A unique index referencing a atom.
Definition atom.h:44
Represents an atom which is uniquely stored in the atom table.
Definition atom.h:32