Skip to content

Commit b0d5865

Browse files
authored
Replace alternative operator representations (#473)
1 parent db0fae7 commit b0d5865

File tree

12 files changed

+87
-93
lines changed

12 files changed

+87
-93
lines changed

apps/SoapyRateTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void runRateTestStreamLoop(
4444
std::cout << "Starting stream loop, press Ctrl+C to exit..." << std::endl;
4545
device->activateStream(stream);
4646
signal(SIGINT, sigIntHandler);
47-
while (not loopDone)
47+
while (!loopDone)
4848
{
4949
int ret(0);
5050
int flags(0);
@@ -129,8 +129,8 @@ int SoapySDRRateTest(
129129

130130
//parse the direction to the integer enum
131131
int direction(-1);
132-
if (directionStr == "RX" or directionStr == "rx") direction = SOAPY_SDR_RX;
133-
if (directionStr == "TX" or directionStr == "tx") direction = SOAPY_SDR_TX;
132+
if (directionStr == "RX" || directionStr == "rx") direction = SOAPY_SDR_RX;
133+
if (directionStr == "TX" || directionStr == "tx") direction = SOAPY_SDR_TX;
134134
if (direction == -1) throw std::invalid_argument("direction not in RX/TX: " + directionStr);
135135

136136
//build channels list, using KwargsFromString is a easy parsing hack

apps/SoapySDRProbe.cpp

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ std::string toString(const std::vector<Type> &options)
1313
if (options.empty()) return "";
1414
for (size_t i = 0; i < options.size(); i++)
1515
{
16-
if (not ss.str().empty()) ss << ", ";
16+
if (!ss.str().empty()) ss << ", ";
1717
ss << options[i];
1818
}
1919
return ss.str();
@@ -34,12 +34,12 @@ std::string toString(const SoapySDR::RangeList &range, const double scale)
3434
std::stringstream ss;
3535
for (size_t i = 0; i < range.size(); i++)
3636
{
37-
if (range.size() >= MAXRLEN and i >= MAXRLEN/2 and i < (range.size()-MAXRLEN/2))
37+
if (range.size() >= MAXRLEN && i >= MAXRLEN/2 && i < (range.size()-MAXRLEN/2))
3838
{
3939
if (i == MAXRLEN) ss << ", ...";
4040
continue;
4141
}
42-
if (not ss.str().empty()) ss << ", ";
42+
if (!ss.str().empty()) ss << ", ";
4343
if (range[i].minimum() == range[i].maximum()) ss << (range[i].minimum()/scale);
4444
else ss << "[" << (range[i].minimum()/scale) << ", " << (range[i].maximum()/scale) << "]";
4545
}
@@ -58,7 +58,7 @@ std::string toString(const std::vector<double> &nums, const double scale)
5858

5959
for (size_t i = 0; i < nums.size(); i++)
6060
{
61-
if (not ss.str().empty()) ss << ", ";
61+
if (!ss.str().empty()) ss << ", ";
6262
ss << (nums[i]/scale);
6363
}
6464
return "[" + ss.str() + "]";
@@ -80,12 +80,12 @@ std::string toString(const SoapySDR::ArgInfo &argInfo, const std::string indent
8080
{
8181
desc.replace(pos, 1, replace);
8282
}
83-
if (not desc.empty()) ss << " - " << desc << std::endl << indent << " ";
83+
if (!desc.empty()) ss << " - " << desc << std::endl << indent << " ";
8484

8585
//other fields
8686
ss << " [key=" << argInfo.key;
87-
if (not argInfo.units.empty()) ss << ", units=" << argInfo.units;
88-
if (not argInfo.value.empty()) ss << ", default=" << argInfo.value;
87+
if (!argInfo.units.empty()) ss << ", units=" << argInfo.units;
88+
if (!argInfo.value.empty()) ss << ", default=" << argInfo.value;
8989

9090
//type
9191
switch (argInfo.type)
@@ -98,7 +98,7 @@ std::string toString(const SoapySDR::ArgInfo &argInfo, const std::string indent
9898

9999
//optional range/enumeration
100100
if (argInfo.range.minimum() < argInfo.range.maximum()) ss << ", range=" << toString(argInfo.range);
101-
if (not argInfo.options.empty()) ss << ", options=(" << toString(argInfo.options) << ")";
101+
if (!argInfo.options.empty()) ss << ", options=(" << toString(argInfo.options) << ")";
102102

103103
ss << "]";
104104

@@ -133,14 +133,14 @@ std::string sensorReadings(SoapySDR::Device *device)
133133
std::string reading = device->readSensor(key);
134134

135135
ss << " * " << sensors[i];
136-
if (not info.name.empty()) ss << " (" << info.name << ")";
136+
if (!info.name.empty()) ss << " (" << info.name << ")";
137137
ss << ":";
138138
if (info.range.maximum() > std::numeric_limits<double>::min()) ss << toString(info.range);
139139
ss << toString(info.options);
140140
ss << " " << reading;
141-
if (not info.units.empty()) ss << " " << info.units;
141+
if (!info.units.empty()) ss << " " << info.units;
142142
ss << std::endl;
143-
if (not info.description.empty()) ss << " " << info.description << std::endl;
143+
if (!info.description.empty()) ss << " " << info.description << std::endl;
144144
}
145145

146146
return ss.str();
@@ -162,14 +162,14 @@ std::string channelSensorReadings(SoapySDR::Device *device, const int dir, const
162162
std::string reading = device->readSensor(dir, chan, key);
163163

164164
ss << " * " << sensors[i];
165-
if (not info.name.empty()) ss << " (" << info.name << ")";
165+
if (!info.name.empty()) ss << " (" << info.name << ")";
166166
ss << ":";
167167
if (info.range.maximum() > std::numeric_limits<double>::min()) ss << toString(info.range);
168168
ss << toString(info.options);
169169
ss << " " << reading;
170-
if (not info.units.empty()) ss << " " << info.units;
170+
if (!info.units.empty()) ss << " " << info.units;
171171
ss << std::endl;
172-
if (not info.description.empty()) ss << " " << info.description << std::endl;
172+
if (!info.description.empty()) ss << " " << info.description << std::endl;
173173
}
174174

175175
return ss.str();
@@ -201,7 +201,7 @@ static std::string probeChannel(SoapySDR::Device *device, const int dir, const s
201201

202202
//formats
203203
std::string formats = toString(device->getStreamFormats(dir, chan));
204-
if (not formats.empty()) ss << " Stream formats: " << formats << std::endl;
204+
if (!formats.empty()) ss << " Stream formats: " << formats << std::endl;
205205

206206
//native
207207
double fullScale = 0.0;
@@ -210,19 +210,19 @@ static std::string probeChannel(SoapySDR::Device *device, const int dir, const s
210210

211211
//stream args
212212
std::string streamArgs = toString(device->getStreamArgsInfo(dir, chan));
213-
if (not streamArgs.empty()) ss << " Stream args:" << std::endl << streamArgs;
213+
if (!streamArgs.empty()) ss << " Stream args:" << std::endl << streamArgs;
214214

215215
//antennas
216216
std::string antennas = toString(device->listAntennas(dir, chan));
217-
if (not antennas.empty()) ss << " Antennas: " << antennas << std::endl;
217+
if (!antennas.empty()) ss << " Antennas: " << antennas << std::endl;
218218

219219
//corrections
220220
std::vector<std::string> correctionsList;
221221
if (device->hasDCOffsetMode(dir, chan)) correctionsList.push_back("DC removal");
222222
if (device->hasDCOffset(dir, chan)) correctionsList.push_back("DC offset");
223223
if (device->hasIQBalance(dir, chan)) correctionsList.push_back("IQ balance");
224224
std::string corrections = toString(correctionsList);
225-
if (not corrections.empty()) ss << " Corrections: " << corrections << std::endl;
225+
if (!corrections.empty()) ss << " Corrections: " << corrections << std::endl;
226226

227227
//gains
228228
ss << " Full gain range: " << toString(device->getGainRange(dir, chan)) << " dB" << std::endl;
@@ -244,23 +244,23 @@ static std::string probeChannel(SoapySDR::Device *device, const int dir, const s
244244

245245
//freq args
246246
std::string freqArgs = toString(device->getFrequencyArgsInfo(dir, chan));
247-
if (not freqArgs.empty()) ss << " Tune args:" << std::endl << freqArgs;
247+
if (!freqArgs.empty()) ss << " Tune args:" << std::endl << freqArgs;
248248

249249
//rates
250250
ss << " Sample rates: " << toString(device->getSampleRateRange(dir, chan), 1e6) << " MSps" << std::endl;
251251

252252
//bandwidths
253253
const auto bws = device->getBandwidthRange(dir, chan);
254-
if (not bws.empty()) ss << " Filter bandwidths: " << toString(bws, 1e6) << " MHz" << std::endl;
254+
if (!bws.empty()) ss << " Filter bandwidths: " << toString(bws, 1e6) << " MHz" << std::endl;
255255

256256
//sensors
257257
std::string sensors = toString(device->listSensors(dir, chan));
258-
if (not sensors.empty()) ss << " Sensors: " << sensors << std::endl;
258+
if (!sensors.empty()) ss << " Sensors: " << sensors << std::endl;
259259
ss << channelSensorReadings(device, dir, chan);
260260

261261
//settings
262262
std::string settings = toString(device->getSettingInfo(dir, chan));
263-
if (not settings.empty()) ss << " Other Settings:" << std::endl << settings;
263+
if (!settings.empty()) ss << " Other Settings:" << std::endl << settings;
264264

265265
return ss.str();
266266
}
@@ -299,26 +299,26 @@ std::string SoapySDRDeviceProbe(SoapySDR::Device *device)
299299
ss << " Timestamps: " << (device->hasHardwareTime()?"YES":"NO") << std::endl;
300300

301301
std::string clockSources = toString(device->listClockSources());
302-
if (not clockSources.empty()) ss << " Clock sources: " << clockSources << std::endl;
302+
if (!clockSources.empty()) ss << " Clock sources: " << clockSources << std::endl;
303303

304304
std::string timeSources = toString(device->listTimeSources());
305-
if (not timeSources.empty()) ss << " Time sources: " << timeSources << std::endl;
305+
if (!timeSources.empty()) ss << " Time sources: " << timeSources << std::endl;
306306

307307
std::string sensors = toString(device->listSensors());
308-
if (not sensors.empty()) ss << " Sensors: " << sensors << std::endl;
308+
if (!sensors.empty()) ss << " Sensors: " << sensors << std::endl;
309309
ss << sensorReadings(device);
310310

311311
std::string registers = toString(device->listRegisterInterfaces());
312-
if (not registers.empty()) ss << " Registers: " << registers << std::endl;
312+
if (!registers.empty()) ss << " Registers: " << registers << std::endl;
313313

314314
std::string settings = toString(device->getSettingInfo());
315-
if (not settings.empty()) ss << " Other Settings:" << std::endl << settings;
315+
if (!settings.empty()) ss << " Other Settings:" << std::endl << settings;
316316

317317
std::string gpios = toString(device->listGPIOBanks());
318-
if (not gpios.empty()) ss << " GPIOs: " << gpios << std::endl;
318+
if (!gpios.empty()) ss << " GPIOs: " << gpios << std::endl;
319319

320320
std::string uarts = toString(device->listUARTs());
321-
if (not uarts.empty()) ss << " UARTs: " << uarts << std::endl;
321+
if (!uarts.empty()) ss << " UARTs: " << uarts << std::endl;
322322

323323
/*******************************************************************
324324
* Per-channel info

apps/SoapySDRUtil.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ static int printInfo(void)
107107
{
108108
std::cout << "Module found: " << mod;
109109
const auto &errMsg = SoapySDR::loadModule(mod);
110-
if (not errMsg.empty()) std::cout << "\n " << errMsg;
110+
if (!errMsg.empty()) std::cout << "\n " << errMsg;
111111
const auto version = SoapySDR::getModuleVersion(mod);
112-
if (not version.empty()) std::cout << std::string(maxPathLen-mod.size(), ' ') << " (" << version << ")";
112+
if (!version.empty()) std::cout << std::string(maxPathLen-mod.size(), ' ') << " (" << version << ")";
113113
std::cout << std::endl;
114114
}
115115
if (modules.empty()) std::cout << "No modules found!" << std::endl;
@@ -118,7 +118,7 @@ static int printInfo(void)
118118
std::string factories;
119119
for (const auto &it : SoapySDR::Registry::listFindFunctions())
120120
{
121-
if (not factories.empty()) factories += ", ";
121+
if (!factories.empty()) factories += ", ";
122122
factories += it.first;
123123
}
124124
if (factories.empty()) factories = "No factories found!";
@@ -130,7 +130,7 @@ static int printInfo(void)
130130
std::string targets;
131131
for (const auto &target : SoapySDR::ConverterRegistry::listTargetFormats(source))
132132
{
133-
if (not targets.empty()) targets += ", ";
133+
if (!targets.empty()) targets += ", ";
134134
targets += target;
135135
}
136136
std::cout << " - " << std::setw(5) << source << " -> [" << targets << "]" << std::endl;
@@ -235,7 +235,7 @@ static int watchDevice(const std::string &argStr)
235235
try
236236
{
237237
auto device = SoapySDR::Device::make(argStr);
238-
while (not loopDone)
238+
while (!loopDone)
239239
{
240240
std::cout << sensorReadings(device) << std::endl;
241241
std::this_thread::sleep_for(std::chrono::seconds(1));
@@ -374,15 +374,15 @@ int main(int argc, char *argv[])
374374
}
375375

376376
//use serial if provided
377-
if (not serial.empty())
377+
if (!serial.empty())
378378
{
379379
auto args = SoapySDR::KwargsFromString(argStr);
380380
args["serial"] = serial;
381381
argStr = SoapySDR::KwargsToString(args);
382382
}
383383

384-
if (not sparsePrintFlag) printBanner();
385-
if (not driverName.empty()) return checkDriver(driverName);
384+
if (!sparsePrintFlag) printBanner();
385+
if (!driverName.empty()) return checkDriver(driverName);
386386
if (findDevicesFlag) return findDevices(argStr, sparsePrintFlag);
387387
if (makeDeviceFlag) return makeDevice(argStr);
388388
if (probeDeviceFlag) return probeDevice(argStr);

include/SoapySDR/Config.hpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,3 @@
1010

1111
#pragma once
1212
#include <SoapySDR/Config.h>
13-
14-
#if (defined(_MSVC_LANG) || __cplusplus < 201703L)
15-
// For old or nonconforming compilers,
16-
// using the alternative operator representations may require including this header.
17-
#include <ciso646>
18-
#endif

include/SoapySDR/Types.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ namespace Detail {
176176
template <typename Type>
177177
typename std::enable_if<std::is_same<Type, bool>::value, Type>::type StringToSetting(const std::string &s)
178178
{
179-
if (s.empty() or s == SOAPY_SDR_FALSE) {
179+
if (s.empty() || s == SOAPY_SDR_FALSE) {
180180
return false;
181181
}
182182
if (s == SOAPY_SDR_TRUE) {
@@ -189,21 +189,21 @@ typename std::enable_if<std::is_same<Type, bool>::value, Type>::type StringToSet
189189

190190
// Either the input wasn't numeric, so str_end should point to the front of the string,
191191
// or the whole string was consumed and the resulting number is non-zero.
192-
return (s == str_end) or ((d != 0.0) and (std::strlen(str_end) == 0));
192+
return (s == str_end) || ((d != 0.0) && (std::strlen(str_end) == 0));
193193
} catch (std::invalid_argument&) {
194194
}
195195
// other values are true
196196
return true;
197197
}
198198

199199
template <typename Type>
200-
typename std::enable_if<not std::is_same<Type, bool>::value and std::is_integral<Type>::value and std::is_signed<Type>::value, Type>::type StringToSetting(const std::string &s)
200+
typename std::enable_if<!std::is_same<Type, bool>::value && std::is_integral<Type>::value && std::is_signed<Type>::value, Type>::type StringToSetting(const std::string &s)
201201
{
202202
return Type(std::stoll(s));
203203
}
204204

205205
template <typename Type>
206-
typename std::enable_if<not std::is_same<Type, bool>::value and std::is_integral<Type>::value and std::is_unsigned<Type>::value, Type>::type StringToSetting(const std::string &s)
206+
typename std::enable_if<!std::is_same<Type, bool>::value && std::is_integral<Type>::value && std::is_unsigned<Type>::value, Type>::type StringToSetting(const std::string &s)
207207
{
208208
return Type(std::stoull(s));
209209
}

lib/Device.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ bool SoapySDR::Device::getFullDuplex(const int, const size_t) const
5858
{
5959
auto numRxChs = this->getNumChannels(SOAPY_SDR_RX);
6060
auto numTxChs = this->getNumChannels(SOAPY_SDR_TX);
61-
if (numRxChs > 0 and numTxChs == 0) return false; //no tx channels
62-
if (numRxChs == 0 and numTxChs > 0) return false; //no rx channels
61+
if (numRxChs > 0 && numTxChs == 0) return false; //no tx channels
62+
if (numRxChs == 0 && numTxChs > 0) return false; //no rx channels
6363
return true; //assume full duplex (usually true minus some tdd devices)
6464
}
6565

@@ -373,11 +373,11 @@ void SoapySDR::Device::setFrequency(const int dir, const size_t chan, double fre
373373
//add offset for RF element (first element)
374374
if (comp_i == 0) freq += offset;
375375

376-
if (args.count(name) != 0 and args.at(name) == "IGNORE")
376+
if (args.count(name) != 0 && args.at(name) == "IGNORE")
377377
{
378378
//do nothing, dont change component
379379
}
380-
else if (args.count(name) != 0 and args.at(name) != "DEFAULT")
380+
else if (args.count(name) != 0 && args.at(name) != "DEFAULT")
381381
{
382382
//specific frequency for component specified
383383
const double f(std::atof(args.at(name).c_str()));
@@ -485,7 +485,7 @@ SoapySDR::ArgInfoList SoapySDR::Device::getFrequencyArgsInfo(const int dir, cons
485485
info.type = SoapySDR::ArgInfo::FLOAT;
486486
info.description = "Tune the LO with an offset and compensate with the baseband CORDIC.";
487487
SoapySDR::RangeList ranges = this->getFrequencyRange(dir, chan, comps.at(1));
488-
if (not ranges.empty()) info.range = ranges.front();
488+
if (!ranges.empty()) info.range = ranges.front();
489489
args.push_back(info);
490490
}
491491

@@ -503,7 +503,7 @@ SoapySDR::ArgInfoList SoapySDR::Device::getFrequencyArgsInfo(const int dir, cons
503503
info.options.push_back("IGNORE");
504504
info.optionNames.push_back("Ignore");
505505
SoapySDR::RangeList ranges = this->getFrequencyRange(dir, chan, comps.at(comp_i));
506-
if (not ranges.empty()) info.range = ranges.front();
506+
if (!ranges.empty()) info.range = ranges.front();
507507
args.push_back(info);
508508
}
509509

0 commit comments

Comments
 (0)