Skip to content

Commit

Permalink
feat: add Edit plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
hello-adam authored Feb 17, 2023
2 parents 59f69f5 + d5dd8a6 commit 9c091e5
Show file tree
Hide file tree
Showing 18 changed files with 933 additions and 206 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ CMakeLists.txt.user
*.pro.user
*.autosave
/build*
/build-debug
/src/build
.vscode
*.so
Expand Down
202 changes: 1 addition & 201 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"del": "^5.1.0",
"filecompare": "^1.0.4",
"glob": "^7.1.6",
"husky": "^4.2.4",
"node-7z": "^2.1.1",
"semantic-release": "^17.0.4",
"yargs": "^15.3.1"
Expand Down
95 changes: 95 additions & 0 deletions src/hobbits-core/bitarray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,101 @@ QSharedPointer<BitArray> BitArray::fromString(QString bitArraySpec, QStringList
}
}

char BitArray::hexTable(qint64 nibble) const {
char chr;
switch (nibble) {
case 0:
chr = '0';
break;
case 1:
chr = '1';
break;
case 2:
chr = '2';
break;
case 3:
chr = '3';
break;
case 4:
chr = '4';
break;
case 5:
chr = '5';
break;
case 6:
chr = '6';
break;
case 7:
chr = '7';
break;
case 8:
chr = '8';
break;
case 9:
chr = '9';
break;
case 10:
chr = 'a';
break;
case 11:
chr = 'b';
break;
case 12:
chr = 'c';
break;
case 13:
chr = 'd';
break;
case 14:
chr = 'e';
break;
case 15:
chr = 'f';
break;
default:
chr = 'o';
}
return chr;
}

QString BitArray::toBin(qint64 start, int length) const {
QString str = "";
if (start + length <= this->sizeInBits()) {
for (quint64 i = start; i < start + length; i ++) {
if (this->at(i) == false) {
str+="0";
} else {
str+="1";
}
}
}
return str;
}

QString BitArray::toHex(qint64 start, int length) const {
QString str = "";
quint64 nib = 0;
if (start + length <= this->sizeInBits()/4) {
for (quint64 i = start*4; i < start*4+length*4; i += 4) {
nib = this->parseUIntValue(i, 4);
str += hexTable(nib);
}
}
return str;
}

QString BitArray::toAscii(qint64 start, int length) const {
QByteArray arr = readBytes(start, length);
for (int i = 0; i < length; i++) {
if (arr[i] < 32) {
arr[i] = '.';
}
}
QString qtext = QString::fromLatin1(arr);

return qtext;
}

BitArray::CacheLoadLocker::CacheLoadLocker(qint64 bitIndex, const BitArray *bitArray) :
m_locker(&bitArray->m_cacheMutex) {
qint64 srcCacheIdx = bitIndex / CACHE_CHUNK_BIT_SIZE;
Expand Down
Loading

0 comments on commit 9c091e5

Please sign in to comment.