C++ wrapper for posix and linux specific functions [closed]
Asked Answered
W

6

6

Do you know about any good library wrapping posix and linux functions and structures ( eg. sockets or file descriptors ) into C++ classes? For example I'm thinking about a base FileDescriptor class and some inheriting classes ( unix sockets etc ) with methods like write, read or even some syscalls ( sendfile, splice ) - all throwing exceptions instead of setting errno. Or some shared memory class etc.

I can't seem to find anything like that and by now I consider writing it myself, as I often have to write a C++ app for linux and either use C functions ( painful error checking ), or wrap them myself every time.

---EDIT---

Well neither QT nor Boost will compile on the system, we're using - it's a small linux kernel based on 2.4.29 installed on embedded computers.

Waddell answered 30/3, 2010 at 9:11 Comment(1)
Why wrapping something if it is not intended to be cross-platform? Besides, C error handling isn't nearly as painful as ensuring exception safety in C++ code.Dentilabial
L
3

Try Common C++. I haven't used it myself, but it supports the things you've mentioned.

Lactobacillus answered 30/3, 2010 at 9:43 Comment(1)
That should be what I'm looking for, thanksWaddell
F
4

Well, not exactly a wrapper, but Boost has a library for everything, and supports all major platforms.

Fraxinella answered 30/3, 2010 at 9:23 Comment(0)
C
4

Boost has a number of portable interfaces for some of the things you need e.g. Boost.Interprocess or Boost.Asio.

Carline answered 30/3, 2010 at 9:27 Comment(0)
L
3

Try Common C++. I haven't used it myself, but it supports the things you've mentioned.

Lactobacillus answered 30/3, 2010 at 9:43 Comment(1)
That should be what I'm looking for, thanksWaddell
P
2

posixcpp. It is at early stage now. It isn't crossplatform, but GCC and Linux oriented. Licensed under LGPL 3.

Prevention answered 11/11, 2014 at 15:55 Comment(0)
R
1

Qt tackles many of the problems which normally are platform dependent. GUI wise, but console stuff is covered too. e.g.:

Rasure answered 30/3, 2010 at 9:19 Comment(0)
S
0

There's Qt - which is much more than a GUI library. Nokia call it "application and UI framework". The "application" part refers to Qt's wrapping of interfaces for files, sockets, threads, and much more.

Qt is C++, and IMHO one of the best designed C++ code bases out there, so it's definitely worth a try.

Scorekeeper answered 30/3, 2010 at 9:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.