Skip to content

Commit c30d1f1

Browse files
committed
Whitespace changes
1 parent 3ecf63f commit c30d1f1

12 files changed

Lines changed: 393 additions & 371 deletions

clirecorder.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#include "recording.h"
22
#include "xdfwriter.h"
33

4-
int main(int argc, char** argv) {
4+
int main(int argc, char **argv) {
55
if (argc < 3 || (argc == 2 && std::string(argv[1]) == "-h")) {
66
std::cout << "Usage: " << argv[0] << " outputfile.xdf 'searchstr' ['searchstr2' ...]\n\n"
7-
<< "searchstr can be anything accepted by lsl_resolve_bypred\n";
7+
<< "searchstr can be anything accepted by lsl_resolve_bypred\n";
88
std::cout << "Keep in mind that your shell might remove quotes\n";
99
std::cout << "Examples:\n\t" << argv[0] << " foo.xdf 'type=\"EEG\"' ";
1010
std::cout << " 'host=\"LabPC1\" or host=\"LabPC2\"'\n\t";
@@ -14,17 +14,17 @@ int main(int argc, char** argv) {
1414

1515
std::vector<lsl::stream_info> infos = lsl::resolve_streams(), recordstreams;
1616

17-
for(int i = 2; i < argc; ++i) {
17+
for (int i = 2; i < argc; ++i) {
1818
bool matched = false;
19-
for(const auto& info: infos) {
20-
if(info.matches_query(argv[i])) {
19+
for (const auto &info : infos) {
20+
if (info.matches_query(argv[i])) {
2121
std::cout << "Found " << info.name() << '@' << info.hostname();
2222
std::cout << " matching '" << argv[i] << "'\n";
2323
matched = true;
2424
recordstreams.emplace_back(info);
2525
}
2626
}
27-
if(!matched) {
27+
if (!matched) {
2828
std::cout << '"' << argv[i] << "\" matched no stream!\n";
2929
return 2;
3030
}

conversions.h

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
#define CONVERSIONS_H_
77

88
#include <cstdint>
9+
#include <limits>
910
#include <ostream>
1011
#include <vector>
11-
#include <limits>
1212

1313
#ifdef EXOTIC_ARCH_SUPPORT
1414
#include <boost/version.hpp>
@@ -31,19 +31,21 @@ using boost::endian::native_to_little_inplace;
3131
// write an integer value in little endian
3232
// derived from portable archive code by christian.pfligersdorffer@eos.info (under boost license)
3333
template <typename T>
34-
typename std::enable_if<std::is_integral<T>::value>::type write_little_endian(std::ostream& dst, T t) {
34+
typename std::enable_if<std::is_integral<T>::value>::type write_little_endian(
35+
std::ostream &dst, T t) {
3536
native_to_little_inplace(t);
36-
dst->sputn(reinterpret_cast<const char*>(&t), sizeof(t));
37+
dst->sputn(reinterpret_cast<const char *>(&t), sizeof(t));
3738
}
3839

3940
// write a floating-point value in little endian
4041
// derived from portable archive code by christian.pfligersdorffer@eos.info (under boost license)
4142
template <typename T>
42-
typename std::enable_if<std::is_floating_point<T>::value>::type
43-
write_little_endian(std::ostream& dst, T t) {
44-
//Get a type big enough to hold
43+
typename std::enable_if<std::is_floating_point<T>::value>::type write_little_endian(
44+
std::ostream &dst, T t) {
45+
// Get a type big enough to hold
4546
using traits = typename fp::detail::fp_traits<T>::type;
46-
static_assert(sizeof(typename traits::bits) == sizeof(T), "floating point type can't be represented accurately");
47+
static_assert(sizeof(typename traits::bits) == sizeof(T),
48+
"floating point type can't be represented accurately");
4749

4850
typename traits::bits bits;
4951
// remap to bit representation
@@ -60,51 +62,50 @@ write_little_endian(std::ostream& dst, T t) {
6062

6163
// store a sample's values to a stream (numeric version) */
6264
template <class T>
63-
inline const T* write_sample_values(std::ostream& dst, const T* sample, std::size_t len) {
65+
inline const T *write_sample_values(std::ostream &dst, const T *sample, std::size_t len) {
6466
// [Value1] .. [ValueN] */
65-
for(const T* end = sample + len; sample < end; ++sample)
66-
write_little_endian(dst, *sample);
67+
for (const T *end = sample + len; sample < end; ++sample) write_little_endian(dst, *sample);
6768
return sample;
6869
}
6970

7071
#else
7172

7273
static_assert(std::numeric_limits<float>::is_iec559,
73-
"Non-IEC559/IEEE754-floats need EXOTIC_ARCH_SUPPORT defined");
74+
"Non-IEC559/IEEE754-floats need EXOTIC_ARCH_SUPPORT defined");
7475
static_assert(std::numeric_limits<float>::has_denorm, "denormalized floats not supported");
7576
static_assert(sizeof(float) == 4, "Unexpected float size!");
7677
static_assert(sizeof(double) == 8, "Unexpected double size!");
7778

7879
template <typename T>
79-
typename std::enable_if<sizeof(T) == 1>::type write_little_endian(std::ostream& dst, T t) {
80+
typename std::enable_if<sizeof(T) == 1>::type write_little_endian(std::ostream &dst, T t) {
8081
dst.put(t);
8182
}
8283

8384
template <typename T>
84-
typename std::enable_if<sizeof(T) >= 2>::type write_little_endian(std::ostream& dst, T t) {
85-
dst.write(reinterpret_cast<const char*>(&t), sizeof(T));
85+
typename std::enable_if<sizeof(T) >= 2>::type write_little_endian(std::ostream &dst, T t) {
86+
dst.write(reinterpret_cast<const char *>(&t), sizeof(T));
8687
}
8788

8889
template <class T>
89-
inline const T* write_sample_values(std::ostream& dst, const T* sample, std::size_t len) {
90+
inline const T *write_sample_values(std::ostream &dst, const T *sample, std::size_t len) {
9091
// [Value1] .. [ValueN] */
91-
dst.write(reinterpret_cast<const char*>(sample), len * sizeof(T));
92+
dst.write(reinterpret_cast<const char *>(sample), len * sizeof(T));
9293
return sample + len;
9394
}
9495
#endif
9596

9697
template <class T>
97-
inline void write_sample_values(std::ostream& dst, const std::vector<T>& sample) {
98+
inline void write_sample_values(std::ostream &dst, const std::vector<T> &sample) {
9899
write_sample_values(dst, sample.data(), sample.size());
99100
}
100101

101102
template <typename T>
102-
inline void write_sample_values(std::ostream& buf, const std::vector<std::vector<T>>& vecs) {
103-
for (const std::vector<T>& vec : vecs) write_sample_values(buf, vec);
103+
inline void write_sample_values(std::ostream &buf, const std::vector<std::vector<T>> &vecs) {
104+
for (const std::vector<T> &vec : vecs) write_sample_values(buf, vec);
104105
}
105106

106107
// write a variable-length integer (int8, int32, or int64)
107-
inline void write_varlen_int(std::ostream& dst, uint64_t val) {
108+
inline void write_varlen_int(std::ostream &dst, uint64_t val) {
108109
if (val < 256) {
109110
dst.put(1);
110111
dst.put(static_cast<uint8_t>(val));
@@ -117,18 +118,18 @@ inline void write_varlen_int(std::ostream& dst, uint64_t val) {
117118
}
118119
}
119120

120-
template<typename T>
121-
inline void write_fixlen_int(std::ostream& dst, T val) {
121+
template <typename T> inline void write_fixlen_int(std::ostream &dst, T val) {
122122
dst.put(sizeof(T));
123123
write_little_endian(dst, val);
124124
}
125125

126126

127127
// store a sample's values to a stream (string version)
128128
template <>
129-
inline const std::string* write_sample_values(std::ostream& dst, const std::string* sample, std::size_t len) {
129+
inline const std::string *write_sample_values(
130+
std::ostream &dst, const std::string *sample, std::size_t len) {
130131
// [Value1] .. [ValueN] */
131-
for(const std::string* end = sample + len; sample < end; ++sample) {
132+
for (const std::string *end = sample + len; sample < end; ++sample) {
132133
// [NumLengthBytes], [Length] (as varlen int)
133134
write_varlen_int(dst, sample->size());
134135
// [StringContent] */

fptest.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
11
#include <iostream>
22

33
int main() {
4-
const double sampling_rate = 500,
5-
sample_interval = 1.0 / sampling_rate,
6-
first_timestamp = 60*60*24*365*48; // e.g. a unix timestamp
4+
const double sampling_rate = 500, sample_interval = 1.0 / sampling_rate,
5+
first_timestamp = 60 * 60 * 24 * 365 * 48; // e.g. a unix timestamp
76
double last_timestamp = first_timestamp;
87
int full = 0, deduced = 0;
98
const int iterations = 100000;
109
double timestamps[iterations];
11-
for(int i=0;i<iterations; ++i)
12-
timestamps[i] = first_timestamp + i/sampling_rate;
13-
for(int i=0; i<iterations; ++i) {
14-
if(last_timestamp + sample_interval == timestamps[i])
10+
for (int i = 0; i < iterations; ++i) timestamps[i] = first_timestamp + i / sampling_rate;
11+
for (int i = 0; i < iterations; ++i) {
12+
if (last_timestamp + sample_interval == timestamps[i])
1513
deduced++;
16-
else full++;
14+
else
15+
full++;
1716
last_timestamp = timestamps[i];
1817
}
1918
std::cout << "Deduced: " << deduced << "\nFully written: " << full << std::endl;
2019
return 0;
2120
}
22-
23-

main.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
#include <QApplication>
21
#include "mainwindow.h"
2+
#include <QApplication>
3+
4+
int main(int argc, char *argv[]) {
35

4-
int main(int argc, char *argv[])
5-
{
6+
// determine the startup config file...
7+
const char *config_file = "default_config.cfg";
8+
for (int k = 1; k < argc; k++)
9+
if (std::string(argv[k]) == "-c" || std::string(argv[k]) == "--config")
10+
config_file = argv[k + 1];
611

7-
// determine the startup config file...
8-
const char* config_file = "default_config.cfg";
9-
for (int k=1;k<argc;k++)
10-
if (std::string(argv[k]) == "-c" || std::string(argv[k]) == "--config")
11-
config_file = argv[k+1];
12+
QApplication a(argc, argv);
13+
MainWindow w(nullptr, config_file);
14+
w.show();
1215

13-
QApplication a(argc, argv);
14-
MainWindow w(nullptr, config_file);
15-
w.show();
16-
17-
return a.exec();
16+
return a.exec();
1817
}

0 commit comments

Comments
 (0)