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.
localinputsettings.cpp
Go to the documentation of this file.
1 // Copyright (C) 2019 Edouard Griffiths, F4EXB //
3 // //
4 // This program is free software; you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation as version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // This program is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
18 #include "util/simpleserializer.h"
19 #include "localinputsettings.h"
20 
22 {
24 }
25 
27 {
28  m_dcBlock = false;
29  m_iqCorrection = false;
30  m_fileRecordName = "";
31  m_useReverseAPI = false;
32  m_reverseAPIAddress = "127.0.0.1";
33  m_reverseAPIPort = 8888;
35 }
36 
38 {
39  SimpleSerializer s(1);
40 
41  s.writeBool(1, m_dcBlock);
47 
48  return s.final();
49 }
50 
51 bool LocalInputSettings::deserialize(const QByteArray& data)
52 {
53  SimpleDeserializer d(data);
54 
55  if (!d.isValid())
56  {
58  return false;
59  }
60 
61  if (d.getVersion() == 1)
62  {
63  quint32 uintval;
64 
65  d.readBool(1, &m_dcBlock, false);
66  d.readBool(2, &m_iqCorrection, false);
67  d.readBool(3, &m_useReverseAPI, false);
68  d.readString(4, &m_reverseAPIAddress, "127.0.0.1");
69  d.readU32(5, &uintval, 0);
70 
71  if ((uintval > 1023) && (uintval < 65535)) {
72  m_reverseAPIPort = uintval;
73  } else {
74  m_reverseAPIPort = 8888;
75  }
76 
77  d.readU32(6, &uintval, 0);
78  m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval;
79  return true;
80  }
81  else
82  {
84  return false;
85  }
86 }
87 
88 
89 
bool readU32(quint32 id, quint32 *result, quint32 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 isValid() const
QByteArray serialize() const
quint32 getVersion() const
void writeU32(quint32 id, quint32 value)
uint16_t m_reverseAPIDeviceIndex
void writeBool(quint32 id, bool value)
void writeString(quint32 id, const QString &value)
const QByteArray & final()
bool deserialize(const QByteArray &data)