VarInt.hpp 639 B

12345678910111213141516171819202122232425262728293031323334
  1. #pragma once
  2. #include <mumlib.hpp>
  3. #include <stdint.h>
  4. #include <vector>
  5. #include <string>
  6. namespace mumlib {
  7. class VarIntException : public MumlibException {
  8. public:
  9. VarIntException(std::string message) : MumlibException(message) { }
  10. };
  11. class VarInt {
  12. public:
  13. VarInt(uint8_t *encoded);
  14. VarInt(std::vector<uint8_t> encoded);
  15. VarInt(int64_t value);
  16. int64_t getValue() const {
  17. return this->value;
  18. }
  19. std::vector<uint8_t> getEncoded() const;
  20. private:
  21. const int64_t value;
  22. int64_t parseVariant(const uint8_t *buffer);
  23. };
  24. }