How can I partition a QByteArray efficiently?

后端 未结 2 548
误落风尘
误落风尘 2021-01-19 23:32

I want to partition a QByteArray message efficiently, so this function I implemented take the Bytes, the part I want to extract, and toEnd flag which tells if I want to extr

2条回答
  •  醉梦人生
    2021-01-20 00:06

    What about this:

      QByteArray Server::getPart(const QByteArray& message, int part, bool toEnd)
      {
        int characters(toEnd ? -1 : message.indexOf(' ', part) - part);
    
        return message.mid(part, characters);
      }
    

提交回复
热议问题