i3ipc++
An C++ implementaiton of the i3 IPC
 All Classes Functions Variables Enumerations Enumerator Modules
i3 IPC internal utilities

Stuff for internal usage in I3Connection. More...

Classes

struct  i3ipc::header_t
 i3 IPC header More...
 
class  i3ipc::ipc_error
 Base class of i3 IPC errors. More...
 
class  i3ipc::invalid_header_error
 Something wrong in message header (wrong magic number, message type etc.) More...
 
class  i3ipc::eof_error
 Socket return EOF, but expected a data. More...
 
class  i3ipc::invalid_reply_payload_error
 If something wrong in a payload of i3's reply. More...
 
class  i3ipc::errno_error
 If any error occured, while using C-functions. More...
 
struct  i3ipc::buf_t
 i3 IPC message buffer More...
 

Enumerations

enum  i3ipc::ClientMessageType : uint32_t {
  COMMAND = 0, GET_WORKSPACES = 1, SUBSCRIBE = 2, GET_OUTPUTS = 3,
  GET_TREE = 4, GET_MARKS = 5, GET_BAR_CONFIG = 6, GET_VERSION = 7
}
 Messages (requests), that can be sended from the client.
 
enum  i3ipc::ReplyType : uint32_t {
  COMMAND = 0, WORKSPACES = 1, SUBSCRIBE = 2, OUTPUTS = 3,
  TREE = 4, MARKS = 5, BAR_CONFIG = 6, VERSION = 7
}
 Replies, that can be sended from the i3 to the client.
 

Functions

struct i3ipc::header_t i3ipc::__attribute__ ((packed))
 
int32_t i3ipc::i3_connect (const std::string &socket_path)
 Connect to the i3 socket. More...
 
void i3ipc::i3_disconnect (const int32_t sockfd)
 Close the connection. More...
 
void i3ipc::i3_send (const int32_t sockfd, const buf_t &buff)
 Send message to the socket. More...
 
std::shared_ptr< buf_t > i3ipc::i3_recv (const int32_t sockfd) throw (invalid_header_error, eof_error)
 Recive a message from i3. More...
 
std::shared_ptr< buf_t > i3ipc::i3_pack (const ClientMessageType type, const std::string &payload)
 Pack a buffer of message.
 
std::shared_ptr< buf_t > i3ipc::i3_msg (const int32_t sockfd, const ClientMessageType type, const std::string &payload=std::string()) throw (invalid_header_error, eof_error)
 Pack, send a message and receiv a reply. More...
 

Variables

i3ipc::ipc_error i3ipc::__attribute__
 

Detailed Description

Stuff for internal usage in I3Connection.

Function Documentation

int32_t i3ipc::i3_connect ( const std::string &  socket_path)

Connect to the i3 socket.

Parameters
socket_patha socket path
Returns
socket id
void i3ipc::i3_disconnect ( const int32_t  sockfd)

Close the connection.

Parameters
sockfdsocket
std::shared_ptr<buf_t> i3ipc::i3_msg ( const int32_t  sockfd,
const ClientMessageType  type,
const std::string &  payload = std::string() 
)
throw (invalid_header_error,
eof_error
)

Pack, send a message and receiv a reply.

Almost same to:

i3_send(sockfd, i3_pack(type, payload));
auto reply = i3_recv(sockfd);
std::shared_ptr<buf_t> i3ipc::i3_recv ( const int32_t  sockfd)
throw (invalid_header_error,
eof_error
)

Recive a message from i3.

Parameters
sockfda socket
Returns
a buffer of the message
void i3ipc::i3_send ( const int32_t  sockfd,
const buf_t &  buff 
)

Send message to the socket.

Parameters
sockfda socket
buffa message