Skip to content

Commit 0b51ec7

Browse files
committed
Changes from running clang format
1 parent 23dc231 commit 0b51ec7

File tree

14 files changed

+590
-581
lines changed

14 files changed

+590
-581
lines changed

include/libdbc/dbc.hpp

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,56 +3,53 @@
33
#define __DBC_HPP__
44

55
#include <libdbc/exceptions/error.hpp>
6-
#include <libdbc/utils/utils.hpp>
7-
#include <libdbc/signal.hpp>
86
#include <libdbc/message.hpp>
7+
#include <libdbc/signal.hpp>
8+
#include <libdbc/utils/utils.hpp>
99

1010
#include <regex>
1111

1212
namespace libdbc {
1313

14-
class Parser {
15-
public:
16-
virtual ~Parser() = default;
17-
18-
virtual void parse_file(const std::string& file) = 0;
19-
20-
protected:
21-
14+
class Parser {
15+
public:
16+
virtual ~Parser() = default;
2217

23-
};
18+
virtual void parse_file(const std::string& file) = 0;
2419

25-
class DbcParser : public Parser {
26-
public:
27-
DbcParser();
20+
protected:
21+
};
2822

29-
virtual ~DbcParser() = default;
23+
class DbcParser : public Parser {
24+
public:
25+
DbcParser();
3026

31-
virtual void parse_file(const std::string& file) final override;
27+
virtual ~DbcParser() = default;
3228

33-
std::string get_version() const;
34-
std::vector<std::string> get_nodes() const;
35-
std::vector<libdbc::Message> get_messages() const;
29+
virtual void parse_file(const std::string& file) final override;
3630

37-
Message::ParseSignalsStatus parseMessage(const uint32_t id, const std::vector<uint8_t>& data, std::vector<double>& out_values);
31+
std::string get_version() const;
32+
std::vector<std::string> get_nodes() const;
33+
std::vector<libdbc::Message> get_messages() const;
3834

39-
private:
40-
std::string version;
41-
std::vector<std::string> nodes;
42-
std::vector<libdbc::Message> messages;
35+
Message::ParseSignalsStatus parseMessage(const uint32_t id, const std::vector<uint8_t>& data, std::vector<double>& out_values);
4336

44-
const std::regex version_re;
45-
const std::regex bit_timing_re;
46-
const std::regex name_space_re;
47-
const std::regex node_re;
48-
const std::regex message_re;
49-
const std::regex signal_re;
37+
private:
38+
std::string version;
39+
std::vector<std::string> nodes;
40+
std::vector<libdbc::Message> messages;
5041

51-
void parse_dbc_header(std::istream& file_stream);
52-
void parse_dbc_nodes(std::istream& file_stream);
53-
void parse_dbc_messages(const std::vector<std::string>& lines);
42+
const std::regex version_re;
43+
const std::regex bit_timing_re;
44+
const std::regex name_space_re;
45+
const std::regex node_re;
46+
const std::regex message_re;
47+
const std::regex signal_re;
5448

55-
};
49+
void parse_dbc_header(std::istream& file_stream);
50+
void parse_dbc_nodes(std::istream& file_stream);
51+
void parse_dbc_messages(const std::vector<std::string>& lines);
52+
};
5653

5754
}
5855

include/libdbc/exceptions/error.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55

66
namespace libdbc {
77

8-
class exception : public std::exception {
9-
public:
10-
const char * what() const throw() {
11-
return "libdbc exception occurred";
12-
}
13-
};
8+
class exception : public std::exception {
9+
public:
10+
const char* what() const throw() {
11+
return "libdbc exception occurred";
12+
}
13+
};
1414

15-
class validity_error : public exception {
16-
public:
17-
const char * what() const throw() {
18-
return "Invalid DBC file";
19-
}
20-
};
15+
class validity_error : public exception {
16+
public:
17+
const char* what() const throw() {
18+
return "Invalid DBC file";
19+
}
20+
};
2121

2222
} // libdbc
2323

include/libdbc/message.hpp

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,50 @@
11
#ifndef __MESSAGE_HPP__
22
#define __MESSAGE_HPP__
33

4-
#include <string>
5-
#include <vector>
64
#include <array>
75
#include <iostream>
86
#include <libdbc/signal.hpp>
7+
#include <string>
8+
#include <vector>
99

1010
namespace libdbc {
11-
struct Message {
12-
Message() = delete;
13-
explicit Message(uint32_t id, const std::string& name, uint8_t size, const std::string& node);
14-
15-
enum class ParseSignalsStatus {
16-
Success,
17-
ErrorMessageToLong,
18-
ErrorBigEndian,
19-
ErrorUnknownID,
20-
ErrorInvalidConversion,
21-
};
22-
23-
/*!
24-
* \brief parseSignals
25-
* \param data
26-
* \param values
27-
* \return
28-
*/
29-
ParseSignalsStatus parseSignals(const std::vector<uint8_t>& data, std::vector<double> &values) const;
30-
31-
void appendSignal(const Signal& signal);
32-
const std::vector<Signal> signals() const;
33-
uint32_t id() const;
34-
35-
virtual bool operator==(const Message& rhs) const;
36-
37-
private:
38-
uint32_t m_id;
39-
std::string m_name;
40-
uint8_t m_size;
41-
std::string m_node;
42-
std::vector<Signal> m_signals;
43-
44-
friend std::ostream& operator<<(std::ostream& os, const Message& dt);
11+
struct Message {
12+
Message() = delete;
13+
explicit Message(uint32_t id, const std::string& name, uint8_t size, const std::string& node);
14+
15+
enum class ParseSignalsStatus {
16+
Success,
17+
ErrorMessageToLong,
18+
ErrorBigEndian,
19+
ErrorUnknownID,
20+
ErrorInvalidConversion,
4521
};
4622

47-
std::ostream& operator<< (std::ostream &out, const Message& msg);
23+
/*!
24+
* \brief parseSignals
25+
* \param data
26+
* \param values
27+
* \return
28+
*/
29+
ParseSignalsStatus parseSignals(const std::vector<uint8_t>& data, std::vector<double>& values) const;
30+
31+
void appendSignal(const Signal& signal);
32+
const std::vector<Signal> signals() const;
33+
uint32_t id() const;
34+
35+
virtual bool operator==(const Message& rhs) const;
36+
37+
private:
38+
uint32_t m_id;
39+
std::string m_name;
40+
uint8_t m_size;
41+
std::string m_node;
42+
std::vector<Signal> m_signals;
43+
44+
friend std::ostream& operator<<(std::ostream& os, const Message& dt);
45+
};
46+
47+
std::ostream& operator<<(std::ostream& out, const Message& msg);
4848

4949
}
5050

include/libdbc/signal.hpp

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,44 @@
22
#ifndef __SIGNAL_HPP__
33
#define __SIGNAL_HPP__
44

5+
#include <iostream>
56
#include <string>
67
#include <vector>
7-
#include <iostream>
88

99
namespace libdbc {
10-
struct Signal {
11-
std::string name;
12-
bool is_multiplexed;
13-
uint32_t start_bit;
14-
uint32_t size;
15-
bool is_bigendian;
16-
bool is_signed;
17-
double factor;
18-
double offset;
19-
double min;
20-
double max;
21-
std::string unit;
22-
std::vector<std::string> receivers;
23-
24-
Signal() = delete;
25-
explicit Signal(std::string name, bool is_multiplexed, uint32_t start_bit, uint32_t size, bool is_bigendian, bool is_signed, double factor, double offset, double min, double max, std::string unit, std::vector<std::string> recievers);
26-
27-
virtual bool operator==(const Signal& rhs) const;
28-
bool operator< (const Signal& rhs) const;
29-
};
30-
31-
std::ostream& operator<< (std::ostream &out, const Signal& sig);
10+
struct Signal {
11+
std::string name;
12+
bool is_multiplexed;
13+
uint32_t start_bit;
14+
uint32_t size;
15+
bool is_bigendian;
16+
bool is_signed;
17+
double factor;
18+
double offset;
19+
double min;
20+
double max;
21+
std::string unit;
22+
std::vector<std::string> receivers;
23+
24+
Signal() = delete;
25+
explicit Signal(std::string name,
26+
bool is_multiplexed,
27+
uint32_t start_bit,
28+
uint32_t size,
29+
bool is_bigendian,
30+
bool is_signed,
31+
double factor,
32+
double offset,
33+
double min,
34+
double max,
35+
std::string unit,
36+
std::vector<std::string> recievers);
37+
38+
virtual bool operator==(const Signal& rhs) const;
39+
bool operator<(const Signal& rhs) const;
40+
};
41+
42+
std::ostream& operator<<(std::ostream& out, const Signal& sig);
3243

3344
}
3445

include/libdbc/utils/utils.hpp

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,47 @@
22
#ifndef __UTILS_HPP__
33
#define __UTILS_HPP__
44

5-
#include <string>
5+
#include <algorithm>
66
#include <fstream>
77
#include <iostream>
8-
#include <sstream>
9-
#include <algorithm>
108
#include <iterator>
9+
#include <sstream>
10+
#include <string>
1111

1212
namespace utils {
1313

14-
class StreamHandler {
15-
public:
16-
/**
17-
* This is a safe non line ending specific get_ine function. This is to help with files
18-
* carried over from different systems. i.e Unix file comes to Windows with LF endings
19-
* instead of CRLF.
20-
*
21-
* @param stream [description]
22-
* @param line [description]
23-
* @return [description]
24-
*/
25-
static std::istream & get_line( std::istream & stream, std::string & line );
26-
27-
28-
static std::istream & get_next_non_blank_line( std::istream & stream, std::string & line );
29-
30-
static std::istream & skip_to_next_blank_line( std::istream & stream, std::string & line );
31-
32-
};
33-
34-
class String {
35-
public:
36-
37-
static std::string trim(const std::string& line);
38-
39-
template <class Container>
40-
static void split(const std::string& str, Container& cont, char delim = ' ') {
41-
std::stringstream ss(str);
42-
std::string token;
43-
44-
while (std::getline(ss, token, delim)) {
45-
cont.push_back(token);
46-
}
14+
class StreamHandler {
15+
public:
16+
/**
17+
* This is a safe non line ending specific get_ine function. This is to help with files
18+
* carried over from different systems. i.e Unix file comes to Windows with LF endings
19+
* instead of CRLF.
20+
*
21+
* @param stream [description]
22+
* @param line [description]
23+
* @return [description]
24+
*/
25+
static std::istream& get_line(std::istream& stream, std::string& line);
26+
27+
static std::istream& get_next_non_blank_line(std::istream& stream, std::string& line);
28+
29+
static std::istream& skip_to_next_blank_line(std::istream& stream, std::string& line);
30+
};
31+
32+
class String {
33+
public:
34+
static std::string trim(const std::string& line);
35+
36+
template<class Container>
37+
static void split(const std::string& str, Container& cont, char delim = ' ') {
38+
std::stringstream ss(str);
39+
std::string token;
40+
41+
while (std::getline(ss, token, delim)) {
42+
cont.push_back(token);
4743
}
48-
49-
50-
};
44+
}
45+
};
5146

5247
}
5348

0 commit comments

Comments
 (0)