1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of the test suite of Qt for Python. 7 ** 8 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ 9 ** Commercial License Usage 10 ** Licensees holding valid commercial Qt licenses may use this file in 11 ** accordance with the commercial license agreement provided with the 12 ** Software or, alternatively, in accordance with the terms contained in 13 ** a written agreement between you and The Qt Company. For licensing terms 14 ** and conditions see https://www.qt.io/terms-conditions. For further 15 ** information use the contact form at https://www.qt.io/contact-us. 16 ** 17 ** GNU General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU 19 ** General Public License version 3 as published by the Free Software 20 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 21 ** included in the packaging of this file. Please review the following 22 ** information to ensure the GNU General Public License requirements will 23 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 24 ** 25 ** $QT_END_LICENSE$ 26 ** 27 ****************************************************************************/ 28 29 #ifndef STR_H 30 #define STR_H 31 #include <string> 32 33 #include "libsamplemacros.h" 34 35 class LIBSAMPLE_API Str 36 { 37 public: 38 Str(const Str& s); 39 Str(char c); 40 Str(const char* cstr = ""); 41 ~Str(); 42 43 Str arg(const Str& s) const; 44 45 Str& append(const Str& s); 46 Str& prepend(const Str& s); 47 48 const char* cstring() const; 49 char get_char(int pos) const; 50 bool set_char(int pos, char ch); 51 52 int toInt(bool *ok = nullptr, int base = 10) const; 53 54 void show() const; 55 size()56 inline int size() const { return m_str.size(); } 57 58 // nonsense operator just to test reverse operators 59 Str operator+(int number) const; 60 bool operator==(const Str& other) const; 61 bool operator<(const Str& other) const; 62 63 private: 64 void init(const char* cstr); 65 std::string m_str; 66 67 friend LIBSAMPLE_API Str operator+(int number, const Str& str); 68 friend LIBSAMPLE_API unsigned int strHash(const Str& str); 69 }; 70 71 LIBSAMPLE_API Str operator+(int number, const Str& str); 72 LIBSAMPLE_API unsigned int strHash(const Str& str); 73 74 using PStr = Str; 75 LIBSAMPLE_API void changePStr(PStr* pstr, const char* suffix); 76 LIBSAMPLE_API void duplicatePStr(PStr *pstr = nullptr); 77 78 #endif // STR_H 79