unflutter/dart/Snapshot.h
Selim Mustafaev 5ec1117337 Fix building on macOS.
Adding LEB128 reader class.
2022-11-28 20:46:19 +03:00

54 lines
1.3 KiB
C++

//
// Created by selim on 27.11.22.
//
#ifndef UNFLUTTER_SNAPSHOT_H
#define UNFLUTTER_SNAPSHOT_H
#include "Leb128Int.h"
#include <cstddef>
#include <cstdint>
#include <string>
#include <vector>
namespace Dart {
class Snapshot {
public:
enum class Kind: uint64_t {
FULL, FULL_JIT, FULL_AOT, MESSAGE, NONE, INVALID
};
static const uint32_t MAGIC = 0xDCDCF5F5;
private:
uint32_t _magic;
uint64_t _size;
Kind _kind;
std::string _versionHash;
std::vector<std::string> _features;
Leb128Int _baseObjectsCount;
Leb128Int _allObjectsCount;
Leb128Int _clustersCount;
Leb128Int _fieldTableLength;
private:
static std::vector<std::string> split(const std::string &str);
public:
explicit Snapshot(const std::byte* data);
[[nodiscard]] uint64_t size() const;
[[nodiscard]] std::string kindString() const;
[[nodiscard]] std::string versionHash() const;
[[nodiscard]] std::string featuresString() const;
[[nodiscard]] uint64_t baseObjectsCount() const;
[[nodiscard]] uint64_t allObjectsCount() const;
[[nodiscard]] uint64_t clustersCount() const;
[[nodiscard]] uint64_t fieldTableLength() const;
};
}
#endif //UNFLUTTER_SNAPSHOT_H