1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#pragma once

#include <cstdint>

#include <better-enums/enum.h>

namespace kooling::datamodel {

BETTER_ENUM(motion_type, std::int32_t,<--- Array index out of bounds<--- Assuming that condition 'index>=_size()' is not redundant<--- Calling function '_size' returns 10<--- Redundant assignment of 'none' to itself.<--- Redundant assignment of 'walking' to itself.<--- Redundant assignment of 'running' to itself.<--- Redundant assignment of 'cycling' to itself.<--- Redundant assignment of 'automotive' to itself.<--- Redundant assignment of 'unknown' to itself.<--- Redundant assignment of 'disabled' to itself.<--- Redundant assignment of 'subway' to itself.<--- Redundant assignment of 'unavailable' to itself.<--- Redundant assignment of 'flight' to itself.
    none        =  3,
    walking     =  7,
    running     =  8,
    cycling     =  1,
    automotive  =  0,
    unknown     =  4,
    disabled    = -3, // from android: userAskedNoTrack
    subway      = -2, // from android: noGpsOrNetwork
    unavailable = -1, // from php
    flight      =  9  // from c++
)

inline motion_type motion_type_or_none(std::int32_t val)
{
    if (const auto maybe{ motion_type::_from_integral_nothrow(val) })
    {
        return *maybe;
    }
    else
    {
        return motion_type::none;
    }
}

inline bool is_none(motion_type mt)
{
    return mt == +motion_type::none;
}

inline bool is_walking(motion_type mt)
{
    return mt == +motion_type::walking;
}

inline bool is_running(motion_type mt)
{
    return mt == +motion_type::running;
}

inline bool is_cycling(motion_type mt)
{
    return mt == +motion_type::cycling;
}

inline bool is_automotive(motion_type mt)
{
    return mt == +motion_type::automotive;
}

inline bool is_unknown(motion_type mt)
{
    return mt == +motion_type::unknown;
}

} // namespace kooling::datamodel