File: Type.hpp

package info (click to toggle)
r-bioc-alabaster.base 1.6.1%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,652 kB
  • sloc: cpp: 11,377; sh: 29; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 824 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
#ifndef COMSERVATORY_TYPE_HPP
#define COMSERVATORY_TYPE_HPP

/**
 * @file Type.hpp
 *
 * @brief Defines the `Type` enumeration for field types.
 */

namespace comservatory {

/**
 * Type of a field in a CSV file.
 */
enum Type {
    STRING,
    NUMBER,
    COMPLEX,
    BOOLEAN,
    UNKNOWN
};

/**
 * @param type Type of a field.
 * @return String containing the type of the field.
 */
inline std::string type_to_name (Type type) {
    switch (type) {
        case NUMBER:
            return "NUMBER";
        case STRING:
            return "STRING";
        case BOOLEAN:
            return "BOOLEAN";
        case COMPLEX:
            return "COMPLEX";
        case UNKNOWN:
            return "UNKNOWN";
        default:
            throw std::runtime_error("unrecognized type for name generation");
    }
}

}

#endif