From cf2126b3293838068aeae822abb064e8e263900b Mon Sep 17 00:00:00 2001 From: tianduanrui <2407223896@qq.com> Date: Thu, 12 Mar 2020 10:08:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=85=B1=E4=BA=AB=E5=86=85?= =?UTF-8?q?=E5=AD=98=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/highgrade/qqtsharedmemory.h | 36 ++++++++++++++++----------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/highgrade/qqtsharedmemory.h b/src/highgrade/qqtsharedmemory.h index adc9d2d1..e2a096a2 100644 --- a/src/highgrade/qqtsharedmemory.h +++ b/src/highgrade/qqtsharedmemory.h @@ -1,4 +1,4 @@ -#ifndef QQTSHAREDMEMORY_H +#ifndef QQTSHAREDMEMORY_H #define QQTSHAREDMEMORY_H #include @@ -89,34 +89,32 @@ public: /*以下函数提供操作方便。*/ - QByteArray readShortString ( QByteArray& bytes ) { + void readShortString ( QByteArray& bytes, QByteArray& shortString ) { quint16 s0; - QByteArray str; bytes >> s0; - str.resize ( s0 ); - bytes >> str; - return str; + shortString.resize ( s0 ); + bytes >> shortString; + return; } - void writeShortString ( QByteArray& bytes, QByteArray& shortString ) { + void readString ( QByteArray& bytes, QByteArray& string ) { + quint32 s0; + bytes >> s0; + string.resize ( s0 ); + bytes >> string; + return; + } + + void writeShortString ( QByteArray& bytes, const QByteArray& shortString ) { quint16 s0 = shortString.size(); bytes << s0; bytes << shortString; } - QByteArray readString ( QByteArray& bytes ) { - quint32 s0; - QByteArray str; - bytes >> s0; - str.resize ( s0 ); - bytes >> str; - return str; - } - - void writeString ( QByteArray& bytes, QByteArray& shortString ) { - quint32 s0 = shortString.size(); + void writeString ( QByteArray& bytes, const QByteArray& string ) { + quint32 s0 = string.size(); bytes << s0; - bytes << shortString; + bytes << string; } signals: