#pragma once

#include <fstream>
#include <string>

class BinaryFile
{
public:

    template<typename T>
    static bool Write(std::ofstream* file, T data)
    {
        file->write(reinterpret_cast<char*>(&data), sizeof(data));
        return true;
    }

    static bool GetNextByteAsInt(std::ifstream* file, int& target);

    static bool GetNextNBytes(std::ifstream* file, char* buffer, unsigned numBytes);

    static bool GetNextWord(std::ifstream* file, char* buffer);

    static bool GetNextDWord(std::ifstream* file, char* buffer);

    static bool GetNextWord(std::ifstream* file, int& target, bool reverse = true);

    static bool GetNextDWord(std::ifstream* file, int& target);

    static bool CheckNextDWord(std::ifstream* file, const char* target);

    static bool GetNextString(std::ifstream* file, std::string& target, unsigned numBytes);
};
