SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
SimpleDeserializer Class Reference

#include <simpleserializer.h>

Classes

struct  Element
 

Public Member Functions

 SimpleDeserializer (const QByteArray &data)
 
bool readS32 (quint32 id, qint32 *result, qint32 def=0) const
 
bool readU32 (quint32 id, quint32 *result, quint32 def=0) const
 
bool readS64 (quint32 id, qint64 *result, qint64 def=0) const
 
bool readU64 (quint32 id, quint64 *result, quint64 def=0) const
 
bool readFloat (quint32 id, float *result, float def=0) const
 
bool readDouble (quint32 id, double *result, double def=0) const
 
bool readReal (quint32 id, Real *result, Real def=0) const
 
bool readBool (quint32 id, bool *result, bool def=false) const
 
bool readString (quint32 id, QString *result, const QString &def=QString::null) const
 
bool readBlob (quint32 id, QByteArray *result, const QByteArray &def=QByteArray()) const
 
bool isValid () const
 
quint32 getVersion () const
 
void dump () const
 

Private Types

enum  Type {
  TSigned32 = 0, TUnsigned32 = 1, TSigned64 = 2, TUnsigned64 = 3,
  TFloat = 4, TDouble = 5, TBool = 6, TString = 7,
  TBlob = 8, TVersion = 9
}
 
typedef QMap< quint32, ElementElements
 

Private Member Functions

bool parseAll ()
 
bool readTag (uint *readOfs, uint readEnd, Type *type, quint32 *id, quint32 *length) const
 
quint8 readByte (uint *readOfs) const
 

Private Attributes

QByteArray m_data
 
bool m_valid
 
Elements m_elements
 
quint32 m_version
 

Detailed Description

Definition at line 51 of file simpleserializer.h.

Member Typedef Documentation

◆ Elements

typedef QMap<quint32, Element> SimpleDeserializer::Elements
private

Definition at line 95 of file simpleserializer.h.

Member Enumeration Documentation

◆ Type

Enumerator
TSigned32 
TUnsigned32 
TSigned64 
TUnsigned64 
TFloat 
TDouble 
TBool 
TString 
TBlob 
TVersion 

Definition at line 71 of file simpleserializer.h.

Constructor & Destructor Documentation

◆ SimpleDeserializer()

SimpleDeserializer::SimpleDeserializer ( const QByteArray &  data)

Definition at line 297 of file simpleserializer.cpp.

References i, m_elements, m_valid, m_version, parseAll(), readByte(), and TVersion.

297  :
298  m_data(data)
299 {
300  m_valid = parseAll();
301 
302  // read version information
303  uint readOfs;
304  Elements::const_iterator it = m_elements.constFind(0);
305  if(it == m_elements.constEnd())
306  goto setInvalid;
307  if(it->type != TVersion)
308  goto setInvalid;
309  if(it->length > 4)
310  goto setInvalid;
311 
312  readOfs = it->ofs;
313  m_version = 0;
314  for(uint i = 0; i < it->length; i++)
315  m_version = (m_version << 8) | readByte(&readOfs);
316  return;
317 
318 setInvalid:
319  m_valid = false;
320 }
quint8 readByte(uint *readOfs) const
int32_t i
Definition: decimators.h:244
+ Here is the call graph for this function:

Member Function Documentation

◆ dump()

void SimpleDeserializer::dump ( ) const

Definition at line 587 of file simpleserializer.cpp.

References m_elements, m_valid, m_version, PRINTF_FORMAT_S32, PRINTF_FORMAT_U32, readBlob(), readBool(), readDouble(), readFloat(), readS32(), readS64(), readString(), readU32(), readU64(), TBlob, TBool, TDouble, TFloat, TSigned32, TSigned64, TString, TUnsigned32, TUnsigned64, and TVersion.

588 {
589  if(!m_valid) {
590  qDebug("SimpleDeserializer dump: data invalid");
591  return;
592  } else {
593  qDebug("SimpleDeserializer dump: version %u", m_version);
594  }
595 
596  for(Elements::const_iterator it = m_elements.constBegin(); it != m_elements.constEnd(); ++it) {
597  switch(it->type) {
598  case TSigned32: {
599  qint32 tmp;
600  readS32(it.key(), &tmp);
601  qDebug("id %d, S32, len %d: " PRINTF_FORMAT_S32, it.key(), it->length, tmp);
602  break;
603  }
604  case TUnsigned32: {
605  quint32 tmp;
606  readU32(it.key(), &tmp);
607  qDebug("id %d, U32, len %d: " PRINTF_FORMAT_U32, it.key(), it->length, tmp);
608  break;
609  }
610  case TSigned64: {
611  qint64 tmp;
612  readS64(it.key(), &tmp);
613 // qDebug("id %d, S64, len %d: " PRINTF_FORMAT_S64, it.key(), it->length, (int)tmp);
614  break;
615  }
616  case TUnsigned64: {
617  quint64 tmp;
618  readU64(it.key(), &tmp);
619 // qDebug("id %d, U64, len %d: " PRINTF_FORMAT_U64, it.key(), it->length, (uint)tmp);
620  break;
621  }
622  case TFloat: {
623  float tmp;
624  readFloat(it.key(), &tmp);
625  qDebug("id %d, FLOAT, len %d: %f", it.key(), it->length, tmp);
626  break;
627  }
628  case TDouble: {
629  double tmp;
630  readDouble(it.key(), &tmp);
631  qDebug("id %d, DOUBLE, len %d: %f", it.key(), it->length, tmp);
632  break;
633  }
634  case TBool: {
635  bool tmp;
636  readBool(it.key(), &tmp);
637  qDebug("id %d, BOOL, len %d: %s", it.key(), it->length, tmp ? "true" : "false");
638  break;
639  }
640  case TString: {
641  QString tmp;
642  readString(it.key(), &tmp);
643  qDebug("id %d, STRING, len %d: \"%s\"", it.key(), it->length, qPrintable(tmp));
644  break;
645  }
646  case TBlob: {
647  QByteArray tmp;
648  readBlob(it.key(), &tmp);
649  qDebug("id %d, BLOB, len %d", it.key(), it->length);
650  break;
651  }
652  case TVersion: {
653  qDebug("id %d, VERSION, len %d", it.key(), it->length);
654  break;
655  }
656  default: {
657  qDebug("id %d, UNKNOWN TYPE 0x%02x, len %d", it.key(), it->type, it->length);
658  break;
659  }
660  }
661  }
662 }
bool readFloat(quint32 id, float *result, float def=0) const
bool readS64(quint32 id, qint64 *result, qint64 def=0) const
#define PRINTF_FORMAT_U32
bool readU32(quint32 id, quint32 *result, quint32 def=0) const
bool readDouble(quint32 id, double *result, double def=0) const
bool readString(quint32 id, QString *result, const QString &def=QString::null) const
bool readBool(quint32 id, bool *result, bool def=false) const
bool readS32(quint32 id, qint32 *result, qint32 def=0) const
bool readBlob(quint32 id, QByteArray *result, const QByteArray &def=QByteArray()) const
bool readU64(quint32 id, quint64 *result, quint64 def=0) const
#define PRINTF_FORMAT_S32
+ Here is the call graph for this function:

◆ getVersion()

quint32 SimpleDeserializer::getVersion ( ) const
inline

Definition at line 67 of file simpleserializer.h.

Referenced by Preferences::deserialize(), LoRaDemodSettings::deserialize(), FileSinkSettings::deserialize(), LocalOutputSettings::deserialize(), GLSpectrumGUI::deserialize(), LocalInputSettings::deserialize(), RemoteInputSettings::deserialize(), Command::deserialize(), FileInputSettings::deserialize(), KiwiSDRSettings::deserialize(), BladeRF2OutputSettings::deserialize(), RemoteOutputSettings::deserialize(), BladeRF1OutputSettings::deserialize(), RemoteSourceSettings::deserialize(), LocalSourceSettings::deserialize(), LocalSinkSettings::deserialize(), FileSourceSettings::deserialize(), AirspyHFSettings::deserialize(), HackRFOutputSettings::deserialize(), SoapySDROutputSettings::deserialize(), HackRFInputSettings::deserialize(), DeviceUserArgs::deserialize(), BladeRF2InputSettings::deserialize(), WFMDemodSettings::deserialize(), ATVDemodGUI::deserialize(), AirspySettings::deserialize(), BladeRF1InputSettings::deserialize(), FCDProPlusSettings::deserialize(), PerseusSettings::deserialize(), RTLSDRSettings::deserialize(), RemoteSinkSettings::deserialize(), CWKeyerSettings::deserialize(), BFMDemodSettings::deserialize(), XTRXOutputSettings::deserialize(), AMDemodSettings::deserialize(), SDRPlaySettings::deserialize(), PlutoSDROutputSettings::deserialize(), GLScopeGUI::deserialize(), NFMDemodSettings::deserialize(), SSBDemodSettings::deserialize(), ChannelAnalyzerSettings::deserialize(), FreqTrackerSettings::deserialize(), FreeDVDemodSettings::deserialize(), FCDProSettings::deserialize(), SoapySDRInputSettings::deserialize(), DSDDemodSettings::deserialize(), AMModSettings::deserialize(), WFMModSettings::deserialize(), XTRXInputSettings::deserialize(), Preset::deserialize(), LimeSDROutputSettings::deserialize(), NFMModSettings::deserialize(), TestSourceSettings::deserialize(), UDPSourceSettings::deserialize(), FreeDVModSettings::deserialize(), SSBModSettings::deserialize(), TestMISettings::deserialize(), LimeSDRInputSettings::deserialize(), UDPSinkSettings::deserialize(), ChannelMarker::deserialize(), PlutoSDRInputSettings::deserialize(), ATVModSettings::deserialize(), ATVDemodSettings::deserialize(), DATVDemodSettings::deserialize(), DoubleBufferSimple< Sample >::deserialize(), AudioDeviceManager::deserialize(), ScopeVis::TraceBackBuffer::deserialize(), ScopeVis::TraceBackDiscreteMemory::deserialize(), ScopeVis::deserializeMemory(), and SampleSourceSerializer::readSerializedData().

67 { return m_version; }
+ Here is the caller graph for this function:

◆ isValid()

bool SimpleDeserializer::isValid ( ) const
inline

Definition at line 66 of file simpleserializer.h.

Referenced by Preferences::deserialize(), LoRaDemodSettings::deserialize(), FileSinkSettings::deserialize(), LocalOutputSettings::deserialize(), GLSpectrumGUI::deserialize(), LocalInputSettings::deserialize(), RemoteInputSettings::deserialize(), Command::deserialize(), FileInputSettings::deserialize(), KiwiSDRSettings::deserialize(), BladeRF2OutputSettings::deserialize(), RemoteOutputSettings::deserialize(), BladeRF1OutputSettings::deserialize(), RemoteSourceSettings::deserialize(), LocalSourceSettings::deserialize(), LocalSinkSettings::deserialize(), FileSourceSettings::deserialize(), AirspyHFSettings::deserialize(), HackRFOutputSettings::deserialize(), SoapySDROutputSettings::deserialize(), HackRFInputSettings::deserialize(), DeviceUserArgs::deserialize(), BladeRF2InputSettings::deserialize(), WFMDemodSettings::deserialize(), ATVDemodGUI::deserialize(), AirspySettings::deserialize(), BladeRF1InputSettings::deserialize(), FCDProPlusSettings::deserialize(), PerseusSettings::deserialize(), RTLSDRSettings::deserialize(), RemoteSinkSettings::deserialize(), CWKeyerSettings::deserialize(), BFMDemodSettings::deserialize(), XTRXOutputSettings::deserialize(), AMDemodSettings::deserialize(), SDRPlaySettings::deserialize(), PlutoSDROutputSettings::deserialize(), GLScopeGUI::deserialize(), NFMDemodSettings::deserialize(), SSBDemodSettings::deserialize(), ChannelAnalyzerSettings::deserialize(), FreqTrackerSettings::deserialize(), FreeDVDemodSettings::deserialize(), FCDProSettings::deserialize(), SoapySDRInputSettings::deserialize(), DSDDemodSettings::deserialize(), AMModSettings::deserialize(), WFMModSettings::deserialize(), XTRXInputSettings::deserialize(), Preset::deserialize(), LimeSDROutputSettings::deserialize(), NFMModSettings::deserialize(), TestSourceSettings::deserialize(), UDPSourceSettings::deserialize(), FreeDVModSettings::deserialize(), SSBModSettings::deserialize(), TestMISettings::deserialize(), LimeSDRInputSettings::deserialize(), UDPSinkSettings::deserialize(), ChannelMarker::deserialize(), PlutoSDRInputSettings::deserialize(), ATVModSettings::deserialize(), ATVDemodSettings::deserialize(), DATVDemodSettings::deserialize(), DoubleBufferSimple< Sample >::deserialize(), AudioDeviceManager::deserialize(), ScopeVis::TraceBackBuffer::deserialize(), ScopeVis::TraceBackDiscreteMemory::deserialize(), ScopeVis::deserializeMemory(), and SampleSourceSerializer::readSerializedData().

66 { return m_valid; }
+ Here is the caller graph for this function:

◆ parseAll()

bool SimpleDeserializer::parseAll ( )
private

Definition at line 664 of file simpleserializer.cpp.

References m_data, m_elements, and readTag().

Referenced by SimpleDeserializer().

665 {
666  uint readOfs = 0;
667  Type type;
668  quint32 id;
669  quint32 length;
670 
671  /*
672  QString hex;
673  for(int i = 0; i < m_data.size(); i++)
674  hex.append(QString("%1 ").arg((quint8)m_data[i], 2, 16, QChar('0')));
675  qDebug("%s", qPrintable(hex));
676  qDebug("==");
677  */
678 
679  while(readOfs < (uint)m_data.size()) {
680  if(!readTag(&readOfs, m_data.size(), &type, &id, &length))
681  return false;
682 
683  //qDebug("-- id %d, TYPE 0x%02x, len %d", id, type, length);
684 
685  if(m_elements.contains(id)) {
686  qDebug("SimpleDeserializer: same ID found twice (id %u)", id);
687  return false;
688  }
689 
690  m_elements.insert(id, Element(type, readOfs, length));
691 
692  readOfs += length;
693 
694  if(readOfs == (uint)m_data.size())
695  return true;
696  }
697  return false;
698 }
bool readTag(uint *readOfs, uint readEnd, Type *type, quint32 *id, quint32 *length) const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readBlob()

bool SimpleDeserializer::readBlob ( quint32  id,
QByteArray *  result,
const QByteArray &  def = QByteArray() 
) const

Definition at line 571 of file simpleserializer.cpp.

References m_data, m_elements, and TBlob.

Referenced by LoRaDemodSettings::deserialize(), SoapySDROutputSettings::deserialize(), DeviceUserArgs::deserialize(), WFMDemodSettings::deserialize(), BFMDemodSettings::deserialize(), AMDemodSettings::deserialize(), SSBDemodSettings::deserialize(), NFMDemodSettings::deserialize(), ChannelAnalyzerSettings::deserialize(), FreqTrackerSettings::deserialize(), FreeDVDemodSettings::deserialize(), DSDDemodSettings::deserialize(), SoapySDRInputSettings::deserialize(), AMModSettings::deserialize(), WFMModSettings::deserialize(), Preset::deserialize(), NFMModSettings::deserialize(), UDPSourceSettings::deserialize(), FreeDVModSettings::deserialize(), SSBModSettings::deserialize(), UDPSinkSettings::deserialize(), ATVModSettings::deserialize(), DATVDemodSettings::deserialize(), DoubleBufferSimple< Sample >::deserialize(), AudioDeviceManager::deserialize(), ScopeVis::TraceBackBuffer::deserialize(), ScopeVis::TraceBackDiscreteMemory::deserialize(), ScopeVis::deserializeMemory(), and dump().

572 {
573  Elements::const_iterator it = m_elements.constFind(id);
574  if(it == m_elements.constEnd())
575  goto returnDefault;
576  if(it->type != TBlob)
577  goto returnDefault;
578 
579  *result = QByteArray(m_data.data() + it->ofs, it->length);
580  return true;
581 
582 returnDefault:
583  *result = def;
584  return false;
585 }
+ Here is the caller graph for this function:

◆ readBool()

bool SimpleDeserializer::readBool ( quint32  id,
bool *  result,
bool  def = false 
) const

Definition at line 531 of file simpleserializer.cpp.

References m_elements, readByte(), and TBool.

Referenced by Preferences::deserialize(), LocalInputSettings::deserialize(), GLSpectrumGUI::deserialize(), RemoteInputSettings::deserialize(), Command::deserialize(), BladeRF2OutputSettings::deserialize(), FileInputSettings::deserialize(), KiwiSDRSettings::deserialize(), RemoteOutputSettings::deserialize(), RemoteSourceSettings::deserialize(), BladeRF1OutputSettings::deserialize(), LocalSourceSettings::deserialize(), LocalSinkSettings::deserialize(), FileSourceSettings::deserialize(), AirspyHFSettings::deserialize(), HackRFOutputSettings::deserialize(), SoapySDROutputSettings::deserialize(), HackRFInputSettings::deserialize(), BladeRF2InputSettings::deserialize(), WFMDemodSettings::deserialize(), ATVDemodGUI::deserialize(), AirspySettings::deserialize(), BladeRF1InputSettings::deserialize(), FCDProPlusSettings::deserialize(), PerseusSettings::deserialize(), RTLSDRSettings::deserialize(), CWKeyerSettings::deserialize(), RemoteSinkSettings::deserialize(), XTRXOutputSettings::deserialize(), BFMDemodSettings::deserialize(), AMDemodSettings::deserialize(), SDRPlaySettings::deserialize(), NFMDemodSettings::deserialize(), SSBDemodSettings::deserialize(), GLScopeGUI::deserialize(), PlutoSDROutputSettings::deserialize(), ChannelAnalyzerSettings::deserialize(), FreqTrackerSettings::deserialize(), FreeDVDemodSettings::deserialize(), FCDProSettings::deserialize(), DSDDemodSettings::deserialize(), SoapySDRInputSettings::deserialize(), AMModSettings::deserialize(), WFMModSettings::deserialize(), XTRXInputSettings::deserialize(), Preset::deserialize(), TestSourceSettings::deserialize(), LimeSDROutputSettings::deserialize(), NFMModSettings::deserialize(), UDPSourceSettings::deserialize(), FreeDVModSettings::deserialize(), SSBModSettings::deserialize(), LimeSDRInputSettings::deserialize(), TestMISettings::deserialize(), UDPSinkSettings::deserialize(), PlutoSDRInputSettings::deserialize(), ATVModSettings::deserialize(), ATVDemodSettings::deserialize(), DATVDemodSettings::deserialize(), and dump().

532 {
533  uint readOfs;
534  quint8 tmp;
535  Elements::const_iterator it = m_elements.constFind(id);
536  if(it == m_elements.constEnd())
537  goto returnDefault;
538  if(it->type != TBool)
539  goto returnDefault;
540  if(it->length != 1)
541  goto returnDefault;
542 
543  readOfs = it->ofs;
544  tmp = readByte(&readOfs);
545  if(tmp == 0x00)
546  *result = false;
547  else *result = true;
548  return true;
549 
550 returnDefault:
551  *result = def;
552  return false;
553 }
quint8 readByte(uint *readOfs) const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readByte()

quint8 SimpleDeserializer::readByte ( uint *  readOfs) const
inlineprivate

Definition at line 104 of file simpleserializer.h.

Referenced by readBool(), readDouble(), readFloat(), readReal(), readS32(), readS64(), readTag(), readU32(), readU64(), and SimpleDeserializer().

105  {
106  quint8 res = m_data[*readOfs];
107  (*readOfs)++;
108  return res;
109  }
+ Here is the caller graph for this function:

◆ readDouble()

bool SimpleDeserializer::readDouble ( quint32  id,
double *  result,
double  def = 0 
) const

Definition at line 450 of file simpleserializer.cpp.

References doubleasint::d, i, m_elements, readByte(), TDouble, and doubleasint::u.

Referenced by SoapySDROutputSettings::deserialize(), XTRXOutputSettings::deserialize(), SoapySDRInputSettings::deserialize(), XTRXInputSettings::deserialize(), and dump().

451 {
452  uint readOfs;
453  union doubleasint tmp;
454  Elements::const_iterator it = m_elements.constFind(id);
455  if(it == m_elements.constEnd())
456  goto returnDefault;
457  if(it->type != TDouble)
458  goto returnDefault;
459  if(it->length != 8)
460  goto returnDefault;
461 
462  readOfs = it->ofs;
463  tmp.u = 0;
464  for(int i = 0; i < 8; i++)
465  tmp.u = (tmp.u << 8) | readByte(&readOfs);
466  *result = tmp.d;
467  return true;
468 
469 returnDefault:
470  *result = def;
471  return false;
472 }
quint8 readByte(uint *readOfs) const
int32_t i
Definition: decimators.h:244
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readFloat()

bool SimpleDeserializer::readFloat ( quint32  id,
float *  result,
float  def = 0 
) const

Definition at line 426 of file simpleserializer.cpp.

References floatasint::f, i, m_elements, readByte(), TFloat, and floatasint::u.

Referenced by Preferences::deserialize(), RemoteOutputSettings::deserialize(), XTRXOutputSettings::deserialize(), GLScopeGUI::deserialize(), FreqTrackerSettings::deserialize(), XTRXInputSettings::deserialize(), TestSourceSettings::deserialize(), LimeSDROutputSettings::deserialize(), LimeSDRInputSettings::deserialize(), TestMISettings::deserialize(), DATVDemodSettings::deserialize(), and dump().

427 {
428  uint readOfs;
429  union floatasint tmp;
430  Elements::const_iterator it = m_elements.constFind(id);
431  if(it == m_elements.constEnd())
432  goto returnDefault;
433  if(it->type != TFloat)
434  goto returnDefault;
435  if(it->length != 4)
436  goto returnDefault;
437 
438  readOfs = it->ofs;
439  tmp.u = 0;
440  for(int i = 0; i < 4; i++)
441  tmp.u = (tmp.u << 8) | readByte(&readOfs);
442  *result = tmp.f;
443  return true;
444 
445 returnDefault:
446  *result = def;
447  return false;
448 }
quint8 readByte(uint *readOfs) const
int32_t i
Definition: decimators.h:244
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readReal()

bool SimpleDeserializer::readReal ( quint32  id,
Real result,
Real  def = 0 
) const

Definition at line 484 of file simpleserializer.cpp.

References i, m_elements, real4asint::r, real8asint::r, readByte(), TDouble, TFloat, real4asint::u, and real8asint::u.

Referenced by GLSpectrumGUI::deserialize(), AMModSettings::deserialize(), WFMModSettings::deserialize(), NFMModSettings::deserialize(), UDPSourceSettings::deserialize(), SSBModSettings::deserialize(), UDPSinkSettings::deserialize(), and ATVModSettings::deserialize().

485 {
486  if(sizeof(Real) == 4) {
487  uint readOfs;
488  union real4asint tmp;
489  Elements::const_iterator it = m_elements.constFind(id);
490  if(it == m_elements.constEnd())
491  goto returnDefault32;
492  if(it->type != TFloat)
493  goto returnDefault32;
494  if(it->length != 4)
495  goto returnDefault32;
496 
497  readOfs = it->ofs;
498  tmp.u = 0;
499  for(int i = 0; i < 4; i++)
500  tmp.u = (tmp.u << 8) | readByte(&readOfs);
501  *result = tmp.r;
502  return true;
503 
504  returnDefault32:
505  *result = def;
506  return false;
507  } else {
508  uint readOfs;
509  union real8asint tmp;
510  Elements::const_iterator it = m_elements.constFind(id);
511  if(it == m_elements.constEnd())
512  goto returnDefault64;
513  if(it->type != TDouble)
514  goto returnDefault64;
515  if(it->length != 8)
516  goto returnDefault64;
517 
518  readOfs = it->ofs;
519  tmp.u = 0;
520  for(int i = 0; i < 8; i++)
521  tmp.u = (tmp.u << 8) | readByte(&readOfs);
522  *result = tmp.r;
523  return true;
524 
525  returnDefault64:
526  *result = def;
527  return false;
528  }
529 }
quint8 readByte(uint *readOfs) const
int32_t i
Definition: decimators.h:244
float Real
Definition: dsptypes.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readS32()

bool SimpleDeserializer::readS32 ( quint32  id,
qint32 *  result,
qint32  def = 0 
) const

Definition at line 322 of file simpleserializer.cpp.

References i, m_elements, readByte(), and TSigned32.

Referenced by Preferences::deserialize(), LoRaDemodSettings::deserialize(), GLSpectrumGUI::deserialize(), Command::deserialize(), BladeRF2OutputSettings::deserialize(), BladeRF1OutputSettings::deserialize(), FileSourceSettings::deserialize(), AirspyHFSettings::deserialize(), HackRFOutputSettings::deserialize(), HackRFInputSettings::deserialize(), SoapySDROutputSettings::deserialize(), BladeRF2InputSettings::deserialize(), WFMDemodSettings::deserialize(), ATVDemodGUI::deserialize(), BladeRF1InputSettings::deserialize(), FCDProPlusSettings::deserialize(), PerseusSettings::deserialize(), RTLSDRSettings::deserialize(), CWKeyerSettings::deserialize(), AirspySettings::deserialize(), BFMDemodSettings::deserialize(), XTRXOutputSettings::deserialize(), SDRPlaySettings::deserialize(), AMDemodSettings::deserialize(), NFMDemodSettings::deserialize(), SSBDemodSettings::deserialize(), GLScopeGUI::deserialize(), PlutoSDROutputSettings::deserialize(), ChannelAnalyzerSettings::deserialize(), FreqTrackerSettings::deserialize(), FreeDVDemodSettings::deserialize(), FCDProSettings::deserialize(), SoapySDRInputSettings::deserialize(), DSDDemodSettings::deserialize(), AMModSettings::deserialize(), WFMModSettings::deserialize(), XTRXInputSettings::deserialize(), Preset::deserialize(), TestSourceSettings::deserialize(), NFMModSettings::deserialize(), LimeSDROutputSettings::deserialize(), UDPSourceSettings::deserialize(), FreeDVModSettings::deserialize(), SSBModSettings::deserialize(), TestMISettings::deserialize(), LimeSDRInputSettings::deserialize(), UDPSinkSettings::deserialize(), ChannelMarker::deserialize(), PlutoSDRInputSettings::deserialize(), ATVModSettings::deserialize(), ATVDemodSettings::deserialize(), DATVDemodSettings::deserialize(), DoubleBufferSimple< Sample >::deserialize(), ScopeVis::deserializeMemory(), dump(), and SampleSourceSerializer::readSerializedData().

323 {
324  uint readOfs;
325  qint32 tmp;
326  Elements::const_iterator it = m_elements.constFind(id);
327  if(it == m_elements.constEnd())
328  goto returnDefault;
329  if(it->type != TSigned32)
330  goto returnDefault;
331  if(it->length > 4)
332  goto returnDefault;
333 
334  readOfs = it->ofs;
335  tmp = 0;
336  for(uint i = 0; i < it->length; i++) {
337  quint8 byte = readByte(&readOfs);
338  if((i == 0) && (byte & 0x80))
339  tmp = -1;
340  tmp = (tmp << 8) | byte;
341  }
342  *result = tmp;
343  return true;
344 
345 returnDefault:
346  *result = def;
347  return false;
348 }
quint8 readByte(uint *readOfs) const
int32_t i
Definition: decimators.h:244
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readS64()

bool SimpleDeserializer::readS64 ( quint32  id,
qint64 *  result,
qint64  def = 0 
) const

Definition at line 374 of file simpleserializer.cpp.

References i, m_elements, readByte(), and TSigned64.

Referenced by BladeRF2OutputSettings::deserialize(), AirspyHFSettings::deserialize(), SoapySDROutputSettings::deserialize(), BladeRF2InputSettings::deserialize(), FCDProPlusSettings::deserialize(), AirspySettings::deserialize(), PerseusSettings::deserialize(), RTLSDRSettings::deserialize(), PlutoSDROutputSettings::deserialize(), FCDProSettings::deserialize(), SoapySDRInputSettings::deserialize(), LimeSDROutputSettings::deserialize(), LimeSDRInputSettings::deserialize(), PlutoSDRInputSettings::deserialize(), and dump().

375 {
376  uint readOfs;
377  qint64 tmp;
378  Elements::const_iterator it = m_elements.constFind(id);
379  if(it == m_elements.constEnd())
380  goto returnDefault;
381  if(it->type != TSigned64)
382  goto returnDefault;
383  if(it->length > 8)
384  goto returnDefault;
385 
386  readOfs = it->ofs;
387  tmp = 0;
388  for(uint i = 0; i < it->length; i++) {
389  quint8 byte = readByte(&readOfs);
390  if((i == 0) && (byte & 0x80))
391  tmp = -1;
392  tmp = (tmp << 8) | byte;
393  }
394  *result = tmp;
395  return true;
396 
397 returnDefault:
398  *result = def;
399  return false;
400 }
quint8 readByte(uint *readOfs) const
int32_t i
Definition: decimators.h:244
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readString()

bool SimpleDeserializer::readString ( quint32  id,
QString *  result,
const QString &  def = QString::null 
) const

Definition at line 555 of file simpleserializer.cpp.

References m_data, m_elements, and TString.

Referenced by Preferences::deserialize(), LoRaDemodSettings::deserialize(), LocalOutputSettings::deserialize(), LocalInputSettings::deserialize(), RemoteInputSettings::deserialize(), Command::deserialize(), FileInputSettings::deserialize(), KiwiSDRSettings::deserialize(), BladeRF2OutputSettings::deserialize(), RemoteOutputSettings::deserialize(), RemoteSourceSettings::deserialize(), BladeRF1OutputSettings::deserialize(), LocalSourceSettings::deserialize(), LocalSinkSettings::deserialize(), FileSourceSettings::deserialize(), AirspyHFSettings::deserialize(), HackRFOutputSettings::deserialize(), SoapySDROutputSettings::deserialize(), HackRFInputSettings::deserialize(), WFMDemodSettings::deserialize(), BladeRF2InputSettings::deserialize(), AirspySettings::deserialize(), BladeRF1InputSettings::deserialize(), FCDProPlusSettings::deserialize(), PerseusSettings::deserialize(), RTLSDRSettings::deserialize(), RemoteSinkSettings::deserialize(), CWKeyerSettings::deserialize(), XTRXOutputSettings::deserialize(), BFMDemodSettings::deserialize(), SDRPlaySettings::deserialize(), AMDemodSettings::deserialize(), SSBDemodSettings::deserialize(), NFMDemodSettings::deserialize(), PlutoSDROutputSettings::deserialize(), ChannelAnalyzerSettings::deserialize(), FreqTrackerSettings::deserialize(), FreeDVDemodSettings::deserialize(), FCDProSettings::deserialize(), SoapySDRInputSettings::deserialize(), DSDDemodSettings::deserialize(), AMModSettings::deserialize(), WFMModSettings::deserialize(), XTRXInputSettings::deserialize(), Preset::deserialize(), TestSourceSettings::deserialize(), NFMModSettings::deserialize(), LimeSDROutputSettings::deserialize(), UDPSourceSettings::deserialize(), FreeDVModSettings::deserialize(), SSBModSettings::deserialize(), LimeSDRInputSettings::deserialize(), TestMISettings::deserialize(), UDPSinkSettings::deserialize(), ChannelMarker::deserialize(), PlutoSDRInputSettings::deserialize(), ATVModSettings::deserialize(), DATVDemodSettings::deserialize(), and dump().

556 {
557  Elements::const_iterator it = m_elements.constFind(id);
558  if(it == m_elements.constEnd())
559  goto returnDefault;
560  if(it->type != TString)
561  goto returnDefault;
562 
563  *result = QString::fromUtf8(m_data.data() + it->ofs, it->length);
564  return true;
565 
566 returnDefault:
567  *result = def;
568  return false;
569 }
+ Here is the caller graph for this function:

◆ readTag()

bool SimpleDeserializer::readTag ( uint *  readOfs,
uint  readEnd,
Type type,
quint32 *  id,
quint32 *  length 
) const
private

Definition at line 700 of file simpleserializer.cpp.

References i, and readByte().

Referenced by parseAll().

701 {
702  quint8 tag = readByte(readOfs);
703 
704  *type = (Type)(tag >> 4);
705  int idLen = ((tag >> 2) & 0x03) + 1;
706  int lengthLen = (tag & 0x03) + 1;
707 
708  // make sure we have enough header bytes left
709  if(((*readOfs) + idLen + lengthLen) > readEnd)
710  return false;
711 
712  quint32 tmp = 0;
713  for(int i = 0; i < idLen; i++)
714  tmp = (tmp << 8) | readByte(readOfs);
715  *id = tmp;
716  tmp = 0;
717  for(int i = 0; i < lengthLen; i++)
718  tmp = (tmp << 8) | readByte(readOfs);
719  *length = tmp;
720 
721  // check if payload fits the buffer
722  if(((*readOfs) + (*length)) > readEnd)
723  return false;
724  else return true;
725 }
quint8 readByte(uint *readOfs) const
int32_t i
Definition: decimators.h:244
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readU32()

bool SimpleDeserializer::readU32 ( quint32  id,
quint32 *  result,
quint32  def = 0 
) const

Definition at line 350 of file simpleserializer.cpp.

References i, m_elements, readByte(), and TUnsigned32.

Referenced by FileSinkSettings::deserialize(), LocalOutputSettings::deserialize(), LocalInputSettings::deserialize(), RemoteInputSettings::deserialize(), FileInputSettings::deserialize(), KiwiSDRSettings::deserialize(), BladeRF2OutputSettings::deserialize(), RemoteOutputSettings::deserialize(), RemoteSourceSettings::deserialize(), BladeRF1OutputSettings::deserialize(), LocalSinkSettings::deserialize(), LocalSourceSettings::deserialize(), FileSourceSettings::deserialize(), AirspyHFSettings::deserialize(), HackRFOutputSettings::deserialize(), SoapySDROutputSettings::deserialize(), HackRFInputSettings::deserialize(), BladeRF2InputSettings::deserialize(), WFMDemodSettings::deserialize(), AirspySettings::deserialize(), BladeRF1InputSettings::deserialize(), FCDProPlusSettings::deserialize(), PerseusSettings::deserialize(), RTLSDRSettings::deserialize(), CWKeyerSettings::deserialize(), RemoteSinkSettings::deserialize(), XTRXOutputSettings::deserialize(), BFMDemodSettings::deserialize(), AMDemodSettings::deserialize(), SDRPlaySettings::deserialize(), SSBDemodSettings::deserialize(), GLScopeGUI::deserialize(), NFMDemodSettings::deserialize(), PlutoSDROutputSettings::deserialize(), ChannelAnalyzerSettings::deserialize(), FreqTrackerSettings::deserialize(), FreeDVDemodSettings::deserialize(), FCDProSettings::deserialize(), DSDDemodSettings::deserialize(), SoapySDRInputSettings::deserialize(), AMModSettings::deserialize(), WFMModSettings::deserialize(), XTRXInputSettings::deserialize(), TestSourceSettings::deserialize(), NFMModSettings::deserialize(), LimeSDROutputSettings::deserialize(), UDPSourceSettings::deserialize(), FreeDVModSettings::deserialize(), SSBModSettings::deserialize(), TestMISettings::deserialize(), LimeSDRInputSettings::deserialize(), UDPSinkSettings::deserialize(), ChannelMarker::deserialize(), PlutoSDRInputSettings::deserialize(), ATVModSettings::deserialize(), DATVDemodSettings::deserialize(), DoubleBufferSimple< Sample >::deserialize(), ScopeVis::TraceBackBuffer::deserialize(), ScopeVis::TraceBackDiscreteMemory::deserialize(), ScopeVis::deserializeMemory(), dump(), and SampleSourceSerializer::readSerializedData().

351 {
352  uint readOfs;
353  quint32 tmp;
354  Elements::const_iterator it = m_elements.constFind(id);
355  if(it == m_elements.constEnd())
356  goto returnDefault;
357  if(it->type != TUnsigned32)
358  goto returnDefault;
359  if(it->length > 4)
360  goto returnDefault;
361 
362  readOfs = it->ofs;
363  tmp = 0;
364  for(uint i = 0; i < it->length; i++)
365  tmp = (tmp << 8) | readByte(&readOfs);
366  *result = tmp;
367  return true;
368 
369 returnDefault:
370  *result = def;
371  return false;
372 }
quint8 readByte(uint *readOfs) const
int32_t i
Definition: decimators.h:244
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readU64()

bool SimpleDeserializer::readU64 ( quint32  id,
quint64 *  result,
quint64  def = 0 
) const

Definition at line 402 of file simpleserializer.cpp.

References i, m_elements, readByte(), and TUnsigned64.

Referenced by FileSinkSettings::deserialize(), RemoteOutputSettings::deserialize(), HackRFOutputSettings::deserialize(), HackRFInputSettings::deserialize(), PlutoSDROutputSettings::deserialize(), Preset::deserialize(), PlutoSDRInputSettings::deserialize(), dump(), and SampleSourceSerializer::readSerializedData().

403 {
404  uint readOfs;
405  quint64 tmp;
406  Elements::const_iterator it = m_elements.constFind(id);
407  if(it == m_elements.constEnd())
408  goto returnDefault;
409  if(it->type != TUnsigned64)
410  goto returnDefault;
411  if(it->length > 8)
412  goto returnDefault;
413 
414  readOfs = it->ofs;
415  tmp = 0;
416  for(uint i = 0; i < it->length; i++)
417  tmp = (tmp << 8) | readByte(&readOfs);
418  *result = tmp;
419  return true;
420 
421 returnDefault:
422  *result = def;
423  return false;
424 }
quint8 readByte(uint *readOfs) const
int32_t i
Definition: decimators.h:244
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_data

QByteArray SimpleDeserializer::m_data
private

Definition at line 97 of file simpleserializer.h.

Referenced by parseAll(), readBlob(), and readString().

◆ m_elements

Elements SimpleDeserializer::m_elements
private

◆ m_valid

bool SimpleDeserializer::m_valid
private

Definition at line 98 of file simpleserializer.h.

Referenced by dump(), and SimpleDeserializer().

◆ m_version

quint32 SimpleDeserializer::m_version
private

Definition at line 100 of file simpleserializer.h.

Referenced by dump(), and SimpleDeserializer().


The documentation for this class was generated from the following files: