<commit_before>/*
    License...
*/
 
#ifndef SERIALPORT_H
#define SERIALPORT_H

#include <QtCore/QIODevice>

#ifdef SERIALPORT_SHARED
#  ifdef SERIALPORT_BUILD
#    define SERIALPORT_EXPORT Q_DECL_EXPORT
#  else
#    define SERIALPORT_EXPORT Q_DECL_IMPORT
#  endif
#else
#  define SERIALPORT_EXPORT
#endif
 
class SerialPortInfo;
class SerialPortPrivate;
 
class SERIALPORT_EXPORT SerialPort : public QIODevice
{
    Q_OBJECT

    Q_PROPERTY(qint32 rate READ rate WRITE setRate)
    Q_PROPERTY(DataBits dataBits READ dataBits WRITE setDataBits)
    Q_PROPERTY(Parity parity READ parity WRITE setParity)
    Q_PROPERTY(StopBits stopBits READ stopBits WRITE setStopBits)
    Q_PROPERTY(FlowControl flowControl READ flowControl WRITE setFlowControl)
    Q_PROPERTY(DataErrorPolicy dataErrorPolicy READ dataErrorPolicy WRITE setDataErrorPolicy)
    Q_PROPERTY(bool dtr READ dtr WRITE setDtr)
    Q_PROPERTY(bool rts READ rts WRITE setRts)
    Q_PROPERTY(PortError error READ error RESET unsetError)
 
    Q_ENUMS( Directions Rate DataBits Parity StopBits FlowControl Lines DataErrorPolicy PortError ) 
 
public:
 
    enum Direction  { 
        Input = 1, 
        Output = 2,
        AllDirections = Input | Output
    };
    Q_DECLARE_FLAGS(Directions, Direction)
 
    enum Rate {
        Rate1200 = 1200, 
        Rate2400 = 2400, 
        Rate4800 = 4800,   
        Rate9600 = 9600, 
        Rate19200 = 19200, 
        Rate38400 = 38400,  
        Rate57600 = 57600, 
        Rate115200 = 115200, 
        UnknownRate = -1 
    };
 
    enum DataBits {
        Data5 = 5, 
        Data6 = 6, 
        Data7 = 7, 
        Data8 = 8, 
        UnknownDataBits = -1 
    };
 
    enum Parity {
        NoParity = 0, 
        EvenParity = 2, 
        OddParity = 3,        
        SpaceParity = 4, 
        MarkParity = 5,         
        UnknownParity = -1 
    };
 
    enum StopBits {
        OneStop = 1, 
        OneAndHalfStop = 3, 
        TwoStop = 2, 
        UnknownStopBits = -1 
    };
 
    enum FlowControl {
        NoFlowControl,      
        HardwareControl, 
        SoftwareControl, 
        UnknownFlowControl = -1 
    };
 
    enum Line {
        Le = 0x01, 
        Dtr = 0x02, 
        Rts = 0x04, 
        St = 0x08, 
        Sr = 0x10, 
        Cts = 0x20, 
        Dcd = 0x40, 
        Ri = 0x80, 
        Dsr = Le    
    };
    Q_DECLARE_FLAGS(Lines, Line)
 
    enum DataErrorPolicy {
        SkipPolicy,
        PassZeroPolicy,
        IgnorePolicy,
        StopReceivingPolicy
    };
 
    enum PortError {
        NoError,                
        NoSuchDeviceError,           
        PermissionDeniedError,       
        DeviceAlreadyOpenedError,    
        DeviceIsNotOpenedError,      
        ParityError,
        IoError
    };
 
    explicit SerialPort(QObject *parent = 0);
    explicit SerialPort(const QString &name, QObject *parent = 0);
    explicit SerialPort(const SerialPortInfo &info, QObject *parent = 0);
    virtual ~SerialPort();
 
    void setPort(const QString &port);
    void setPort(const SerialPortInfo &info);
    QString portName() const;
 
    virtual bool open(OpenMode mode);
    virtual void close();
 
    bool setRate(qint32 rate, Directions dir = AllDirections);
    qint32 rate(Directions dir = AllDirections) const;
 
    bool setDataBits(DataBits dataBits);
    DataBits dataBits() const;
 
    bool setParity(Parity parity);
    Parity parity() const;
 
    bool setStopBits(StopBits stopBits);
    StopBits stopBits() const;
 
    bool setFlowControl(FlowControl flow);
    FlowControl flowControl() const;
 
    bool setDataInterval(int usecs);
    int dataInterval() const;
 
    bool setReadTimeout(int msecs);
    int readTimeout() const;
 
    bool dtr() const;
    bool rts() const;
 
    Lines lines() const;
 
    bool flush();
    virtual bool reset();
 
    bool setDataErrorPolicy(DataErrorPolicy policy = IgnorePolicy);
    DataErrorPolicy dataErrorPolicy() const;
 
    PortError error() const;
    void unsetError();
 
    virtual bool isSequential() const;
 
    virtual qint64 bytesAvailable() const;
    virtual qint64 bytesToWrite() const;
 
    virtual bool waitForReadyRead(int msecs);
    virtual bool waitForBytesWritten(int msecs);
 
 public Q_SLOTS:
    bool setDtr(bool set);
    bool setRts(bool set);
    bool sendBreak(int duration = 0);
    bool setBreak(bool set = true);
    bool clearBreak(bool clear = true);
 
protected:
    virtual qint64 readData(char *data, qint64 maxSize);
    virtual qint64 writeData(const char *data, qint64 maxSize);
 
private:
    SerialPortPrivate * const d_ptr;
 
    Q_DECLARE_PRIVATE(SerialPort)
    Q_DISABLE_COPY(SerialPort)
};
 
inline bool SerialPort::clearBreak(bool clear)
{ return setBreak(!clear); }
 
Q_DECLARE_OPERATORS_FOR_FLAGS(SerialPort::Directions)
Q_DECLARE_OPERATORS_FOR_FLAGS(SerialPort::Lines)
 
#endif // SERIALPORT_H<commit_msg>Removed spaces from end of lines<commit_after>/*
    License...
*/

#ifndef SERIALPORT_H
#define SERIALPORT_H

#include <QtCore/QIODevice>

#ifdef SERIALPORT_SHARED
#  ifdef SERIALPORT_BUILD
#    define SERIALPORT_EXPORT Q_DECL_EXPORT
#  else
#    define SERIALPORT_EXPORT Q_DECL_IMPORT
#  endif
#else
#  define SERIALPORT_EXPORT
#endif

class SerialPortInfo;
class SerialPortPrivate;

class SERIALPORT_EXPORT SerialPort : public QIODevice
{
    Q_OBJECT

    Q_PROPERTY(qint32 rate READ rate WRITE setRate)
    Q_PROPERTY(DataBits dataBits READ dataBits WRITE setDataBits)
    Q_PROPERTY(Parity parity READ parity WRITE setParity)
    Q_PROPERTY(StopBits stopBits READ stopBits WRITE setStopBits)
    Q_PROPERTY(FlowControl flowControl READ flowControl WRITE setFlowControl)
    Q_PROPERTY(DataErrorPolicy dataErrorPolicy READ dataErrorPolicy WRITE setDataErrorPolicy)
    Q_PROPERTY(bool dtr READ dtr WRITE setDtr)
    Q_PROPERTY(bool rts READ rts WRITE setRts)
    Q_PROPERTY(PortError error READ error RESET unsetError)

    Q_ENUMS( Directions Rate DataBits Parity StopBits FlowControl Lines DataErrorPolicy PortError ) 

public:

    enum Direction  {
        Input = 1,
        Output = 2,
        AllDirections = Input | Output
    };
    Q_DECLARE_FLAGS(Directions, Direction)

    enum Rate {
        Rate1200 = 1200,
        Rate2400 = 2400,
        Rate4800 = 4800,
        Rate9600 = 9600,
        Rate19200 = 19200,
        Rate38400 = 38400,
        Rate57600 = 57600,
        Rate115200 = 115200,
        UnknownRate = -1
    };

    enum DataBits {
        Data5 = 5,
        Data6 = 6,
        Data7 = 7,
        Data8 = 8,
        UnknownDataBits = -1
    };

    enum Parity {
        NoParity = 0,
        EvenParity = 2,
        OddParity = 3,
        SpaceParity = 4,
        MarkParity = 5,
        UnknownParity = -1
    };

    enum StopBits {
        OneStop = 1,
        OneAndHalfStop = 3,
        TwoStop = 2,
        UnknownStopBits = -1
    };

    enum FlowControl {
        NoFlowControl,
        HardwareControl,
        SoftwareControl,
        UnknownFlowControl = -1
    };

    enum Line {
        Le = 0x01,
        Dtr = 0x02,
        Rts = 0x04,
        St = 0x08,
        Sr = 0x10,
        Cts = 0x20,
        Dcd = 0x40,
        Ri = 0x80,
        Dsr = Le
    };
    Q_DECLARE_FLAGS(Lines, Line)

    enum DataErrorPolicy {
        SkipPolicy,
        PassZeroPolicy,
        IgnorePolicy,
        StopReceivingPolicy
    };

    enum PortError {
        NoError,
        NoSuchDeviceError,
        PermissionDeniedError,
        DeviceAlreadyOpenedError,
        DeviceIsNotOpenedError,
        ParityError,
        IoError
    };

    explicit SerialPort(QObject *parent = 0);
    explicit SerialPort(const QString &name, QObject *parent = 0);
    explicit SerialPort(const SerialPortInfo &info, QObject *parent = 0);
    virtual ~SerialPort();

    void setPort(const QString &port);
    void setPort(const SerialPortInfo &info);
    QString portName() const;

    virtual bool open(OpenMode mode);
    virtual void close();

    bool setRate(qint32 rate, Directions dir = AllDirections);
    qint32 rate(Directions dir = AllDirections) const;

    bool setDataBits(DataBits dataBits);
    DataBits dataBits() const;

    bool setParity(Parity parity);
    Parity parity() const;

    bool setStopBits(StopBits stopBits);
    StopBits stopBits() const;

    bool setFlowControl(FlowControl flow);
    FlowControl flowControl() const;

    bool setDataInterval(int usecs);
    int dataInterval() const;

    bool setReadTimeout(int msecs);
    int readTimeout() const;

    bool dtr() const;
    bool rts() const;

    Lines lines() const;

    bool flush();
    virtual bool reset();

    bool setDataErrorPolicy(DataErrorPolicy policy = IgnorePolicy);
    DataErrorPolicy dataErrorPolicy() const;

    PortError error() const;
    void unsetError();

    virtual bool isSequential() const;

    virtual qint64 bytesAvailable() const;
    virtual qint64 bytesToWrite() const;

    virtual bool waitForReadyRead(int msecs);
    virtual bool waitForBytesWritten(int msecs);

public Q_SLOTS:
    bool setDtr(bool set);
    bool setRts(bool set);
    bool sendBreak(int duration = 0);
    bool setBreak(bool set = true);
    bool clearBreak(bool clear = true);

protected:
    virtual qint64 readData(char *data, qint64 maxSize);
    virtual qint64 writeData(const char *data, qint64 maxSize);

private:
    SerialPortPrivate * const d_ptr;

    Q_DECLARE_PRIVATE(SerialPort)
    Q_DISABLE_COPY(SerialPort)
};

inline bool SerialPort::clearBreak(bool clear)
{ return setBreak(!clear); }

Q_DECLARE_OPERATORS_FOR_FLAGS(SerialPort::Directions)
Q_DECLARE_OPERATORS_FOR_FLAGS(SerialPort::Lines)

#endif // SERIALPORT_H
{'fraction_non_alphanumeric': 0.07379767827529021, 'fraction_numerical': 0.029643449419568823, 'mean_word_length': 2.6044079193126635, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4970196', 'n_tokens_mistral': 3320, 'n_tokens_neox': 2956, 'n_words': 786}