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

antonvw / wex / 15210572863

23 May 2025 12:42PM UTC coverage: 58.95% (+0.2%) from 58.799%
15210572863

push

github

web-flow
942 more vim g z commands (#943)

* first fix some tests

* moved vim z commands, added some g commands

* fixed test error

* added more vim z commands

16674 of 31160 branches covered (53.51%)

Branch coverage included in aggregate %.

13429 of 19905 relevant lines covered (67.47%)

1267.94 hits per line

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

86.09
/src/core/reflection.cpp
1
////////////////////////////////////////////////////////////////////////////////
2
// Name:      reflection.cpp
3
// Purpose:   Declaration of wex::reflection class
4
// Author:    Anton van Wezenbeek
5
// Copyright: (c) 2023-2024 Anton van Wezenbeek
6
////////////////////////////////////////////////////////////////////////////////
7

8
#include <wex/core/reflection.h>
9

10
namespace wex
11
{
12
const std::string to_string(const std::any& any)
660✔
13
{
14
  std::stringstream s;
660✔
15

16
  if (any.has_value())
660!
17
  {
18
    try
19
    {
20
      if (any.type() == typeid(double))
660✔
21
      {
22
        s << std::any_cast<double>(any);
3✔
23
      }
24
      else if (any.type() == typeid(bool))
657✔
25
      {
26
        s << std::any_cast<bool>(any);
3✔
27
      }
28
      else if (any.type() == typeid(int))
654✔
29
      {
30
        s << std::any_cast<int>(any);
215✔
31
      }
32
      else if (any.type() == typeid(long))
439✔
33
      {
34
        s << std::any_cast<long>(any);
3✔
35
      }
36
      else if (any.type() == typeid(float))
436✔
37
      {
38
        s << std::any_cast<float>(any);
3✔
39
      }
40
      else if (any.type() == typeid(size_t))
433✔
41
      {
42
        s << std::any_cast<size_t>(any);
302✔
43
      }
44
      else if (any.type() == typeid(std::string))
131✔
45
      {
46
        const auto str(std::any_cast<std::string>(any));
125✔
47
        s.write(str.data(), str.size());
125✔
48
      }
125✔
49
      else if (any.type() == typeid(const char*))
6!
50
      {
51
        s << std::any_cast<const char*>(any);
×
52
      }
53
      else
54
      {
55
        s << "<no cast available>";
6✔
56
      }
57
    }
58
    catch (const std::exception& e)
×
59
    {
60
      s << "<exception: " << e.what() << ">";
×
61
    }
×
62
  }
63
  else
64
  {
65
    s << "<no value>";
×
66
  }
67

68
  return s.str();
1,320✔
69
}
660✔
70
} // namespace wex
71

72
wex::reflection::reflection(const std::vector<reflection_t>& t, log_t what)
1,232✔
73
  : m_items(t)
1,232✔
74
  , m_log_t(what)
1,232✔
75
{
76
}
1,232✔
77

78
std::stringstream wex::reflection::log() const
200✔
79
{
80
  std::stringstream ss;
200✔
81
  bool              first = true;
200✔
82

83
  for (const auto& i : m_items)
860✔
84
  {
85
    const auto val(to_string(i.f())); // do not take reference
660✔
86

87
    if (m_log_t == log_t::SKIP_EMPTY && val.empty())
660✔
88
    {
89
      continue;
17✔
90
    }
91

92
    ss << (!first ? ", " : "") << i.name;
643✔
93

94
    if (!val.empty())
643✔
95
    {
96
      ss << ": " << val;
641✔
97
    }
98

99
    first = false;
643✔
100
  }
660✔
101

102
  if (!ss.str().empty())
200✔
103
  {
104
    ss << std::endl;
198✔
105
  }
106

107
  return ss;
200✔
108
}
×
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

© 2026 Coveralls, Inc