maslak
maslak

Reputation: 1265

Protobuf empty string as ENUM name

Let's say I have this Protocol Buffers schema:

message Person{
  enum Height{
    UNDEFINED = 0;
    TALL = 1;
    SHORT = 2;
  }
  HEIGHT Height = 1;
}

Is it possible to have an empty string ("") instead of UNDEFINED ?

Upvotes: 2

Views: 836

Answers (1)

Marc Gravell
Marc Gravell

Reputation: 1064324

No, it is not. The enum name is used to generate a member in most (all?) languages, and that member is usually an identifier, and therefore needs a name. Due to how member resolution is defined for multiple enums in some languages (C++, cough), you might also want to prefix the names, so that you can have more than one UNDEFINED.

Personally I'd be more concerned by how ambiguous, overloaded, and limiting is a height option of "tall", "short", or "undefined".

Upvotes: 1

Related Questions