From anthony.holzer at ngc.com Fri Jun 27 13:18:32 2014 From: anthony.holzer at ngc.com (Holzer, Tony (AS)) Date: Fri Jun 27 17:34:37 2014 Subject: [xsde-users] C1061: Blocks nested too deeply Message-ID: I am using xsde 3.2 with a schema delivered that I cannot modify. The schema has an enumeration defined to have close to 300 values. A short snippet of the schema is: I generate code using the following command: xsde cxx-hybrid --no-stl --no-exceptions --no-iostream --no-long-long --generate-parser --generate-serializer --generate-aggregate XSD/e generates a huge if/else-if block to compare each string value and assign an enumeration. The code generated is: if (strcmp (s, "Value 1") == 0) v = MessageTypeEnum::Value1; else if (strcmp (s, "Value 2") == 0) v = ::NIOP::MessageTypeEnum::AIR_SAMPLE_CAPABILITY; else if (strcmp (s, "Value 3") == 0) Since the enumeration is so large, it quickly hits the Visual Studio compiler limit of 128 nesting levels. I have searched the xsde-users archives and have not seen this issue raised. Any help is appreciated. Tony Holzer Northrop Grumman Aerospace Systems From boris at codesynthesis.com Mon Jun 30 05:55:01 2014 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Jun 30 05:59:48 2014 Subject: [xsde-users] C1061: Blocks nested too deeply In-Reply-To: References: Message-ID: Hi Tony, Holzer, Tony (AS) writes: > Since the enumeration is so large, it quickly hits the Visual Studio > compiler limit of 128 nesting levels. I assume you still want to have the C++ enum interface (rather than, say, represent it as a string). In this case the easiest way forward would be to provide custom parser implementation that avoids this limitation. On how to provide a custom parser, see: http://www.codesynthesis.com/projects/xsde/documentation/cxx/hybrid/guide/#6.1 The easiest way to actually implement it would be to copy the generated version and tweak it. One way would be to initialize the enum value ('v' variable) to some invalid value, say -1, and then break the if-else chain with a check and a return if 'v' is no longer -1. The major drawback of this approach is that if the enumeration changes, then you need to remember to update the custom parser code. Boris From anthony.holzer at ngc.com Mon Jun 30 09:48:05 2014 From: anthony.holzer at ngc.com (Holzer, Tony (AS)) Date: Tue Jul 1 02:57:42 2014 Subject: EXT :Re: [xsde-users] C1061: Blocks nested too deeply In-Reply-To: References: Message-ID: Boris, Thanks for the quick reply. What is the easiest way to remove the C++ enum interface? In a quick read on custom parsers, looks like I can also not have a parser created for the XML schema type. Tony Holzer Northrop Grumman Aerospace Systems -----Original Message----- From: Boris Kolpackov [mailto:boris@codesynthesis.com] Sent: Monday, June 30, 2014 2:55 AM To: Holzer, Tony (AS) Cc: xsde-users@codesynthesis.com Subject: EXT :Re: [xsde-users] C1061: Blocks nested too deeply Hi Tony, Holzer, Tony (AS) writes: > Since the enumeration is so large, it quickly hits the Visual Studio > compiler limit of 128 nesting levels. I assume you still want to have the C++ enum interface (rather than, say, represent it as a string). In this case the easiest way forward would be to provide custom parser implementation that avoids this limitation. On how to provide a custom parser, see: http://www.codesynthesis.com/projects/xsde/documentation/cxx/hybrid/guide/#6.1 The easiest way to actually implement it would be to copy the generated version and tweak it. One way would be to initialize the enum value ('v' variable) to some invalid value, say -1, and then break the if-else chain with a check and a return if 'v' is no longer -1. The major drawback of this approach is that if the enumeration changes, then you need to remember to update the custom parser code. Boris