You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Hudson (JIRA)" <ji...@apache.org> on 2014/05/04 22:48:19 UTC

[jira] [Commented] (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:comment-tabpanel&focusedCommentId=13989138#comment-13989138 ] 

Hudson commented on THRIFT-2494:
--------------------------------

FAILURE: Integrated in Thrift #1146 (See [https://builds.apache.org/job/Thrift/1146/])
THRIFT-2494: Add enum toString helper function in c_glib (roger: rev 40f8ce2b4dd270d56ae39a4638f4a05bbdeb83d4)
* compiler/cpp/src/generate/t_c_glib_generator.cc


> 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)