MCPcopy Create free account
hub / github.com/DreamSourceLab/DSView / get_decoder_json_from_data_file

Method get_decoder_json_from_data_file

DSView/pv/mainwindow.cpp:1739–1777  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1737 }
1738
1739 QJsonArray MainWindow::get_decoder_json_from_data_file(QString file, bool &bSucesss)
1740 {
1741 QJsonArray dec_array;
1742 QJsonParseError error;
1743
1744 bSucesss = false;
1745
1746 if (file == ""){
1747 dsv_err("File name is empty.");
1748 assert(false);
1749 }
1750
1751 /* read "decoders" */
1752 auto f_name = path::ConvertPath(file);
1753 ZipReader rd(f_name.c_str());
1754 auto *data = rd.GetInnterFileData("decoders");
1755
1756 if (data != NULL)
1757 {
1758 QByteArray raw_bytes = QByteArray::fromRawData(data->data(), data->size());
1759 QString jsonStr(raw_bytes.data());
1760 QByteArray qbs = jsonStr.toUtf8();
1761 QJsonDocument sessionDoc = QJsonDocument::fromJson(qbs, &error);
1762
1763 if (error.error != QJsonParseError::NoError)
1764 {
1765 QString estr = error.errorString();
1766 dsv_err("MainWindow::get_decoder_json_from_file(), parse json error:\"%s\"!", estr.toUtf8().data());
1767 }
1768 else{
1769 bSucesss = true;
1770 }
1771
1772 dec_array = sessionDoc.array();
1773 rd.ReleaseInnerFileData(data);
1774 }
1775
1776 return dec_array;
1777 }
1778
1779 void MainWindow::update_toolbar_view_status()
1780 {

Callers

nothing calls this directly

Calls 5

ConvertPathFunction · 0.85
GetInnterFileDataMethod · 0.80
sizeMethod · 0.80
ReleaseInnerFileDataMethod · 0.80
dataMethod · 0.45

Tested by

no test coverage detected