2020-12-29 22:44:04 +00:00
|
|
|
#pragma once
|
2022-10-10 00:22:17 +00:00
|
|
|
#include <Common/CriticalSection.h>
|
|
|
|
#include <Common/File.h>
|
2021-02-28 21:32:50 +00:00
|
|
|
#include <Project64-core/N64System/Enhancement/Enhancement.h>
|
|
|
|
#include <Project64-core/N64System/Enhancement/EnhancementList.h>
|
2022-10-10 00:22:17 +00:00
|
|
|
#include <map>
|
|
|
|
#include <memory>
|
2020-12-29 22:44:04 +00:00
|
|
|
#include <set>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
class CEnhancmentFile
|
|
|
|
{
|
|
|
|
struct insensitive_compare
|
|
|
|
{
|
2022-10-10 00:22:17 +00:00
|
|
|
bool operator()(const std::string & a, const std::string & b) const
|
2020-12-29 22:44:04 +00:00
|
|
|
{
|
|
|
|
return _stricmp(a.c_str(), b.c_str()) < 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::map<std::string, long> FILELOC;
|
|
|
|
typedef FILELOC::iterator FILELOC_ITR;
|
|
|
|
|
|
|
|
public:
|
|
|
|
typedef std::set<std::string> SectionList;
|
|
|
|
|
|
|
|
CEnhancmentFile(const char * FileName, const char * Ident);
|
|
|
|
~CEnhancmentFile();
|
|
|
|
|
|
|
|
void SetName(const char * Section, const char * Name);
|
|
|
|
bool AddEnhancement(const char * Section, const CEnhancement & Details);
|
|
|
|
void SaveCurrentSection(void);
|
|
|
|
|
|
|
|
bool GetName(const char * Section, std::string & Name);
|
|
|
|
bool GetEnhancementList(const char * Section, CEnhancementList & List);
|
|
|
|
bool RemoveEnhancements(const char * Section);
|
|
|
|
|
|
|
|
void GetSections(SectionList & sections);
|
|
|
|
|
2022-10-10 00:22:17 +00:00
|
|
|
const char * FileName(void) const
|
|
|
|
{
|
|
|
|
return m_FileName.c_str();
|
|
|
|
}
|
2020-12-29 22:44:04 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
CEnhancmentFile();
|
2022-10-10 00:22:17 +00:00
|
|
|
CEnhancmentFile(const CEnhancmentFile &);
|
|
|
|
CEnhancmentFile & operator=(const CEnhancmentFile &);
|
2020-12-29 22:44:04 +00:00
|
|
|
|
|
|
|
bool AddEnhancement(const CEnhancement & Details);
|
|
|
|
void OpenFile(void);
|
|
|
|
bool MoveToSection(const char * Section, bool ChangeCurrentSection);
|
2022-10-10 00:22:17 +00:00
|
|
|
int GetStringFromFile(char *& String, std::unique_ptr<char> & Data, int & MaxDataSize, int & DataSize, int & ReadPos);
|
2020-12-29 22:44:04 +00:00
|
|
|
const char * CleanLine(char * Line);
|
|
|
|
void fInsertSpaces(int32_t Pos, int32_t NoOfSpaces);
|
|
|
|
void ClearSectionPosList(long FilePos);
|
|
|
|
|
|
|
|
CriticalSection m_CS;
|
|
|
|
std::string m_Ident;
|
|
|
|
std::string m_CurrentSection;
|
|
|
|
std::string m_SectionName;
|
|
|
|
CEnhancementList m_EnhancementList;
|
|
|
|
FILELOC m_SectionsPos;
|
|
|
|
int32_t m_lastSectionSearch;
|
|
|
|
int32_t m_CurrentSectionFilePos;
|
|
|
|
bool m_CurrentSectionDirty;
|
|
|
|
bool m_ReadOnly;
|
|
|
|
CFile m_File;
|
|
|
|
std::string m_FileName;
|
|
|
|
const char * m_LineFeed;
|
|
|
|
};
|