Recover the value of enum constants names

  • Thread starter Thread starter roger.breton
  • Start date Start date
R

roger.breton

Guest
I'm new to c++. Have an old rusted C background...

I have the following statement:

uint8_rb StateTable[2][4] = { "Eth", "USB" };

The way I understand, this is a 2 x 4 array of unsigned integers defined the following way:

typedef unsigned char uint8_rb; //!< 8bit (unsigned)


Yet, further down the code, I see the following statements :

RB_GetDevicePortList(portInfo, &portCount, portCount); // Call the API again
// display device list
for (uint8_km i = 0; i < portCount; i++) {
printf("%d: [%s] %08d (%s)\n", i, StateTable[portInfo.State], portInfo.SerialNo, portInfo.Name);
}

My question is as follows:

I tried to understand the workings of the StateTable this way, by just defining a one-dimension variable :

uint8_rb RB_State[15] = { "12345678911234" };
*RB_State = *StateTable[portInfo[0].State];

But I am not getting the correct results. I realize I need to better research this before moving on. An help is appreciated.
It does not make sense that I try to dereference pointers to get the values of their memory locations? But I'm running out of ideas... Ultimately, for now, all I want to do is to be able to retrieve in a new variable the value in StateTable[portInfo[0].State].

This application uses a lot of enumerators. I understand the logic of enumerators in general. One thing that baffles me is how to retrieve the name associated with an enumerator value?

Continue reading...
 
Back
Top