You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Roger Meier (JIRA)" <ji...@apache.org> on 2014/05/04 21:51:15 UTC
[jira] [Resolved] (THRIFT-2494) Add enum toString helper function
in c_glib
[ https://issues.apache.org/jira/browse/THRIFT-2494?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Roger Meier resolved THRIFT-2494.
---------------------------------
Resolution: Fixed
Fix Version/s: 0.9.2
Assignee: Roger Meier
thanks Xiaodong!
committed
;-r
> 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
> Assignee: Roger Meier
> Fix For: 0.9.2
>
> 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)