MCPcopy Index your code
hub / github.com/DreamSourceLab/DSView / export_start

Method export_start

DSView/pv/storesession.cpp:796–852  ·  view source on GitHub ↗

export as csv file

Source from the content-addressed store, hash-verified

794
795//export as csv file
796bool StoreSession::export_start()
797{
798 std::set<int> type_set;
799 for(auto s : _session->get_signals()) {
800 int _tp = s->get_type();
801 type_set.insert(_tp);
802 }
803
804 if (type_set.size() > 1) {
805 _error = L_S(STR_PAGE_DLG, S_ID(IDS_MSG_STORESESS_EXPORTSTART_ERROR1),
806 "DSView does not currently support\nfile export for multiple data types.");
807 return false;
808 } else if (type_set.size() == 0) {
809 _error = L_S(STR_PAGE_DLG, S_ID(IDS_MSG_STORESESS_EXPORTSTART_ERROR2), "No data to save.");
810 return false;
811 }
812
813 const auto snapshot = _session->get_snapshot(*type_set.begin());
814 assert(snapshot);
815 // Check we have data
816 if (snapshot->empty()) {
817 _error = L_S(STR_PAGE_DLG, S_ID(IDS_MSG_STORESESS_EXPORTSTART_ERROR2), "No data to save.");
818 return false;
819 }
820
821 if (_file_name == ""){
822 _error = L_S(STR_PAGE_DLG, S_ID(IDS_MSG_STORESESS_EXPORTSTART_ERROR3), "No set file name.");
823 return false;
824 }
825
826 const struct sr_output_module **supportedModules = sr_output_list();
827 while (*supportedModules)
828 {
829 if (*supportedModules == NULL)
830 break;
831 if (!strcmp((*supportedModules)->id, _suffix.toUtf8().data()))
832 {
833 _outModule = *supportedModules;
834 break;
835 }
836 supportedModules++;
837 }
838
839 if (_outModule == NULL)
840 {
841 _error = L_S(STR_PAGE_DLG, S_ID(IDS_MSG_STORESESS_EXPORTSTART_ERROR4), "Invalid export format.");
842 }
843 else
844 {
845 if (_thread.joinable()) _thread.join();
846 _thread = std::thread(&StoreSession::export_proc, this, snapshot);
847 return !_has_error;
848 }
849
850 _error.clear();
851 return false;
852}
853

Callers 1

acceptMethod · 0.80

Calls 7

sr_output_listFunction · 0.85
sizeMethod · 0.80
get_snapshotMethod · 0.80
emptyMethod · 0.80
get_typeMethod · 0.45
dataMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected