Enforce plist correctness.

This commit is contained in:
jief666 2020-09-19 23:32:46 +03:00
parent f4e10b1a2a
commit 648f5c3d3b
2 changed files with 6 additions and 8 deletions

View File

@ -126,7 +126,7 @@ const TagDict* TagArray::dictElementAt(size_t idx, const XString8& currentTag) c
{
const TagStruct* tag = elementAt(idx);
if ( !tag->isDict() ) {
MsgLog("MALFORMED PLIST in '%s' : TagArray::dictElementAt(%zu) -> trying to get a dict element at %zu, but element is %s\n", currentTag.c_str(), idx, idx, tag->getTypeAsXString8().c_str());
panic("MALFORMED PLIST in '%s' : TagArray::dictElementAt(%zu) -> trying to get a dict element at %zu, but element is %s\n", currentTag.c_str(), idx, idx, tag->getTypeAsXString8().c_str());
}
return _arrayContent[idx].getDict();
}
@ -135,7 +135,7 @@ const TagArray* TagArray::arrayElementAt(size_t idx, const XString8& currentTag)
{
const TagStruct* tag = elementAt(idx);
if ( !tag->isArray() ) {
MsgLog("MALFORMED PLIST in '%s' : TagArray::dictElementAt(%zu) -> trying to get a array element at %zu, but element is %s\n", currentTag.c_str(), idx, idx, tag->getTypeAsXString8().c_str());
panic("MALFORMED PLIST in '%s' : TagArray::dictElementAt(%zu) -> trying to get a array element at %zu, but element is %s\n", currentTag.c_str(), idx, idx, tag->getTypeAsXString8().c_str());
}
return _arrayContent[idx].getArray();
}
@ -144,7 +144,7 @@ const TagDict* TagArray::dictElementAt(size_t idx) const
{
const TagStruct* tag = elementAt(idx);
if ( !tag->isDict() ) {
MsgLog("MALFORMED PLIST : TagArray::dictElementAt(%zu) -> trying to get a dict element at %zu, but element is %s\n", idx, idx, tag->getTypeAsXString8().c_str());
panic("MALFORMED PLIST : TagArray::dictElementAt(%zu) -> trying to get a dict element at %zu, but element is %s\n", idx, idx, tag->getTypeAsXString8().c_str());
}
return _arrayContent[idx].getDict();
}
@ -153,7 +153,7 @@ const TagArray* TagArray::arrayElementAt(size_t idx) const
{
const TagStruct* tag = elementAt(idx);
if ( !tag->isArray() ) {
MsgLog("MALFORMED PLIST : TagArray::dictElementAt(%zu) -> trying to get a array element at %zu, but element is %s\n", idx, idx, tag->getTypeAsXString8().c_str());
panic("MALFORMED PLIST : TagArray::dictElementAt(%zu) -> trying to get a array element at %zu, but element is %s\n", idx, idx, tag->getTypeAsXString8().c_str());
}
return _arrayContent[idx].getArray();
}

View File

@ -167,8 +167,7 @@ const TagDict* TagDict::dictPropertyForKey(const CHAR8* key) const
const TagStruct* tag = propertyForKey(key);
if ( tag == NULL ) return NULL;
if ( !tag->isDict() ) {
MsgLog("MALFORMED PLIST : Property value for key %s must be a dict\n", key);
return NULL;
panic("MALFORMED PLIST : Property value for key %s must be a dict\n", key);
}
return tag->getDict();
}
@ -178,8 +177,7 @@ const TagArray* TagDict::arrayPropertyForKey(const CHAR8* key) const
const TagStruct* tag = propertyForKey(key);
if ( tag == NULL ) return NULL;
if ( !tag->isArray() ) {
MsgLog("MALFORMED PLIST : Property value for key %s must be an array\n", key);
return NULL;
panic("MALFORMED PLIST : Property value for key %s must be an array\n", key);
}
return tag->getArray();
}