| 1 | // Copyright (C) 2014 Robin Burchell <robin.burchell@viroteck.net> |
| 2 | // Copyright (C) 2016 The Qt Company Ltd. |
| 3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 4 | |
| 5 | #ifndef QTUIO_P_H |
| 6 | #define QTUIO_P_H |
| 7 | |
| 8 | QT_BEGIN_NAMESPACE |
| 9 | |
| 10 | inline bool qt_readOscString(const QByteArray &source, QByteArray &dest, quint32 &pos) |
| 11 | { |
| 12 | int end = source.indexOf(ch: '\0', from: pos); |
| 13 | if (end < 0) { |
| 14 | pos = source.size(); |
| 15 | dest = QByteArray(); |
| 16 | return false; |
| 17 | } |
| 18 | |
| 19 | dest = source.mid(index: pos, len: end - pos); |
| 20 | |
| 21 | // Skip additional NULL bytes at the end of the string to make sure the |
| 22 | // total number of bits a multiple of 32 bits ("OSC-string" in the |
| 23 | // specification). |
| 24 | end += 4 - ((end - pos) % 4); |
| 25 | |
| 26 | pos = end; |
| 27 | return true; |
| 28 | } |
| 29 | |
| 30 | QT_END_NAMESPACE |
| 31 | |
| 32 | #endif |
| 33 | |