mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-12 23:26:10 -05:00
Make DataTree throw exception objects, instead of dynamically allocated ones for simplicity
This commit is contained in:
parent
cf06709cb4
commit
2f84df3c47
@ -2485,10 +2485,10 @@ bool AppFrame::loadSession(std::string fileName) {
|
||||
|
||||
std::cout << "Loading session file version: '" << version << "'..." << std::endl;
|
||||
}
|
||||
catch (DataTypeMismatchException* e) {
|
||||
catch (DataTypeMismatchException e) {
|
||||
//this is for managing the old session format NOT encoded as std:wstring,
|
||||
//force current version
|
||||
std::cout << "Warning while Loading session file version, probably old format :'" << e->what() << "' please consider re-saving the current session..." << std::endl;
|
||||
std::cout << "Warning while Loading session file version, probably old format :'" << e.what() << "' please consider re-saving the current session..." << std::endl << std::flush;
|
||||
version = wxString(CUBICSDR_VERSION).ToStdWstring();
|
||||
}
|
||||
}
|
||||
@ -2612,7 +2612,7 @@ bool AppFrame::loadSession(std::string fileName) {
|
||||
if (loadedActiveDemod || newDemod) {
|
||||
wxGetApp().getDemodMgr().setActiveDemodulator(loadedActiveDemod?loadedActiveDemod:newDemod, false);
|
||||
}
|
||||
} catch (DataTypeMismatchException &e) {
|
||||
} catch (DataTypeMismatchException e) {
|
||||
std::cout << e.what() << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
@ -582,9 +582,8 @@ std::wstring BookmarkMgr::getSafeWstringValue(DataNode* node, const std::string&
|
||||
try {
|
||||
childNode->element()->get(decodedWString);
|
||||
|
||||
} catch (DataTypeMismatchException* e) {
|
||||
} catch (DataTypeMismatchException e) {
|
||||
//2) wstring decode fail, try simple std::string
|
||||
delete e;
|
||||
std::string decodedStdString;
|
||||
try {
|
||||
|
||||
@ -593,9 +592,8 @@ std::wstring BookmarkMgr::getSafeWstringValue(DataNode* node, const std::string&
|
||||
//use wxString for a clean conversion to a wstring:
|
||||
decodedWString = wxString(decodedStdString).ToStdWstring();
|
||||
|
||||
} catch (DataTypeMismatchException* e) {
|
||||
} catch (DataTypeMismatchException e) {
|
||||
//nothing works, return an empty string.
|
||||
delete e;
|
||||
decodedWString = L"";
|
||||
}
|
||||
}
|
||||
|
@ -443,9 +443,8 @@ std::wstring DemodulatorMgr::getSafeWstringValue(DataNode* node) {
|
||||
try {
|
||||
node->element()->get(decodedWString);
|
||||
|
||||
} catch (DataTypeMismatchException* e) {
|
||||
} catch (DataTypeMismatchException e) {
|
||||
//2) wstring decode fail, try simple std::string
|
||||
delete e;
|
||||
std::string decodedStdString;
|
||||
try {
|
||||
|
||||
@ -454,8 +453,7 @@ std::wstring DemodulatorMgr::getSafeWstringValue(DataNode* node) {
|
||||
//use wxString for a clean conversion to a wstring:
|
||||
decodedWString = wxString(decodedStdString).ToStdWstring();
|
||||
|
||||
} catch (DataTypeMismatchException* e) {
|
||||
delete e;
|
||||
} catch (DataTypeMismatchException e) {
|
||||
//nothing works, return an empty string.
|
||||
decodedWString = L"";
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ return; \
|
||||
} \
|
||||
} \
|
||||
if (!compat) { \
|
||||
throw(new DataTypeMismatchException("Type mismatch, element type " #enumtype " is not compatible with a " #datatype)); \
|
||||
throw(DataTypeMismatchException("Type mismatch, element type " #enumtype " is not compatible with a " #datatype)); \
|
||||
} \
|
||||
if (sizeof(datatype) < data_size) { \
|
||||
std::cout << "Warning, data type mismatch requested size for '" << #datatype << "(" << sizeof(datatype) << ")' < data size '" << data_size << "'; possible loss of data."; \
|
||||
@ -254,7 +254,7 @@ return; \
|
||||
} \
|
||||
} \
|
||||
if (!compat) { \
|
||||
throw(new DataTypeMismatchException("Type mismatch, element type " #enumtype " is not compatible with a " #datatype)); \
|
||||
throw(DataTypeMismatchException("Type mismatch, element type " #enumtype " is not compatible with a " #datatype)); \
|
||||
} \
|
||||
if (data_type == DATA_FLOAT || data_type == DATA_DOUBLE) { \
|
||||
if (sizeof(datatype) < data_size) { \
|
||||
@ -286,7 +286,7 @@ DataElementGetFloatingPointDef(DATA_DOUBLE, double, DATA_FLOAT, DATA_CHAR, DATA_
|
||||
|
||||
void DataElement::get(char **data_in) {
|
||||
if (data_type != DATA_VOID)
|
||||
throw(new DataTypeMismatchException("Type mismatch, not a CHAR*"));
|
||||
throw(DataTypeMismatchException("Type mismatch, not a CHAR*"));
|
||||
*data_in = new char[data_size];
|
||||
memcpy(*data_in, data_val, data_size);
|
||||
}
|
||||
@ -296,7 +296,7 @@ void DataElement::get(string &str_in) {
|
||||
return;
|
||||
|
||||
if (data_type != DATA_STRING)
|
||||
throw(new DataTypeMismatchException("Type mismatch, not a STRING"));
|
||||
throw(DataTypeMismatchException("Type mismatch, not a STRING"));
|
||||
|
||||
if (!str_in.empty()) // flush the string
|
||||
{
|
||||
@ -313,7 +313,7 @@ void DataElement::get(wstring &wstr_in) {
|
||||
return;
|
||||
|
||||
if (data_type != DATA_WSTRING)
|
||||
throw(new DataTypeMismatchException("Type mismatch, not a WSTRING"));
|
||||
throw(DataTypeMismatchException("Type mismatch, not a WSTRING"));
|
||||
|
||||
// flush the string
|
||||
wstr_in.clear();
|
||||
@ -342,7 +342,7 @@ void DataElement::get(vector<string> &strvect_in) {
|
||||
return;
|
||||
|
||||
if (data_type != DATA_STR_VECTOR)
|
||||
throw(new DataTypeMismatchException("Type mismatch, not a STRING VECTOR"));
|
||||
throw(DataTypeMismatchException("Type mismatch, not a STRING VECTOR"));
|
||||
|
||||
ptr = 0;
|
||||
|
||||
@ -358,7 +358,7 @@ void DataElement::get(std::set<string> &strset_in) {
|
||||
return;
|
||||
|
||||
if (data_type != DATA_STR_VECTOR)
|
||||
throw(new DataTypeMismatchException("Type mismatch, not a STRING VECTOR/SET"));
|
||||
throw(DataTypeMismatchException("Type mismatch, not a STRING VECTOR/SET"));
|
||||
|
||||
std::vector<string> tmp_vect;
|
||||
std::vector<string>::iterator i;
|
||||
@ -382,7 +382,7 @@ if (data_type != enumtype) { \
|
||||
} \
|
||||
} \
|
||||
if (!compat) { \
|
||||
throw(new DataTypeMismatchException("Type mismatch, element type is not compatible with a " #datatype)); \
|
||||
throw(DataTypeMismatchException("Type mismatch, element type is not compatible with a " #datatype)); \
|
||||
} \
|
||||
if (sizeof(datatype) < unit_size) { \
|
||||
std::cout << "Warning, data type mismatch for vector<" #datatype ">; " #datatype " size " << sizeof(datatype) << " is less than unit size " << unit_size << "; possible loss of data."; \
|
||||
|
@ -205,7 +205,7 @@ public:
|
||||
unsigned int getUInt() { unsigned int i_get; get(i_get); return i_get; };
|
||||
long getLong() { long l_get; get(l_get); return l_get; };
|
||||
unsigned long getULong() { unsigned long l_get; get(l_get); return l_get; };
|
||||
long getLongLong() { long long l_get; get(l_get); return l_get; };
|
||||
long long getLongLong() { long long l_get; get(l_get); return l_get; };
|
||||
float getFloat() { float f_get; get(f_get); return f_get; };
|
||||
double getDouble() { double d_get; get(d_get); return d_get; };
|
||||
long double getLongDouble() { long double d_get; get(d_get); return d_get; };
|
||||
|
Loading…
Reference in New Issue
Block a user