mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2025-02-17 01:11:36 +01:00
Further refactor of plist.
This commit is contained in:
parent
2607bd4fbb
commit
85716960f9
@ -412,11 +412,11 @@ GetSleepImageLocation(IN REFIT_VOLUME *Volume, REFIT_VOLUME **SleepImageVolume,
|
||||
if (!EFI_ERROR(Status)) {
|
||||
Status = ParseXML((const CHAR8*)PrefBuffer, &PrefDict, (UINT32)PrefBufferLen);
|
||||
if (!EFI_ERROR(Status)) {
|
||||
dict = GetProperty(PrefDict, "Custom Profile");
|
||||
dict = PrefDict->dictPropertyForKey("Custom Profile");
|
||||
if (dict) {
|
||||
dict2 = GetProperty(dict, "AC Power");
|
||||
dict2 = dict->dictPropertyForKey("AC Power");
|
||||
if (dict2) {
|
||||
prop = GetProperty(dict2, "Hibernate File");
|
||||
prop = dict2->dictPropertyForKey("Hibernate File");
|
||||
if (prop && prop->isString() ) {
|
||||
if (prop->stringValue().contains("/Volumes/")) {
|
||||
CHAR8 *VolNameStart = NULL, *VolNameEnd = NULL;
|
||||
@ -457,6 +457,7 @@ GetSleepImageLocation(IN REFIT_VOLUME *Volume, REFIT_VOLUME **SleepImageVolume,
|
||||
}
|
||||
}
|
||||
}
|
||||
PrefDict->FreeTag();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1030,8 +1030,7 @@ VOID
|
||||
PutNvramPlistToRtVars ()
|
||||
{
|
||||
// EFI_STATUS Status;
|
||||
const TagStruct* ValTag;
|
||||
INTN Size, i;
|
||||
size_t Size;
|
||||
const VOID *Value;
|
||||
|
||||
if (gNvramDict == NULL) {
|
||||
@ -1041,109 +1040,115 @@ PutNvramPlistToRtVars ()
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !gNvramDict->isDict() ) {
|
||||
DBG("PutNvramPlistToRtVars: MALFORMED PLIST nvram.plist. Root must be a dict\n");
|
||||
return;
|
||||
}
|
||||
DbgHeader("PutNvramPlistToRtVars");
|
||||
// DBG("PutNvramPlistToRtVars ...\n");
|
||||
// iterate over dict elements
|
||||
for (size_t tagIdx = 0 ; tagIdx < gNvramDict->dictOrArrayContent().size() ; tagIdx++ )
|
||||
size_t count = gNvramDict->dictKeyCount(); // ok
|
||||
for (size_t tagIdx = 0 ; tagIdx < count ; tagIdx++ )
|
||||
{
|
||||
const TagStruct& Tag = gNvramDict->dictOrArrayContent()[tagIdx];
|
||||
const TagStruct* keyTag;
|
||||
const TagStruct* valueTag;
|
||||
if ( EFI_ERROR(gNvramDict->dictKeyAndValueAtIndex(tagIdx, &keyTag, &valueTag)) ) { //If GetKeyValueAtIndex return success, key and value != NULL
|
||||
MsgLog("MALFORMED PLIST nvram.plist. A key is expected at pos : %zu\n", tagIdx);
|
||||
continue;
|
||||
}
|
||||
EFI_GUID *VendorGuid = &gEfiAppleBootGuid;
|
||||
Value = NULL;
|
||||
if ( Tag.isKey() )
|
||||
{
|
||||
ValTag = Tag.keyTagValue();
|
||||
if ( tagIdx + 1 < gNvramDict->dictContent().size() && !gNvramDict->dictContent()[tagIdx+1].isKey() ) valueTag = &gNvramDict->dictContent()[tagIdx+1];
|
||||
|
||||
// process only valid <key> tags
|
||||
if (!Tag.isKey() || ValTag == NULL) {
|
||||
DBG(" ERROR: Tag is not <key> : type %s\n", ValTag->getTypeAsXString8().c_str());
|
||||
continue;
|
||||
}
|
||||
// DBG("tag: %s\n", Tag.stringValue());
|
||||
// skip OsxAptioFixDrv-RelocBase - appears and causes trouble
|
||||
// in kernel and kext patcher when mixing UEFI and CloverEFI boot
|
||||
if ( Tag.keyValue() == "OsxAptioFixDrv-RelocBase"_XS8 ) {
|
||||
DBG(" Skipping OsxAptioFixDrv-RelocBase\n");
|
||||
continue;
|
||||
} else if ( Tag.keyValue() == "OsxAptioFixDrv-ErrorExitingBootServices"_XS8 ) {
|
||||
DBG(" Skipping OsxAptioFixDrv-ErrorExitingBootServices\n");
|
||||
continue;
|
||||
} else if ( Tag.keyValue() == "EmuVariableUefiPresent"_XS8 ) {
|
||||
DBG(" Skipping EmuVariableUefiPresent\n");
|
||||
continue;
|
||||
} else if ( Tag.keyValue() == "aapl,panic-info"_XS8 ) {
|
||||
DBG(" Skipping aapl,panic-info\n");
|
||||
continue;
|
||||
}
|
||||
// process only valid <key> tags
|
||||
if ( valueTag == NULL ) {
|
||||
DBG(" ERROR: ValTag is not NULL\n");
|
||||
continue;
|
||||
}
|
||||
// DBG("tag: %s\n", Tag.stringValue());
|
||||
// skip OsxAptioFixDrv-RelocBase - appears and causes trouble
|
||||
// in kernel and kext patcher when mixing UEFI and CloverEFI boot
|
||||
if ( keyTag->keyStringValue() == "OsxAptioFixDrv-RelocBase"_XS8 ) {
|
||||
DBG(" Skipping OsxAptioFixDrv-RelocBase\n");
|
||||
continue;
|
||||
} else if ( keyTag->keyStringValue() == "OsxAptioFixDrv-ErrorExitingBootServices"_XS8 ) {
|
||||
DBG(" Skipping OsxAptioFixDrv-ErrorExitingBootServices\n");
|
||||
continue;
|
||||
} else if ( keyTag->keyStringValue() == "EmuVariableUefiPresent"_XS8 ) {
|
||||
DBG(" Skipping EmuVariableUefiPresent\n");
|
||||
continue;
|
||||
} else if ( keyTag->keyStringValue() == "aapl,panic-info"_XS8 ) {
|
||||
DBG(" Skipping aapl,panic-info\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
// // key to unicode; check if key buffer is large enough
|
||||
// if ( Tag.keyValue().length() > sizeof(KeyBuf) - 1 ) {
|
||||
// DBG(" ERROR: Skipping too large key %s\n", Tag.keyValue().c_str());
|
||||
// continue;
|
||||
// }
|
||||
// // key to unicode; check if key buffer is large enough
|
||||
// if ( Tag.keyValue().length() > sizeof(KeyBuf) - 1 ) {
|
||||
// DBG(" ERROR: Skipping too large key %s\n", Tag.keyValue().c_str());
|
||||
// continue;
|
||||
// }
|
||||
|
||||
if ( Tag.keyValue() == "Boot0082"_XS8 || Tag.keyValue() == "BootNext"_XS8 ) {
|
||||
VendorGuid = &gEfiGlobalVariableGuid;
|
||||
// it may happen only in this case
|
||||
GlobalConfig.HibernationFixup = TRUE;
|
||||
}
|
||||
if ( keyTag->keyStringValue() == "Boot0082"_XS8 || keyTag->keyStringValue() == "BootNext"_XS8 ) {
|
||||
VendorGuid = &gEfiGlobalVariableGuid;
|
||||
// it may happen only in this case
|
||||
GlobalConfig.HibernationFixup = TRUE;
|
||||
}
|
||||
|
||||
// AsciiStrToUnicodeStrS(Tag.stringValue(), KeyBuf, 128);
|
||||
XStringW KeyBuf = Tag.keyValue();
|
||||
// AsciiStrToUnicodeStrS(Tag.stringValue(), KeyBuf, 128);
|
||||
XStringW KeyBuf = keyTag->keyStringValue();
|
||||
if (!GlobalConfig.DebugLog) {
|
||||
DBG(" Adding Key: %ls: ", KeyBuf.wc_str());
|
||||
}
|
||||
// process value tag
|
||||
|
||||
if (valueTag->isString()) {
|
||||
|
||||
// <string> element
|
||||
Value = (void*)valueTag->stringValue().c_str();
|
||||
Size = valueTag->stringValue().length();
|
||||
if (!GlobalConfig.DebugLog) {
|
||||
DBG(" Adding Key: %ls: ", KeyBuf.wc_str());
|
||||
}
|
||||
// process value tag
|
||||
|
||||
if (ValTag->isString()) {
|
||||
|
||||
// <string> element
|
||||
Value = (void*)ValTag->stringValue().c_str();
|
||||
Size = ValTag->stringValue().length();
|
||||
if (!GlobalConfig.DebugLog) {
|
||||
DBG("String: Size = %lld, Val = '%s'\n", Size, ValTag->stringValue().c_str());
|
||||
}
|
||||
|
||||
} else if (ValTag->isData()) {
|
||||
|
||||
// <data> element
|
||||
Size = ValTag->dataLenValue();
|
||||
Value = ValTag->dataValue();
|
||||
if (!GlobalConfig.DebugLog) {
|
||||
DBG("Size = %lld, Data: ", Size);
|
||||
for (i = 0; i < Size; i++) {
|
||||
DBG("%02hhX ", *(((UINT8*)Value) + i));
|
||||
}
|
||||
}
|
||||
if (!GlobalConfig.DebugLog) {
|
||||
DBG("\n");
|
||||
}
|
||||
} else {
|
||||
DBG("ERROR: Unsupported tag type: %s\n", ValTag->getTypeAsXString8().c_str());
|
||||
continue;
|
||||
DBG("String: Size = %zu, Val = '%s'\n", Size, valueTag->stringValue().c_str());
|
||||
}
|
||||
|
||||
if (Size == 0 || !Value) {
|
||||
continue;
|
||||
}
|
||||
} else if (valueTag->isData()) {
|
||||
|
||||
// set RT var: all vars visible in nvram.plist are gEfiAppleBootGuid
|
||||
/* Status = gRT->SetVariable (
|
||||
KeyBuf,
|
||||
// <data> element
|
||||
Size = valueTag->dataLenValue();
|
||||
Value = valueTag->dataValue();
|
||||
if (!GlobalConfig.DebugLog) {
|
||||
DBG("Size = %zu, Data: ", Size);
|
||||
for (size_t i = 0; i < Size; i++) {
|
||||
DBG("%02hhX ", *(((UINT8*)Value) + i));
|
||||
}
|
||||
}
|
||||
if (!GlobalConfig.DebugLog) {
|
||||
DBG("\n");
|
||||
}
|
||||
} else {
|
||||
DBG("ERROR: Unsupported tag type: %s\n", valueTag->getTypeAsXString8().c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Size == 0 || !Value) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// set RT var: all vars visible in nvram.plist are gEfiAppleBootGuid
|
||||
/* Status = gRT->SetVariable (
|
||||
KeyBuf,
|
||||
VendorGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
Size,
|
||||
Value
|
||||
); */
|
||||
|
||||
SetNvramVariable (
|
||||
KeyBuf.wc_str(),
|
||||
VendorGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
Size,
|
||||
Value
|
||||
); */
|
||||
|
||||
SetNvramVariable (
|
||||
KeyBuf.wc_str(),
|
||||
VendorGuid,
|
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||
Size,
|
||||
Value
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -111,14 +111,14 @@ VOID FillCardList(const TagStruct* CfgDict)
|
||||
for (Index = 0; Index < Count; Index++) {
|
||||
CONST CHAR8 *key = VEN[Index];
|
||||
|
||||
prop = GetProperty(CfgDict, key);
|
||||
prop = CfgDict->dictPropertyForKey(key);
|
||||
if( prop && prop->isArray() ) {
|
||||
INTN i;
|
||||
INTN count;
|
||||
|
||||
const TagStruct* prop2 = 0;
|
||||
const TagStruct* element = 0;
|
||||
count = GetTagCount(prop);
|
||||
count = prop->arrayContent().size();
|
||||
for (i = 0; i < count; i++) {
|
||||
CONST CHAR8 *model_name = NULL;
|
||||
UINT32 dev_id = 0;
|
||||
@ -126,40 +126,39 @@ VOID FillCardList(const TagStruct* CfgDict)
|
||||
UINT64 VramSize = 0;
|
||||
UINTN VideoPorts = 0;
|
||||
BOOLEAN LoadVBios = FALSE;
|
||||
EFI_STATUS status = GetElement(prop, i, &element);
|
||||
|
||||
if (status == EFI_SUCCESS) {
|
||||
if (element) {
|
||||
prop2 = GetProperty(element, "Model");
|
||||
if ( prop2->isString() && prop2->stringValue().notEmpty() ) {
|
||||
model_name = prop2->stringValue().c_str();
|
||||
} else {
|
||||
model_name = "VideoCard";
|
||||
}
|
||||
|
||||
prop2 = GetProperty(element, "IOPCIPrimaryMatch");
|
||||
dev_id = (UINT32)GetPropertyInteger(prop2, 0);
|
||||
|
||||
prop2 = GetProperty(element, "IOPCISubDevId");
|
||||
subdev_id = (UINT32)GetPropertyInteger(prop2, 0);
|
||||
|
||||
prop2 = GetProperty(element, "VRAM");
|
||||
VramSize = LShiftU64((UINTN)GetPropertyInteger(prop2, (INTN)VramSize), 20); //Mb -> bytes
|
||||
|
||||
prop2 = GetProperty(element, "VideoPorts");
|
||||
VideoPorts = (UINT16)GetPropertyInteger(prop2, VideoPorts);
|
||||
|
||||
prop2 = GetProperty(element, "LoadVBios");
|
||||
if (prop2 != NULL && IsPropertyTrue(prop2)) {
|
||||
LoadVBios = TRUE;
|
||||
}
|
||||
|
||||
DBG("FillCardList :: %s : \"%s\" (%08X, %08X)\n", key, model_name, dev_id, subdev_id);
|
||||
|
||||
AddCard(model_name, dev_id, subdev_id, VramSize, VideoPorts, LoadVBios);
|
||||
}
|
||||
|
||||
element = &prop->arrayContent()[i];
|
||||
if ( !element->isDict()) {
|
||||
MsgLog("MALFORMED PLIST in FillCardList() : element is not a dict");
|
||||
continue;
|
||||
}
|
||||
|
||||
prop2 = element->dictPropertyForKey("Model");
|
||||
if ( prop2->isString() && prop2->stringValue().notEmpty() ) {
|
||||
model_name = prop2->stringValue().c_str();
|
||||
} else {
|
||||
model_name = "VideoCard";
|
||||
}
|
||||
|
||||
prop2 = element->dictPropertyForKey("IOPCIPrimaryMatch");
|
||||
dev_id = (UINT32)GetPropertyAsInteger(prop2, 0);
|
||||
|
||||
prop2 = element->dictPropertyForKey("IOPCISubDevId");
|
||||
subdev_id = (UINT32)GetPropertyAsInteger(prop2, 0);
|
||||
|
||||
prop2 = element->dictPropertyForKey("VRAM");
|
||||
VramSize = LShiftU64((UINTN)GetPropertyAsInteger(prop2, (INTN)VramSize), 20); //Mb -> bytes
|
||||
|
||||
prop2 = element->dictPropertyForKey("VideoPorts");
|
||||
VideoPorts = (UINT16)GetPropertyAsInteger(prop2, VideoPorts);
|
||||
|
||||
prop2 = element->dictPropertyForKey("LoadVBios");
|
||||
if (prop2 != NULL && IsPropertyNotNullAndTrue(prop2)) {
|
||||
LoadVBios = TRUE;
|
||||
}
|
||||
|
||||
DBG("FillCardList :: %s : \"%s\" (%08X, %08X)\n", key, model_name, dev_id, subdev_id);
|
||||
|
||||
AddCard(model_name, dev_id, subdev_id, VramSize, VideoPorts, LoadVBios);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ BOOLEAN checkOSBundleRequired(UINT8 loaderType, const TagStruct* dict)
|
||||
const TagStruct* osBundleRequiredTag;
|
||||
XString8 osbundlerequired;
|
||||
|
||||
osBundleRequiredTag = GetProperty(dict,"OSBundleRequired");
|
||||
osBundleRequiredTag = dict->dictPropertyForKey("OSBundleRequired");
|
||||
if (osBundleRequiredTag) {
|
||||
osbundlerequired = osBundleRequiredTag->stringValue();
|
||||
osbundlerequired.lowerAscii();
|
||||
@ -157,7 +157,7 @@ EFI_STATUS LOADER_ENTRY::LoadKext(IN EFI_FILE *RootDir, IN CONST CHAR16 *FileNam
|
||||
}
|
||||
NoContents = TRUE;
|
||||
}
|
||||
if(ParseXML((CHAR8*)infoDictBuffer,&dict,(UINT32)infoDictBufferLength)!=0) {
|
||||
if( ParseXML((CHAR8*)infoDictBuffer, &dict,(UINT32)infoDictBufferLength)!=0 ) {
|
||||
FreePool(infoDictBuffer);
|
||||
MsgLog("Failed to load extra kext (failed to parse Info.plist): %ls\n", FileName);
|
||||
return EFI_NOT_FOUND;
|
||||
@ -169,7 +169,7 @@ EFI_STATUS LOADER_ENTRY::LoadKext(IN EFI_FILE *RootDir, IN CONST CHAR16 *FileNam
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
prop = GetProperty(dict,"CFBundleExecutable");
|
||||
prop = dict->dictPropertyForKey("CFBundleExecutable");
|
||||
if( prop != NULL && prop->isString() && prop->stringValue().notEmpty() ) {
|
||||
Executable.takeValueFrom(prop->stringValue());
|
||||
// AsciiStrToUnicodeStrS(prop->stringValue(), Executable, 256);
|
||||
@ -213,6 +213,7 @@ EFI_STATUS LOADER_ENTRY::LoadKext(IN EFI_FILE *RootDir, IN CONST CHAR16 *FileNam
|
||||
FreePool(infoDictBuffer);
|
||||
FreePool(executableFatBuffer);
|
||||
FreePool(bundlePathBuffer);
|
||||
dict->FreeTag();
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include "../libeg/FloatLib.h"
|
||||
|
||||
#ifndef DEBUG_ALL
|
||||
#define DEBUG_PLIST 0
|
||||
#define DEBUG_PLIST 1
|
||||
#else
|
||||
#define DEBUG_PLIST DEBUG_ALL
|
||||
#endif
|
||||
@ -45,52 +45,6 @@
|
||||
#define DBG(...) DebugLog(DEBUG_PLIST, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
XObjArray<TagStruct> gTagsFree;
|
||||
|
||||
|
||||
|
||||
|
||||
void TagStruct::FreeTag()
|
||||
{
|
||||
// Clear and free the tag.
|
||||
type = kTagTypeNone;
|
||||
|
||||
_string.setEmpty();
|
||||
_intValue = 0;
|
||||
_floatValue = 0;
|
||||
|
||||
if ( _data ) {
|
||||
FreePool(_data);
|
||||
_data = NULL;
|
||||
}
|
||||
_dataLen = 0;
|
||||
|
||||
|
||||
if ( _tag ) {
|
||||
_tag->FreeTag();
|
||||
_tag = NULL;
|
||||
}
|
||||
// while ( tagIdx < _dictOrArrayContent.notEmpty() ) {
|
||||
// _dictOrArrayContent[0].FreeTag();
|
||||
// _dictOrArrayContent.RemoveWithoutFreeingAtIndex(0);
|
||||
// }
|
||||
// this loop is better because removing objects from the end don't do any memory copying.
|
||||
for (size_t tagIdx = _dictOrArrayContent.size() ; tagIdx > 0 ; ) {
|
||||
tagIdx--;
|
||||
_dictOrArrayContent[tagIdx].FreeTag();
|
||||
_dictOrArrayContent.RemoveWithoutFreeingAtIndex(tagIdx);
|
||||
}
|
||||
|
||||
// if ( _nextTag ) {
|
||||
// _nextTag->FreeTag();
|
||||
// _nextTag = NULL;
|
||||
// }
|
||||
|
||||
gTagsFree.AddReference(this, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -112,22 +66,31 @@ EFI_STATUS ParseTagBoolean(CHAR8* buffer, TagStruct* * tag, bool value, UINT32*
|
||||
|
||||
EFI_STATUS XMLParseNextTag (CHAR8 *buffer, TagStruct**tag, UINT32 *lenPtr);
|
||||
|
||||
TagStruct* NewTag( void );
|
||||
EFI_STATUS FixDataMatchingTag( CHAR8* buffer, CONST CHAR8* tag,UINT32* lenPtr);
|
||||
|
||||
/* Function for basic XML character entities parsing */
|
||||
typedef struct XMLEntity {
|
||||
const CHAR8* name;
|
||||
UINTN nameLen;
|
||||
class XMLEntity
|
||||
{
|
||||
public:
|
||||
const XString8 name;
|
||||
size_t nameLen;
|
||||
CHAR8 value;
|
||||
} XMLEntity;
|
||||
|
||||
/* This is ugly, but better than specifying the lengths by hand */
|
||||
#define _e(str,c) {str,sizeof(str)-1,c}
|
||||
CONST XMLEntity ents[] = {
|
||||
_e("quot;",'"'), _e("apos;",'\''),
|
||||
_e("lt;", '<'), _e("gt;", '>'),
|
||||
_e("amp;", '&')
|
||||
XMLEntity() : name(), nameLen(0), value(0) { }
|
||||
XMLEntity(const XString8& _name, CHAR8 _value) : name(_name), nameLen(name.length()), value(_value) { }
|
||||
|
||||
// Not sure if default are valid. Delete them. If needed, proper ones can be created
|
||||
XMLEntity(const XMLEntity&) = delete;
|
||||
XMLEntity& operator=(const XMLEntity&) = delete;
|
||||
|
||||
};
|
||||
|
||||
const XMLEntity ents[] = {
|
||||
{ "quot;"_XS8, '"' },
|
||||
{"apos;"_XS8,'\''},
|
||||
{"lt;"_XS8, '<'},
|
||||
{"gt;"_XS8, '>'},
|
||||
{"amp;"_XS8, '&'}
|
||||
};
|
||||
|
||||
/* Replace XML entities by their value */
|
||||
@ -163,7 +126,7 @@ XMLDecode(CHAR8* src)
|
||||
UINTN i;
|
||||
s++;
|
||||
for (i = 0; i < sizeof(ents)/sizeof(ents[0]); i++) {
|
||||
if ( strncmp(s, ents[i].name, ents[i].nameLen) == 0 ) {
|
||||
if ( ents[i].name.strncmp(s, ents[i].nameLen) == 0 ) {
|
||||
entFound = TRUE;
|
||||
break;
|
||||
}
|
||||
@ -181,55 +144,154 @@ XMLDecode(CHAR8* src)
|
||||
return out;
|
||||
}
|
||||
|
||||
INTN GetTagCount(const TagStruct* dict )
|
||||
{
|
||||
INTN count = 0;
|
||||
|
||||
if ( !dict ) return 0;
|
||||
|
||||
if ( dict->isArray() ) {
|
||||
return dict->dictOrArrayContent().size(); // If we are an array, any element is valid
|
||||
}else
|
||||
if ( dict->isDict() ) {
|
||||
const XObjArray<TagStruct>& tagList = dict->dictOrArrayContent();
|
||||
for (size_t tagIdx = 0 ; tagIdx < tagList.size() ; tagIdx++ ) {
|
||||
if ( tagList[tagIdx].isKey() ) count++;
|
||||
}
|
||||
return count;
|
||||
}else{
|
||||
return 0;
|
||||
/**************************************** TagStruct ****************************************/
|
||||
|
||||
XObjArray<TagStruct> gTagsFree;
|
||||
|
||||
//UINTN newtagcount = 0;
|
||||
//UINTN tagcachehit = 0;
|
||||
TagStruct* TagStruct::getEmptyTag()
|
||||
{
|
||||
TagStruct* tag;
|
||||
|
||||
if ( gTagsFree.size() > 0 ) {
|
||||
tag = &gTagsFree[0];
|
||||
gTagsFree.RemoveWithoutFreeingAtIndex(0);
|
||||
//tagcachehit++;
|
||||
//DBG("tagcachehit=%lld\n", tagcachehit);
|
||||
return tag;
|
||||
}
|
||||
tag = new TagStruct();
|
||||
//newtagcount += 1;
|
||||
//DBG("newtagcount=%lld\n", newtagcount);
|
||||
return tag;
|
||||
}
|
||||
|
||||
EFI_STATUS GetElement(const TagStruct* dict, INTN id, const TagStruct** dict1)
|
||||
TagStruct* TagStruct::getEmptyDictTag()
|
||||
{
|
||||
TagStruct* newDictTag = getEmptyTag();
|
||||
newDictTag->type = kTagTypeDict;
|
||||
return newDictTag;
|
||||
}
|
||||
|
||||
TagStruct* TagStruct::getEmptyArrayTag()
|
||||
{
|
||||
TagStruct* newArrayTag = getEmptyTag();
|
||||
newArrayTag->type = kTagTypeArray;
|
||||
return newArrayTag;
|
||||
}
|
||||
|
||||
void TagStruct::FreeTag()
|
||||
{
|
||||
// Clear and free the tag.
|
||||
type = kTagTypeNone;
|
||||
|
||||
_string.setEmpty();
|
||||
_intValue = 0;
|
||||
_floatValue = 0;
|
||||
|
||||
if ( _data ) {
|
||||
FreePool(_data);
|
||||
_data = NULL;
|
||||
}
|
||||
_dataLen = 0;
|
||||
|
||||
//while ( tagIdx < _dictOrArrayContent.notEmpty() ) {
|
||||
// _dictOrArrayContent[0].FreeTag();
|
||||
// _dictOrArrayContent.RemoveWithoutFreeingAtIndex(0);
|
||||
//}
|
||||
// this loop is better because removing objects from the end don't do any memory copying.
|
||||
for (size_t tagIdx = _dictOrArrayContent.size() ; tagIdx > 0 ; ) {
|
||||
tagIdx--;
|
||||
_dictOrArrayContent[tagIdx].FreeTag();
|
||||
_dictOrArrayContent.RemoveWithoutFreeingAtIndex(tagIdx);
|
||||
}
|
||||
|
||||
gTagsFree.AddReference(this, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
INTN TagStruct::dictKeyCount() const
|
||||
{
|
||||
if ( !isDict() ) panic("TagStruct::dictKeyCount() : !isDict() ");
|
||||
INTN count = 0;
|
||||
for (size_t tagIdx = 0 ; tagIdx + 1 < _dictOrArrayContent.size() ; tagIdx++ ) { // tagIdx + 1 because a key as a last element cannot have value and is ignored. Can't do size()-1, because it's unsigned.
|
||||
if ( _dictOrArrayContent[tagIdx].isKey() && !_dictOrArrayContent[tagIdx+1].isKey() ) { // if this key is followed by another key, it'll be ignored
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
EFI_STATUS TagStruct::dictKeyAndValueAtIndex(INTN id, const TagStruct** key, const TagStruct** value) const
|
||||
{
|
||||
INTN element = 0;
|
||||
*key = NULL;
|
||||
*value = NULL;
|
||||
|
||||
if ( !dict ) return EFI_UNSUPPORTED;
|
||||
if ( id < 0 ) return EFI_UNSUPPORTED;
|
||||
|
||||
if ( dict->isArray() ) {
|
||||
if ( (size_t)id < dict->dictOrArrayContent().size() ) {
|
||||
*dict1 = &dict->dictOrArrayContent()[id];
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}else
|
||||
if ( dict->isDict() ) {
|
||||
const XObjArray<TagStruct>& tagList = dict->dictOrArrayContent();
|
||||
size_t tagIdx;
|
||||
for (tagIdx = 0 ; tagIdx < tagList.size() ; tagIdx++ ) {
|
||||
if ( tagList[tagIdx].isKey() ) {
|
||||
if ( element == id ) {
|
||||
*dict1 = &tagList[tagIdx];
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
element++;
|
||||
const XObjArray<TagStruct>& tagList = _dictOrArrayContent;
|
||||
size_t tagIdx;
|
||||
for (tagIdx = 0 ; tagIdx + 1 < tagList.size() ; tagIdx++ ) { // tagIdx + 1 because a key as a last element cannot have value and is ignored. Can't do size()-1, because it's unsigned.
|
||||
if ( tagList[tagIdx].isKey() && !tagList[tagIdx+1].isKey() ) {
|
||||
if ( element == id ) {
|
||||
*key = &tagList[tagIdx];
|
||||
*value = &tagList[tagIdx+1];
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
element++;
|
||||
}
|
||||
}
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
const TagStruct* TagStruct::dictPropertyForKey(const CHAR8* key) const
|
||||
{
|
||||
const XObjArray<TagStruct>& tagList = _dictOrArrayContent;
|
||||
for (size_t tagIdx = 0 ; tagIdx < tagList.size() ; tagIdx++ )
|
||||
{
|
||||
if ( tagList[tagIdx].isKey() && tagList[tagIdx].keyStringValue().equalIC(key) ) {
|
||||
if ( tagIdx+1 >= tagList.size() ) return NULL;
|
||||
if ( tagList[tagIdx+1].isKey() ) return NULL;
|
||||
return &tagList[tagIdx+1];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//TagStruct* GetNextProperty(TagStruct* dict)
|
||||
//{
|
||||
// TagStruct* tagList, tag;
|
||||
//
|
||||
// if (dict->isDict()) {
|
||||
// return NULL;
|
||||
// }
|
||||
//
|
||||
// tag = NULL;
|
||||
// tagList = dict->tag;
|
||||
// while (tagList)
|
||||
// {
|
||||
// tag = tagList;
|
||||
// tagList = tag->tagNext;
|
||||
//
|
||||
// if ( !tag->isKey() || tag->keyValue().isEmpty() ) {
|
||||
// continue;
|
||||
//
|
||||
// }
|
||||
// return tag->tag;
|
||||
// }
|
||||
//
|
||||
// return NULL;
|
||||
//}
|
||||
|
||||
|
||||
|
||||
/**************************************** XML ****************************************/
|
||||
|
||||
// Expects to see one dictionary in the XML file, the final pos will be returned
|
||||
// If the pos is not equal to the strlen, then there are multiple dicts
|
||||
// Puts the first dictionary it finds in the
|
||||
@ -286,7 +348,8 @@ EFI_STATUS ParseXML(const CHAR8* buffer, TagStruct** dict, UINT32 bufSize)
|
||||
break;
|
||||
}
|
||||
|
||||
FreeTag(tag); tag = NULL;
|
||||
tag->FreeTag();
|
||||
tag = NULL;
|
||||
}
|
||||
|
||||
// FreePool(configBuffer);
|
||||
@ -305,48 +368,6 @@ EFI_STATUS ParseXML(const CHAR8* buffer, TagStruct** dict, UINT32 bufSize)
|
||||
|
||||
#define DOFREE 1
|
||||
|
||||
//==========================================================================
|
||||
// GetProperty
|
||||
|
||||
const TagStruct* GetProperty(const TagStruct* dict, const CHAR8* key )
|
||||
{
|
||||
if ( !dict->isDict() ) return NULL;
|
||||
|
||||
const XObjArray<TagStruct>& tagList = dict->dictOrArrayContent();
|
||||
for (size_t tagIdx = 0 ; tagIdx < tagList.size() ; tagIdx++ )
|
||||
{
|
||||
if ( tagList[tagIdx].isKey() && tagList[tagIdx].keyValue().equalIC(key) ) return tagList[tagIdx].keyTagValue();
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//TagStruct* GetNextProperty(TagStruct* dict)
|
||||
//{
|
||||
// TagStruct* tagList, tag;
|
||||
//
|
||||
// if (dict->isDict()) {
|
||||
// return NULL;
|
||||
// }
|
||||
//
|
||||
// tag = NULL;
|
||||
// tagList = dict->tag;
|
||||
// while (tagList)
|
||||
// {
|
||||
// tag = tagList;
|
||||
// tagList = tag->tagNext;
|
||||
//
|
||||
// if ( !tag->isKey() || tag->keyValue().isEmpty() ) {
|
||||
// continue;
|
||||
//
|
||||
// }
|
||||
// return tag->tag;
|
||||
// }
|
||||
//
|
||||
// return NULL;
|
||||
//}
|
||||
|
||||
|
||||
|
||||
//==========================================================================
|
||||
// ParseNextTag
|
||||
@ -502,13 +523,16 @@ EFI_STATUS __ParseTagList(bool isArray, CHAR8* buffer, TagStruct** tag, UINT32 e
|
||||
tagTail = NULL;
|
||||
pos = 0;
|
||||
|
||||
TagStruct* dictOrArrayTag = NewTag();
|
||||
TagStruct* dictOrArrayTag;
|
||||
XObjArray<TagStruct>* tagListPtr;
|
||||
if (isArray) {
|
||||
dictOrArrayTag->setArrayTagValue(NULL);
|
||||
dictOrArrayTag = TagStruct::getEmptyArrayTag();
|
||||
tagListPtr = &dictOrArrayTag->arrayContent();
|
||||
} else {
|
||||
dictOrArrayTag->setDictTagValue(NULL);
|
||||
dictOrArrayTag = TagStruct::getEmptyDictTag();
|
||||
tagListPtr = &dictOrArrayTag->dictContent();
|
||||
}
|
||||
XObjArray<TagStruct>& tagList = dictOrArrayTag->dictOrArrayContent();
|
||||
XObjArray<TagStruct>& tagList = *tagListPtr;
|
||||
|
||||
if (!empty) {
|
||||
while (TRUE) {
|
||||
@ -529,7 +553,7 @@ EFI_STATUS __ParseTagList(bool isArray, CHAR8* buffer, TagStruct** tag, UINT32 e
|
||||
}
|
||||
|
||||
if (EFI_ERROR(Status)) {
|
||||
FreeTag(dictOrArrayTag);
|
||||
dictOrArrayTag->FreeTag();
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
@ -559,7 +583,7 @@ EFI_STATUS ParseTagKey( char * buffer, TagStruct** tag, UINT32* lenPtr)
|
||||
UINT32 length = 0;
|
||||
UINT32 length2 = 0;
|
||||
TagStruct* tmpTag;
|
||||
TagStruct* subTag = NULL;
|
||||
// TagStruct* subTag = NULL;
|
||||
|
||||
Status = FixDataMatchingTag(buffer, kXMLTagKey, &length);
|
||||
DBG("fixing key len=%d status=%s\n", length, strerror(Status));
|
||||
@ -567,16 +591,16 @@ EFI_STATUS ParseTagKey( char * buffer, TagStruct** tag, UINT32* lenPtr)
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = XMLParseNextTag(buffer + length, &subTag, &length2);
|
||||
if (EFI_ERROR(Status)) {
|
||||
return Status;
|
||||
}
|
||||
tmpTag = NewTag();
|
||||
tmpTag->setKeyValue(LString8(buffer), subTag);
|
||||
// Status = XMLParseNextTag(buffer + length, &subTag, &length2);
|
||||
// if (EFI_ERROR(Status)) {
|
||||
// return Status;
|
||||
// }
|
||||
tmpTag = TagStruct::getEmptyTag();
|
||||
tmpTag->setKeyValue(LString8(buffer));
|
||||
|
||||
*tag = tmpTag;
|
||||
*lenPtr = length + length2;
|
||||
DBG("parse key '%s' success len=%d\n", tmpString, *lenPtr);
|
||||
DBG("parse key '%s' success len=%d\n", tmpTag->keyStringValue().c_str(), *lenPtr);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -594,7 +618,7 @@ EFI_STATUS ParseTagString(CHAR8* buffer, TagStruct* * tag,UINT32* lenPtr)
|
||||
return Status;
|
||||
}
|
||||
|
||||
tmpTag = NewTag();
|
||||
tmpTag = TagStruct::getEmptyTag();
|
||||
if (tmpTag == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -602,7 +626,7 @@ EFI_STATUS ParseTagString(CHAR8* buffer, TagStruct* * tag,UINT32* lenPtr)
|
||||
tmpTag->setStringValue(LString8(XMLDecode(buffer)));
|
||||
*tag = tmpTag;
|
||||
*lenPtr = length;
|
||||
DBG(" parse string %s\n", tmpString);
|
||||
DBG(" parse string %s\n", tmpTag->stringValue().c_str());
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -624,7 +648,7 @@ EFI_STATUS ParseTagInteger(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr)
|
||||
return Status;
|
||||
}
|
||||
|
||||
tmpTag = NewTag();
|
||||
tmpTag = TagStruct::getEmptyTag();
|
||||
tmpTag->setIntValue(0);
|
||||
|
||||
size = length;
|
||||
@ -651,7 +675,7 @@ EFI_STATUS ParseTagInteger(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr)
|
||||
else {
|
||||
MsgLog("ParseTagInteger hex error (0x%hhX) in buffer %s\n", *val, buffer);
|
||||
// getchar();
|
||||
FreeTag(tmpTag);
|
||||
tmpTag->FreeTag();
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
@ -668,7 +692,7 @@ EFI_STATUS ParseTagInteger(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr)
|
||||
if (*val < '0' || *val > '9') {
|
||||
MsgLog("ParseTagInteger decimal error (0x%hhX) in buffer %s\n", *val, buffer);
|
||||
// getchar();
|
||||
FreeTag(tmpTag);
|
||||
tmpTag->FreeTag();
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
integer = (integer * 10) + (*val++ - '0');
|
||||
@ -702,7 +726,7 @@ EFI_STATUS ParseTagFloat(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr)
|
||||
return Status;
|
||||
}
|
||||
|
||||
tmpTag = NewTag();
|
||||
tmpTag = TagStruct::getEmptyTag();
|
||||
if (tmpTag == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -731,7 +755,7 @@ EFI_STATUS ParseTagData(CHAR8* buffer, TagStruct* * tag, UINT32* lenPtr)
|
||||
return Status;
|
||||
}
|
||||
|
||||
tmpTag = NewTag();
|
||||
tmpTag = TagStruct::getEmptyTag();
|
||||
if (tmpTag == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -763,7 +787,7 @@ EFI_STATUS ParseTagDate(CHAR8* buffer, TagStruct* * tag,UINT32* lenPtr)
|
||||
}
|
||||
|
||||
|
||||
tmpTag = NewTag();
|
||||
tmpTag = TagStruct::getEmptyTag();
|
||||
if (tmpTag == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -783,7 +807,7 @@ EFI_STATUS ParseTagBoolean(CHAR8* buffer, TagStruct* * tag, bool value, UINT32*
|
||||
{
|
||||
TagStruct* tmpTag;
|
||||
|
||||
tmpTag = NewTag();
|
||||
tmpTag = TagStruct::getEmptyTag();
|
||||
if (tmpTag == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
@ -883,34 +907,6 @@ EFI_STATUS FixDataMatchingTag( CHAR8* buffer, CONST CHAR8* tag, UINT32* lenPtr)
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
// NewTag
|
||||
|
||||
TagStruct* NewTag( void )
|
||||
{
|
||||
TagStruct* tag;
|
||||
|
||||
if ( gTagsFree.size() > 0 ) {
|
||||
tag = &gTagsFree[0];
|
||||
gTagsFree.RemoveWithoutFreeingAtIndex(0);
|
||||
return tag;
|
||||
}
|
||||
tag = new TagStruct();
|
||||
return tag;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
// XMLFreeTag
|
||||
|
||||
void FreeTag( TagStruct* tag )
|
||||
{
|
||||
if (tag == NULL) {
|
||||
return;
|
||||
}
|
||||
tag->FreeTag();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@ -918,7 +914,7 @@ void FreeTag( TagStruct* tag )
|
||||
else return FALSE
|
||||
*/
|
||||
BOOLEAN
|
||||
IsPropertyTrue(const TagStruct* Prop)
|
||||
IsPropertyNotNullAndTrue(const TagStruct* Prop)
|
||||
{
|
||||
return Prop != NULL && Prop->isTrueOrYy();
|
||||
}
|
||||
@ -928,7 +924,7 @@ IsPropertyTrue(const TagStruct* Prop)
|
||||
else return FALSE
|
||||
*/
|
||||
BOOLEAN
|
||||
IsPropertyFalse(const TagStruct* Prop)
|
||||
IsPropertyNotNullAndFalse(const TagStruct* Prop)
|
||||
{
|
||||
return Prop != NULL && Prop->isFalseOrNn();
|
||||
}
|
||||
@ -941,7 +937,7 @@ IsPropertyFalse(const TagStruct* Prop)
|
||||
<string>0x12abd</string>
|
||||
*/
|
||||
INTN
|
||||
GetPropertyInteger(
|
||||
GetPropertyAsInteger(
|
||||
const TagStruct* Prop,
|
||||
INTN Default
|
||||
)
|
||||
|
@ -42,7 +42,6 @@ typedef enum {
|
||||
class TagStruct;
|
||||
extern XObjArray<TagStruct> gTagsFree;
|
||||
|
||||
|
||||
class TagStruct
|
||||
{
|
||||
UINTN type; // type is private. Use is...() functions.
|
||||
@ -51,16 +50,18 @@ class TagStruct
|
||||
float _floatValue;
|
||||
UINT8 *_data;
|
||||
UINTN _dataLen;
|
||||
TagStruct *_tag;
|
||||
XObjArray<TagStruct> _dictOrArrayContent;
|
||||
|
||||
public:
|
||||
|
||||
TagStruct() : type(kTagTypeNone), _string(), _intValue(0), _floatValue(0), _data(0), _dataLen(0), /*offset(0), */_tag(NULL), _dictOrArrayContent() {}
|
||||
TagStruct() : type(kTagTypeNone), _string(), _intValue(0), _floatValue(0), _data(0), _dataLen(0), _dictOrArrayContent() {}
|
||||
TagStruct(const TagStruct& other) = delete; // Can be defined if needed
|
||||
const TagStruct& operator = ( const TagStruct & ) = delete; // Can be defined if needed
|
||||
~TagStruct() { delete _data; delete _tag; }
|
||||
~TagStruct() { delete _data; }
|
||||
|
||||
static TagStruct* getEmptyTag();
|
||||
static TagStruct* getEmptyDictTag();
|
||||
static TagStruct* getEmptyArrayTag();
|
||||
void FreeTag();
|
||||
|
||||
// Property<XString8> string();
|
||||
@ -74,25 +75,6 @@ public:
|
||||
bool isDate() const { return type == kTagTypeDate; }
|
||||
bool isArray() const { return type == kTagTypeArray; }
|
||||
|
||||
const XObjArray<TagStruct>& dictOrArrayContent() const
|
||||
{
|
||||
if ( isDict() ) return _dictOrArrayContent;
|
||||
if ( isArray() ) return _dictOrArrayContent;
|
||||
panic("TagStruct::dictOrArrayTagValue() : !isDict() && isArray() ");
|
||||
}
|
||||
XObjArray<TagStruct>& dictOrArrayContent()
|
||||
{
|
||||
if ( isDict() ) return _dictOrArrayContent;
|
||||
if ( isArray() ) return _dictOrArrayContent;
|
||||
panic("TagStruct::dictOrArrayTagValue() : !isDict() && isArray() ");
|
||||
}
|
||||
// void setNextTagValue(TagStruct* nextTag)
|
||||
// {
|
||||
// if ( nextTag == NULL ) panic("TagStruct::setDictNextTagValue() : nextTag == NULL ");
|
||||
// if ( _nextTag != NULL ) panic("TagStruct::setDictNextTagValue() : _nextTag != NULL ");
|
||||
// _nextTag = nextTag;
|
||||
// }
|
||||
|
||||
const XString8 getTypeAsXString8() const {
|
||||
if ( isDict() ) return "Dict"_XS8;
|
||||
if ( isKey() ) return "Dict"_XS8;
|
||||
@ -106,7 +88,11 @@ public:
|
||||
panic("Unknown type %lld : this is bug", type);
|
||||
}
|
||||
|
||||
// getter and setter
|
||||
/*
|
||||
* getters and setters
|
||||
*/
|
||||
|
||||
/* data */
|
||||
const UINT8* dataValue() const
|
||||
{
|
||||
if ( !isData() ) panic("TagStruct::dataValue() : !isData() ");
|
||||
@ -117,11 +103,11 @@ public:
|
||||
if ( !isData() ) panic("TagStruct::dataValue() : !isData() ");
|
||||
return _data;
|
||||
}
|
||||
const XString8& dataStringValue()
|
||||
{
|
||||
if ( !isData() ) panic("TagStruct::dataStringValue() : !isData() ");
|
||||
return _string;
|
||||
}
|
||||
// const XString8& dataStringValue()
|
||||
// {
|
||||
// if ( !isData() ) panic("TagStruct::dataStringValue() : !isData() ");
|
||||
// return _string;
|
||||
// }
|
||||
UINTN dataLenValue() const
|
||||
{
|
||||
if ( !isData() ) panic("TagStruct::dataLenValue() : !isData() ");
|
||||
@ -135,6 +121,7 @@ public:
|
||||
type = kTagTypeData;
|
||||
}
|
||||
|
||||
/* date */
|
||||
const XString8& dateValue()
|
||||
{
|
||||
if ( !isDict() ) panic("TagStruct::dictValue() : !isDict() ");
|
||||
@ -147,60 +134,52 @@ public:
|
||||
_string = xstring;
|
||||
}
|
||||
|
||||
TagStruct* dictTagValue()
|
||||
/* dict */
|
||||
const XObjArray<TagStruct>& dictContent() const
|
||||
{
|
||||
if ( !isDict() ) panic("TagStruct::dictValue() : !isDict() ");
|
||||
return _tag;
|
||||
if ( !isDict() ) panic("TagStruct::dictContent() : !isDict() ");
|
||||
return _dictOrArrayContent;
|
||||
}
|
||||
void setDictTagValue(TagStruct* tagList)
|
||||
XObjArray<TagStruct>& dictContent()
|
||||
{
|
||||
// empty dict is allowed
|
||||
//if ( tagList == NULL ) panic("TagStruct::setDictTagValue() : tagList == NULL ");
|
||||
if ( _tag != NULL ) panic("TagStruct::setDictTagValue() : _tag != NULL ");
|
||||
if ( _dictOrArrayContent.notEmpty() ) panic("TagStruct::setDictTagValue() : __dictOrArrayContent.notEmpty() ");
|
||||
_tag = tagList;
|
||||
type = kTagTypeDict;
|
||||
if ( !isDict() ) panic("TagStruct::dictContent() : !isDict() ");
|
||||
return _dictOrArrayContent;
|
||||
}
|
||||
INTN dictKeyCount() const;
|
||||
EFI_STATUS dictKeyAndValueAtIndex(INTN id, const TagStruct** key, const TagStruct** value) const;
|
||||
const TagStruct* dictPropertyForKey(const CHAR8* key ) const;
|
||||
|
||||
/* array */
|
||||
const XObjArray<TagStruct>& arrayContent() const
|
||||
{
|
||||
if ( isArray() ) return _dictOrArrayContent;
|
||||
panic("TagStruct::arrayContent() const : !isArray() ");
|
||||
}
|
||||
XObjArray<TagStruct>& arrayContent()
|
||||
{
|
||||
if ( isArray() ) return _dictOrArrayContent;
|
||||
panic("TagStruct::arrayContent() : !isDict() && !isArray() ");
|
||||
}
|
||||
|
||||
TagStruct* arrayTagValue()
|
||||
/* key */
|
||||
const XString8& keyStringValue() const
|
||||
{
|
||||
if ( !isArray() ) panic("TagStruct::arrayValue() : !isArray() ");
|
||||
return _tag;
|
||||
}
|
||||
void setArrayTagValue(TagStruct* tag)
|
||||
{
|
||||
// Array value with tagList = NULL is allowed
|
||||
//if ( tag == NULL ) panic("TagStruct::setArrayValue() : tag == NULL ");
|
||||
if ( _tag != NULL ) panic("TagStruct::setArrayValue() : _tag != NULL ");
|
||||
if ( _dictOrArrayContent.notEmpty() ) panic("TagStruct::setArrayTagValue() : __dictOrArrayContent.notEmpty() ");
|
||||
_tag = tag;
|
||||
type = kTagTypeArray;
|
||||
}
|
||||
|
||||
|
||||
const XString8& keyValue() const
|
||||
{
|
||||
if ( !isKey() ) panic("TagStruct::keyValue() : !isKey() ");
|
||||
if ( !isKey() ) panic("TagStruct::keyStringValue() const : !isKey() ");
|
||||
return _string;
|
||||
}
|
||||
XString8& keyValue()
|
||||
XString8& keyStringValue()
|
||||
{
|
||||
if ( !isKey() ) panic("TagStruct::keyValue() : !isKey() ");
|
||||
if ( !isKey() ) panic("TagStruct::keyStringValue() : !isKey() ");
|
||||
return _string;
|
||||
}
|
||||
const TagStruct* keyTagValue() const
|
||||
{
|
||||
if ( !isKey() ) panic("TagStruct::keyTagValue() : !isKey() ");
|
||||
return _tag;
|
||||
}
|
||||
void setKeyValue(const XString8& xstring, TagStruct* subTag)
|
||||
void setKeyValue(const XString8& xstring)
|
||||
{
|
||||
if ( xstring.isEmpty() ) panic("TagStruct::setKeyValue() : xstring.isEmpty() ");
|
||||
type = kTagTypeKey;
|
||||
_string = xstring;
|
||||
_tag = subTag;
|
||||
}
|
||||
|
||||
/* string */
|
||||
const XString8& stringValue() const
|
||||
{
|
||||
if ( !isString() ) panic("TagStruct::stringValue() : !isString() ");
|
||||
@ -219,6 +198,7 @@ public:
|
||||
_string = xstring;
|
||||
}
|
||||
|
||||
/* int */
|
||||
INTN intValue() const
|
||||
{
|
||||
if ( !isInt() ) panic("TagStruct::intValue() : !isInt() ");
|
||||
@ -230,6 +210,7 @@ public:
|
||||
_intValue = i;
|
||||
}
|
||||
|
||||
/* float */
|
||||
float floatValue() const
|
||||
{
|
||||
if ( !isFloat() ) panic("TagStruct::floatValue() : !isFloat() ");
|
||||
@ -241,6 +222,7 @@ public:
|
||||
_floatValue = f;
|
||||
}
|
||||
|
||||
/* bool */
|
||||
INTN boolValue() const
|
||||
{
|
||||
if ( !isBool() ) panic("TagStruct::boolValue() : !isBool() ");
|
||||
@ -281,22 +263,8 @@ public:
|
||||
if ( isString() && stringValue().notEmpty() && (stringValue()[0] == 'n' || stringValue()[0] == 'N') ) return true;
|
||||
return false;
|
||||
}
|
||||
TagStruct* dictOrArrayTagValue()
|
||||
{
|
||||
if ( isDict() ) return dictTagValue();
|
||||
if ( isArray() ) return arrayTagValue();
|
||||
panic("TagStruct::dictOrArrayTagValue() : !isDict() && isArray() ");
|
||||
}
|
||||
};
|
||||
|
||||
//typedef union {
|
||||
// struct {
|
||||
// float fNum; //4 bytes
|
||||
// UINT32 pad; // else 4
|
||||
// } B;
|
||||
// CHAR8 *string;
|
||||
//} FlMix;
|
||||
|
||||
|
||||
CHAR8*
|
||||
XMLDecode (
|
||||
@ -311,21 +279,6 @@ ParseXML(
|
||||
);
|
||||
|
||||
|
||||
//VOID RenderSVGfont(NSVGfont *fontSVG);
|
||||
|
||||
const TagStruct*
|
||||
GetProperty(
|
||||
const TagStruct* dict,
|
||||
CONST CHAR8* key
|
||||
);
|
||||
|
||||
TagStruct* NewTag( void );
|
||||
|
||||
VOID
|
||||
FreeTag (
|
||||
TagStruct* tag
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
GetNextTag (
|
||||
UINT8 *buffer,
|
||||
@ -334,30 +287,18 @@ GetNextTag (
|
||||
UINT32 *length
|
||||
);
|
||||
|
||||
INTN
|
||||
GetTagCount (
|
||||
const TagStruct* dict
|
||||
);
|
||||
|
||||
EFI_STATUS
|
||||
GetElement(
|
||||
const TagStruct* dict,
|
||||
INTN id,
|
||||
const TagStruct** dict1
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
IsPropertyTrue(
|
||||
IsPropertyNotNullAndTrue(
|
||||
const TagStruct* Prop
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
IsPropertyFalse(
|
||||
IsPropertyNotNullAndFalse(
|
||||
const TagStruct* Prop
|
||||
);
|
||||
|
||||
INTN
|
||||
GetPropertyInteger(
|
||||
GetPropertyAsInteger(
|
||||
const TagStruct* Prop,
|
||||
INTN Default
|
||||
);
|
||||
|
@ -24,10 +24,9 @@ template<class TYPE>
|
||||
class XArray
|
||||
{
|
||||
protected:
|
||||
TYPE *m_data;
|
||||
TYPE* m_data;
|
||||
size_t m_len;
|
||||
size_t m_allocatedSize;
|
||||
// size_t _GrowBy;
|
||||
|
||||
public:
|
||||
// void Init();
|
||||
|
@ -123,7 +123,26 @@ class XObjArray : public XObjArrayNC<TYPE>
|
||||
{
|
||||
public:
|
||||
XObjArray() : XObjArrayNC<TYPE>() {}
|
||||
|
||||
XObjArray(bool FreeThem, TYPE* n1, ...);
|
||||
|
||||
XObjArray(const TYPE &n1, bool FreeIt = true);
|
||||
XObjArray(const TYPE &n1, const TYPE &n2, bool FreeThem = true);
|
||||
XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, bool FreeThem = true);
|
||||
XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, bool FreeThem = true);
|
||||
XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, bool FreeThem = true);
|
||||
XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, bool FreeThem = true);
|
||||
XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, bool FreeThem = true);
|
||||
XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, bool FreeThem = true);
|
||||
XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, bool FreeThem = true);
|
||||
XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, bool FreeThem = true);
|
||||
XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, bool FreeThem = true);
|
||||
XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, const TYPE &n12, bool FreeThem = true);
|
||||
XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, const TYPE &n12, const TYPE &n13, bool FreeThem = true);
|
||||
XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, const TYPE &n12, const TYPE &n13, const TYPE &n14, bool FreeThem = true);
|
||||
|
||||
XObjArray(const XObjArray<TYPE> &anObjArray);
|
||||
|
||||
const XObjArray<TYPE> &operator =(const XObjArray<TYPE> &anObjArray);
|
||||
|
||||
size_t AddCopy(const TYPE &newElement, bool FreeIt = true);
|
||||
@ -169,6 +188,225 @@ void XObjArrayNC<TYPE>::Init()
|
||||
// }
|
||||
// #endif
|
||||
}
|
||||
/* Constructeur */
|
||||
template<class TYPE>
|
||||
XObjArray<TYPE>::XObjArray(bool FreeThem, TYPE* n1, ...)
|
||||
{
|
||||
va_list va;
|
||||
|
||||
va_start (va, n1);
|
||||
size_t count = 0;
|
||||
TYPE* t = VA_ARG(va, TYPE*);
|
||||
while ( t != nullptr ) {
|
||||
count++;
|
||||
t = VA_ARG(va, TYPE*);
|
||||
}
|
||||
va_end(va);
|
||||
|
||||
XObjArrayNC<TYPE>::Init();
|
||||
this->CheckSize(count+1, (size_t)0);
|
||||
XObjArrayNC<TYPE>::AddReference(n1, FreeThem);
|
||||
|
||||
va_start (va, n1);
|
||||
t = VA_ARG(va, TYPE*);
|
||||
while ( t != nullptr ) {
|
||||
XObjArrayNC<TYPE>::AddReference(t, FreeThem);
|
||||
t = VA_ARG(va, TYPE*);
|
||||
}
|
||||
va_end(va);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class TYPE>
|
||||
XObjArray<TYPE>::XObjArray(const TYPE &n1, bool FreeIt)
|
||||
{
|
||||
XObjArrayNC<TYPE>::Init();
|
||||
this->CheckSize(1, (size_t)0);
|
||||
AddCopy(n1, FreeIt);
|
||||
}
|
||||
template<class TYPE>
|
||||
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, bool FreeThem)
|
||||
{
|
||||
XObjArrayNC<TYPE>::Init();
|
||||
this->CheckSize(2, (size_t)0);
|
||||
AddCopy(n1, FreeThem);
|
||||
AddCopy(n2, FreeThem);
|
||||
}
|
||||
template<class TYPE>
|
||||
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, bool FreeThem)
|
||||
{
|
||||
XObjArrayNC<TYPE>::Init();
|
||||
this->CheckSize(3, (size_t)0);
|
||||
AddCopy(n1, FreeThem);
|
||||
AddCopy(n2, FreeThem);
|
||||
AddCopy(n3, FreeThem);
|
||||
}
|
||||
template<class TYPE>
|
||||
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, bool FreeThem)
|
||||
{
|
||||
XObjArrayNC<TYPE>::Init();
|
||||
this->CheckSize(4, (size_t)0);
|
||||
AddCopy(n1, FreeThem);
|
||||
AddCopy(n2, FreeThem);
|
||||
AddCopy(n3, FreeThem);
|
||||
AddCopy(n4, FreeThem);
|
||||
}
|
||||
template<class TYPE>
|
||||
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, bool FreeThem)
|
||||
{
|
||||
XObjArrayNC<TYPE>::Init();
|
||||
this->CheckSize(5, (size_t)0);
|
||||
AddCopy(n1, FreeThem);
|
||||
AddCopy(n2, FreeThem);
|
||||
AddCopy(n3, FreeThem);
|
||||
AddCopy(n4, FreeThem);
|
||||
AddCopy(n5, FreeThem);
|
||||
}
|
||||
template<class TYPE>
|
||||
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, bool FreeThem)
|
||||
{
|
||||
XObjArrayNC<TYPE>::Init();
|
||||
this->CheckSize(6, (size_t)0);
|
||||
AddCopy(n1, FreeThem);
|
||||
AddCopy(n2, FreeThem);
|
||||
AddCopy(n3, FreeThem);
|
||||
AddCopy(n4, FreeThem);
|
||||
AddCopy(n5, FreeThem);
|
||||
AddCopy(n6, FreeThem);
|
||||
}
|
||||
template<class TYPE>
|
||||
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, bool FreeThem)
|
||||
{
|
||||
XObjArrayNC<TYPE>::Init();
|
||||
this->CheckSize(7, (size_t)0);
|
||||
AddCopy(n1, FreeThem);
|
||||
AddCopy(n2, FreeThem);
|
||||
AddCopy(n3, FreeThem);
|
||||
AddCopy(n4, FreeThem);
|
||||
AddCopy(n5, FreeThem);
|
||||
AddCopy(n6, FreeThem);
|
||||
AddCopy(n7, FreeThem);
|
||||
}
|
||||
template<class TYPE>
|
||||
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, bool FreeThem)
|
||||
{
|
||||
XObjArrayNC<TYPE>::Init();
|
||||
this->CheckSize(8, (size_t)0);
|
||||
AddCopy(n1, FreeThem);
|
||||
AddCopy(n2, FreeThem);
|
||||
AddCopy(n3, FreeThem);
|
||||
AddCopy(n4, FreeThem);
|
||||
AddCopy(n5, FreeThem);
|
||||
AddCopy(n6, FreeThem);
|
||||
AddCopy(n7, FreeThem);
|
||||
AddCopy(n8, FreeThem);
|
||||
}
|
||||
template<class TYPE>
|
||||
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, bool FreeThem)
|
||||
{
|
||||
XObjArrayNC<TYPE>::Init();
|
||||
this->CheckSize(9, (size_t)0);
|
||||
AddCopy(n1, FreeThem);
|
||||
AddCopy(n2, FreeThem);
|
||||
AddCopy(n3, FreeThem);
|
||||
AddCopy(n4, FreeThem);
|
||||
AddCopy(n5, FreeThem);
|
||||
AddCopy(n6, FreeThem);
|
||||
AddCopy(n7, FreeThem);
|
||||
AddCopy(n8, FreeThem);
|
||||
AddCopy(n9, FreeThem);
|
||||
}
|
||||
template<class TYPE>
|
||||
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, bool FreeThem)
|
||||
{
|
||||
XObjArrayNC<TYPE>::Init();
|
||||
this->CheckSize(10, (size_t)0);
|
||||
AddCopy(n1, FreeThem);
|
||||
AddCopy(n2, FreeThem);
|
||||
AddCopy(n3, FreeThem);
|
||||
AddCopy(n4, FreeThem);
|
||||
AddCopy(n5, FreeThem);
|
||||
AddCopy(n6, FreeThem);
|
||||
AddCopy(n7, FreeThem);
|
||||
AddCopy(n8, FreeThem);
|
||||
AddCopy(n9, FreeThem);
|
||||
AddCopy(n10, FreeThem);
|
||||
}
|
||||
template<class TYPE>
|
||||
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, bool FreeThem)
|
||||
{
|
||||
XObjArrayNC<TYPE>::Init();
|
||||
this->CheckSize(11, (size_t)0);
|
||||
AddCopy(n1, FreeThem);
|
||||
AddCopy(n2, FreeThem);
|
||||
AddCopy(n3, FreeThem);
|
||||
AddCopy(n4, FreeThem);
|
||||
AddCopy(n5, FreeThem);
|
||||
AddCopy(n6, FreeThem);
|
||||
AddCopy(n7, FreeThem);
|
||||
AddCopy(n8, FreeThem);
|
||||
AddCopy(n9, FreeThem);
|
||||
AddCopy(n10, FreeThem);
|
||||
AddCopy(n11, FreeThem);
|
||||
}
|
||||
template<class TYPE>
|
||||
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, const TYPE &n12, bool FreeThem)
|
||||
{
|
||||
XObjArrayNC<TYPE>::Init();
|
||||
this->CheckSize(12, (size_t)0);
|
||||
AddCopy(n1, FreeThem);
|
||||
AddCopy(n2, FreeThem);
|
||||
AddCopy(n3, FreeThem);
|
||||
AddCopy(n4, FreeThem);
|
||||
AddCopy(n5, FreeThem);
|
||||
AddCopy(n6, FreeThem);
|
||||
AddCopy(n7, FreeThem);
|
||||
AddCopy(n8, FreeThem);
|
||||
AddCopy(n9, FreeThem);
|
||||
AddCopy(n10, FreeThem);
|
||||
AddCopy(n11, FreeThem);
|
||||
AddCopy(n12, FreeThem);
|
||||
}
|
||||
template<class TYPE>
|
||||
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, const TYPE &n12, const TYPE &n13, bool FreeThem)
|
||||
{
|
||||
XObjArrayNC<TYPE>::Init();
|
||||
this->CheckSize(13, (size_t)0);
|
||||
AddCopy(n1, FreeThem);
|
||||
AddCopy(n2, FreeThem);
|
||||
AddCopy(n3, FreeThem);
|
||||
AddCopy(n4, FreeThem);
|
||||
AddCopy(n5, FreeThem);
|
||||
AddCopy(n6, FreeThem);
|
||||
AddCopy(n7, FreeThem);
|
||||
AddCopy(n8, FreeThem);
|
||||
AddCopy(n9, FreeThem);
|
||||
AddCopy(n10, FreeThem);
|
||||
AddCopy(n11, FreeThem);
|
||||
AddCopy(n12, FreeThem);
|
||||
AddCopy(n13, FreeThem);
|
||||
}
|
||||
template<class TYPE>
|
||||
XObjArray<TYPE>::XObjArray(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, const TYPE &n12, const TYPE &n13, const TYPE &n14, bool FreeThem)
|
||||
{
|
||||
XObjArrayNC<TYPE>::Init();
|
||||
this->CheckSize(14, (size_t)0);
|
||||
AddCopy(n1, FreeThem);
|
||||
AddCopy(n2, FreeThem);
|
||||
AddCopy(n3, FreeThem);
|
||||
AddCopy(n4, FreeThem);
|
||||
AddCopy(n5, FreeThem);
|
||||
AddCopy(n6, FreeThem);
|
||||
AddCopy(n7, FreeThem);
|
||||
AddCopy(n8, FreeThem);
|
||||
AddCopy(n9, FreeThem);
|
||||
AddCopy(n10, FreeThem);
|
||||
AddCopy(n11, FreeThem);
|
||||
AddCopy(n12, FreeThem);
|
||||
AddCopy(n13, FreeThem);
|
||||
AddCopy(n14, FreeThem);
|
||||
}
|
||||
|
||||
/* Constructeur */
|
||||
template<class TYPE>
|
||||
@ -176,7 +414,7 @@ XObjArray<TYPE>::XObjArray(const XObjArray<TYPE> &anObjArray) : XObjArrayNC<TYPE
|
||||
{
|
||||
size_t ui;
|
||||
|
||||
XObjArrayNC<TYPE>::Init();
|
||||
XObjArrayNC<TYPE>::Init();
|
||||
this->CheckSize(anObjArray.size(), (size_t)0);
|
||||
for ( ui=0 ; ui<anObjArray.size() ; ui+=1 ) AddCopy(anObjArray.ElementAt(ui));
|
||||
}
|
||||
|
@ -489,6 +489,10 @@ public:
|
||||
// int Compare(const char32_t* S) const { return ::Compare<T, char32_t>(m_data, S); };
|
||||
// int Compare(const wchar_t* S) const { return ::Compare<T, wchar_t>(m_data, S); };
|
||||
//
|
||||
|
||||
template<typename O>
|
||||
int strncmp(const O* S, size_t n) const { return XStringAbstract__ncompare(m_data, S, n, false); }
|
||||
|
||||
template<typename O, class OtherXStringClass>
|
||||
bool equal(const __String<O, OtherXStringClass>& S) const { return XStringAbstract__compare(m_data, S.s(), false) == 0; }
|
||||
template<typename O>
|
||||
|
@ -1,6 +1,7 @@
|
||||
|
||||
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile
|
||||
#include "../cpp_foundation/XObjArray.h"
|
||||
#include "../cpp_foundation/XArray.h"
|
||||
|
||||
class TestObjInt
|
||||
{
|
||||
@ -62,5 +63,11 @@ int XObjArray_tests()
|
||||
delete(obj14);
|
||||
if ( !m_destructor_called14 ) return 11;
|
||||
|
||||
{
|
||||
XObjArray<XString8> testCtor(true, new XString8("s1"_XS8), new XString8("s2"_XS8), new XString8("s3"_XS8), NULL);
|
||||
if ( testCtor[0] != "s1"_XS8 ) return 20;
|
||||
if ( testCtor[1] != "s2"_XS8 ) return 21;
|
||||
if ( testCtor[2] != "s3"_XS8 ) return 22;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -353,7 +353,7 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
|
||||
/*
|
||||
Dict = GetProperty(DictPointer, "Anime");
|
||||
if (Dict != NULL) {
|
||||
INTN Count = GetTagCount (Dict);
|
||||
INTN Count = Get_TagCount (Dict);
|
||||
for (INTN i = 0; i < Count; i++) {
|
||||
FILM *NewFilm = new FILM();
|
||||
if (EFI_ERROR(GetElement(Dict, i, &Dict3))) {
|
||||
|
@ -1952,7 +1952,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
|
||||
}
|
||||
}
|
||||
if (gConfigDict[1]) {
|
||||
const TagStruct* UniteTag = GetProperty(gConfigDict[1], "Unite");
|
||||
const TagStruct* UniteTag = gConfigDict[1]->dictPropertyForKey("Unite");
|
||||
if(UniteTag) {
|
||||
UniteConfigs = UniteTag->isTrueOrYy();
|
||||
DBG("UniteConfigs = %ls", UniteConfigs ? L"TRUE\n": L"FALSE\n" );
|
||||
@ -2218,7 +2218,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
|
||||
// }
|
||||
// Load any extra SMBIOS information
|
||||
if (!EFI_ERROR(LoadUserSettings(SelfRootDir, L"smbios"_XSW, &smbiosTags)) && (smbiosTags != NULL)) {
|
||||
const TagStruct* dictPointer = GetProperty(smbiosTags,"SMBIOS");
|
||||
const TagStruct* dictPointer = smbiosTags->dictPropertyForKey("SMBIOS");
|
||||
if (dictPointer) {
|
||||
ParseSMBIOSSettings(dictPointer);
|
||||
} else {
|
||||
|
@ -869,7 +869,7 @@ VOID ApplyInputs(VOID)
|
||||
gBootChanged = TRUE;
|
||||
gThemeChanged = TRUE;
|
||||
Status = GetUserSettings(SelfRootDir, dict);
|
||||
if (gConfigDict[2]) FreeTag(gConfigDict[2]);
|
||||
if (gConfigDict[2]) gConfigDict[2]->FreeTag();
|
||||
gConfigDict[2] = dict;
|
||||
snwprintf(gSettings.ConfigName, 64, "%ls", ConfigsList[OldChosenConfig]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user