Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
remove need to use std::regex explicitly in constructor
  • Loading branch information
raybellis committed Oct 22, 2018
1 parent f76f228 commit 3a00060
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 18 deletions.
6 changes: 3 additions & 3 deletions drv_bcm.cc
Expand Up @@ -13,12 +13,12 @@

static RegexParser bnx2x(
{ "bnx2x" },
{ std::regex("^(rx|tx)_(bytes|[bum]cast_packets)$"), { 1, 2 } },
{ std::regex("^\\[(\\d+)\\]: (rx|tx)_(bytes|[bum]cast_packets)$"), { 2, 3, 1 } }
{ "^(rx|tx)_(bytes|[bum]cast_packets)$", { 1, 2 } },
{ "^\\[(\\d+)\\]: (rx|tx)_(bytes|[bum]cast_packets)$", { 2, 3, 1 } }
);

static RegexParser tg3(
{ "tg3" },
{ std::regex("^(rx|tx)_(octets|[bum]cast_packets)$"), { 1, 2 } },
{ "^(rx|tx)_(octets|[bum]cast_packets)$", { 1, 2 } },
RegexParser::queue_nomatch
);
2 changes: 1 addition & 1 deletion drv_emulex.cc
Expand Up @@ -14,5 +14,5 @@
static RegexParser emulex_be2net (
{ "be2net" },
RegexParser::total_nomatch,
{ std::regex("^(rx|tx)q(\\d+): \\1_(bytes|pkts)$"), { 1, 3, 2 } }
{ "^(rx|tx)q(\\d+): \\1_(bytes|pkts)$", { 1, 3, 2 } }
);
4 changes: 2 additions & 2 deletions drv_intel.cc
Expand Up @@ -14,11 +14,11 @@
static RegexParser intel_generic(
{ "ixgbe", "igb" },
RegexParser::total_nomatch,
{ std::regex("^(rx|tx)_queue_(\\d+)_(bytes|packets)$"), { 1, 3, 2 } }
{ "^(rx|tx)_queue_(\\d+)_(bytes|packets)$", { 1, 3, 2 } }
);

static RegexParser intel_i40e(
{ "i40e" },
RegexParser::total_nomatch,
{ std::regex("^(rx|tx)-(\\d+)\\.\\1_(bytes|packets)$"), { 1, 3, 2 } }
{ "^(rx|tx)-(\\d+)\\.\\1_(bytes|packets)$", { 1, 3, 2 } }
);
4 changes: 2 additions & 2 deletions drv_mellanox.cc
Expand Up @@ -13,6 +13,6 @@

static RegexParser mellaonx_mlx5_core(
{ "mlx5_core" },
{ std::regex("^(rx|tx)_(bytes|packets)$"), { 1, 2} },
{ std::regex("^(rx|tx)(\\d+)_(?:0_)?(bytes|packets)$"), { 1, 3, 2 } }
{ "^(rx|tx)_(bytes|packets)$", { 1, 2} },
{ "^(rx|tx)(\\d+)_(?:0_)?(bytes|packets)$", { 1, 3, 2 } }
);
2 changes: 1 addition & 1 deletion drv_realtek.cc
Expand Up @@ -13,6 +13,6 @@

static RegexParser r8169(
{ "r8169" },
{ std::regex("^(rx|tx)_(bytes|packets)$"), { 1, 2 } },
{ "^(rx|tx)_(bytes|packets)$", { 1, 2 } },
RegexParser::queue_nomatch
);
12 changes: 7 additions & 5 deletions parser.cc
Expand Up @@ -38,14 +38,16 @@ StringsetParser::ptr_t StringsetParser::find(const std::string& driver) {
}
}

RegexParser::total_t RegexParser::total_nomatch = { std::regex(""), { 0, 0 } };
RegexParser::queue_t RegexParser::queue_nomatch = { std::regex(""), { 0, 0, 0 } };
RegexParser::total_str_t RegexParser::total_nomatch = { "", { 0, 0 } };
RegexParser::queue_str_t RegexParser::queue_nomatch = { "", { 0, 0, 0 } };

RegexParser::RegexParser(
const driverlist_t& drivers,
const total_t& total,
const queue_t& queue
) : StringsetParser(drivers), total(total), queue(queue)
const total_str_t& total,
const queue_str_t& queue
) : StringsetParser(drivers),
total(std::regex(total.first), total.second),
queue(std::regex(queue.first), queue.second)
{
}

Expand Down
11 changes: 7 additions & 4 deletions parser.h
Expand Up @@ -72,9 +72,12 @@ class RegexParser : public StringsetParser {
typedef std::pair<std::regex, total_order_t> total_t;
typedef std::pair<std::regex, queue_order_t> queue_t;

typedef std::pair<std::string, total_order_t> total_str_t;
typedef std::pair<std::string, queue_order_t> queue_str_t;

public:
static total_t total_nomatch;
static queue_t queue_nomatch;
static total_str_t total_nomatch;
static queue_str_t queue_nomatch;

protected:
std::smatch ma;
Expand All @@ -84,8 +87,8 @@ class RegexParser : public StringsetParser {

public:
RegexParser(const driverlist_t& drivers,
const total_t& total,
const queue_t& queue);
const total_str_t& total,
const queue_str_t& queue);

virtual bool match_total(const std::string& key, size_t value, bool& rx, bool& bytes);
virtual bool match_queue(const std::string& key, size_t value, bool& rx, bool& bytes, size_t& qnum);
Expand Down

0 comments on commit 3a00060

Please sign in to comment.