[ https://issues.apache.org/jira/browse/THRIFT-2494?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Xiaodong Ma updated THRIFT-2494: -------------------------------- Attachment: c_glib_enum_toString.diff > Add enum toString helper function in c_glib > ------------------------------------------- > > Key: THRIFT-2494 > URL: https://issues.apache.org/jira/browse/THRIFT-2494 > Project: Thrift > Issue Type: Improvement > Components: C glib - Compiler > Reporter: Xiaodong Ma > Attachments: c_glib_enum_toString.diff > > > If I have IDL like this: > enum CertificateStoreType > { > CERT = 1, > PKCS12 = 2 > } > In header file, it will be: > enum _CertificateStoreType { > CERTIFICATE_STORE_TYPE_CERT = 1, > CERTIFICATE_STORE_TYPE_PKCS12 = 2 > }; > typedef enum _CertificateStoreType CertificateStoreType; > + /* return the name of the constant */ > + const char * > + toString_CertificateStoreType(int value); > In c file > + /* return the name of the constant */ > + const char * > + toString_CertificateStoreType(int value) > + { > + static __thread char buf[16] = {0}; > + switch(value) { > + case CERTIFICATE_STORE_TYPE_CERT:return "CERTIFICATE_STORE_TYPE_CERT"; > + case CERTIFICATE_STORE_TYPE_PKCS12:return "CERTIFICATE_STORE_TYPE_PKCS12"; > + default: g_snprintf(buf, 16, "%d", value); return buf; > + } > + } -- This message was sent by Atlassian JIRA (v6.2#6252)