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.
localoutputsettings.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 "localoutputsettings.h"
20 
22 {
24 }
25 
27 {
28  m_useReverseAPI = false;
29  m_reverseAPIAddress = "127.0.0.1";
30  m_reverseAPIPort = 8888;
32 }
33 
35 {
36  SimpleSerializer s(1);
37 
41 
42  return s.final();
43 }
44 
45 bool LocalOutputSettings::deserialize(const QByteArray& data)
46 {
47  SimpleDeserializer d(data);
48 
49  if (!d.isValid())
50  {
52  return false;
53  }
54 
55  if (d.getVersion() == 1)
56  {
57  quint32 uintval;
58 
59  d.readString(4, &m_reverseAPIAddress, "127.0.0.1");
60  d.readU32(5, &uintval, 0);
61 
62  if ((uintval > 1023) && (uintval < 65535)) {
63  m_reverseAPIPort = uintval;
64  } else {
65  m_reverseAPIPort = 8888;
66  }
67 
68  d.readU32(6, &uintval, 0);
69  m_reverseAPIDeviceIndex = uintval > 99 ? 99 : uintval;
70  return true;
71  }
72  else
73  {
75  return false;
76  }
77 }
78 
79 
80 
QByteArray serialize() const
bool readU32(quint32 id, quint32 *result, quint32 def=0) const
bool readString(quint32 id, QString *result, const QString &def=QString::null) const
bool isValid() const
bool deserialize(const QByteArray &data)
quint32 getVersion() const
void writeU32(quint32 id, quint32 value)
void writeString(quint32 id, const QString &value)
const QByteArray & final()