mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-22 07:58:22 +08:00
UString integration done
- now UString works for both Qt (uses QString) and non-Qt (uses modified CBString) builds
This commit is contained in:
parent
9bd71281b9
commit
804a55ba64
@ -79,7 +79,7 @@ USTATUS FfsDumper::recursiveDump(const UModelIndex & index, const UString & path
|
||||
if (!file.open(QFile::Text | QFile::WriteOnly))
|
||||
return U_FILE_OPEN;
|
||||
|
||||
file.write(info);
|
||||
file.write(info.toLocal8Bit());
|
||||
file.close();
|
||||
dumped = true;
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ int main(int argc, char *argv[])
|
||||
// Show ffsParser's messages
|
||||
std::vector<std::pair<UString, UModelIndex> > messages = ffsParser.getMessages();
|
||||
for (size_t i = 0; i < messages.size(); i++) {
|
||||
std::cout << messages[i].first << std::endl;
|
||||
std::cout << (const char*)messages[i].first.toLocal8Bit() << std::endl;
|
||||
}
|
||||
|
||||
// Get last VTF
|
||||
@ -76,7 +76,7 @@ int main(int argc, char *argv[])
|
||||
// Show fitParser's messages
|
||||
std::vector<std::pair<UString, UModelIndex> > fitMessages = fitParser.getMessages();
|
||||
for (size_t i = 0; i < fitMessages.size(); i++) {
|
||||
std::cout << fitMessages[i].first << std::endl;
|
||||
std::cout << (const char*)fitMessages[i].first.toLocal8Bit() << std::endl;
|
||||
}
|
||||
|
||||
// Show FIT table
|
||||
@ -86,11 +86,11 @@ int main(int argc, char *argv[])
|
||||
std::cout << " Address | Size | Ver | Type | CS " << std::endl;
|
||||
std::cout << "-------------------------------------------------------------------" << std::endl;
|
||||
for (size_t i = 0; i < fitTable.size(); i++) {
|
||||
std::cout << fitTable[i][0] << " | "
|
||||
<< fitTable[i][1] << " | "
|
||||
<< fitTable[i][2] << " | "
|
||||
<< fitTable[i][3] << " | "
|
||||
<< fitTable[i][4] << std::endl;
|
||||
std::cout << (const char*)fitTable[i][0].toLocal8Bit() << " | "
|
||||
<< (const char*)fitTable[i][1].toLocal8Bit() << " | "
|
||||
<< (const char*)fitTable[i][2].toLocal8Bit() << " | "
|
||||
<< (const char*)fitTable[i][3].toLocal8Bit() << " | "
|
||||
<< (const char*)fitTable[i][4].toLocal8Bit() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -103,7 +103,7 @@ int main(int argc, char *argv[])
|
||||
std::ofstream ofs;
|
||||
ofs.open("report.txt", std::ofstream::out);
|
||||
for (size_t i = 0; i < report.size(); i++) {
|
||||
ofs << report[i] << std::endl;
|
||||
ofs << (const char*)report[i].toLocal8Bit() << std::endl;
|
||||
}
|
||||
ofs.close();
|
||||
}
|
||||
|
@ -903,7 +903,7 @@ struct tagbstring t;
|
||||
return bninchrr ((bstring) this, pos, &t);
|
||||
}
|
||||
|
||||
const CBString CBString::midstr (int left, int len) const {
|
||||
CBString CBString::midstr (int left, int len) const {
|
||||
struct tagbstring t;
|
||||
if (left < 0) {
|
||||
len += left;
|
||||
|
@ -317,7 +317,7 @@ struct CBString : public tagbstring {
|
||||
void findreplacecaseless (const char * find, const char * repl, int pos = 0);
|
||||
|
||||
// Extraction method.
|
||||
const CBString midstr (int left, int len) const;
|
||||
CBString midstr (int left, int len) const;
|
||||
|
||||
// Standard manipulation methods.
|
||||
void setsubstr (int pos, const CBString& b, unsigned char fill = ' ');
|
||||
@ -362,8 +362,11 @@ struct CBString : public tagbstring {
|
||||
int read (bNread readPtr, void * parm);
|
||||
|
||||
// QString compatibility methods
|
||||
CBString toLocal8Bit() { return *this; }
|
||||
bool isEmpty() const { return slen == 0; }
|
||||
void clear() { *this = ""; }
|
||||
CBString left(int len) { return midstr(0, len); }
|
||||
CBString mid(int pos, int len) { return midstr(pos, len); }
|
||||
static CBString fromUtf16(const ushort* str) { // Naive implementation assuming that only ASCII part of UCS2 is used
|
||||
CBString msg; while (*str) { msg += *(char*)str; str++; } return msg;
|
||||
}
|
||||
|
@ -4137,8 +4137,8 @@ USTATUS FfsParser::parseSlicMarkerHeader(const UByteArray & store, const UINT32
|
||||
markerHeader->Size, markerHeader->Size,
|
||||
header.size(), header.size(),
|
||||
markerHeader->Version,
|
||||
(const char*)UString((const char*)&(markerHeader->OemId), 6),
|
||||
(const char*)UString((const char*)&(markerHeader->OemTableId), 8),
|
||||
(const char*)UString((const char*)&(markerHeader->OemId)).left(6).toLocal8Bit(),
|
||||
(const char*)UString((const char*)&(markerHeader->OemTableId)).left(8).toLocal8Bit(),
|
||||
markerHeader->SlicVersion);
|
||||
|
||||
// Add correct offset
|
||||
|
@ -44,9 +44,9 @@ QVariant TreeModel::data(const UModelIndex &index, int role) const
|
||||
TreeItem *item = static_cast<TreeItem*>(index.internalPointer());
|
||||
|
||||
if (role == Qt::DisplayRole)
|
||||
return (const char*)item->data(index.column());
|
||||
return (const char*)item->data(index.column()).toLocal8Bit();
|
||||
else
|
||||
return (const char*)item->info();
|
||||
return (const char*)item->info().toLocal8Bit();
|
||||
}
|
||||
|
||||
Qt::ItemFlags TreeModel::flags(const UModelIndex &index) const
|
||||
|
@ -15,7 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
//TODO: modify properly
|
||||
|
||||
#ifndef QT_CORE_LIB
|
||||
#if defined(QT_CORE_LIB) && defined (U_USE_QSTRING)
|
||||
UString usprintf(const char* fmt, ...)
|
||||
{
|
||||
UString msg;
|
||||
|
@ -13,9 +13,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#ifndef USTRING_H
|
||||
#define USTRING_H
|
||||
|
||||
//TODO: modify properly
|
||||
|
||||
#ifndef QT_CORE_LIB
|
||||
#if defined (QT_CORE_LIB) && defined(U_USE_QSTRING)
|
||||
// Use Qt class, if Qt is available
|
||||
#include <QString>
|
||||
#define UString QString
|
||||
|
Loading…
Reference in New Issue
Block a user