xbytearray.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #ifndef XBYTEARRAY_H
  2. #define XBYTEARRAY_H
  3. /** \cond docNever */
  4. #include <QtCore>
  5. /*! XByteArray represents the content of QHexEcit.
  6. XByteArray comprehend the data itself and informations to store if it was
  7. changed. The QHexEdit component uses these informations to perform nice
  8. rendering of the data
  9. XByteArray also provides some functionality to insert, replace and remove
  10. single chars and QByteArras. Additionally some functions support rendering
  11. and converting to readable strings.
  12. */
  13. class XByteArray
  14. {
  15. public:
  16. explicit XByteArray();
  17. int addressOffset();
  18. void setAddressOffset(int offset);
  19. int addressWidth();
  20. void setAddressWidth(int width);
  21. QByteArray & data();
  22. void setData(QByteArray data);
  23. bool dataChanged(int i);
  24. QByteArray dataChanged(int i, int len);
  25. void setDataChanged(int i, bool state);
  26. void setDataChanged(int i, const QByteArray & state);
  27. int realAddressNumbers();
  28. int size();
  29. QByteArray & insert(int i, char ch);
  30. QByteArray & insert(int i, const QByteArray & ba);
  31. QByteArray & remove(int pos, int len);
  32. QByteArray & replace(int index, char ch);
  33. QByteArray & replace(int index, const QByteArray & ba);
  34. QByteArray & replace(int index, int length, const QByteArray & ba);
  35. QChar asciiChar(int index);
  36. QString toRedableString(int start=0, int end=-1);
  37. signals:
  38. public slots:
  39. private:
  40. QByteArray _data;
  41. QByteArray _changedData;
  42. int _addressNumbers; // wanted width of address area
  43. int _addressOffset; // will be added to the real addres inside bytearray
  44. int _realAddressNumbers; // real width of address area (can be greater then wanted width)
  45. int _oldSize; // size of data
  46. };
  47. /** \endcond docNever */
  48. #endif // XBYTEARRAY_H