DS_ByteQueue.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (c) 2014, Oculus VR, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. *
  9. */
  10. /// \file DS_ByteQueue.h
  11. /// \internal
  12. /// \brief Byte queue
  13. ///
  14. #ifndef __BYTE_QUEUE_H
  15. #define __BYTE_QUEUE_H
  16. #include "RakMemoryOverride.h"
  17. #include "Export.h"
  18. /// The namespace DataStructures was only added to avoid compiler errors for commonly named data structures
  19. /// As these data structures are stand-alone, you can use them outside of RakNet for your own projects if you wish.
  20. namespace DataStructures
  21. {
  22. class ByteQueue
  23. {
  24. public:
  25. ByteQueue();
  26. ~ByteQueue();
  27. void WriteBytes(const char *in, unsigned length, const char *file, unsigned int line);
  28. bool ReadBytes(char *out, unsigned maxLengthToRead, bool peek);
  29. unsigned GetBytesWritten(void) const;
  30. char* PeekContiguousBytes(unsigned int *outLength) const;
  31. void IncrementReadOffset(unsigned length);
  32. void DecrementReadOffset(unsigned length);
  33. void Clear(const char *file, unsigned int line);
  34. void Print(void);
  35. protected:
  36. char *data;
  37. unsigned readOffset, writeOffset, lengthAllocated;
  38. };
  39. }
  40. #endif
粤ICP备19079148号