How can I partition a QByteArray efficiently?

后端 未结 2 552
误落风尘
误落风尘 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);
      }
    
    0 讨论(0)
  • 2021-01-20 00:23

    Why not make it a regular QString and use split. That will give you a QStringList.

    0 讨论(0)
提交回复
热议问题