Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. { 0x7f, 0x10, 0x7f, 0x7f, 0x10, 0x7f, 0x7f, 0x7f, 0x7f, 0x11, 0x7f, 0x7f };
  2.  
  3. { 0x7f, 0x10, 0x7f, 0x10, 0x7f, 0x7f, 0x11, 0x7f };
  4.  
  5. const unsigned char _ssp_stx = 0x7f;
  6. //--------------------------------------------------------------------------
  7. void stx_shrink(std::vector<char>& data)
  8. {
  9. std::vector<char> result;
  10. result.reserve(data.size());
  11.  
  12. bool stx_lock { false };
  13.  
  14. for (int i = 0; i < data.size(); ++i)
  15. {
  16. if (stx_lock == true)
  17. {
  18. stx_lock = false;
  19.  
  20. if ((unsigned char)data[i] == _ssp_stx)
  21. continue;
  22. }
  23.  
  24. if ((unsigned char)data[i] == _ssp_stx)
  25. stx_lock = true;
  26.  
  27. result.push_back(data[i]);
  28. }
  29.  
  30. data = result;
  31. }
  32.  
  33. int main()
  34. {
  35. std::vector<char> test = { 0x7f, 0x10, 0x7f, 0x7f, 0x10, 0x7f, 0x7f, 0x7f, 0x7f, 0x11, 0x7f, 0x7f };
  36.  
  37. stx_shrink(test);
  38.  
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement