Dawn/src/dawn/save/SaveFile.hpp
2022-12-17 23:18:06 -08:00

63 lines
1.4 KiB
C++

// Copyright (c) 2022 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
#pragma once
#include "dawnlibs.hpp"
#include "assert/assert.hpp"
#include "util/array.hpp"
namespace Dawn {
typedef union {
float_t f;
int64_t i64;
int32_t i32;
uint32_t u32;
int16_t i16;
uint16_t u16;
uint8_t u8;
int8_t i8;
} savedata_t;
struct SaveFile {
bool_t hasChanges;
std::map<std::string, savedata_t> values;
// std::map<std::string, std::string> stringValues;
// std::map<std::string, std::vector<savedata_t>> arrayValues;
/**
* Returns true if the given key exists in the save file.
*
* @param key Key to check if exists.
* @return True if exists.
*/
bool_t has(std::string key);
/**
* Returns the value of a given key.
*
* @param key Key to get the value of.
* @return The value.
*/
savedata_t get(std::string key);
// std::string getString(std::string key);
// std::vector<savedata_t> getArray(std::string key);
/**
* Sets the given value to the save file.
*
* @param key Key to set.
* @param data Data to set.
*/
void set(std::string key, savedata_t data);
void copy(struct SaveFile raw, std::string key);
/**
* Completely resets the save file (empties all the values).
*/
void reset();
};
}