Skip to content

Commit a145604

Browse files
committed
Merge branch 'install-fix'
2 parents e10cd0f + 539de2a commit a145604

File tree

8 files changed

+56
-56
lines changed

8 files changed

+56
-56
lines changed

src/analysis/CANFrameAnalysis.cpp

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#include "CANDatabaseAnalysis.h"
2-
#include "CANDatabase.h"
1+
#include "cpp-can-parser/CANDatabaseAnalysis.h"
2+
#include "cpp-can-parser/CANDatabase.h"
33
#include <algorithm>
44
#include <cmath>
55
#include <tuple>
@@ -48,28 +48,28 @@ struct SignalLayoutEntry {
4848

4949
SignalRanges big_endian_ranges(const CANSignal& src) {
5050
SignalRanges result;
51-
52-
// For BigEndian signals, the start bit already represents the left mostbit
51+
52+
// For BigEndian signals, the start bit already represents the left mostbit
5353
// ----------------- -----------------
5454
// |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*|
5555
// ----------------- -----------------
5656
// 7 0 15 8
57-
57+
5858
unsigned bitsLeft = src.length();
5959
unsigned currentPos = src.start_bit();
60-
60+
6161
for(unsigned current_byte = src.start_bit() / 8; bitsLeft > 0; current_byte++) {
6262
char lbit = currentPos % 8;
6363
char rbit = std::max<char>(-1, lbit - bitsLeft);
6464

6565
// The static_cast are not "necessary" but it removes some warnings
66-
result.push_back({ static_cast<uint8_t>(current_byte),
66+
result.push_back({ static_cast<uint8_t>(current_byte),
6767
lbit, rbit });
68-
68+
6969
bitsLeft -= lbit - rbit;
70-
currentPos += (lbit - rbit);
70+
currentPos += (lbit - rbit);
7171
}
72-
72+
7373
return result;
7474
}
7575

@@ -78,22 +78,22 @@ SignalRanges little_endian_ranges(const CANSignal& src) {
7878
// ----------------- -----------------
7979
// |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*|
8080
// ----------------- -----------------
81-
// 0 7 8 15
82-
//
81+
// 0 7 8 15
82+
//
8383
// The signal can be found from the start bit + read to the right.
8484
SignalRanges result;
8585

8686
if(src.length() == 0) // length is 0, we return an empty result.
8787
return result;
88-
88+
8989
unsigned bitsLeft = src.length();
9090
unsigned currentPos = src.start_bit();
9191
for(unsigned current_byte = src.start_bit() / 8; bitsLeft > 0; current_byte++) {
9292
char lbit = currentPos % 8;
9393
char rbit = std::min<char>(lbit + bitsLeft, 8);
9494

9595
// The static_cast are not "necessary" but it removes some warnings
96-
result.push_back({ static_cast<uint8_t>(current_byte),
96+
result.push_back({ static_cast<uint8_t>(current_byte),
9797
lbit, rbit });
9898

9999
bitsLeft -= rbit - lbit;
@@ -107,7 +107,7 @@ std::vector<SignalLayoutEntry> compute_layout(const CANFrame& src) {
107107
std::vector<SignalLayoutEntry> result;
108108

109109
for(const auto& signal: src) {
110-
const CANSignal& sig = signal.second;
110+
const CANSignal& sig = signal.second;
111111

112112
if(sig.endianness() == CANSignal::BigEndian) {
113113
auto ranges = big_endian_ranges(sig);
@@ -126,12 +126,12 @@ std::vector<SignalLayoutEntry> compute_layout(const CANFrame& src) {
126126
bool overlap(const SignalLayoutEntry& e1, const SignalLayoutEntry& e2) {
127127
for(const SignalRange& r1 : e1.ranges) {
128128
for(const SignalRange& r2: e2.ranges) {
129-
// Find if r2 shares a SignalRange with the same byte with r1
129+
// Find if r2 shares a SignalRange with the same byte with r1
130130
if(r1.byte != r2.byte)
131131
continue;
132-
132+
133133
// Now we know that the SignalRange(s) share a common byte
134-
134+
135135
// ordered.first is the leftmost SignalRange in the byte
136136
// ordered.second is the rightmost SignalRange in the byte
137137
auto ordered = std::minmax(r1, r2, [](const SignalRange& r, const SignalRange& rr) {
@@ -154,7 +154,7 @@ bool CppCAN::analysis::is_frame_layout_ok(const CANFrame& src) {
154154
for(size_t i = 0; i < layout.size(); i++) {
155155
for(size_t j = i + 1; j < layout.size(); j++) {
156156
if(overlap(layout[i], layout[j])) {
157-
return false;
157+
return false;
158158
}
159159
}
160160
}
@@ -179,7 +179,7 @@ bool CppCAN::analysis::is_frame_layout_ok(const CANFrame& src, std::vector<std::
179179
if(overlap(layout[i], layout[j])) {
180180
report_issue(i, *layout[i].src_signal);
181181
report_issue(j, *layout[j].src_signal);
182-
}
182+
}
183183
}
184184
}
185185

src/models/CANDatabase.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "CANDatabase.h"
1+
#include "cpp-can-parser/CANDatabase.h"
22
#include "DBCParser.h"
33
#include <utility>
44
#include <iostream>
@@ -17,7 +17,7 @@ class CANDatabase::CANDatabaseImpl {
1717
CANDatabaseImpl& operator=(CANDatabaseImpl&&) = delete;
1818

1919
CANDatabaseImpl(const std::string& filename)
20-
: filename_(filename), map_(),
20+
: filename_(filename), map_(),
2121
intKeyIndex_(), strKeyIndex_() {
2222

2323
}
@@ -80,7 +80,7 @@ CANDatabase CANDatabase::fromFile(const std::string& filename, std::vector<parsi
8080
if (!test_stream.good()) {
8181
throw CANDatabaseException("Cannot find file " + filename);
8282
}
83-
83+
8484
dtl::FileTokenizer tokenizer(filename);
8585
return CppCAN::parser::dbc::fromTokenizer(filename, tokenizer, warnings);
8686
}
@@ -125,7 +125,7 @@ void CANDatabase::removeFrame(const std::string& name) {
125125
impl->map_.erase(impl->map_.find(map_key));
126126
impl->strKeyIndex_.erase(impl->strKeyIndex_.find(map_key.str_key));
127127
impl->intKeyIndex_.erase(impl->intKeyIndex_.find(map_key.int_key));
128-
}
128+
}
129129
catch(const std::out_of_range&) {
130130
std::string excepText = "Cannot remove frame with name " + name;
131131
throw std::out_of_range(excepText);
@@ -139,7 +139,7 @@ void CANDatabase::removeFrame(unsigned int can_id) {
139139
impl->map_.erase(impl->map_.find(map_key));
140140
impl->strKeyIndex_.erase(impl->strKeyIndex_.find(map_key.str_key));
141141
impl->intKeyIndex_.erase(impl->intKeyIndex_.find(map_key.int_key));
142-
}
142+
}
143143
catch(const std::out_of_range&) {
144144
std::string excepText = "Cannot remove frame with CAN ID ";
145145
excepText += std::to_string(can_id);
@@ -155,12 +155,12 @@ bool CANDatabase::contains(const std::string& name) const {
155155
return impl->strKeyIndex_.find(name) != impl->strKeyIndex_.end();
156156
}
157157

158-
CANDatabase::iterator
158+
CANDatabase::iterator
159159
CANDatabase::begin() {
160160
return impl->map_.begin();
161161
}
162162

163-
CANDatabase::const_iterator
163+
CANDatabase::const_iterator
164164
CANDatabase::begin() const {
165165
return impl->map_.begin();
166166
}
@@ -170,12 +170,12 @@ CANDatabase::cbegin() const {
170170
return impl->map_.cbegin();
171171
}
172172

173-
CANDatabase::iterator
173+
CANDatabase::iterator
174174
CANDatabase::end() {
175175
return impl->map_.end();
176176
}
177177

178-
CANDatabase::const_iterator
178+
CANDatabase::const_iterator
179179
CANDatabase::end() const {
180180
return impl->map_.end();
181181
}
@@ -185,12 +185,12 @@ CANDatabase::cend() const {
185185
return impl->map_.cend();
186186
}
187187

188-
CANDatabase::reverse_iterator
188+
CANDatabase::reverse_iterator
189189
CANDatabase::rbegin() {
190190
return impl->map_.rbegin();
191191
}
192192

193-
CANDatabase::const_reverse_iterator
193+
CANDatabase::const_reverse_iterator
194194
CANDatabase::rbegin() const {
195195
return impl->map_.rbegin();
196196
}
@@ -200,12 +200,12 @@ CANDatabase::crbegin() const {
200200
return impl->map_.crbegin();
201201
}
202202

203-
CANDatabase::reverse_iterator
203+
CANDatabase::reverse_iterator
204204
CANDatabase::rend() {
205205
return impl->map_.rend();
206206
}
207207

208-
CANDatabase::const_reverse_iterator
208+
CANDatabase::const_reverse_iterator
209209
CANDatabase::rend() const {
210210
return impl->map_.rend();
211211
}

src/models/CANFrame.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#include "CANDatabase.h"
1+
#include "cpp-can-parser/CANDatabase.h"
22
#include <utility>
33
#include <iostream>
44

55
using namespace CppCAN;
66

7-
CANFrame::CANFrame(const std::string& name, unsigned long long can_id,
8-
unsigned int dlc, unsigned int period,
7+
CANFrame::CANFrame(const std::string& name, unsigned long long can_id,
8+
unsigned int dlc, unsigned int period,
99
const std::string& comment)
1010
: name_(name), can_id_(can_id), dlc_(dlc), period_(0), comment_(comment) {}
1111

@@ -46,7 +46,7 @@ const CANSignal& CANFrame::at(const std::string& name) const {
4646
}
4747

4848
CANSignal& CANFrame::at(const std::string& name) {
49-
return map_.at(name);
49+
return map_.at(name);
5050
}
5151

5252
const CANSignal& CANFrame::operator[](const std::string& name) const {
@@ -57,19 +57,19 @@ CANSignal& CANFrame::operator[](const std::string& name) {
5757
return at(name);
5858
}
5959

60-
void CANFrame::addSignal(const CANSignal& signal) {
60+
void CANFrame::addSignal(const CANSignal& signal) {
6161
map_.insert(std::make_pair(signal.name(), signal));
6262
}
6363

6464
void CANFrame::removeSignal(const std::string& name) {
6565

6666
auto ite = map_.find(name);
6767
if(ite == map_.end()) {
68-
std::string excepText = "Cannot remove signal with name \"" + name +
68+
std::string excepText = "Cannot remove signal with name \"" + name +
6969
"\" from frame \"" + this->name() + "\"";
7070
throw std::out_of_range(excepText);
7171
}
72-
72+
7373
map_.erase(ite);
7474
}
7575

src/models/CANSignal.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "CANDatabase.h"
1+
#include "cpp-can-parser/CANDatabase.h"
22

33
using namespace CppCAN;
44

src/parsing/DBCParser.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef DBCParser_H
22
#define DBCParser_H
33

4-
#include "CANDatabase.h"
4+
#include "cpp-can-parser/CANDatabase.h"
55
#include "Tokenizer.h"
66
#include <set>
77
#include <memory>
@@ -15,9 +15,9 @@ CANDatabase fromTokenizer(
1515
std::vector<CANDatabase::parsing_warning>* warnings = nullptr);
1616

1717
CANDatabase fromTokenizer(
18-
details::Tokenizer& tokenizer,
18+
details::Tokenizer& tokenizer,
1919
std::vector<CANDatabase::parsing_warning>* warnings = nullptr);
20-
20+
2121
}
2222
}
2323
}

src/parsing/ParsingUtils.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <iostream>
66

77
#include "Tokenizer.h"
8-
#include "CANDatabase.h"
8+
#include "cpp-can-parser/CANDatabase.h"
99

1010
namespace CppCAN {
1111
namespace parser {
@@ -16,7 +16,7 @@ void throw_error(
1616
unsigned long long line);
1717

1818
void warning(
19-
std::vector<CANDatabase::parsing_warning>* warnings,
19+
std::vector<CANDatabase::parsing_warning>* warnings,
2020
const std::string& description, unsigned long long line);
2121

2222
const Token&

src/parsing/Tokenizer.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "Tokenizer.h"
2-
#include "CANDatabase.h"
2+
#include "cpp-can-parser/CANDatabase.h"
33
#include <cctype>
44
#include <iostream>
55

@@ -45,11 +45,11 @@ bool Token::operator==(const std::string& other) const {
4545

4646
bool Token::operator==(Token::Type other) const {
4747
if(type == Number) {
48-
return other == Number || other == PositiveNumber ||
48+
return other == Number || other == PositiveNumber ||
4949
other == NegativeNumber || other == FloatingPointNumber;
5050
}
5151
else if(other == Number) {
52-
return type == Number || type == PositiveNumber ||
52+
return type == Number || type == PositiveNumber ||
5353
type == NegativeNumber || type == FloatingPointNumber;
5454
}
5555

@@ -173,7 +173,7 @@ const Token& Tokenizer::getNextToken() {
173173
else { // Negative number
174174
bool is_float;
175175
std::string literal = "-" + parseNumber(is_float);
176-
176+
177177
currentToken = Token::createNumber(literal, false, is_float);
178178
}
179179
}
@@ -239,7 +239,7 @@ void Tokenizer::skipLine() {
239239

240240
std::string Tokenizer::parseNumber(bool& is_float) {
241241
std::string result(1, getCurrentChar());
242-
242+
243243
char currentChar = getNextChar();
244244
is_float = false;
245245

@@ -255,7 +255,7 @@ std::string Tokenizer::parseNumber(bool& is_float) {
255255
else if(currentChar == 'e') {
256256
result += currentChar;
257257
currentChar = getNextChar();
258-
258+
259259
// Plus "in the wild" are not considered to be part of a number
260260
// They are only allowed after "e" (eg. 3e+002)
261261
if(currentChar == '+') {
@@ -326,7 +326,7 @@ char StringTokenizer::doGetNextChar() {
326326
return 0;
327327

328328
char result = src_str[charCnt++];
329-
329+
330330
if (addLine) {
331331
lineCnt += 1;
332332
addLine = false;

tests/test-parsing.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include <iostream>
2-
#include "CANDatabase.h"
2+
#include "cpp-can-parser/CANDatabase.h"
33

44
int main(int argc, char** argv) {
55
using namespace CppCAN;
6-
6+
77
std::vector<std::string> successParseFile = {
88
"dbc-files/empty.dbc", "dbc-files/single-frame-1.dbc"
99
};
@@ -14,7 +14,7 @@ int main(int argc, char** argv) {
1414
for(const auto& file : successParseFile) {
1515
try {
1616
CANDatabase::fromFile(file);
17-
}
17+
}
1818
catch(const CANDatabaseException& e) {
1919
std::cerr << "Error with file \"" << file << "\": " << e.what() << std::endl;
2020
errors.push_back(i);

0 commit comments

Comments
 (0)