/// @file xed-reg-role-enum.c

// This file was automatically generated.
// Do not edit this file.

#include <string.h>
#include <assert.h>
#include "xed-reg-role-enum.h"

typedef struct {
    const char* name;
    xed_reg_role_enum_t value;
} name_table_xed_reg_role_enum_t;
static const name_table_xed_reg_role_enum_t name_array_xed_reg_role_enum_t[] = {
{"INVALID", XED_REG_ROLE_INVALID},
{"NORMAL", XED_REG_ROLE_NORMAL},
{"SEGREG0", XED_REG_ROLE_SEGREG0},
{"SEGREG1", XED_REG_ROLE_SEGREG1},
{"BASE0", XED_REG_ROLE_BASE0},
{"BASE1", XED_REG_ROLE_BASE1},
{"INDEX", XED_REG_ROLE_INDEX},
{"LAST", XED_REG_ROLE_LAST},
{0, XED_REG_ROLE_LAST},
};

        
xed_reg_role_enum_t str2xed_reg_role_enum_t(const char* s)
{
   const name_table_xed_reg_role_enum_t* p = name_array_xed_reg_role_enum_t;
   while( p->name ) {
     if (strcmp(p->name,s) == 0) {
      return p->value;
     }
     p++;
   }
        

   return XED_REG_ROLE_INVALID;
}


const char* xed_reg_role_enum_t2str(const xed_reg_role_enum_t p)
{
   xed_reg_role_enum_t type_idx = p;
   if ( p > XED_REG_ROLE_LAST) type_idx = XED_REG_ROLE_LAST;
   return name_array_xed_reg_role_enum_t[type_idx].name;
}

xed_reg_role_enum_t xed_reg_role_enum_t_last(void) {
    return XED_REG_ROLE_LAST;
}
       
/*

Here is a skeleton switch statement embedded in a comment


  switch(p) {
  case XED_REG_ROLE_INVALID:
  case XED_REG_ROLE_NORMAL:
  case XED_REG_ROLE_SEGREG0:
  case XED_REG_ROLE_SEGREG1:
  case XED_REG_ROLE_BASE0:
  case XED_REG_ROLE_BASE1:
  case XED_REG_ROLE_INDEX:
  case XED_REG_ROLE_LAST:
  default:
     xed_assert(0);
  }
*/
