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 | Private Attributes | List of all members
MainParser Class Reference

#include <mainparser.h>

Public Member Functions

 MainParser ()
 
 ~MainParser ()
 
void parse (const QCoreApplication &app)
 
const QString & getServerAddress () const
 
uint16_t getServerPort () const
 
bool getMIMOSupport () const
 

Private Attributes

QString m_serverAddress
 
uint16_t m_serverPort
 
bool m_mimoSupport
 
QCommandLineParser m_parser
 
QCommandLineOption m_serverAddressOption
 
QCommandLineOption m_serverPortOption
 
QCommandLineOption m_mimoOption
 

Detailed Description

Definition at line 27 of file mainparser.h.

Constructor & Destructor Documentation

◆ MainParser()

MainParser::MainParser ( )

Definition at line 25 of file mainparser.cpp.

References m_mimoOption, m_mimoSupport, m_parser, m_serverAddress, m_serverAddressOption, m_serverPort, and m_serverPortOption.

25  :
26  m_serverAddressOption(QStringList() << "a" << "api-address",
27  "Web API server address.",
28  "address",
29  "127.0.0.1"),
30  m_serverPortOption(QStringList() << "p" << "api-port",
31  "Web API server port.",
32  "port",
33  "8091"),
34  m_mimoOption("mimo", "Activate MIMO functionality")
35 {
36  m_serverAddress = "127.0.0.1";
37  m_serverPort = 8091;
38  m_mimoSupport = false;
39  m_mimoOption.setFlags(QCommandLineOption::HiddenFromHelp);
40 
41  m_parser.setApplicationDescription("Software Defined Radio application");
42  m_parser.addHelpOption();
43  m_parser.addVersionOption();
44 
46  m_parser.addOption(m_serverPortOption);
47  m_parser.addOption(m_mimoOption);
48 }
QCommandLineOption m_mimoOption
Definition: mainparser.h:47
QCommandLineOption m_serverAddressOption
Definition: mainparser.h:45
QCommandLineParser m_parser
Definition: mainparser.h:44
QCommandLineOption m_serverPortOption
Definition: mainparser.h:46
bool m_mimoSupport
Definition: mainparser.h:42
QString m_serverAddress
Definition: mainparser.h:40
uint16_t m_serverPort
Definition: mainparser.h:41

◆ ~MainParser()

MainParser::~MainParser ( )

Definition at line 50 of file mainparser.cpp.

51 { }

Member Function Documentation

◆ getMIMOSupport()

bool MainParser::getMIMOSupport ( ) const
inline

Definition at line 37 of file mainparser.h.

Referenced by MainCore::MainCore(), and MainWindow::MainWindow().

37 { return m_mimoSupport; }
bool m_mimoSupport
Definition: mainparser.h:42
+ Here is the caller graph for this function:

◆ getServerAddress()

const QString& MainParser::getServerAddress ( ) const
inline

Definition at line 35 of file mainparser.h.

Referenced by MainCore::MainCore(), and MainWindow::MainWindow().

35 { return m_serverAddress; }
QString m_serverAddress
Definition: mainparser.h:40
+ Here is the caller graph for this function:

◆ getServerPort()

uint16_t MainParser::getServerPort ( ) const
inline

Definition at line 36 of file mainparser.h.

Referenced by MainCore::MainCore(), and MainWindow::MainWindow().

36 { return m_serverPort; }
uint16_t m_serverPort
Definition: mainparser.h:41
+ Here is the caller graph for this function:

◆ parse()

void MainParser::parse ( const QCoreApplication &  app)

Definition at line 53 of file mainparser.cpp.

References m_mimoOption, m_mimoSupport, m_parser, m_serverAddress, m_serverAddressOption, m_serverPort, and m_serverPortOption.

54 {
55  m_parser.process(app);
56 
57  int pos;
58  bool ok;
59 
60  // server address
61 
62  QString serverAddress = m_parser.value(m_serverAddressOption);
63 
64  QString ipRange = "(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])";
65  QRegExp ipRegex ("^" + ipRange
66  + "\\." + ipRange
67  + "\\." + ipRange
68  + "\\." + ipRange + "$");
69  QRegExpValidator ipValidator(ipRegex);
70 
71  if (ipValidator.validate(serverAddress, pos) == QValidator::Acceptable) {
72  m_serverAddress = serverAddress;
73  } else {
74  qWarning() << "MainParser::parse: server address invalid. Defaulting to " << m_serverAddress;
75  }
76 
77  // server port
78 
79  QString serverPortStr = m_parser.value(m_serverPortOption);
80  int serverPort = serverPortStr.toInt(&ok);
81 
82  if (ok && (serverPort > 1023) && (serverPort < 65536)) {
83  m_serverPort = serverPort;
84  } else {
85  qWarning() << "MainParser::parse: server port invalid. Defaulting to " << m_serverPort;
86  }
87 
88  // MIMO
89 
91 }
QCommandLineOption m_mimoOption
Definition: mainparser.h:47
QCommandLineOption m_serverAddressOption
Definition: mainparser.h:45
QCommandLineParser m_parser
Definition: mainparser.h:44
QCommandLineOption m_serverPortOption
Definition: mainparser.h:46
bool m_mimoSupport
Definition: mainparser.h:42
QString m_serverAddress
Definition: mainparser.h:40
uint16_t m_serverPort
Definition: mainparser.h:41

Member Data Documentation

◆ m_mimoOption

QCommandLineOption MainParser::m_mimoOption
private

Definition at line 47 of file mainparser.h.

Referenced by MainParser(), and parse().

◆ m_mimoSupport

bool MainParser::m_mimoSupport
private

Definition at line 42 of file mainparser.h.

Referenced by MainParser(), and parse().

◆ m_parser

QCommandLineParser MainParser::m_parser
private

Definition at line 44 of file mainparser.h.

Referenced by MainParser(), and parse().

◆ m_serverAddress

QString MainParser::m_serverAddress
private

Definition at line 40 of file mainparser.h.

Referenced by MainParser(), and parse().

◆ m_serverAddressOption

QCommandLineOption MainParser::m_serverAddressOption
private

Definition at line 45 of file mainparser.h.

Referenced by MainParser(), and parse().

◆ m_serverPort

uint16_t MainParser::m_serverPort
private

Definition at line 41 of file mainparser.h.

Referenced by MainParser(), and parse().

◆ m_serverPortOption

QCommandLineOption MainParser::m_serverPortOption
private

Definition at line 46 of file mainparser.h.

Referenced by MainParser(), and parse().


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