File: err.h

package info (click to toggle)
simrisc 16.05.00-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,568 kB
  • sloc: cpp: 6,877; fortran: 665; makefile: 112; ansic: 112; sh: 107
file content (111 lines) | stat: -rw-r--r-- 2,898 bytes parent folder | download | duplicates (2)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#ifndef INCLUDED_ERR_
#define INCLUDED_ERR_

#include <iosfwd>

#include <bobcat/mstream>

#include "../typedefs/typedefs.h"

    // err messages to cerr, messages may end in '\n'

class Err
{
    static char const *s_plain[];
    static char const *s_context[];
    static char const *s_src[];

    static LineInfo const *s_lineInfo;             // last set LineInfo
    static bool s_handle;                          // handle a context message

    public:
        enum Plain                          // plain errors,
        {                                   // no line context
            CUMPROB,
            INCIDENCE_SUM_PROB,
            MISSING_SPEC,
            MULTIPLY_SPECIFIED,
            CT_NO_SENS,
            UNDEFINED_SPEC,
            CUM_DEATH,
        };

        enum Context
        {
            AT_LEAST,
            CT_SENS,
            CT_SENS_RANGE,
            GROUP_NO_COLON,
            INVALID_TYPE,
            INVALID_VALUE,
            MODALITY_REPEATED,
            NEGATIVE,
            NOT_CONSECUTIVE,
            PROB_SUM,
            RANGE_0_1,
            ROUND_AGES_DONT_INC,
            ROUND_NONE,
            SPEC_ERROR,
            UNDEFINED_DIST,
            UNDEFINED_MODALITY,
            VSD_MISSING,
            LC_INVALID_MODALITY,
            BC_CT_INVALID,
            TABLEPARAMS
        };

        static char const *src(ParamsSrc type);

                    // merely the error message:
        static std::ostream &msg(Plain err);                            // 1.

                    // error msg + src and line nr, ending in ": "
        static std::ostream &msg(Context err);                          // 2.
        static void msgTxt(Context err);            // also inserts line txt

                    // msg(RANGE_0_1 using line)
        static void range();

                    // msg(NEGATIVE using line)
        static void negative();

                    // msg(AT_LEAST using line)
        static void atLeast(double minimum);

                    // msg(SPEC_ERROR using line
        static void specification();

                    // msg(MULTIPLY_SPECIFIED)
        static void multiplySpecified(LineInfoVect::const_iterator begin,
                                      LineInfoVect::const_iterator end,
                                      std::string const &sectionList);

        static LineInfo const *reset(LineInfo const &lineInfo);

        static std::string const &txt();

                                    // status of all operations since the
        static bool valid();        // last reset
};

inline bool Err::valid()
{
    return s_handle;
}

inline char const *Err::src(ParamsSrc type)
{
    return s_src[type];
}

inline void Err::msgTxt(Context err)
{
    msg(err) << '`' << s_lineInfo->txt << '\'' << std::endl;
}

inline std::string const &Err::txt()
{
    return s_lineInfo->txt;
}

#endif