2016-06-14 23:32:35 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
#define BOOST_DI_CFG_DIAGNOSTICS_LEVEL 2
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <boost/di.hpp>
|
|
|
|
#include <cassert>
|
|
|
|
#include <cerrno>
|
|
|
|
#include <cstring>
|
|
|
|
#include <map>
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2016-10-10 21:01:12 -04:00
|
|
|
#include "config.hpp"
|
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
#define POLYBAR_NS \
|
|
|
|
namespace polybar { \
|
2016-06-14 23:32:35 -04:00
|
|
|
inline namespace v2_0_0 {
|
2016-11-19 00:22:44 -05:00
|
|
|
#define POLYBAR_NS_END \
|
2016-06-14 23:32:35 -04:00
|
|
|
} \
|
|
|
|
}
|
2016-11-19 00:22:44 -05:00
|
|
|
#define POLYBAR_NS_PATH "polybar::v2_0_0"
|
2016-06-14 23:32:35 -04:00
|
|
|
|
2016-11-20 17:04:31 -05:00
|
|
|
#ifndef PIPE_READ
|
2016-06-14 23:32:35 -04:00
|
|
|
#define PIPE_READ 0
|
2016-11-20 17:04:31 -05:00
|
|
|
#endif
|
|
|
|
#ifndef PIPE_WRITE
|
2016-06-14 23:32:35 -04:00
|
|
|
#define PIPE_WRITE 1
|
2016-11-20 17:04:31 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef STDOUT_FILENO
|
|
|
|
#define STDOUT_FILENO 1
|
|
|
|
#endif
|
|
|
|
#ifndef STDERR_FILENO
|
|
|
|
#define STDERR_FILENO 2
|
|
|
|
#endif
|
2016-06-14 23:32:35 -04:00
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
#include "debug.hpp"
|
|
|
|
#endif
|
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS
|
2016-06-14 23:32:35 -04:00
|
|
|
|
|
|
|
//==================================================
|
|
|
|
// Include common types (i.e, unclutter editor!)
|
|
|
|
//==================================================
|
|
|
|
|
|
|
|
namespace di = boost::di;
|
2016-10-29 00:48:51 -04:00
|
|
|
namespace placeholders = std::placeholders;
|
2016-06-14 23:32:35 -04:00
|
|
|
|
|
|
|
using std::string;
|
|
|
|
using std::stringstream;
|
|
|
|
using std::size_t;
|
2016-10-25 01:10:03 -04:00
|
|
|
using std::move;
|
2016-06-14 23:32:35 -04:00
|
|
|
using std::bind;
|
|
|
|
using std::forward;
|
2016-10-29 00:48:51 -04:00
|
|
|
using std::pair;
|
2016-06-14 23:32:35 -04:00
|
|
|
using std::function;
|
|
|
|
using std::shared_ptr;
|
|
|
|
using std::unique_ptr;
|
|
|
|
using std::make_unique;
|
|
|
|
using std::make_shared;
|
|
|
|
using std::make_pair;
|
|
|
|
using std::array;
|
|
|
|
using std::map;
|
|
|
|
using std::vector;
|
|
|
|
using std::to_string;
|
|
|
|
using std::strerror;
|
2016-11-12 03:40:14 -05:00
|
|
|
using std::exception;
|
2016-06-14 23:32:35 -04:00
|
|
|
|
|
|
|
//==================================================
|
|
|
|
// Errors and exceptions
|
|
|
|
//==================================================
|
|
|
|
|
|
|
|
class application_error : public std::runtime_error {
|
|
|
|
public:
|
|
|
|
int m_code;
|
|
|
|
|
|
|
|
explicit application_error(string&& message, int code = 0)
|
|
|
|
: std::runtime_error(forward<string>(message)), m_code(code) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class system_error : public application_error {
|
|
|
|
public:
|
|
|
|
explicit system_error() : application_error(strerror(errno), errno) {}
|
|
|
|
explicit system_error(string&& message)
|
|
|
|
: application_error(forward<string>(message) + " (reason: " + strerror(errno) + ")", errno) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
#define DEFINE_CHILD_ERROR(error, parent) \
|
|
|
|
class error : public parent { \
|
|
|
|
using parent::parent; \
|
|
|
|
}
|
|
|
|
#define DEFINE_ERROR(error) DEFINE_CHILD_ERROR(error, application_error)
|
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS_END
|