mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-09-06 23:27:53 -04:00
DataTree refactoring / 64-bit expansion
This commit is contained in:
parent
aa13aa2e16
commit
cf2b11f496
@ -31,6 +31,8 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define STRINGIFY(A) #A
|
||||
|
||||
DataElement::DataElement() {
|
||||
data_type = DATA_NULL;
|
||||
data_val = NULL;
|
||||
@ -180,6 +182,120 @@ void DataElement::set(std::set<string> &strset_in) {
|
||||
set(tmp_vect);
|
||||
}
|
||||
|
||||
void DataElement::set(vector<char>& charvect_in) {
|
||||
long ptr;
|
||||
char temp_char;
|
||||
|
||||
data_type = DATA_CHAR_VECTOR;
|
||||
|
||||
data_init(sizeof(char) * charvect_in.size());
|
||||
|
||||
vector<char>::iterator i;
|
||||
|
||||
ptr = 0;
|
||||
|
||||
for (i = charvect_in.begin(); i != charvect_in.end(); i++) {
|
||||
temp_char = *i;
|
||||
memcpy(data_val + ptr, &temp_char, sizeof(char));
|
||||
ptr += sizeof(char);
|
||||
}
|
||||
}
|
||||
|
||||
void DataElement::set(vector<unsigned char>& ucharvect_in) {
|
||||
long ptr;
|
||||
unsigned char temp_uchar;
|
||||
|
||||
data_type = DATA_UCHAR_VECTOR;
|
||||
|
||||
data_init(sizeof(unsigned char) * ucharvect_in.size());
|
||||
|
||||
vector<unsigned char>::iterator i;
|
||||
|
||||
ptr = 0;
|
||||
|
||||
for (i = ucharvect_in.begin(); i != ucharvect_in.end(); i++) {
|
||||
temp_uchar = *i;
|
||||
memcpy(data_val + ptr, &temp_uchar, sizeof(unsigned char));
|
||||
ptr += sizeof(unsigned char);
|
||||
}
|
||||
}
|
||||
|
||||
void DataElement::set(vector<unsigned int>& uintvect_in) {
|
||||
long ptr;
|
||||
unsigned int temp_uint;
|
||||
|
||||
data_type = DATA_UCHAR_VECTOR;
|
||||
|
||||
data_init(sizeof(unsigned int) * uintvect_in.size());
|
||||
|
||||
vector<unsigned int>::iterator i;
|
||||
|
||||
ptr = 0;
|
||||
|
||||
for (i = uintvect_in.begin(); i != uintvect_in.end(); i++) {
|
||||
temp_uint = *i;
|
||||
memcpy(data_val + ptr, &temp_uint, sizeof(unsigned int));
|
||||
ptr += sizeof(unsigned int);
|
||||
}
|
||||
}
|
||||
|
||||
void DataElement::set(vector<unsigned long>& ulongvect_in) {
|
||||
long ptr;
|
||||
unsigned long temp_ulong;
|
||||
|
||||
data_type = DATA_ULONG_VECTOR;
|
||||
|
||||
data_init(sizeof(unsigned long) * ulongvect_in.size());
|
||||
|
||||
vector<unsigned long>::iterator i;
|
||||
|
||||
ptr = 0;
|
||||
|
||||
for (i = ulongvect_in.begin(); i != ulongvect_in.end(); i++) {
|
||||
temp_ulong = *i;
|
||||
memcpy(data_val + ptr, &temp_ulong, sizeof(unsigned long));
|
||||
ptr += sizeof(unsigned long);
|
||||
}
|
||||
}
|
||||
|
||||
void DataElement::set(vector<long long>& llongvect_in) {
|
||||
long ptr;
|
||||
long long temp_llong;
|
||||
|
||||
data_type = DATA_CHAR_VECTOR;
|
||||
|
||||
data_init(sizeof(long long) * llongvect_in.size());
|
||||
|
||||
vector<long long>::iterator i;
|
||||
|
||||
ptr = 0;
|
||||
|
||||
for (i = llongvect_in.begin(); i != llongvect_in.end(); i++) {
|
||||
temp_llong = *i;
|
||||
memcpy(data_val + ptr, &temp_llong, sizeof(long long));
|
||||
ptr += sizeof(long long);
|
||||
}
|
||||
}
|
||||
|
||||
void DataElement::set(vector<long double>& ldoublevect_in) {
|
||||
long ptr;
|
||||
long double temp_ldouble;
|
||||
|
||||
data_type = DATA_CHAR_VECTOR;
|
||||
|
||||
data_init(sizeof(long double) * ldoublevect_in.size());
|
||||
|
||||
vector<long double>::iterator i;
|
||||
|
||||
ptr = 0;
|
||||
|
||||
for (i = ldoublevect_in.begin(); i != ldoublevect_in.end(); i++) {
|
||||
temp_ldouble = *i;
|
||||
memcpy(data_val + ptr, &temp_ldouble, sizeof(long double));
|
||||
ptr += sizeof(long double);
|
||||
}
|
||||
}
|
||||
|
||||
void DataElement::set(vector<int> &intvect_in) {
|
||||
long ptr;
|
||||
int temp_int;
|
||||
@ -259,79 +375,119 @@ void DataElement::set(vector<double> &doublevect_in) {
|
||||
}
|
||||
}
|
||||
|
||||
//void DataElement::get(bool &bool_in) throw (DataTypeMismatchException)
|
||||
//{
|
||||
// if (!data_type) return;
|
||||
// if (data_type != DATA_BOOL) throw(new DataTypeMismatchException("Type mismatch, not a BOOL"));
|
||||
#define DataElementGetNumericDef(enumtype, datatype) void DataElement::get(datatype& val_out) throw (DataTypeMismatchException) { \
|
||||
if (!data_type) \
|
||||
return; \
|
||||
if (data_type != enumtype) { \
|
||||
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."; \
|
||||
} \
|
||||
memset(&val_out, 0, sizeof(datatype)); \
|
||||
memcpy(&val_out, data_val, (sizeof(datatype) < data_size) ? sizeof(datatype) : data_size); \
|
||||
} \
|
||||
memcpy(&val_out, data_val, data_size); \
|
||||
}
|
||||
|
||||
DataElementGetNumericDef(DATA_CHAR, char)
|
||||
DataElementGetNumericDef(DATA_UCHAR, unsigned char)
|
||||
DataElementGetNumericDef(DATA_UINT, unsigned int)
|
||||
DataElementGetNumericDef(DATA_ULONG, unsigned long)
|
||||
DataElementGetNumericDef(DATA_LONGLONG, long long)
|
||||
DataElementGetNumericDef(DATA_LONGDOUBLE, long double)
|
||||
DataElementGetNumericDef(DATA_INT, int)
|
||||
DataElementGetNumericDef(DATA_LONG, long)
|
||||
DataElementGetNumericDef(DATA_FLOAT, float)
|
||||
DataElementGetNumericDef(DATA_DOUBLE, double)
|
||||
|
||||
////void DataElement::get(char& char_in) throw (DataTypeMismatchException) {
|
||||
////if (!data_type)
|
||||
//// return;
|
||||
////if (data_type != DATA_CHAR)
|
||||
//// throw(new DataTypeMismatchException("Type mismatch, not a INT"));
|
||||
////
|
||||
////memcpy(&char_in, data_val, data_size);
|
||||
////}
|
||||
//
|
||||
// memcpy(&bool_in, data_val, data_size);
|
||||
////void DataElement::get(unsigned char& uchar_in) throw (DataTypeMismatchException) {
|
||||
////if (!data_type)
|
||||
//// return;
|
||||
////if (data_type != DATA_UCHAR)
|
||||
//// throw(new DataTypeMismatchException("Type mismatch, not a INT"));
|
||||
////
|
||||
////memcpy(&uchar_in, data_val, data_size);
|
||||
////}
|
||||
//
|
||||
////void DataElement::get(unsigned int& uint_in) throw (DataTypeMismatchException) {
|
||||
////if (!data_type)
|
||||
//// return;
|
||||
////if (data_type != DATA_UINT)
|
||||
//// throw(new DataTypeMismatchException("Type mismatch, not a INT"));
|
||||
////
|
||||
////memcpy(&uint_in, data_val, data_size);
|
||||
////}
|
||||
//
|
||||
////void DataElement::get(unsigned long & ulong_in) throw (DataTypeMismatchException) {
|
||||
////if (!data_type)
|
||||
//// return;
|
||||
////if (data_type != DATA_ULONG)
|
||||
//// throw(new DataTypeMismatchException("Type mismatch, not a INT"));
|
||||
////
|
||||
////memcpy(&ulong_in, data_val, data_size);
|
||||
////}
|
||||
//
|
||||
////void DataElement::get(long long & long_in) throw (DataTypeMismatchException) {
|
||||
////if (!data_type)
|
||||
//// return;
|
||||
////if (data_type != DATA_LONG)
|
||||
//// throw(new DataTypeMismatchException("Type mismatch, not a INT"));
|
||||
////
|
||||
////memcpy(&long_in, data_val, data_size);
|
||||
////}
|
||||
//
|
||||
////void DataElement::get(long double& ldouble_in) throw (DataTypeMismatchException) {
|
||||
////if (!data_type)
|
||||
//// return;
|
||||
////if (data_type != DATA_LONGDOUBLE)
|
||||
//// throw(new DataTypeMismatchException("Type mismatch, not a INT"));
|
||||
////
|
||||
////memcpy(&ldouble_in, data_val, data_size);
|
||||
////}
|
||||
//
|
||||
//void DataElement::get(int &int_in) throw (DataTypeMismatchException) {
|
||||
//if (!data_type)
|
||||
// return;
|
||||
//if (data_type != DATA_INT)
|
||||
// throw(new DataTypeMismatchException("Type mismatch, not a INT"));
|
||||
//
|
||||
//memcpy(&int_in, data_val, data_size);
|
||||
//}
|
||||
//
|
||||
//void DataElement::get(long &long_in) throw (DataTypeMismatchException) {
|
||||
//if (!data_type)
|
||||
// return;
|
||||
//if (data_type != DATA_LONG)
|
||||
// throw(new DataTypeMismatchException("Type mismatch, not a LONG"));
|
||||
//
|
||||
//memcpy(&long_in, data_val, data_size);
|
||||
//}
|
||||
//
|
||||
//void DataElement::get(float &float_in) throw (DataTypeMismatchException) {
|
||||
//if (!data_type)
|
||||
// return;
|
||||
//if (data_type != DATA_FLOAT)
|
||||
// throw(new DataTypeMismatchException("Type mismatch, not a FLOAT"));
|
||||
//
|
||||
//memcpy(&float_in, data_val, data_size);
|
||||
//}
|
||||
//
|
||||
//void DataElement::get(double &double_in) throw (DataTypeMismatchException) {
|
||||
//if (!data_type)
|
||||
// return;
|
||||
//if (data_type != DATA_DOUBLE)
|
||||
// throw(new DataTypeMismatchException("Type mismatch, not a DOUBLE"));
|
||||
//
|
||||
//memcpy(&double_in, data_val, data_size);
|
||||
//}
|
||||
|
||||
void DataElement::get(char& char_in) throw (DataTypeMismatchException) {
|
||||
if (!data_type)
|
||||
return;
|
||||
}
|
||||
|
||||
void DataElement::get(unsigned char& uchar_in) throw (DataTypeMismatchException) {
|
||||
if (!data_type)
|
||||
return;
|
||||
}
|
||||
|
||||
void DataElement::get(unsigned int& uint_in) throw (DataTypeMismatchException) {
|
||||
if (!data_type)
|
||||
return;
|
||||
}
|
||||
|
||||
void DataElement::get(unsigned long & ulong_in) throw (DataTypeMismatchException) {
|
||||
if (!data_type)
|
||||
return;
|
||||
}
|
||||
|
||||
void DataElement::get(long long & long_in) throw (DataTypeMismatchException) {
|
||||
if (!data_type)
|
||||
return;
|
||||
}
|
||||
|
||||
void DataElement::get(long double& ldouble_in) throw (DataTypeMismatchException) {
|
||||
if (!data_type)
|
||||
return;
|
||||
}
|
||||
|
||||
void DataElement::get(int &int_in) throw (DataTypeMismatchException) {
|
||||
if (!data_type)
|
||||
return;
|
||||
if (data_type != DATA_INT)
|
||||
throw(new DataTypeMismatchException("Type mismatch, not a INT"));
|
||||
|
||||
memcpy(&int_in, data_val, data_size);
|
||||
}
|
||||
|
||||
void DataElement::get(long &long_in) throw (DataTypeMismatchException) {
|
||||
if (!data_type)
|
||||
return;
|
||||
if (data_type != DATA_LONG)
|
||||
throw(new DataTypeMismatchException("Type mismatch, not a LONG"));
|
||||
|
||||
memcpy(&long_in, data_val, data_size);
|
||||
}
|
||||
|
||||
void DataElement::get(float &float_in) throw (DataTypeMismatchException) {
|
||||
if (!data_type)
|
||||
return;
|
||||
if (data_type != DATA_FLOAT)
|
||||
throw(new DataTypeMismatchException("Type mismatch, not a FLOAT"));
|
||||
|
||||
memcpy(&float_in, data_val, data_size);
|
||||
}
|
||||
|
||||
void DataElement::get(double &double_in) throw (DataTypeMismatchException) {
|
||||
if (!data_type)
|
||||
return;
|
||||
if (data_type != DATA_DOUBLE)
|
||||
throw(new DataTypeMismatchException("Type mismatch, not a DOUBLE"));
|
||||
|
||||
memcpy(&double_in, data_val, data_size);
|
||||
}
|
||||
|
||||
void DataElement::get(char **data_in) throw (DataTypeMismatchException) {
|
||||
if (data_type != DATA_VOID)
|
||||
@ -389,6 +545,120 @@ void DataElement::get(std::set<string> &strset_in) throw (DataTypeMismatchExcept
|
||||
}
|
||||
}
|
||||
|
||||
void DataElement::get(vector<char>& charvect_in) throw (DataTypeMismatchException) {
|
||||
long ptr;
|
||||
if (!data_type)
|
||||
return;
|
||||
|
||||
if (data_type != DATA_CHAR_VECTOR)
|
||||
throw(new DataTypeMismatchException("Type mismatch, not a INT VECTOR"));
|
||||
|
||||
ptr = 0;
|
||||
|
||||
char temp_char;
|
||||
while (ptr < data_size) {
|
||||
temp_char = 0;
|
||||
memcpy(&temp_char, data_val + ptr, sizeof(char));
|
||||
charvect_in.push_back(temp_char);
|
||||
ptr += sizeof(char);
|
||||
}
|
||||
}
|
||||
|
||||
void DataElement::get(vector<unsigned char>& ucharvect_in) throw (DataTypeMismatchException) {
|
||||
long ptr;
|
||||
if (!data_type)
|
||||
return;
|
||||
|
||||
if (data_type != DATA_UCHAR_VECTOR)
|
||||
throw(new DataTypeMismatchException("Type mismatch, not a INT VECTOR"));
|
||||
|
||||
ptr = 0;
|
||||
|
||||
unsigned char temp_char;
|
||||
while (ptr < data_size) {
|
||||
temp_char = 0;
|
||||
memcpy(&temp_char, data_val + ptr, sizeof(unsigned char));
|
||||
ucharvect_in.push_back(temp_char);
|
||||
ptr += sizeof(unsigned char);
|
||||
}
|
||||
}
|
||||
|
||||
void DataElement::get(vector<unsigned int>& uintvect_in) throw (DataTypeMismatchException) {
|
||||
long ptr;
|
||||
if (!data_type)
|
||||
return;
|
||||
|
||||
if (data_type != DATA_UINT_VECTOR)
|
||||
throw(new DataTypeMismatchException("Type mismatch, not a INT VECTOR"));
|
||||
|
||||
ptr = 0;
|
||||
|
||||
unsigned int temp_char;
|
||||
while (ptr < data_size) {
|
||||
temp_char = 0;
|
||||
memcpy(&temp_char, data_val + ptr, sizeof(unsigned int));
|
||||
uintvect_in.push_back(temp_char);
|
||||
ptr += sizeof(unsigned int);
|
||||
}
|
||||
}
|
||||
|
||||
void DataElement::get(vector<unsigned long>& ulongvect_in) throw (DataTypeMismatchException) {
|
||||
long ptr;
|
||||
if (!data_type)
|
||||
return;
|
||||
|
||||
if (data_type != DATA_ULONG_VECTOR)
|
||||
throw(new DataTypeMismatchException("Type mismatch, not a INT VECTOR"));
|
||||
|
||||
ptr = 0;
|
||||
|
||||
unsigned long temp_char;
|
||||
while (ptr < data_size) {
|
||||
temp_char = 0;
|
||||
memcpy(&temp_char, data_val + ptr, sizeof(unsigned long));
|
||||
ulongvect_in.push_back(temp_char);
|
||||
ptr += sizeof(unsigned long);
|
||||
}
|
||||
}
|
||||
|
||||
void DataElement::get(vector<long long>& llongvect_in) throw (DataTypeMismatchException) {
|
||||
long ptr;
|
||||
if (!data_type)
|
||||
return;
|
||||
|
||||
if (data_type != DATA_LONGLONG_VECTOR)
|
||||
throw(new DataTypeMismatchException("Type mismatch, not a INT VECTOR"));
|
||||
|
||||
ptr = 0;
|
||||
|
||||
long long temp_char;
|
||||
while (ptr < data_size) {
|
||||
temp_char = 0;
|
||||
memcpy(&temp_char, data_val + ptr, sizeof(long long));
|
||||
llongvect_in.push_back(temp_char);
|
||||
ptr += sizeof(long long);
|
||||
}
|
||||
}
|
||||
|
||||
void DataElement::get(vector<long double>& ldoublevect_in) throw (DataTypeMismatchException) {
|
||||
long ptr;
|
||||
if (!data_type)
|
||||
return;
|
||||
|
||||
if (data_type != DATA_LONGDOUBLE_VECTOR)
|
||||
throw(new DataTypeMismatchException("Type mismatch, not a INT VECTOR"));
|
||||
|
||||
ptr = 0;
|
||||
|
||||
long double temp_char;
|
||||
while (ptr < data_size) {
|
||||
temp_char = 0;
|
||||
memcpy(&temp_char, data_val + ptr, sizeof(long double));
|
||||
ldoublevect_in.push_back(temp_char);
|
||||
ptr += sizeof(long double);
|
||||
}
|
||||
}
|
||||
|
||||
void DataElement::get(vector<int> &intvect_in) throw (DataTypeMismatchException) {
|
||||
long ptr;
|
||||
if (!data_type)
|
||||
@ -488,42 +758,6 @@ long DataElement::getSerialized(char **ser_str) {
|
||||
return ser_size;
|
||||
}
|
||||
|
||||
void DataElement::set(vector<char>& charvect_in) {
|
||||
}
|
||||
|
||||
void DataElement::set(vector<unsigned char>& ucharvect_in) {
|
||||
}
|
||||
|
||||
void DataElement::set(vector<unsigned int>& uintvect_in) {
|
||||
}
|
||||
|
||||
void DataElement::set(vector<unsigned long>& ulongvect_in) {
|
||||
}
|
||||
|
||||
void DataElement::set(vector<long long>& llongvect_in) {
|
||||
}
|
||||
|
||||
void DataElement::set(vector<long double>& ldoublevect_in) {
|
||||
}
|
||||
|
||||
void DataElement::get(vector<char>& charvect_in) throw (DataTypeMismatchException) {
|
||||
}
|
||||
|
||||
void DataElement::get(vector<unsigned char>& ucharvect_in) throw (DataTypeMismatchException) {
|
||||
}
|
||||
|
||||
void DataElement::get(vector<unsigned int>& uintvect_in) throw (DataTypeMismatchException) {
|
||||
}
|
||||
|
||||
void DataElement::get(vector<unsigned long>& ulongvect_in) throw (DataTypeMismatchException) {
|
||||
}
|
||||
|
||||
void DataElement::get(vector<long long>& llongvect_in) throw (DataTypeMismatchException) {
|
||||
}
|
||||
|
||||
void DataElement::get(vector<long double>& ldoublevect_in) throw (DataTypeMismatchException) {
|
||||
}
|
||||
|
||||
void DataElement::setSerialized(char *ser_str) {
|
||||
char *ser_pointer = ser_str;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user