Refactor ContentOpfParser to use a constexpr for MEDIA_TYPE_NCX

This commit is contained in:
Arthur Tazhitdinov 2025-12-16 20:20:06 +03:00
parent 7074deb9ad
commit 8a99436e6a

View File

@ -3,6 +3,10 @@
#include <HardwareSerial.h> #include <HardwareSerial.h>
#include <ZipFile.h> #include <ZipFile.h>
namespace {
constexpr const char MEDIA_TYPE_NCX[] = "application/x-dtbncx+xml";
}
bool ContentOpfParser::setup() { bool ContentOpfParser::setup() {
parser = XML_ParserCreate(nullptr); parser = XML_ParserCreate(nullptr);
if (!parser) { if (!parser) {
@ -125,7 +129,7 @@ void XMLCALL ContentOpfParser::startElement(void* userData, const XML_Char* name
self->items[itemId] = href; self->items[itemId] = href;
if (mediaType == "application/x-dtbncx+xml") { if (mediaType == MEDIA_TYPE_NCX) {
if (self->tocNcxPath.empty()) { if (self->tocNcxPath.empty()) {
self->tocNcxPath = href; self->tocNcxPath = href;
} else { } else {