1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-03 04:33:30 -05:00
polybar/include/components/parser.hpp

47 lines
1.1 KiB
C++
Raw Normal View History

2016-06-14 23:32:35 -04:00
#pragma once
#include "common.hpp"
2016-11-25 07:55:15 -05:00
#include "errors.hpp"
#include "utils/color.hpp"
2016-06-14 23:32:35 -04:00
2016-11-19 00:22:44 -05:00
POLYBAR_NS
2016-06-14 23:32:35 -04:00
class signal_emitter;
2017-01-19 05:11:28 -05:00
enum class attribute;
enum class controltag;
2017-01-19 05:11:28 -05:00
enum class mousebtn;
struct bar_settings;
2016-11-21 09:07:00 -05:00
2016-11-24 22:10:26 -05:00
DEFINE_ERROR(parser_error);
DEFINE_CHILD_ERROR(unrecognized_token, parser_error);
DEFINE_CHILD_ERROR(unrecognized_attribute, parser_error);
DEFINE_CHILD_ERROR(unclosed_actionblocks, parser_error);
2016-06-14 23:32:35 -04:00
class parser {
public:
using make_type = unique_ptr<parser>;
static make_type make();
public:
explicit parser(signal_emitter& emitter);
void parse(const bar_settings& bar, string data);
2016-06-14 23:32:35 -04:00
protected:
void codeblock(string&& data, const bar_settings& bar);
2016-12-13 23:17:18 -05:00
size_t text(string&& data);
static rgba parse_color(const string& s, rgba fallback = rgba{0});
2019-08-06 13:35:07 -04:00
static int parse_fontindex(const string& s);
static attribute parse_attr(const char attr);
2016-12-13 23:17:18 -05:00
mousebtn parse_action_btn(const string& data);
2019-08-06 13:35:07 -04:00
static string parse_action_cmd(string&& data);
static controltag parse_control(const string& data);
2016-06-14 23:32:35 -04:00
private:
signal_emitter& m_sig;
2016-06-14 23:32:35 -04:00
vector<int> m_actions;
unique_ptr<parser> m_parser;
2016-06-14 23:32:35 -04:00
};
2016-11-19 00:22:44 -05:00
POLYBAR_NS_END