You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Matt Chambers <mv...@me.com> on 2012/10/28 06:45:41 UTC

C++ enumeration example

Anyone have any example code on how to use the thrift generated enumerations in C++?  I'm not sure what to do with this:

struct JobState {
  enum type {
    INITIALIZE = 0,
    RUNNING = 1,
    FINISHED = 2
  };
};

In Java its easy, JobState.RUNNING, no such thing in C++.

-Matt



Re: C++ enumeration example

Posted by Matt Chambers <mv...@me.com>.
Ah, nevermind, I got it.  JobState::RUNNING.  I had to set the type of my var to JobState::type.

On Oct 28, 2012, at 6:51 PM, Tarun Goyal <jo...@gmail.com> wrote:

> Hi,
> 
> if i got your question correctly then In C++ this works fine.
> 
> enum JOBSTATE{
> 
>  INITIALIZE = 0,
>    RUNNING = 1,
>    FINISHED = 2
> }
> 
> Thanks,
> Tarun
> 
> 
> On Sun, Oct 28, 2012 at 11:15 AM, Matt Chambers <mv...@me.com> wrote:
> 
>> Anyone have any example code on how to use the thrift generated
>> enumerations in C++?  I'm not sure what to do with this:
>> 
>> struct JobState {
>>  enum type {
>>    INITIALIZE = 0,
>>    RUNNING = 1,
>>    FINISHED = 2
>>  };
>> };
>> 
>> In Java its easy, JobState.RUNNING, no such thing in C++.
>> 
>> -Matt
>> 
>> 
>> 
> 
> 
> -- 
> Regards,
> Tarun


Re: C++ enumeration example

Posted by Matt Chambers <mv...@me.com>.
The code I posed was the generated thrift code, I'm just not sure how to access the values though.  I need to make  a vector of states.  (sorry somewhat new to C++)

-Matt

On Oct 28, 2012, at 6:51 PM, Tarun Goyal <jo...@gmail.com> wrote:

> Hi,
> 
> if i got your question correctly then In C++ this works fine.
> 
> enum JOBSTATE{
> 
>  INITIALIZE = 0,
>    RUNNING = 1,
>    FINISHED = 2
> }
> 
> Thanks,
> Tarun
> 
> 
> On Sun, Oct 28, 2012 at 11:15 AM, Matt Chambers <mv...@me.com> wrote:
> 
>> Anyone have any example code on how to use the thrift generated
>> enumerations in C++?  I'm not sure what to do with this:
>> 
>> struct JobState {
>>  enum type {
>>    INITIALIZE = 0,
>>    RUNNING = 1,
>>    FINISHED = 2
>>  };
>> };
>> 
>> In Java its easy, JobState.RUNNING, no such thing in C++.
>> 
>> -Matt
>> 
>> 
>> 
> 
> 
> -- 
> Regards,
> Tarun


Re: C++ enumeration example

Posted by Tarun Goyal <jo...@gmail.com>.
Hi,

if i got your question correctly then In C++ this works fine.

enum JOBSTATE{

  INITIALIZE = 0,
    RUNNING = 1,
    FINISHED = 2
}

Thanks,
Tarun


On Sun, Oct 28, 2012 at 11:15 AM, Matt Chambers <mv...@me.com> wrote:

> Anyone have any example code on how to use the thrift generated
> enumerations in C++?  I'm not sure what to do with this:
>
> struct JobState {
>   enum type {
>     INITIALIZE = 0,
>     RUNNING = 1,
>     FINISHED = 2
>   };
> };
>
> In Java its easy, JobState.RUNNING, no such thing in C++.
>
> -Matt
>
>
>


-- 
Regards,
Tarun