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.
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
SimpleSerializer Class Reference

#include <simpleserializer.h>

Public Member Functions

 SimpleSerializer (quint32 version)
 
void writeS32 (quint32 id, qint32 value)
 
void writeU32 (quint32 id, quint32 value)
 
void writeS64 (quint32 id, qint64 value)
 
void writeU64 (quint32 id, quint64 value)
 
void writeFloat (quint32 id, float value)
 
void writeDouble (quint32 id, double value)
 
void writeReal (quint32 id, Real value)
 
void writeBool (quint32 id, bool value)
 
void writeString (quint32 id, const QString &value)
 
void writeBlob (quint32 id, const QByteArray &value)
 
const QByteArray & final ()
 

Protected Types

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

Protected Member Functions

bool writeTag (Type type, quint32 id, quint32 length)
 

Protected Attributes

QByteArray m_data
 
bool m_finalized
 

Detailed Description

Definition at line 9 of file simpleserializer.h.

Member Enumeration Documentation

◆ Type

enum SimpleSerializer::Type
protected
Enumerator
TSigned32 
TUnsigned32 
TSigned64 
TUnsigned64 
TFloat 
TDouble 
TBool 
TString 
TBlob 
TVersion 

Definition at line 32 of file simpleserializer.h.

Constructor & Destructor Documentation

◆ SimpleSerializer()

SimpleSerializer::SimpleSerializer ( quint32  version)

Definition at line 20 of file simpleserializer.cpp.

References i, m_data, TVersion, and writeTag().

20  :
21  m_data(),
22  m_finalized(false)
23 {
24  m_data.reserve(100);
25 
26  // write version information
27  int length;
28  if(version >= (1 << 24))
29  length = 4;
30  else if(version >= (1 << 16))
31  length = 3;
32  else if(version >= (1 << 8))
33  length = 2;
34  else if(version > 0)
35  length = 1;
36  else length = 0;
37  if(!writeTag(TVersion, 0, length))
38  return;
39  length--;
40  for(int i = length; i >= 0; i--)
41  m_data.push_back((char)((version >> (i * 8)) & 0xff));
42 }
bool writeTag(Type type, quint32 id, quint32 length)
int32_t i
Definition: decimators.h:244
+ Here is the call graph for this function:

Member Function Documentation

◆ final()

const QByteArray & SimpleSerializer::final ( )

Definition at line 257 of file simpleserializer.cpp.

References m_data, and m_finalized.

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

258 {
259  m_finalized = true;
260  return m_data;
261 }
+ Here is the caller graph for this function:

◆ writeBlob()

void SimpleSerializer::writeBlob ( quint32  id,
const QByteArray &  value 
)

Definition at line 245 of file simpleserializer.cpp.

References m_data, TBlob, and writeTag().

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

246 {
247  if(id == 0) {
248  qCritical("SimpleSerializer: ID 0 is not allowed");
249  return;
250  }
251 
252  if(!writeTag(TBlob, id, value.size()))
253  return;
254  m_data.append(value);
255 }
bool writeTag(Type type, quint32 id, quint32 length)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeBool()

void SimpleSerializer::writeBool ( quint32  id,
bool  value 
)

Definition at line 218 of file simpleserializer.cpp.

References m_data, TBool, and writeTag().

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

219 {
220  if(id == 0) {
221  qCritical("SimpleSerializer: ID 0 is not allowed");
222  return;
223  }
224 
225  if(!writeTag(TBool, id, 1))
226  return;
227  if(value)
228  m_data.push_back((char)0x01);
229  else m_data.push_back((char)0x00);
230 }
bool writeTag(Type type, quint32 id, quint32 length)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeDouble()

void SimpleSerializer::writeDouble ( quint32  id,
double  value 
)

Definition at line 196 of file simpleserializer.cpp.

References doubleasint::d, m_data, TDouble, doubleasint::u, and writeTag().

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

197 {
198  union doubleasint tmp;
199  if(id == 0) {
200  qCritical("SimpleSerializer: ID 0 is not allowed");
201  return;
202  }
203 
204  if(!writeTag(TDouble, id, 8))
205  return;
206 
207  tmp.d = value;
208  m_data.push_back((char)((tmp.u >> 56) & 0xff));
209  m_data.push_back((char)((tmp.u >> 48) & 0xff));
210  m_data.push_back((char)((tmp.u >> 40) & 0xff));
211  m_data.push_back((char)((tmp.u >> 32) & 0xff));
212  m_data.push_back((char)((tmp.u >> 24) & 0xff));
213  m_data.push_back((char)((tmp.u >> 16) & 0xff));
214  m_data.push_back((char)((tmp.u >> 8) & 0xff));
215  m_data.push_back((char)(tmp.u & 0xff));
216 }
bool writeTag(Type type, quint32 id, quint32 length)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeFloat()

void SimpleSerializer::writeFloat ( quint32  id,
float  value 
)

Definition at line 173 of file simpleserializer.cpp.

References floatasint::f, m_data, TFloat, floatasint::u, and writeTag().

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

174 {
175  union floatasint tmp;
176  if(id == 0) {
177  qCritical("SimpleSerializer: ID 0 is not allowed");
178  return;
179  }
180 
181  if(!writeTag(TFloat, id, 4))
182  return;
183 
184  tmp.f = value;
185  m_data.push_back((char)((tmp.u >> 24) & 0xff));
186  m_data.push_back((char)((tmp.u >> 16) & 0xff));
187  m_data.push_back((char)((tmp.u >> 8) & 0xff));
188  m_data.push_back((char)(tmp.u & 0xff));
189 }
bool writeTag(Type type, quint32 id, quint32 length)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeReal()

void SimpleSerializer::writeReal ( quint32  id,
Real  value 
)
inline

Definition at line 19 of file simpleserializer.h.

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

20  {
21  if(sizeof(Real) == 4)
22  writeFloat(id, value);
23  else writeDouble(id, value);
24  }
void writeDouble(quint32 id, double value)
void writeFloat(quint32 id, float value)
float Real
Definition: dsptypes.h:42
+ Here is the caller graph for this function:

◆ writeS32()

void SimpleSerializer::writeS32 ( quint32  id,
qint32  value 
)

Definition at line 44 of file simpleserializer.cpp.

References i, m_data, TSigned32, and writeTag().

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

45 {
46  int length;
47 
48  if(id == 0) {
49  qCritical("SimpleSerializer: ID 0 is not allowed");
50  return;
51  }
52 
53  if((value < -(1 << 23)) || (value >= (1 << 23)))
54  length = 4;
55  else if((value < -(1 << 15)) || (value >= (1 << 15)))
56  length = 3;
57  else if((value < -(1 << 7)) || (value >= (1 << 7)))
58  length = 2;
59  else if(value != 0)
60  length = 1;
61  else length = 0;
62 
63  if(!writeTag(TSigned32, id, length))
64  return;
65 
66  length--;
67  for(int i = length; i >= 0; i--)
68  m_data.push_back((char)((value >> (i * 8)) & 0xff));
69 }
bool writeTag(Type type, quint32 id, quint32 length)
int32_t i
Definition: decimators.h:244
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeS64()

void SimpleSerializer::writeS64 ( quint32  id,
qint64  value 
)

Definition at line 98 of file simpleserializer.cpp.

References i, m_data, TSigned64, and writeTag().

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

99 {
100  int length;
101 
102  if(id == 0) {
103  qCritical("SimpleSerializer: ID 0 is not allowed");
104  return;
105  }
106 
107  if((value < -(1ll << 55)) || (value >= (1ll << 55)))
108  length = 8;
109  else if((value < -(1ll << 47)) || (value >= (1ll << 47)))
110  length = 7;
111  else if((value < -(1ll << 39)) || (value >= (1ll << 39)))
112  length = 6;
113  else if((value < -(1ll << 31)) || (value >= (1ll << 31)))
114  length = 5;
115  else if((value < -(1ll << 23)) || (value >= (1ll << 23)))
116  length = 4;
117  else if((value < -(1ll << 15)) || (value >= (1ll << 15)))
118  length = 3;
119  else if((value < -(1ll << 7)) || (value >= (1ll << 7)))
120  length = 2;
121  else if(value != 0)
122  length = 1;
123  else length = 0;
124 
125  if(!writeTag(TSigned64, id, length))
126  return;
127 
128  length--;
129  for(int i = length; i >= 0; i--)
130  m_data.push_back((char)((value >> (i * 8)) & 0xff));
131 }
bool writeTag(Type type, quint32 id, quint32 length)
int32_t i
Definition: decimators.h:244
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeString()

void SimpleSerializer::writeString ( quint32  id,
const QString &  value 
)

Definition at line 232 of file simpleserializer.cpp.

References m_data, TString, and writeTag().

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

233 {
234  if(id == 0) {
235  qCritical("SimpleSerializer: ID 0 is not allowed");
236  return;
237  }
238 
239  QByteArray utf8 = value.toUtf8();
240  if(!writeTag(TString, id, utf8.size()))
241  return;
242  m_data.append(utf8);
243 }
bool writeTag(Type type, quint32 id, quint32 length)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeTag()

bool SimpleSerializer::writeTag ( Type  type,
quint32  id,
quint32  length 
)
protected

Definition at line 263 of file simpleserializer.cpp.

References i, m_data, and m_finalized.

Referenced by SimpleSerializer(), writeBlob(), writeBool(), writeDouble(), writeFloat(), writeS32(), writeS64(), writeString(), writeU32(), and writeU64().

264 {
265  if(m_finalized) {
266  qCritical("SimpleSerializer: config has already been finalized (id %u)", id);
267  return false;
268  }
269 
270  int idLen;
271  int lengthLen;
272 
273  if(id < (1 << 8))
274  idLen = 0;
275  else if(id < (1 << 16))
276  idLen = 1;
277  else if(id < (1 << 24))
278  idLen = 2;
279  else idLen = 3;
280 
281  if(length < (1 << 8))
282  lengthLen = 0;
283  else if(length < (1 << 16))
284  lengthLen = 1;
285  else if(length < (1 << 24))
286  lengthLen = 2;
287  else lengthLen = 3;
288 
289  m_data.push_back((char)((type << 4) | (idLen << 2) | lengthLen));
290  for(int i = idLen; i >= 0; i--)
291  m_data.push_back((char)((id >> (i * 8)) & 0xff));
292  for(int i = lengthLen; i >= 0; i--)
293  m_data.push_back((char)((length >> (i * 8)) & 0xff));
294  return true;
295 }
int32_t i
Definition: decimators.h:244
+ Here is the caller graph for this function:

◆ writeU32()

void SimpleSerializer::writeU32 ( quint32  id,
quint32  value 
)

Definition at line 71 of file simpleserializer.cpp.

References i, m_data, TUnsigned32, and writeTag().

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

72 {
73  int length;
74 
75  if(id == 0) {
76  qCritical("SimpleSerializer: ID 0 is not allowed");
77  return;
78  }
79 
80  if(value >= (1 << 24))
81  length = 4;
82  else if(value >= (1 << 16))
83  length = 3;
84  else if(value >= (1 << 8))
85  length = 2;
86  else if(value > 0)
87  length = 1;
88  else length = 0;
89 
90  if(!writeTag(TUnsigned32, id, length))
91  return;
92 
93  length--;
94  for(int i = length; i >= 0; i--)
95  m_data.push_back((char)((value >> (i * 8)) & 0xff));
96 }
bool writeTag(Type type, quint32 id, quint32 length)
int32_t i
Definition: decimators.h:244
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ writeU64()

void SimpleSerializer::writeU64 ( quint32  id,
quint64  value 
)

Definition at line 133 of file simpleserializer.cpp.

References i, m_data, TUnsigned64, and writeTag().

Referenced by FileSinkSettings::serialize(), RemoteOutputSettings::serialize(), HackRFOutputSettings::serialize(), HackRFInputSettings::serialize(), PlutoSDROutputSettings::serialize(), Preset::serialize(), PlutoSDRInputSettings::serialize(), and SampleSourceSerializer::writeSerializedData().

134 {
135  int length;
136 
137  if(id == 0) {
138  qCritical("SimpleSerializer: ID 0 is not allowed");
139  return;
140  }
141 
142  if(value >= (1ll << 56))
143  length = 8;
144  else if(value >= (1ll << 48))
145  length = 7;
146  else if(value >= (1ll << 40))
147  length = 6;
148  else if(value >= (1ll << 32))
149  length = 5;
150  else if(value >= (1ll << 24))
151  length = 4;
152  else if(value >= (1ll << 16))
153  length = 3;
154  else if(value >= (1ll << 8))
155  length = 2;
156  else if(value > 0)
157  length = 1;
158  else length = 0;
159 
160  if(!writeTag(TUnsigned64, id, length))
161  return;
162 
163  length--;
164  for(int i = length; i >= 0; i--)
165  m_data.push_back((char)((value >> (i * 8)) & 0xff));
166 }
bool writeTag(Type type, quint32 id, quint32 length)
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 SimpleSerializer::m_data
protected

◆ m_finalized

bool SimpleSerializer::m_finalized
protected

Definition at line 46 of file simpleserializer.h.

Referenced by final(), and writeTag().


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