mirror of
https://github.com/ScrelliCopter/tmx2gba.git
synced 2025-02-21 03:29:25 +11:00
first pass at splitting writer logic
This commit is contained in:
45
src/headerwriter.hpp
Normal file
45
src/headerwriter.hpp
Normal file
@@ -0,0 +1,45 @@
|
||||
/* headerwriter.hpp - Copyright (C) 2015-2024 a dinosaur (zlib, see COPYING.txt) */
|
||||
|
||||
#ifndef HEADERWRITER_HPP
|
||||
#define HEADERWRITER_HPP
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <span>
|
||||
#include <concepts>
|
||||
#include <fstream>
|
||||
|
||||
template <typename T>
|
||||
concept NumericType = std::integral<T> || std::floating_point<T>;
|
||||
|
||||
class HeaderWriter
|
||||
{
|
||||
std::ofstream stream;
|
||||
std::string name;
|
||||
|
||||
void WriteGuardStart();
|
||||
void WriteGuardEnd();
|
||||
|
||||
public:
|
||||
~HeaderWriter();
|
||||
|
||||
[[nodiscard]] bool Open(const std::string_view path, const std::string_view name);
|
||||
|
||||
void WriteDefine(const std::string_view name, const std::string_view value);
|
||||
void WriteSymbol(const std::string_view name, const std::string_view type, std::size_t count);
|
||||
|
||||
template <NumericType T>
|
||||
void WriteDefine(const std::string_view name, T value)
|
||||
{
|
||||
WriteDefine(name, std::to_string(value));
|
||||
}
|
||||
|
||||
void WriteSize(int width, int height);
|
||||
void WriteCharacterMap(const std::span<uint16_t> charData);
|
||||
void WriteCollision(const std::span<uint8_t> collisionData);
|
||||
void WriteObjects(const std::span<uint32_t> objData);
|
||||
};
|
||||
|
||||
#endif//HEADERWRITER_HPP
|
||||
Reference in New Issue
Block a user