libutil++  1.9.3
 All Classes Functions Variables
Pipe.h
1 /*
2 ** libutil++
3 ** $Id: Pipe.h 1653 2016-02-28 19:54:59Z sella $
4 ** Copyright (c) 2011-2016 Digital Genesis, LLC. All Rights Reserved.
5 ** Released under the LGPL Version 2.1 License.
6 ** http://www.digitalgenesis.com
7 */
8 
9 #ifndef __libutilxx__sella__net__Pipe_H__
10 #define __libutilxx__sella__net__Pipe_H__
11 
12 #include "../../common.h"
13 #include "UnixSocket.h"
14 
15 #include <sys/socket.h>
16 
17 namespace sella {
18  namespace net {
19  class Pipe;
20  }
21 }
22 
24  public:
25  typedef std::shared_ptr<Pipe> shared;
26  typedef Pipe *ptr;
27 
28  static const size_t ReadSizeDefault = 65536;
29 
30  public:
31  Pipe(bool nonBlock = true) throw (SocketException);
32  Pipe(const Pipe &sock) = delete;
33  virtual ~Pipe();
34  void operator=(const Pipe &sock) = delete;
35 
36  ssize_t write(const void *data, size_t len) throw (SocketException);
37  ssize_t write(const std::string &data) throw (SocketException);
38  ssize_t write(const std::vector<uint8_t> &data) throw (SocketException);
39  ssize_t read(void *data, size_t len) throw (SocketException);
40  ssize_t read(std::string &data, size_t len = ReadSizeDefault) throw (SocketException);
41  ssize_t read(std::vector<uint8_t> &data, size_t len = ReadSizeDefault) throw (SocketException);
42 
43  int getWriteFD(void);
44  int getReadFD(void);
45 
46  static const Pipe::shared shared_ptr(bool nonBlock = true) throw (SocketException);
47 
48  protected:
49  int fd[2];
50 };
51 
52 #endif
53 
54 /*
55 ** vim: noet ts=3 sw=3
56 */