Buffer.h 740 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #ifndef HERMES_PUBLIC_BUFFER_H
  8. #define HERMES_PUBLIC_BUFFER_H
  9. #include <cstddef>
  10. #include <cstdint>
  11. namespace hermes {
  12. /// A generic buffer interface. E.g. for memmapped bytecode.
  13. class Buffer {
  14. public:
  15. Buffer() : data_(nullptr), size_(0) {}
  16. Buffer(const uint8_t *data, size_t size) : data_(data), size_(size) {}
  17. virtual ~Buffer() {}
  18. const uint8_t *data() const {
  19. return data_;
  20. };
  21. size_t size() const {
  22. return size_;
  23. }
  24. protected:
  25. const uint8_t *data_ = nullptr;
  26. size_t size_ = 0;
  27. };
  28. } // namespace hermes
  29. #endif