[xsd-users] Help me: How to find out what is the type of a class

Boris Kolpackov boris at codesynthesis.com
Fri Oct 23 10:44:34 EDT 2009


Hi James, Message-ID: <boris.20091023163820 at codesynthesis.com>

James Mei <jxmei3 at gmail.com> writes:

> May I know how to get the text value of the Enum from the generated class ?
> With the following class, I want to get GSSE and GOOSE as text.
> 
>  class tGSEControlTypeEnum: public ::xml_schema::name
>   {
>     public:
>     enum value
>     {
>       GSSE,
>       GOOSE
>     };

Since tGSEControlTypeEnum is derived from xml_schema::name which in turn
is derived from std::string, you can do it like this:

tGSEControlTypeEnum x (tGSEControlTypeEnum::GOOSE);
std::string& str = x;

You can also user the enum object directly where std::string is expected
or can be used, for example:

cerr << x;
const char* s = x.c_str ();


> ... is there any variable stores the number of values in the enum ? in 
> this case it is 2.

No, there is no such variable. The last enumerator's value + 1 is the
total number of enumerators, though its name is not regular.

Boris



More information about the xsd-users mailing list