summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlouist103 <louist103@gmail.com>2022-07-18 17:36:55 -0400
committerlouist103 <louist103@gmail.com>2022-07-18 17:36:55 -0400
commit09235c97f3a4fe243ae6fad581471c08fd5faeb3 (patch)
tree665ce4e21a8a3ef3e5961a4f84e9d9667633face
parentf54f2fa96bfc476a15fcc3ebcd6124bc19164fcd (diff)
Custom header guards.
-rw-r--r--ZAPD/ZFile.cpp15
-rw-r--r--ZAPD/ZFile.h4
2 files changed, 17 insertions, 2 deletions
diff --git a/ZAPD/ZFile.cpp b/ZAPD/ZFile.cpp
index b81399e..34c57f5 100644
--- a/ZAPD/ZFile.cpp
+++ b/ZAPD/ZFile.cpp
@@ -98,6 +98,14 @@ void ZFile::ParseXML(tinyxml2::XMLElement* reader, const std::string& filename)
if (outNameXml != nullptr)
outName = outNameXml;
+ const char* customHeaderGuard = reader->Attribute("CustomGuard");
+
+ if (customHeaderGuard != nullptr)
+ {
+ useCustomHeaderGuard = true;
+ customGuard = customHeaderGuard;
+ }
+
// TODO: This should be a variable on the ZFile, but it is a large change in order to force all
// ZResource types to have a parent ZFile.
const char* gameStr = reader->Attribute("Game");
@@ -778,8 +786,13 @@ void ZFile::GenerateSourceHeaderFiles()
std::string objectNameUpper = StringHelper::ToUpper(GetName());
- formatter.Write(StringHelper::Sprintf("#ifndef %s_H\n#define %s_H 1\n\n",
+ if (!useCustomHeaderGuard)
+ formatter.Write(StringHelper::Sprintf("#ifndef %s_H\n#define %s_H 1\n\n",
objectNameUpper.c_str(), objectNameUpper.c_str()));
+ else
+ formatter.Write(StringHelper::Sprintf("#ifndef %s_H\n#define %s_H 1\n\n",
+ customGuard.c_str(), customGuard.c_str()));
+
for (ZResource* res : resources)
{
diff --git a/ZAPD/ZFile.h b/ZAPD/ZFile.h
index 275e27f..acd5649 100644
--- a/ZAPD/ZFile.h
+++ b/ZAPD/ZFile.h
@@ -31,13 +31,15 @@ class ZFile
{
public:
std::map<offset_t, Declaration*> declarations;
- std::string defines;
std::vector<ZResource*> resources;
+ std::string defines;
+ std::string customGuard;
// Default to using virtual addresses
uint32_t segment = 0x80;
uint32_t baseAddress, rangeStart, rangeEnd;
bool isExternalFile = false;
+ bool useCustomHeaderGuard = false;
ZFile(const fs::path& nOutPath, const std::string& nName);
ZFile(ZFileMode nMode, tinyxml2::XMLElement* reader, const fs::path& nBasePath,