• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

STEllAR-GROUP / hpx / #882

31 Aug 2023 07:44PM UTC coverage: 41.798% (-44.7%) from 86.546%
#882

push

19442 of 46514 relevant lines covered (41.8%)

126375.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
/libs/full/performance_counters/src/counter_parser.cpp
1
//  Copyright (c) 2020 Agustin Berge
2
//  Copyright (c) 2007-2017 Hartmut Kaiser
3
//  Copyright (c) 2011 Bryce Lelbach
4
//
5
//  SPDX-License-Identifier: BSL-1.0
6
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
7
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8

9
#include <hpx/config.hpp>
10
#include <hpx/performance_counters/counter_parser.hpp>
11
#include <hpx/performance_counters/counters.hpp>
12

13
#include <boost/fusion/include/adapt_struct.hpp>
14

15
#include <boost/spirit/home/x3/auxiliary.hpp>
16
#include <boost/spirit/home/x3/char.hpp>
17
#include <boost/spirit/home/x3/core.hpp>
18
#include <boost/spirit/home/x3/directive.hpp>
19
#include <boost/spirit/home/x3/nonterminal.hpp>
20
#include <boost/spirit/home/x3/numeric.hpp>
21
#include <boost/spirit/home/x3/operator.hpp>
22
#include <boost/spirit/home/x3/string.hpp>
23

24
#include <string>
25

26
BOOST_FUSION_ADAPT_STRUCT(
×
27
    hpx::performance_counters::instance_name, name_, index_, basename_)
28

29
BOOST_FUSION_ADAPT_STRUCT(
36,270✔
30
    hpx::performance_counters::instance_elements, parent_, child_, subchild_)
31

32
BOOST_FUSION_ADAPT_STRUCT(hpx::performance_counters::path_elements, object_,
48,360✔
33
    instance_, counter_, parameters_)
34

35
namespace {
36
    ///
37
    ///    /objectname{parentinstancename#parentindex/instancename#instanceindex}
38
    ///       /countername#parameters
39
    ///    /objectname{parentinstancename#*/instancename#*}/countername#parameters
40
    ///    /objectname{/basecounter}/countername,parameters
41
    ///
42
    namespace x3 = boost::spirit::x3;
43

44
    x3::rule<class path_parser, hpx::performance_counters::path_elements> const
45
        path_parser = "path_parser";
46
    x3::rule<class instance, hpx::performance_counters::instance_elements> const
47
        instance = "instance";
48
    x3::rule<class parent, hpx::performance_counters::instance_name> const
49
        parent = "parent";
50
    x3::rule<class child, hpx::performance_counters::instance_name> const
51
        child = "child";
52
    x3::rule<class subchild, hpx::performance_counters::instance_name> const
53
        subchild = "subchild";
54
    x3::rule<class raw_uint, std::string> const raw_uint = "raw_uint";
55

56
    auto const path_parser_def =
57
        -x3::lit(hpx::performance_counters::counter_prefix) >> '/' >>
58
        +~x3::char_("/{#@") >> -instance >> -('/' >> +~x3::char_("#}@")) >>
59
        -('@' >> +x3::char_);
60

61
    auto const instance_def = '{' >> parent >> -('/' >> child) >>
62
        -('/' >> subchild) >> '}';
63

64
    auto const parent_def = &x3::lit('/') >> x3::raw[path_parser] >>
65
            x3::attr("-1") >> x3::attr(true)
66
        // base counter
67
        | +~x3::char_("#/}") >>
68
            ('#' >> raw_uint           // counter parent-instance name
69
                | -x3::string("#*")    // counter parent-instance skeleton name
70
                ) >>
71
            x3::attr(false);
72

73
    auto const child_def = +~x3::char_("#/}") >>
74
        (x3::char_('#') >> +~x3::char_("/}")    // counter instance name
75
            | -x3::string("#*")    // counter instance skeleton name
76
            ) >>
77
        x3::attr(false);
78

79
    auto const subchild_def = +~x3::char_("#}") >>
80
        ('#' >> raw_uint           // counter (sub-)instance name
81
            | -x3::string("#*")    // counter (sub-)instance skeleton name
82
            ) >>
83
        x3::attr(false);
84

85
    auto const raw_uint_def = x3::raw[x3::uint_];
86

87
    BOOST_SPIRIT_DEFINE(    //-V801
×
88
        path_parser, instance, parent, child, subchild, raw_uint)
89

90
}    // namespace
91

92
namespace hpx::performance_counters {
93

94
    bool parse_counter_name(std::string const& name, path_elements& elements)
12,090✔
95
    {
96
        // parse the full name
97
        std::string::const_iterator begin = name.begin();
12,090✔
98
        return x3::parse(begin, name.end(), path_parser, elements) &&
12,090✔
99
            begin == name.end();
12,090✔
100
    }
101
}    // namespace hpx::performance_counters
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc