mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-12 09:54:36 +01:00
Fix compilation Xcode 12.5.
Debug message in Smbios.cpp.
This commit is contained in:
parent
f28e98fb33
commit
51d5d4a141
@ -951,6 +951,36 @@ void PatchTableType4()
|
||||
BrandStr.S8Printf("%llX", gCPUStructure.MicroCode);
|
||||
UpdateSmbiosString(newSmbiosTable, &newSmbiosTable.Type4->SerialNumber, BrandStr);
|
||||
}
|
||||
|
||||
#ifdef JIEF_DEBUG
|
||||
DBG("newSmbiosTable.Type4->AssetTag=%d\n", newSmbiosTable.Type4->AssetTag);
|
||||
DBG("newSmbiosTable.Type4->CoreCount=%d\n", newSmbiosTable.Type4->CoreCount);
|
||||
DBG("newSmbiosTable.Type4->CoreCount2=%d\n", newSmbiosTable.Type4->CoreCount2);
|
||||
DBG("newSmbiosTable.Type4->CurrentSpeed=%d\n", newSmbiosTable.Type4->CurrentSpeed);
|
||||
DBG("newSmbiosTable.Type4->EnabledCoreCount=%d\n", newSmbiosTable.Type4->EnabledCoreCount);
|
||||
DBG("newSmbiosTable.Type4->EnabledCoreCount2=%d\n", newSmbiosTable.Type4->EnabledCoreCount2);
|
||||
DBG("newSmbiosTable.Type4->ExternalClock=%d\n", newSmbiosTable.Type4->ExternalClock);
|
||||
DBG("newSmbiosTable.Type4->L1CacheHandle=%d\n", newSmbiosTable.Type4->L1CacheHandle);
|
||||
DBG("newSmbiosTable.Type4->L2CacheHandle=%d\n", newSmbiosTable.Type4->L2CacheHandle);
|
||||
DBG("newSmbiosTable.Type4->L3CacheHandle=%d\n", newSmbiosTable.Type4->L3CacheHandle);
|
||||
DBG("newSmbiosTable.Type4->MaxSpeed=%d\n", newSmbiosTable.Type4->MaxSpeed);
|
||||
DBG("newSmbiosTable.Type4->PartNumber=%d\n", newSmbiosTable.Type4->PartNumber);
|
||||
DBG("newSmbiosTable.Type4->ProcessorCharacteristics=%d\n", newSmbiosTable.Type4->ProcessorCharacteristics);
|
||||
DBG("newSmbiosTable.Type4->ProcessorFamily=%d\n", newSmbiosTable.Type4->ProcessorFamily);
|
||||
DBG("newSmbiosTable.Type4->ProcessorFamily2=%d\n", newSmbiosTable.Type4->ProcessorFamily2);
|
||||
DBG("newSmbiosTable.Type4->ProcessorId.FeatureFlags=%d\n", *(UINT32*)&newSmbiosTable.Type4->ProcessorId.FeatureFlags);
|
||||
DBG("newSmbiosTable.Type4->ProcessorId.Signatur=%d\n", *(UINT32*)&newSmbiosTable.Type4->ProcessorId.Signature);
|
||||
DBG("newSmbiosTable.Type4->ProcessorManufacture=%d\n", newSmbiosTable.Type4->ProcessorManufacture);
|
||||
DBG("newSmbiosTable.Type4->ProcessorType=%d\n", newSmbiosTable.Type4->ProcessorType);
|
||||
DBG("newSmbiosTable.Type4->ProcessorUpgrade=%d\n", newSmbiosTable.Type4->ProcessorUpgrade);
|
||||
DBG("newSmbiosTable.Type4->ProcessorVersion=%d\n", newSmbiosTable.Type4->ProcessorVersion);
|
||||
DBG("newSmbiosTable.Type4->SerialNumber=%d\n", newSmbiosTable.Type4->SerialNumber);
|
||||
DBG("newSmbiosTable.Type4->Socket=%d\n", newSmbiosTable.Type4->Socket);
|
||||
DBG("newSmbiosTable.Type4->Status=%d\n", newSmbiosTable.Type4->Status);
|
||||
DBG("newSmbiosTable.Type4->ThreadCount=%d\n", newSmbiosTable.Type4->ThreadCount);
|
||||
DBG("newSmbiosTable.Type4->ThreadCount2=%d\n", newSmbiosTable.Type4->ThreadCount2);
|
||||
DBG("newSmbiosTable.Type4->Voltage=%d\n", *(UINT8*)&newSmbiosTable.Type4->Voltage);
|
||||
#endif
|
||||
|
||||
Handle = LogSmbiosTable(newSmbiosTable);
|
||||
}
|
||||
@ -1072,6 +1102,18 @@ void PatchTableType9()
|
||||
// SlotType = 32bit PCI/SlotTypePciExpressX1/x4/x16
|
||||
// real PC -> PCI, real Mac -> PCIe
|
||||
|
||||
#ifdef JIEF_DEBUG
|
||||
for (Index = 0; Index <= 15; Index++) {
|
||||
DBG("SlotDevice[%lld].BusNum = %d\n", Index, gSettings.Smbios.SlotDevices[Index].Valid ? gSettings.Smbios.SlotDevices[Index].BusNum : 0);
|
||||
DBG("SlotDevice[%lld].DevFuncNum = %d\n", Index, gSettings.Smbios.SlotDevices[Index].Valid ? gSettings.Smbios.SlotDevices[Index].DevFuncNum : 0);
|
||||
DBG("SlotDevice[%lld].SegmentGroupNum = %d\n", Index, gSettings.Smbios.SlotDevices[Index].Valid ? gSettings.Smbios.SlotDevices[Index].SegmentGroupNum : 0);
|
||||
DBG("SlotDevice[%lld].SlotID = %d\n", Index, gSettings.Smbios.SlotDevices[Index].Valid ? gSettings.Smbios.SlotDevices[Index].SlotID : 0);
|
||||
DBG("SlotDevice[%lld].SlotType = %d\n", Index, gSettings.Smbios.SlotDevices[Index].Valid ? gSettings.Smbios.SlotDevices[Index].SlotType : 0);
|
||||
DBG("SlotDevice[%lld].SlotName = %s\n", Index, gSettings.Smbios.SlotDevices[Index].Valid ? gSettings.Smbios.SlotDevices[Index].SlotName.c_str() : "");
|
||||
DBG("SlotDevice[%lld].Valid = %d\n", Index, gSettings.Smbios.SlotDevices[Index].Valid);
|
||||
}
|
||||
#endif
|
||||
|
||||
for (Index = 0; Index < 15; Index++) {
|
||||
if (gSettings.Smbios.SlotDevices[Index].Valid) {
|
||||
INTN Dev, Func;
|
||||
@ -1374,6 +1416,19 @@ void PatchTableType17()
|
||||
//
|
||||
gRAMCount = 0;
|
||||
// Inject tables
|
||||
#ifdef JIEF_DEBUG
|
||||
DBG("gSettings.Smbios.Memory.SlotCounts=%d\n", gSettings.Smbios.Memory.SlotCounts);
|
||||
DBG("gSettings.Smbios.Memory.UserChannels=%d\n", gSettings.Smbios.Memory.UserChannels);
|
||||
for (Index = 0; Index < gSettings.Smbios.Memory.SlotCounts; Index++) {
|
||||
DBG("gSettings.Smbios.Memory.User[%lld].Frequency=%d\n", Index, gSettings.Smbios.Memory.User[Index].Frequency);
|
||||
DBG("gSettings.Smbios.Memory.User[%lld].InUse=%d\n", Index, gSettings.Smbios.Memory.User[Index].InUse);
|
||||
DBG("gSettings.Smbios.Memory.User[%lld].ModuleSize=%d\n", Index, gSettings.Smbios.Memory.User[Index].ModuleSize);
|
||||
DBG("gSettings.Smbios.Memory.User[%lld].PartNo=%s\n", Index, gSettings.Smbios.Memory.User[Index].PartNo.c_str());
|
||||
DBG("gSettings.Smbios.Memory.User[%lld].SerialNo=%s\n", Index, gSettings.Smbios.Memory.User[Index].SerialNo.c_str());
|
||||
DBG("gSettings.Smbios.Memory.User[%lld].Type=%d\n", Index, gSettings.Smbios.Memory.User[Index].Type);
|
||||
DBG("gSettings.Smbios.Memory.User[%lld].Vendor=%s\n", Index, gSettings.Smbios.Memory.User[Index].Vendor.c_str());
|
||||
}
|
||||
#endif
|
||||
for (Index = 0; Index < gSettings.Smbios.Memory.SlotCounts; Index++) {
|
||||
UINTN UserIndex = channelMap[Index];
|
||||
UINT8 bank = (UINT8)(Index / gSettings.Smbios.Memory.UserChannels);
|
||||
|
@ -23,42 +23,43 @@ template<class XStringClass_, class XStringArrayClass>
|
||||
class XStringArray_/* : public XStringArraySuper*/
|
||||
{
|
||||
protected:
|
||||
XObjArray<XStringClass_> array;
|
||||
|
||||
XObjArray<XStringClass_> array;
|
||||
|
||||
public:
|
||||
typedef XStringClass_ XStringClass;
|
||||
typedef XStringClass_ XStringClass;
|
||||
|
||||
XStringArray_() : array() {};
|
||||
XStringArray_() : array() {};
|
||||
|
||||
XStringArray_(const XStringArray_& other) : array() {
|
||||
array = other.array;
|
||||
}
|
||||
template<typename OtherXStringClass_, class OtherXStringArrayClass>
|
||||
XStringArray_(const XStringArray_<OtherXStringClass_, OtherXStringArrayClass>& other) : array() {
|
||||
XStringArray_(const XStringArray_<OtherXStringClass_, OtherXStringArrayClass>& other) : array() { *this = other; }
|
||||
|
||||
template<typename OtherXStringClass_, class OtherXStringArrayClass>
|
||||
XStringArrayClass& operator = (const XStringArray_<OtherXStringClass_, OtherXStringArrayClass>& other) {
|
||||
for ( size_t idx = 0 ; idx < other.size() ; ++idx ) {
|
||||
array.AddCopy(other[idx]);
|
||||
}
|
||||
return *(XStringArrayClass*)this;
|
||||
}
|
||||
|
||||
// template<typename OtherXStringClass_, class OtherXStringArrayClass>
|
||||
// XStringArrayClass& operator =(const XStringArray_<OtherXStringClass_, OtherXStringArrayClass>& other) { array = other.array; return *((XStringArrayClass*)this); }
|
||||
|
||||
size_t size() const { return array.size(); }
|
||||
void setEmpty() { array.setEmpty(); }
|
||||
bool isEmpty() const { return this->size() == 0 ; }
|
||||
bool notEmpty() const { return this->size() > 0 ; }
|
||||
|
||||
// #define enable_if _xtools_enable_if_t
|
||||
/* [] */
|
||||
size_t size() const { return array.size(); }
|
||||
void setEmpty() { array.setEmpty(); }
|
||||
bool isEmpty() const { return this->size() == 0 ; }
|
||||
bool notEmpty() const { return this->size() > 0 ; }
|
||||
|
||||
// #define enable_if _xtools_enable_if_t
|
||||
/* [] */
|
||||
template<typename IntegralType, enable_if(is_integral(IntegralType))>
|
||||
const XStringClass& operator [](IntegralType i) const { return array[i]; }
|
||||
template<typename IntegralType, enable_if(is_integral(IntegralType))>
|
||||
XStringClass& operator [](IntegralType i) { return array[i]; }
|
||||
/* ElementAt */
|
||||
template<typename IntegralType, enable_if(is_integral(IntegralType))>
|
||||
const XStringClass& elementAt(IntegralType i) const { return array[i]; }
|
||||
template<typename IntegralType, enable_if(is_integral(IntegralType))>
|
||||
XStringClass& elementAt(IntegralType i) { return array[i]; }
|
||||
/* ElementAt */
|
||||
template<typename IntegralType, enable_if(is_integral(IntegralType))>
|
||||
const XStringClass& elementAt(IntegralType i) const { return array[i]; }
|
||||
template<typename IntegralType, enable_if(is_integral(IntegralType))>
|
||||
XStringClass& elementAt(IntegralType i) { return array[i]; }
|
||||
|
||||
template<class Type1, class Type2, class Type3,
|
||||
enable_if(
|
||||
@ -84,10 +85,10 @@ public:
|
||||
return s;
|
||||
}
|
||||
|
||||
XStringClass ConcatAll() const
|
||||
{
|
||||
return ConcatAll(", ", "", "");
|
||||
}
|
||||
XStringClass ConcatAll() const
|
||||
{
|
||||
return ConcatAll(", ", "", "");
|
||||
}
|
||||
|
||||
template<class Type1, enable_if(is_char(Type1) || is_char_ptr(Type1) || is___String(Type1))>
|
||||
XStringClass ConcatAll(const Type1& Separator) const
|
||||
@ -96,113 +97,113 @@ public:
|
||||
}
|
||||
|
||||
|
||||
template<class OtherXStringArrayClass>
|
||||
bool Equal(const OtherXStringArrayClass &aStrings) const
|
||||
{
|
||||
size_t ui;
|
||||
|
||||
if ( array.size() != aStrings.size() ) return false;
|
||||
for ( ui=0 ; ui<array.size() ; ui+=1 ) {
|
||||
if ( array.ElementAt(ui) != aStrings[ui] ) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
template<class OtherXStringArrayClass>
|
||||
bool operator ==(const OtherXStringArrayClass &aXStrings) const { return Equal(aXStrings); }
|
||||
template<class OtherXStringArrayClass>
|
||||
bool operator !=(const OtherXStringArrayClass& aXStrings) const { return !Equal(aXStrings); }
|
||||
|
||||
/* contains */
|
||||
template<typename CharType, enable_if(is_char(CharType))>
|
||||
bool contains(const CharType* s) const
|
||||
{
|
||||
for ( size_t i=0 ; i<array.size() ; i+=1 ) {
|
||||
if ( array.ElementAt(i).isEqual(s) ) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
template<class OtherXStringClass, enable_if(!is_char(OtherXStringClass) && !is_char_ptr(OtherXStringClass))>
|
||||
bool contains(const OtherXStringClass &S) const
|
||||
{
|
||||
return contains(S.s());
|
||||
}
|
||||
/* containsIC */
|
||||
template<typename CharType, enable_if(is_char(CharType))>
|
||||
bool containsIC(const CharType* s) const
|
||||
{
|
||||
for ( size_t i=0 ; i<array.size() ; i+=1 ) {
|
||||
if ( array.ElementAt(i).isEqualIC(s) ) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
template<class OtherXStringClass, enable_if(!is_char(OtherXStringClass) && !is_char_ptr(OtherXStringClass))>
|
||||
bool containsIC(const OtherXStringClass &S) const
|
||||
{
|
||||
return containsIC(S.s());
|
||||
}
|
||||
/* ContainsStartWithIC */
|
||||
template<typename CharType, enable_if(is_char(CharType))>
|
||||
bool containsStartWithIC(const CharType* s) const
|
||||
{
|
||||
for ( size_t i=0 ; i<array.size() ; i+=1 ) {
|
||||
if ( array.ElementAt(i).startWithIC(s) ) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
template<class OtherXStringClass, enable_if(!is_char(OtherXStringClass) && !is_char_ptr(OtherXStringClass))>
|
||||
bool containsStartWithIC(const OtherXStringClass &S) const
|
||||
{
|
||||
return ContainsStartWithIC(S.s());
|
||||
}
|
||||
template<class OtherXStringArrayClass>
|
||||
bool Equal(const OtherXStringArrayClass &aStrings) const
|
||||
{
|
||||
size_t ui;
|
||||
|
||||
if ( array.size() != aStrings.size() ) return false;
|
||||
for ( ui=0 ; ui<array.size() ; ui+=1 ) {
|
||||
if ( array.ElementAt(ui) != aStrings[ui] ) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
template<class OtherXStringArrayClass>
|
||||
bool operator ==(const OtherXStringArrayClass &aXStrings) const { return Equal(aXStrings); }
|
||||
template<class OtherXStringArrayClass>
|
||||
bool operator !=(const OtherXStringArrayClass& aXStrings) const { return !Equal(aXStrings); }
|
||||
|
||||
/* contains */
|
||||
template<typename CharType, enable_if(is_char(CharType))>
|
||||
bool contains(const CharType* s) const
|
||||
{
|
||||
for ( size_t i=0 ; i<array.size() ; i+=1 ) {
|
||||
if ( array.ElementAt(i).isEqual(s) ) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
template<class OtherXStringClass, enable_if(!is_char(OtherXStringClass) && !is_char_ptr(OtherXStringClass))>
|
||||
bool contains(const OtherXStringClass &S) const
|
||||
{
|
||||
return contains(S.s());
|
||||
}
|
||||
/* containsIC */
|
||||
template<typename CharType, enable_if(is_char(CharType))>
|
||||
bool containsIC(const CharType* s) const
|
||||
{
|
||||
for ( size_t i=0 ; i<array.size() ; i+=1 ) {
|
||||
if ( array.ElementAt(i).isEqualIC(s) ) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
template<class OtherXStringClass, enable_if(!is_char(OtherXStringClass) && !is_char_ptr(OtherXStringClass))>
|
||||
bool containsIC(const OtherXStringClass &S) const
|
||||
{
|
||||
return containsIC(S.s());
|
||||
}
|
||||
/* ContainsStartWithIC */
|
||||
template<typename CharType, enable_if(is_char(CharType))>
|
||||
bool containsStartWithIC(const CharType* s) const
|
||||
{
|
||||
for ( size_t i=0 ; i<array.size() ; i+=1 ) {
|
||||
if ( array.ElementAt(i).startWithIC(s) ) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
template<class OtherXStringClass, enable_if(!is_char(OtherXStringClass) && !is_char_ptr(OtherXStringClass))>
|
||||
bool containsStartWithIC(const OtherXStringClass &S) const
|
||||
{
|
||||
return ContainsStartWithIC(S.s());
|
||||
}
|
||||
|
||||
|
||||
template<class OtherXStringArrayClass>
|
||||
bool Same(const OtherXStringArrayClass &aStrings) const
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for ( i=0 ; i<this->size() ; i+=1 ) {
|
||||
if ( !aStrings.contains(array.ElementAt(i)) ) return false;
|
||||
}
|
||||
for ( i=0 ; i<aStrings.size() ; i+=1 ) {
|
||||
if ( !contains(aStrings[i]) ) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
template<class OtherXStringArrayClass>
|
||||
bool Same(const OtherXStringArrayClass &aStrings) const
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for ( i=0 ; i<this->size() ; i+=1 ) {
|
||||
if ( !aStrings.contains(array.ElementAt(i)) ) return false;
|
||||
}
|
||||
for ( i=0 ; i<aStrings.size() ; i+=1 ) {
|
||||
if ( !contains(aStrings[i]) ) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Add
|
||||
template<typename CharType>
|
||||
template<typename CharType>
|
||||
void AddStrings(const CharType* Val1, ...)
|
||||
{
|
||||
XTOOLS_VA_LIST va;
|
||||
const wchar_t *p;
|
||||
|
||||
{
|
||||
remove_const(XStringClass)* newS = new remove_const(XStringClass);
|
||||
newS->takeValueFrom(Val1);
|
||||
AddReference(newS, true);
|
||||
}
|
||||
XTOOLS_VA_START(va, Val1);
|
||||
p = VA_ARG(va, const CharType*);
|
||||
while ( p != nullptr ) {
|
||||
{
|
||||
XTOOLS_VA_LIST va;
|
||||
const wchar_t *p;
|
||||
|
||||
{
|
||||
remove_const(XStringClass)* newS = new remove_const(XStringClass);
|
||||
newS->takeValueFrom(p);
|
||||
AddReference(newS, true);
|
||||
p = VA_ARG(va, const CharType*);
|
||||
}
|
||||
XTOOLS_VA_END(va);
|
||||
}
|
||||
newS->takeValueFrom(Val1);
|
||||
AddReference(newS, true);
|
||||
}
|
||||
XTOOLS_VA_START(va, Val1);
|
||||
p = VA_ARG(va, const CharType*);
|
||||
while ( p != nullptr ) {
|
||||
remove_const(XStringClass)* newS = new remove_const(XStringClass);
|
||||
newS->takeValueFrom(p);
|
||||
AddReference(newS, true);
|
||||
p = VA_ARG(va, const CharType*);
|
||||
}
|
||||
XTOOLS_VA_END(va);
|
||||
}
|
||||
|
||||
void AddNoNull(const XStringClass &aString) { if ( !aString.isEmpty() ) array.AddCopy(aString); }
|
||||
void AddEvenNull(const XStringClass &aString) { array.AddCopy(aString); }
|
||||
void AddNoNull(const XStringClass &aString) { if ( !aString.isEmpty() ) array.AddCopy(aString); }
|
||||
void AddEvenNull(const XStringClass &aString) { array.AddCopy(aString); }
|
||||
|
||||
template<typename CharType, enable_if(is_char(CharType))>
|
||||
void Add(const CharType* s)
|
||||
{
|
||||
remove_const(XStringClass)* xstr = new remove_const(XStringClass);
|
||||
xstr->strcpy(s);
|
||||
array.AddReference(xstr, true);
|
||||
}
|
||||
template<typename CharType, enable_if(is_char(CharType))>
|
||||
void Add(const CharType* s)
|
||||
{
|
||||
remove_const(XStringClass)* xstr = new remove_const(XStringClass);
|
||||
xstr->strcpy(s);
|
||||
array.AddReference(xstr, true);
|
||||
}
|
||||
|
||||
template<typename XStringClass1, enable_if(is___String(XStringClass1))>
|
||||
void Add(const XStringClass1 &aString) { Add(aString.s()); }
|
||||
@ -216,28 +217,28 @@ public:
|
||||
template<typename IntegralType, enable_if(is_integral(IntegralType))>
|
||||
XStringClass* ExtractFromPos(IntegralType i) { return array.RemoveWithoutFreeingAtIndex(i); }
|
||||
|
||||
template<class OtherXStringClass, class OtherXStringArrayClass>
|
||||
void import(const XStringArray_<OtherXStringClass, OtherXStringArrayClass> &aStrings)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for ( i=0 ; i<aStrings.size() ; i+=1 ) {
|
||||
array.AddCopy(aStrings[i]);
|
||||
}
|
||||
}
|
||||
template<class OtherXStringClass, class OtherXStringArrayClass>
|
||||
void import(const XStringArray_<OtherXStringClass, OtherXStringArrayClass> &aStrings)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for ( i=0 ; i<aStrings.size() ; i+=1 ) {
|
||||
array.AddCopy(aStrings[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void AddID(const XStringClass &aString) /* ignore Duplicate */
|
||||
{
|
||||
if ( !contains(aString) ) array.AddCopy(aString);
|
||||
}
|
||||
void importID(const XStringArray_ &aStrings) /* ignore Duplicate */
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for ( i=0 ; i<aStrings.size() ; i+=1 ) {
|
||||
if ( !Contains(aStrings[i]) ) AddCopy(aStrings[i]);
|
||||
}
|
||||
}
|
||||
void AddID(const XStringClass &aString) /* ignore Duplicate */
|
||||
{
|
||||
if ( !contains(aString) ) array.AddCopy(aString);
|
||||
}
|
||||
void importID(const XStringArray_ &aStrings) /* ignore Duplicate */
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for ( i=0 ; i<aStrings.size() ; i+=1 ) {
|
||||
if ( !Contains(aStrings[i]) ) AddCopy(aStrings[i]);
|
||||
}
|
||||
}
|
||||
void remove(const XStringClass &aString)
|
||||
{
|
||||
if ( array.size() > 0 )
|
||||
@ -256,20 +257,20 @@ public:
|
||||
{
|
||||
array.RemoveAtIndex(pos);
|
||||
}
|
||||
void removeIC(const XStringClass &aString)
|
||||
{
|
||||
if ( array.size() > 0 )
|
||||
{
|
||||
size_t i = array.size();
|
||||
do {
|
||||
i--;
|
||||
if ( array[i].isEqualIC(aString) ) {
|
||||
array.RemoveAtIndex(i);
|
||||
break;
|
||||
}
|
||||
} while ( i > 0 );
|
||||
}
|
||||
}
|
||||
void removeIC(const XStringClass &aString)
|
||||
{
|
||||
if ( array.size() > 0 )
|
||||
{
|
||||
size_t i = array.size();
|
||||
do {
|
||||
i--;
|
||||
if ( array[i].isEqualIC(aString) ) {
|
||||
array.RemoveAtIndex(i);
|
||||
break;
|
||||
}
|
||||
} while ( i > 0 );
|
||||
}
|
||||
}
|
||||
XStringArrayClass trimEachString()
|
||||
{
|
||||
for ( size_t i=0 ; i<array.size() ; i+=1 ) {
|
||||
@ -361,7 +362,7 @@ extern const ConstXStringWArray NullConstXStringWArray;
|
||||
//template<class XStringArrayClass, class XStringClass1, enable_if(!is_char(XStringClass1) && !is_char_ptr(XStringClass1))>
|
||||
//XStringArrayClass Split(const XStringClass1& S)
|
||||
//{
|
||||
// return Split<XStringArrayClass>(S, ", "_XS8);
|
||||
// return Split<XStringArrayClass>(S, ", "_XS8);
|
||||
//};
|
||||
|
||||
|
||||
@ -382,54 +383,54 @@ XStringArrayClass Split(Type1 S, const Type2 Separator)
|
||||
auto separator = _xstringarray__char_type<Type2>::getCharPtr(Separator);
|
||||
// typename _xstringarray__char_type<Type2>::type separator = Separator;
|
||||
|
||||
size_t separatorLength = length_of_utf_string(separator);
|
||||
|
||||
if ( separatorLength == 0 ) {
|
||||
typename XStringArrayClass::XStringClass* xstr;
|
||||
xstr = new typename XStringArrayClass::XStringClass;
|
||||
xstr->takeValueFrom(S);
|
||||
xsArray.AddReference(xstr, true);
|
||||
return xsArray;
|
||||
}
|
||||
size_t separatorLength = length_of_utf_string(separator);
|
||||
|
||||
if ( separatorLength == 0 ) {
|
||||
typename XStringArrayClass::XStringClass* xstr;
|
||||
xstr = new typename XStringArrayClass::XStringClass;
|
||||
xstr->takeValueFrom(S);
|
||||
xsArray.AddReference(xstr, true);
|
||||
return xsArray;
|
||||
}
|
||||
|
||||
// typename _xstringarray__char_type<Type1>::type s = S;
|
||||
// const CharType1* s = S;
|
||||
char32_t char32 = 1;
|
||||
|
||||
do
|
||||
{
|
||||
while ( XStringAbstract__ncompare(s, separator, separatorLength, false) == 0 ) {
|
||||
// I have to implement a move_forward_one_char in unicode_conversions, as we don't care about char32
|
||||
for ( size_t i = 0 ; i < separatorLength ; i++ ) s = get_char32_from_string(s, &char32);
|
||||
}
|
||||
// const CharType1* s = S;
|
||||
char32_t char32 = 1;
|
||||
|
||||
do
|
||||
{
|
||||
while ( XStringAbstract__ncompare(s, separator, separatorLength, false) == 0 ) {
|
||||
// I have to implement a move_forward_one_char in unicode_conversions, as we don't care about char32
|
||||
for ( size_t i = 0 ; i < separatorLength ; i++ ) s = get_char32_from_string(s, &char32);
|
||||
}
|
||||
if ( !*s ) return xsArray;
|
||||
auto t = s;
|
||||
// typename _xstringarray__char_type<Type1>::type t = s;
|
||||
// const CharType1* t = s;
|
||||
size_t nb = 0;
|
||||
while ( char32 && XStringAbstract__ncompare(t, separator, separatorLength, false) != 0 ) {
|
||||
nb++;
|
||||
t = get_char32_from_string(t, &char32);
|
||||
}
|
||||
typename XStringArrayClass::XStringClass* xstr;
|
||||
xstr = new typename XStringArrayClass::XStringClass;
|
||||
xstr->strncpy(s, nb);
|
||||
xsArray.AddReference(xstr, true);
|
||||
// s = get_char32_from_string(t, &char32);
|
||||
s = t;
|
||||
// Consume the separator we found
|
||||
for ( size_t i = 0 ; i < separatorLength ; i++ ) s = get_char32_from_string(s, &char32);
|
||||
} while ( char32 );
|
||||
|
||||
return xsArray;
|
||||
// const CharType1* t = s;
|
||||
size_t nb = 0;
|
||||
while ( char32 && XStringAbstract__ncompare(t, separator, separatorLength, false) != 0 ) {
|
||||
nb++;
|
||||
t = get_char32_from_string(t, &char32);
|
||||
}
|
||||
typename XStringArrayClass::XStringClass* xstr;
|
||||
xstr = new typename XStringArrayClass::XStringClass;
|
||||
xstr->strncpy(s, nb);
|
||||
xsArray.AddReference(xstr, true);
|
||||
// s = get_char32_from_string(t, &char32);
|
||||
s = t;
|
||||
// Consume the separator we found
|
||||
for ( size_t i = 0 ; i < separatorLength ; i++ ) s = get_char32_from_string(s, &char32);
|
||||
} while ( char32 );
|
||||
|
||||
return xsArray;
|
||||
//
|
||||
//
|
||||
// // TODO : Allocating temporary strings could be avoided by using low level function from unicode_conversions
|
||||
// typename XStringArrayClass::XStringClass SS;
|
||||
// SS.takeValueFrom(S);
|
||||
// typename XStringArrayClass::XStringClass XSeparator;
|
||||
// SS.takeValueFrom(Separator);
|
||||
// return Split<XStringArrayClass>(SS, XSeparator);
|
||||
// // TODO : Allocating temporary strings could be avoided by using low level function from unicode_conversions
|
||||
// typename XStringArrayClass::XStringClass SS;
|
||||
// SS.takeValueFrom(S);
|
||||
// typename XStringArrayClass::XStringClass XSeparator;
|
||||
// SS.takeValueFrom(Separator);
|
||||
// return Split<XStringArrayClass>(SS, XSeparator);
|
||||
};
|
||||
|
||||
|
||||
@ -447,31 +448,31 @@ XStringArrayClass Split(Type1 S)
|
||||
//template<class XStringArrayClass, class XStringClass1, class XStringClass2, enable_if(is___String(XStringClass1) && is___String(XStringClass2))>
|
||||
//XStringArrayClass Split(const XStringClass1& S, const XStringClass2& Separator)
|
||||
//{
|
||||
// return Split<XStringArrayClass>(S.s(), Separator.s());
|
||||
// return Split<XStringArrayClass>(S.s(), Separator.s());
|
||||
////
|
||||
//// XStringArrayClass Ss;
|
||||
//// size_t idxB, idxE;
|
||||
////
|
||||
//// if ( Separator.length() == 0 ) {
|
||||
//// Ss.Add(S);
|
||||
//// return Ss;
|
||||
//// }
|
||||
//// idxB = 0;
|
||||
//// idxE = S.indexOf(Separator, idxB);
|
||||
//// while ( idxE != MAX_XSIZE ) {
|
||||
//// Ss.Add(S.subString(idxB, idxE-idxB));
|
||||
//// idxB = idxE + Separator.length();
|
||||
//// idxE = S.indexOf(Separator, idxB);
|
||||
//// }
|
||||
//// if ( idxB < S.length() ) Ss.Add(S.subString(idxB, S.length()-idxB));
|
||||
//// return Ss;
|
||||
//// if ( Separator.length() == 0 ) {
|
||||
//// Ss.Add(S);
|
||||
//// return Ss;
|
||||
//// }
|
||||
//// idxB = 0;
|
||||
//// idxE = S.indexOf(Separator, idxB);
|
||||
//// while ( idxE != MAX_XSIZE ) {
|
||||
//// Ss.Add(S.subString(idxB, idxE-idxB));
|
||||
//// idxB = idxE + Separator.length();
|
||||
//// idxE = S.indexOf(Separator, idxB);
|
||||
//// }
|
||||
//// if ( idxB < S.length() ) Ss.Add(S.subString(idxB, S.length()-idxB));
|
||||
//// return Ss;
|
||||
//};
|
||||
//
|
||||
//
|
||||
//template<class XStringArrayClass, class XStringClass1, enable_if(!is_char(XStringClass1) && !is_char_ptr(XStringClass1))>
|
||||
//XStringArrayClass Split(const XStringClass1& S)
|
||||
//{
|
||||
// return Split<XStringArrayClass>(S, ", "_XS8);
|
||||
// return Split<XStringArrayClass>(S, ", "_XS8);
|
||||
//};
|
||||
|
||||
#endif
|
||||
|
@ -8,6 +8,7 @@ int XStringArray_tests()
|
||||
// printf("XStringWArray_tests -> Enter\n");
|
||||
#endif
|
||||
|
||||
// Test ConstXStringWArray
|
||||
{
|
||||
ConstXStringWArray constArray;
|
||||
constArray.Add(L"aa");
|
||||
@ -25,6 +26,7 @@ int XStringArray_tests()
|
||||
if ( !b ) return 5;
|
||||
}
|
||||
|
||||
// test contains
|
||||
{
|
||||
XStringWArray array1;
|
||||
|
||||
@ -104,6 +106,7 @@ int XStringArray_tests()
|
||||
XString8Array array3bis = Split<XString8Array>(c);
|
||||
if ( array != array3bis ) return 20;
|
||||
}
|
||||
|
||||
// Test Split char[64]
|
||||
{
|
||||
char buf[64];
|
||||
@ -115,6 +118,7 @@ int XStringArray_tests()
|
||||
if ( array[2] != "3333"_XS8 ) return 33;
|
||||
if ( array[3] != "4th_item"_XS8 ) return 34;
|
||||
}
|
||||
|
||||
// Test concat and Split @Pene
|
||||
{
|
||||
XString8Array array;
|
||||
@ -140,7 +144,8 @@ int XStringArray_tests()
|
||||
LoadOptions2 = array;
|
||||
if ( LoadOptions2 != array ) return 22;
|
||||
}
|
||||
//
|
||||
|
||||
// test == versus Same
|
||||
{
|
||||
XStringWArray array;
|
||||
array.Add(L"word1"_XSW);
|
||||
@ -158,6 +163,8 @@ int XStringArray_tests()
|
||||
if ( !array.Same(array2) ) return 41; // Arrays are the same
|
||||
|
||||
}
|
||||
|
||||
// Test AddNoNull and AddID
|
||||
{
|
||||
XStringWArray array1;
|
||||
array1.Add(L"word1"_XSW);
|
||||
@ -172,6 +179,8 @@ int XStringArray_tests()
|
||||
array1.AddID(L"other2"_XSW);
|
||||
if ( array1.size() != 4 ) return 53;
|
||||
}
|
||||
|
||||
// Test operator =
|
||||
{
|
||||
XString8Array array;
|
||||
array.Add(L"word1");
|
||||
@ -184,7 +193,14 @@ int XStringArray_tests()
|
||||
XString8Array* array2Ptr = &array2;
|
||||
*array2Ptr = array2;
|
||||
if ( array2 != array ) return 22;
|
||||
|
||||
XStringWArray warray1;
|
||||
warray1 = array;
|
||||
XString8Array array3 = warray1;
|
||||
if ( array3 != array ) return 24;
|
||||
}
|
||||
|
||||
// test remove() and removeIC()
|
||||
{
|
||||
XString8Array array;
|
||||
array.Add(L"word1");
|
||||
@ -192,42 +208,31 @@ int XStringArray_tests()
|
||||
array.Add(L"3333");
|
||||
array.Add(L"4th_item");
|
||||
|
||||
XString8Array array2 = array;
|
||||
if ( array2 != array ) return 22;
|
||||
XString8Array* array2Ptr = &array2;
|
||||
*array2Ptr = array2;
|
||||
if ( array2 != array ) return 22;
|
||||
}
|
||||
{
|
||||
XString8Array array;
|
||||
array.Add(L"word1");
|
||||
array.Add(L"other2");
|
||||
array.Add(L"3333");
|
||||
array.Add(L"4th_item");
|
||||
|
||||
array.remove("WOrd1"_XS8);
|
||||
array.remove("WOrd1"_XS8);
|
||||
if ( !array.contains("word1"_XS8) ) return 22;
|
||||
array.remove("word1"_XS8);
|
||||
array.remove("word1"_XS8);
|
||||
if ( array.contains("word1"_XS8) ) return 22;
|
||||
array.removeIC("oTHEr2"_XS8);
|
||||
array.removeIC("oTHEr2"_XS8);
|
||||
if ( array.contains("other2"_XS8) ) return 22;
|
||||
array.removeIC("4th_ITEM"_XS8);
|
||||
array.removeIC("4th_ITEM"_XS8);
|
||||
if ( array.contains("4th_item"_XS8) ) return 22;
|
||||
XString8 c = array.ConcatAll();
|
||||
// printf("c=%s\n", c.c_str());
|
||||
}
|
||||
//XString8 c = array.ConcatAll();
|
||||
//printf("c=%s\n", c.c_str());
|
||||
}
|
||||
|
||||
// test remove until array is empty
|
||||
{
|
||||
XString8Array array;
|
||||
array.Add(L"splash");
|
||||
array.Add(L"quiet");
|
||||
|
||||
array.remove("splash"_XS8);
|
||||
array.remove("splash"_XS8);
|
||||
if ( array.contains("splash"_XS8) ) return 22;
|
||||
array.removeIC("quiet"_XS8);
|
||||
array.removeIC("quiet"_XS8);
|
||||
if ( array.contains("quiet"_XS8) ) return 22;
|
||||
if ( array.size() != 0 ) return 22;
|
||||
XString8 c = array.ConcatAll();
|
||||
// printf("c=%s\n", c.c_str());
|
||||
//XString8 c = array.ConcatAll();
|
||||
//printf("c=%s\n", c.c_str());
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user