Skip to content

Commit 122668e

Browse files
author
Daniel K. O.
committed
convert TypeCode to strings, plus some fixes
1 parent df84b57 commit 122668e

File tree

15 files changed

+84
-38
lines changed

15 files changed

+84
-38
lines changed

include/libevdevxx/Event.hpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* SPDX-License-Identifier: MIT
66
*/
77

8+
89
#ifndef LIBEVDEVXX_EVENT_HPP
910
#define LIBEVDEVXX_EVENT_HPP
1011

@@ -85,14 +86,9 @@ namespace evdev {
8586
to_string(const Event& e);
8687

8788

88-
//std::ostream&
89-
inline
90-
auto&
91-
operator <<(std::basic_ostream<auto, auto>& out,
92-
const Event& e)
93-
{
94-
return out << to_string(e);
95-
}
89+
std::ostream&
90+
operator <<(std::ostream& out,
91+
const Event& e);
9692

9793

9894
}

include/libevdevxx/Property.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
#include <cstddef>
14-
#include <ostream>
14+
#include <iosfwd>
1515
#include <stdexcept>
1616
#include <string>
1717
#include <string_view>

include/libevdevxx/ReadStatus.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
namespace evdev {
2121

2222

23-
enum class ReadStatus : int {
23+
enum ReadStatus : int {
2424
success = LIBEVDEV_READ_STATUS_SUCCESS,
2525
dropped = LIBEVDEV_READ_STATUS_SYNC,
2626
again = -EAGAIN

include/libevdevxx/Type.hpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#include <cstddef>
1414
#include <cstdint>
15-
#include <ostream>
15+
#include <iosfwd>
1616
#include <stdexcept>
1717
#include <string>
1818
#include <string_view>
@@ -115,15 +115,12 @@ namespace evdev {
115115

116116

117117
std::string
118-
to_string(Type t);
118+
to_string(Type type);
119119

120120

121-
auto&
122-
operator <<(std::basic_ostream<auto, auto>& out,
123-
Type t)
124-
{
125-
return out << to_string(t);
126-
}
121+
std::ostream&
122+
operator <<(std::ostream& out,
123+
Type type);
127124

128125

129126
} // namespace evdev

include/libevdevxx/TypeCode.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
#define LIBEVDEVXX_TYPE_CODE_HPP
1111

1212

13+
#include <string>
14+
#include <utility>
15+
16+
#include "Code.hpp"
17+
#include "Type.hpp"
18+
19+
1320
namespace evdev {
1421

1522

@@ -18,6 +25,10 @@ namespace evdev {
1825
Code code;
1926
};
2027

28+
29+
std::pair<std::string, std::string>
30+
to_strings(const TypeCode& tc);
31+
2132
}
2233

2334

include/libevdevxx/Uinput.hpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,13 @@
2323
namespace evdev {
2424

2525

26-
26+
/// A class to send events to a virtual device.
2727
class Uinput {
2828

29-
struct Deleter {
30-
void operator()(::libevdev_uinput* udev) const noexcept;
31-
};
32-
33-
std::unique_ptr<::libevdev_uinput, Deleter> udev;
34-
3529
public:
3630

3731
Uinput(const Device& dev);
38-
Uinput(const Device& dev, int f);
32+
Uinput(const Device& dev, int filedes);
3933

4034

4135
::libevdev_uinput* data() noexcept;
@@ -72,10 +66,19 @@ namespace evdev {
7266

7367
void flush();
7468

69+
70+
private:
71+
72+
struct Deleter {
73+
void operator()(::libevdev_uinput* udev) const noexcept;
74+
};
75+
76+
std::unique_ptr<::libevdev_uinput, Deleter> udev;
77+
7578
};
7679

7780

78-
}
81+
} // namespace evdev
7982

8083

8184
#endif

include/libevdevxx/detail/ScopedFile.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ namespace evdev::detail {
6060

6161
};
6262

63+
6364
} // namespace evdev::detail
6465

6566

libevdevxx.spec.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Version: @PACKAGE_VERSION@
66
Release: %mkrel 1
77
Summary: A C++ wrapper for libevdev.
88
Group: System/Libraries
9-
License: GPLv3+
9+
License: MIT
1010
Source0: @TARBALL_NAME@
1111

1212
%description

src/Event.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
* SPDX-License-Identifier: MIT
66
*/
77

8+
9+
#include <ostream>
10+
811
#include "libevdevxx/Event.hpp"
912

1013
#include "utils.hpp"
@@ -30,11 +33,13 @@ namespace evdev {
3033
}
3134

3235

33-
void
34-
test(std::ostream& out, const Event& e)
36+
std::ostream&
37+
operator <<(std::ostream& out,
38+
const Event& e)
3539
{
36-
out << "test: " << e << std::endl;
40+
return out << to_string(e);
3741
}
3842

3943

44+
4045
} // namespace evdev

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ libevdevxx_la_SOURCES = \
2525
ScopedFile.cpp \
2626
SyncError.cpp \
2727
Type.cpp \
28+
TypeCode.cpp \
2829
Uinput.cpp \
2930
utils.cpp utils.hpp
3031

0 commit comments

Comments
 (0)