使用枚举的节俭常量结构

时间:2014-03-12 14:28:40

标签: enums constants thrift

我有以下枚举,并希望使用此枚举的元素创建一个常量映射:

enum UploadFileType {
    POPULATION,
    PROBABILITY,
    REACH,
    CMOBILE,
    CMOBAPP
}

/**
 * Defines which files are uploadable in which country
 */
const map<string,list<UploadFileType>> uploadable_files = {
    'hu': [POPULATION, PROBABILITY, REACH, CMOBILE, CMOBAPP],
    'sk': [POPULATION, PROBABILITY, REACH]
}

我在这里遇到以下错误:

[FAILURE:/home/abc/internal.thrift:29] error: identifier POPULATION is unqualified!
[FAILURE:/home/abc/internal.thrift:29] error: identifier POPULATION is unqualified!

我不知道这应该如何正确。

2 个答案:

答案 0 :(得分:5)

枚举使用点表示法:

const map<string,list<UploadFileType>> uploadable_files = {
    'hu': [UploadFileType.POPULATION, UploadFileType.PROBABILITY, UploadFileType.REACH, UploadFileType.CMOBILE, UploadFileType.CMOBAPP],
    'sk': [UploadFileType.POPULATION, UploadFileType.PROBABILITY, UploadFileType.REACH]
}

答案 1 :(得分:0)

enum UploadFileType {
    POPULATION,
    PROBABILITY,
    REACH,
    CMOBILE,
    CMOBAPP
}

/**
 * Defines which files are uploadable in which country
 */
const map<string,list<UploadFileType>> uploadable_files = {
    'hu': [UploadFileType.POPULATION, UploadFileType.PROBABILITY, UploadFileType.REACH, UploadFileType.CMOBILE, UploadFileType.CMOBAPP],
    'sk': [UploadFileType.POPULATION, UploadFileType.PROBABILITY, UploadFileType.REACH]
}