Code-style consistency improvement:

Apply clang-format-all.sh using the _clang-format file through all the cpp/.h files.
make sure not to apply it to certain serialization structures, since some parser expects the * as part of the name, instead of type.
This commit contains no other changes aside from adding and applying clang-format-all.sh
This commit is contained in:
erwincoumans
2018-09-23 14:17:31 -07:00
parent b73b05e9fb
commit ab8f16961e
1773 changed files with 1081087 additions and 474249 deletions

View File

@@ -44,178 +44,180 @@
#include <pthread.h>
namespace serial {
namespace serial
{
using std::invalid_argument;
using std::size_t;
using std::string;
using std::invalid_argument;
using serial::SerialException;
using serial::IOException;
using serial::SerialException;
class MillisecondTimer {
class MillisecondTimer
{
public:
MillisecondTimer(const uint32_t millis);
int64_t remaining();
MillisecondTimer(const uint32_t millis);
int64_t remaining();
private:
static timespec timespec_now();
timespec expiry;
static timespec timespec_now();
timespec expiry;
};
class serial::Serial::SerialImpl {
class serial::Serial::SerialImpl
{
public:
SerialImpl (const string &port,
unsigned long baudrate,
bytesize_t bytesize,
parity_t parity,
stopbits_t stopbits,
flowcontrol_t flowcontrol);
SerialImpl(const string &port,
unsigned long baudrate,
bytesize_t bytesize,
parity_t parity,
stopbits_t stopbits,
flowcontrol_t flowcontrol);
virtual ~SerialImpl ();
virtual ~SerialImpl();
void
open ();
void
open();
void
close ();
void
close();
bool
isOpen () const;
bool
isOpen() const;
size_t
available ();
size_t
available();
bool
waitReadable (uint32_t timeout);
bool
waitReadable(uint32_t timeout);
void
waitByteTimes (size_t count);
void
waitByteTimes(size_t count);
size_t
read (uint8_t *buf, size_t size = 1);
size_t
read(uint8_t *buf, size_t size = 1);
size_t
write (const uint8_t *data, size_t length);
size_t
write(const uint8_t *data, size_t length);
void
flush ();
void
flush();
void
flushInput ();
void
flushInput();
void
flushOutput ();
void
flushOutput();
void
sendBreak (int duration);
void
sendBreak(int duration);
void
setBreak (bool level);
void
setBreak(bool level);
void
setRTS (bool level);
void
setRTS(bool level);
void
setDTR (bool level);
void
setDTR(bool level);
bool
waitForChange ();
bool
waitForChange();
bool
getCTS ();
bool
getCTS();
bool
getDSR ();
bool
getDSR();
bool
getRI ();
bool
getRI();
bool
getCD ();
bool
getCD();
void
setPort (const string &port);
void
setPort(const string &port);
string
getPort () const;
string
getPort() const;
void
setTimeout (Timeout &timeout);
void
setTimeout(Timeout &timeout);
Timeout
getTimeout () const;
Timeout
getTimeout() const;
void
setBaudrate (unsigned long baudrate);
void
setBaudrate(unsigned long baudrate);
unsigned long
getBaudrate () const;
unsigned long
getBaudrate() const;
void
setBytesize (bytesize_t bytesize);
void
setBytesize(bytesize_t bytesize);
bytesize_t
getBytesize () const;
bytesize_t
getBytesize() const;
void
setParity (parity_t parity);
void
setParity(parity_t parity);
parity_t
getParity () const;
parity_t
getParity() const;
void
setStopbits (stopbits_t stopbits);
void
setStopbits(stopbits_t stopbits);
stopbits_t
getStopbits () const;
stopbits_t
getStopbits() const;
void
setFlowcontrol (flowcontrol_t flowcontrol);
void
setFlowcontrol(flowcontrol_t flowcontrol);
flowcontrol_t
getFlowcontrol () const;
flowcontrol_t
getFlowcontrol() const;
void
readLock ();
void
readLock();
void
readUnlock ();
void
readUnlock();
void
writeLock ();
void
writeLock();
void
writeUnlock ();
void
writeUnlock();
protected:
void reconfigurePort ();
void reconfigurePort();
private:
string port_; // Path to the file descriptor
int fd_; // The current file descriptor
string port_; // Path to the file descriptor
int fd_; // The current file descriptor
bool is_open_;
bool xonxoff_;
bool rtscts_;
bool is_open_;
bool xonxoff_;
bool rtscts_;
Timeout timeout_; // Timeout for read operations
unsigned long baudrate_; // Baudrate
uint32_t byte_time_ns_; // Nanoseconds to transmit/receive a single byte
Timeout timeout_; // Timeout for read operations
unsigned long baudrate_; // Baudrate
uint32_t byte_time_ns_; // Nanoseconds to transmit/receive a single byte
parity_t parity_; // Parity
bytesize_t bytesize_; // Size of the bytes
stopbits_t stopbits_; // Stop Bits
flowcontrol_t flowcontrol_; // Flow Control
parity_t parity_; // Parity
bytesize_t bytesize_; // Size of the bytes
stopbits_t stopbits_; // Stop Bits
flowcontrol_t flowcontrol_; // Flow Control
// Mutex used to lock the read functions
pthread_mutex_t read_mutex;
// Mutex used to lock the write functions
pthread_mutex_t write_mutex;
// Mutex used to lock the read functions
pthread_mutex_t read_mutex;
// Mutex used to lock the write functions
pthread_mutex_t write_mutex;
};
}
} // namespace serial
#endif // SERIAL_IMPL_UNIX_H
#endif // SERIAL_IMPL_UNIX_H
#endif // !defined(_WIN32)
#endif // !defined(_WIN32)

View File

@@ -43,165 +43,166 @@
#include "windows.h"
namespace serial {
namespace serial
{
using std::invalid_argument;
using std::string;
using std::wstring;
using std::invalid_argument;
using serial::SerialException;
using serial::IOException;
using serial::SerialException;
class serial::Serial::SerialImpl {
class serial::Serial::SerialImpl
{
public:
SerialImpl (const string &port,
unsigned long baudrate,
bytesize_t bytesize,
parity_t parity,
stopbits_t stopbits,
flowcontrol_t flowcontrol);
SerialImpl(const string &port,
unsigned long baudrate,
bytesize_t bytesize,
parity_t parity,
stopbits_t stopbits,
flowcontrol_t flowcontrol);
virtual ~SerialImpl ();
virtual ~SerialImpl();
void
open ();
void
open();
void
close ();
void
close();
bool
isOpen () const;
bool
isOpen() const;
size_t
available ();
bool
waitReadable (uint32_t timeout);
size_t
available();
void
waitByteTimes (size_t count);
bool
waitReadable(uint32_t timeout);
size_t
read (uint8_t *buf, size_t size = 1);
void
waitByteTimes(size_t count);
size_t
write (const uint8_t *data, size_t length);
size_t
read(uint8_t *buf, size_t size = 1);
void
flush ();
size_t
write(const uint8_t *data, size_t length);
void
flushInput ();
void
flush();
void
flushOutput ();
void
flushInput();
void
sendBreak (int duration);
void
flushOutput();
void
setBreak (bool level);
void
sendBreak(int duration);
void
setRTS (bool level);
void
setBreak(bool level);
void
setDTR (bool level);
void
setRTS(bool level);
bool
waitForChange ();
void
setDTR(bool level);
bool
getCTS ();
bool
waitForChange();
bool
getDSR ();
bool
getCTS();
bool
getRI ();
bool
getDSR();
bool
getCD ();
bool
getRI();
void
setPort (const string &port);
bool
getCD();
string
getPort () const;
void
setPort(const string &port);
void
setTimeout (Timeout &timeout);
string
getPort() const;
Timeout
getTimeout () const;
void
setTimeout(Timeout &timeout);
void
setBaudrate (unsigned long baudrate);
Timeout
getTimeout() const;
unsigned long
getBaudrate () const;
void
setBaudrate(unsigned long baudrate);
void
setBytesize (bytesize_t bytesize);
unsigned long
getBaudrate() const;
bytesize_t
getBytesize () const;
void
setBytesize(bytesize_t bytesize);
void
setParity (parity_t parity);
bytesize_t
getBytesize() const;
parity_t
getParity () const;
void
setParity(parity_t parity);
void
setStopbits (stopbits_t stopbits);
parity_t
getParity() const;
stopbits_t
getStopbits () const;
void
setStopbits(stopbits_t stopbits);
void
setFlowcontrol (flowcontrol_t flowcontrol);
stopbits_t
getStopbits() const;
flowcontrol_t
getFlowcontrol () const;
void
setFlowcontrol(flowcontrol_t flowcontrol);
void
readLock ();
flowcontrol_t
getFlowcontrol() const;
void
readUnlock ();
void
readLock();
void
writeLock ();
void
readUnlock();
void
writeUnlock ();
void
writeLock();
void
writeUnlock();
protected:
void reconfigurePort ();
void reconfigurePort();
private:
wstring port_; // Path to the file descriptor
HANDLE fd_;
wstring port_; // Path to the file descriptor
HANDLE fd_;
bool is_open_;
bool is_open_;
Timeout timeout_; // Timeout for read operations
unsigned long baudrate_; // Baudrate
Timeout timeout_; // Timeout for read operations
unsigned long baudrate_; // Baudrate
parity_t parity_; // Parity
bytesize_t bytesize_; // Size of the bytes
stopbits_t stopbits_; // Stop Bits
flowcontrol_t flowcontrol_; // Flow Control
parity_t parity_; // Parity
bytesize_t bytesize_; // Size of the bytes
stopbits_t stopbits_; // Stop Bits
flowcontrol_t flowcontrol_; // Flow Control
// Mutex used to lock the read functions
HANDLE read_mutex;
// Mutex used to lock the write functions
HANDLE write_mutex;
// Mutex used to lock the read functions
HANDLE read_mutex;
// Mutex used to lock the write functions
HANDLE write_mutex;
};
}
} // namespace serial
#endif // SERIAL_IMPL_WINDOWS_H
#endif // SERIAL_IMPL_WINDOWS_H
#endif // if defined(_WIN32)
#endif // if defined(_WIN32)