// ------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version: 14.0.0.0
//  
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
namespace macro_utils_h_generator
{
    using System.Linq;
    using System.Text;
    using System.Collections.Generic;
    using System;
    
    /// <summary>
    /// Class to produce the template output
    /// </summary>
    
    #line 1 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "14.0.0.0")]
    public partial class macro_utils : macro_utilsBase
    {
#line hidden
        /// <summary>
        /// Create the template output
        /// </summary>
        public virtual string TransformText()
        {
            this.Write("// Copyright (c) Microsoft. All rights reserved.\r\n// Licensed under the MIT licen" +
                    "se. See LICENSE file in the project root for full license information.\r\n\r\n/*THIS" +
                    " FILE IS GENERATED*/\r\n/*DO NOT EDIT BY HAND!!!*/\r\n/*instead edit macro_utils.tt " +
                    "*/\r\n");
            
            #line 13 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
/*CHANGE BELOW 2 VARIABLES TO GET MORE / LESS */ 
            
            #line default
            #line hidden
            
            #line 14 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
int nArithmetic=1024;
            
            #line default
            #line hidden
            
            #line 15 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
int nMacroParameters=124;/*127 parameters in one macro definition in C99 in chapter 5.2.4.1 Translation limits*/
            
            #line default
            #line hidden
            this.Write(@"
#ifndef MACRO_UTILS_H
#define MACRO_UTILS_H

#include <string.h>
#include ""azure_c_shared_utility/optimize_size.h""

/*""pointer or NULL"" macro - because when printf-ing arguments NULL is not valid for %p or %s (section 7.1.4 of C11 standard) */
#define P_OR_NULL(p) (((p)!=NULL)?(p):""NULL"")

#define TOSTRING_(x) #x
#define TOSTRING(x) TOSTRING_(x)

#define IFCOMMA(N) C2(IFCOMMA_, N)
#define IFCOMMA_0
#define IFCOMMA_2
");
            
            #line 32 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var i=4;i<=nMacroParameters;i+=2)
            
            #line default
            #line hidden
            
            #line 33 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
{
            
            #line default
            #line hidden
            this.Write("#define IFCOMMA_");
            
            #line 34 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i));
            
            #line default
            #line hidden
            this.Write(" ,\r\n");
            
            #line 35 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write("\r\n#define IFCOMMA_NOFIRST(N) C2(IFCOMMA_NOFIRST, N)\r\n#define IFCOMMA_NOFIRST1 \r\n");
            
            #line 39 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var i=2;i<=nMacroParameters;i++)
            
            #line default
            #line hidden
            
            #line 40 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
{
            
            #line default
            #line hidden
            this.Write("#define IFCOMMA_NOFIRST");
            
            #line 41 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i));
            
            #line default
            #line hidden
            this.Write(" ,\r\n");
            
            #line 42 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write("\r\n#define DEC(x) C2(DEC,x)\r\n");
            
            #line 45 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var i=nArithmetic;i>=1;i--)
            
            #line default
            #line hidden
            
            #line 46 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
{
            
            #line default
            #line hidden
            this.Write("#define DEC");
            
            #line 47 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i));
            
            #line default
            #line hidden
            this.Write(" ");
            
            #line 47 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i-1));
            
            #line default
            #line hidden
            this.Write("\r\n");
            
            #line 48 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write("\r\n#define INC(x) C2(INC,x)\r\n");
            
            #line 51 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var i=nArithmetic;i>=0;i--)
            
            #line default
            #line hidden
            
            #line 52 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
{
            
            #line default
            #line hidden
            this.Write("#define INC");
            
            #line 53 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i));
            
            #line default
            #line hidden
            this.Write(" ");
            
            #line 53 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i+1));
            
            #line default
            #line hidden
            this.Write("\r\n");
            
            #line 54 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write("\r\n#define DIV2(x) C2(DIV2_,x)\r\n\r\n");
            
            #line 58 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var i=nArithmetic;i>=0;i--)
            
            #line default
            #line hidden
            
            #line 59 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
{
            
            #line default
            #line hidden
            this.Write("#define DIV2_");
            
            #line 60 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i));
            
            #line default
            #line hidden
            this.Write(" ");
            
            #line 60 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i/2));
            
            #line default
            #line hidden
            this.Write("\r\n");
            
            #line 61 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write("\r\n#define THE_NTH_ARG(");
            
            #line 63 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var i=1;i<=nMacroParameters;i++)
            
            #line default
            #line hidden
            
            #line 64 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
{
            
            #line default
            #line hidden
            this.Write("P");
            
            #line 64 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i));
            
            #line default
            #line hidden
            this.Write(", ");
            
            #line 64 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write(" ... ) P");
            
            #line 64 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(nMacroParameters));
            
            #line default
            #line hidden
            this.Write("\r\n\r\n#define _TRIGGER_PARENTHESIS_(...) ,\r\n\r\n#define LPAREN (\r\n\r\n#ifdef _MSC_VER\r\n" +
                    "#define COUNT_1_OR_MORE_ARG(...) THE_NTH_ARG LPAREN __VA_ARGS__, \\\r\n");
            
            #line 72 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var i=nMacroParameters-1;i>=1;i--){
            
            #line default
            #line hidden
            
            #line 72 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i.ToString()+((i>1)?", ":"")));
            
            #line default
            #line hidden
            
            #line 72 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write(")\r\n#define MORE_THAN_1_ARG(...) THE_NTH_ARG LPAREN __VA_ARGS__, ");
            
            #line 73 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var i=nMacroParameters-2;i>=1;i--){
            
            #line default
            #line hidden
            
            #line 73 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(1));
            
            #line default
            #line hidden
            this.Write(",");
            
            #line 73 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write("0)\r\n#else\r\n#define COUNT_1_OR_MORE_ARG(...) THE_NTH_ARG (__VA_ARGS__, \\\r\n");
            
            #line 76 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var i=nMacroParameters-1;i>=1;i--){
            
            #line default
            #line hidden
            
            #line 76 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i.ToString()+((i>1)?", ":"")));
            
            #line default
            #line hidden
            
            #line 76 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write(")\r\n#define MORE_THAN_1_ARG(...) THE_NTH_ARG(__VA_ARGS__, ");
            
            #line 77 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var i=nMacroParameters-2;i>=1;i--){
            
            #line default
            #line hidden
            
            #line 77 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(1));
            
            #line default
            #line hidden
            this.Write(",");
            
            #line 77 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write(@" 0)
#endif

#define COUNT_ARG(...) C2(COUNT_ARG_, ISEMPTY(__VA_ARGS__))(__VA_ARGS__)
#define COUNT_ARG_1(...) 0
#define COUNT_ARG_0(...) C1(COUNT_1_OR_MORE_ARG(__VA_ARGS__))

#define ISEMPTY(...) C5(DISPTACH_EMPTY_, MORE_THAN_1_ARG(_TRIGGER_PARENTHESIS_ __VA_ARGS__ ()), MORE_THAN_1_ARG(__VA_ARGS__), MORE_THAN_1_ARG(__VA_ARGS__ ()), MORE_THAN_1_ARG(_TRIGGER_PARENTHESIS_ __VA_ARGS__))
#define DISPTACH_EMPTY_1000 1
#define DISPTACH_EMPTY_0000 0
#define DISPTACH_EMPTY_1100 0
#define DISPTACH_EMPTY_1111 0
#define DISPTACH_EMPTY_1001 0
#define DISPTACH_EMPTY_1010 0


#define C2_(x,y) x##y

#define C2(x,y) C2_(x,y)

#define C3(x,y,z) C2(x, C2(y,z))

#define C4(x,y,z, u) C2(C2(x,y), C2(z,u))

#define C5(x,y,z,u, v) C2(C4(x,y, z, u), v)

#define C1_(x) x

#define C1(x) C1_(x)

#define C2STRING(x,y) x y

#define C3STRING(x,y,z) x y z

#define C4STRING(x,y,z,u) x y z u

#define C5STRING(x,y,z,u,v) x y z u v


");
            
            #line 116 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var i=nMacroParameters;i>=2;i--)
            
            #line default
            #line hidden
            
            #line 117 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
{
            
            #line default
            #line hidden
            this.Write("#define FOR_EACH_1_");
            
            #line 118 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i));
            
            #line default
            #line hidden
            this.Write("(X, ");
            
            #line 118 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var j=1;j<=i;j++){
            
            #line default
            #line hidden
            this.Write("P");
            
            #line 118 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(j.ToString()+((j<i)?", ":"")));
            
            #line default
            #line hidden
            
            #line 118 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write(") \\\r\nX(P1) \\\r\nFOR_EACH_1_");
            
            #line 120 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i-1));
            
            #line default
            #line hidden
            this.Write("(X, ");
            
            #line 120 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var j=2;j<=i;j++){
            
            #line default
            #line hidden
            this.Write("P");
            
            #line 120 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(j.ToString()+((j<i)?", ":"")));
            
            #line default
            #line hidden
            
            #line 120 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write(")\r\n\r\n");
            
            #line 122 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write(@"#define FOR_EACH_1_1(X, P1) \
X(P1)

#ifdef _MSC_VER
#define FOR_EACH_1(MACRO_TO_INVOKE, ...) C2(FOR_EACH_1_,C1(COUNT_ARG(__VA_ARGS__))) LPAREN MACRO_TO_INVOKE, __VA_ARGS__)
#else
#define FOR_EACH_1(MACRO_TO_INVOKE, ...) C2(FOR_EACH_1_,C1(COUNT_ARG(__VA_ARGS__))) ( MACRO_TO_INVOKE, __VA_ARGS__)
#endif

");
            
            #line 132 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var i=nMacroParameters;i>=2;i--)
            
            #line default
            #line hidden
            
            #line 133 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
{
            
            #line default
            #line hidden
            this.Write("#define FOR_EACH_1_KEEP_1_");
            
            #line 134 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i));
            
            #line default
            #line hidden
            this.Write("(X, keep, ");
            
            #line 134 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var j=1;j<=i;j++){
            
            #line default
            #line hidden
            this.Write("P");
            
            #line 134 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(j.ToString()+(j<i?", ":"")));
            
            #line default
            #line hidden
            
            #line 134 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write(") \\\r\nX(keep, P1) \\\r\nFOR_EACH_1_KEEP_1_");
            
            #line 136 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i-1));
            
            #line default
            #line hidden
            this.Write("(X, keep, ");
            
            #line 136 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var j=2;j<=i;j++){
            
            #line default
            #line hidden
            this.Write("P");
            
            #line 136 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture((j).ToString()+(j<i?", ":"")));
            
            #line default
            #line hidden
            
            #line 136 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write(")\r\n\r\n\r\n");
            
            #line 139 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write(@"
#define FOR_EACH_1_KEEP_1_1(X, keep, P1) \
X(keep, P1)

#ifdef _MSC_VER
#define FOR_EACH_1_KEEP_1(MACRO_TO_INVOKE, ...) C2(FOR_EACH_1_KEEP_1_, C2(DEC,C1(COUNT_ARG(__VA_ARGS__)))) LPAREN MACRO_TO_INVOKE, __VA_ARGS__)
#else
#define FOR_EACH_1_KEEP_1(MACRO_TO_INVOKE, ...) C2(FOR_EACH_1_KEEP_1_, C2(DEC,C1(COUNT_ARG(__VA_ARGS__)))) ( MACRO_TO_INVOKE, __VA_ARGS__)
#endif

");
            
            #line 150 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var i=nMacroParameters;i>=4;i-=2)
            
            #line default
            #line hidden
            
            #line 151 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
{
            
            #line default
            #line hidden
            this.Write("#define FOR_EACH_2_KEEP_1_");
            
            #line 152 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i));
            
            #line default
            #line hidden
            this.Write("(X, keep, ");
            
            #line 152 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var j=1;j<=i;j++){
            
            #line default
            #line hidden
            this.Write("P");
            
            #line 152 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(j.ToString()+(j<i?", ":"")));
            
            #line default
            #line hidden
            
            #line 152 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write(") \\\r\nX(keep, P1, P2) \\\r\nFOR_EACH_2_KEEP_1_");
            
            #line 154 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i-2));
            
            #line default
            #line hidden
            this.Write("(X, keep, ");
            
            #line 154 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var j=3;j<=i;j++){
            
            #line default
            #line hidden
            this.Write("P");
            
            #line 154 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture((j).ToString()+(j<i?", ":"")));
            
            #line default
            #line hidden
            
            #line 154 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write(")\r\n\r\n\r\n");
            
            #line 157 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write(@"
#define FOR_EACH_2_KEEP_1_1(...)

#define FOR_EACH_2_KEEP_1_0(...)

#define FOR_EACH_2_KEEP_1_2(X, keep, P1, P2) \
    X(keep, P1, P2) \

#ifdef _MSC_VER
#define FOR_EACH_2_KEEP_1(MACRO_TO_INVOKE, ...) C2(FOR_EACH_2_KEEP_1_, C2(DEC,C1(COUNT_ARG(__VA_ARGS__)))) LPAREN MACRO_TO_INVOKE, __VA_ARGS__)
#else
#define FOR_EACH_2_KEEP_1(MACRO_TO_INVOKE, ...) C2(FOR_EACH_2_KEEP_1_, C2(DEC,C1(COUNT_ARG(__VA_ARGS__)))) ( MACRO_TO_INVOKE, __VA_ARGS__)
#endif


");
            
            #line 173 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var i=nMacroParameters;i>=4;i-=2)
            
            #line default
            #line hidden
            
            #line 174 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
{
            
            #line default
            #line hidden
            this.Write("#define FOR_EACH_2_KEEP_2_");
            
            #line 175 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i));
            
            #line default
            #line hidden
            this.Write("(X, keep1, keep2, ");
            
            #line 175 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var j=1;j<=i;j++){
            
            #line default
            #line hidden
            this.Write("P");
            
            #line 175 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(j.ToString()+(j<i?", ":"")));
            
            #line default
            #line hidden
            
            #line 175 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write(") \\\r\nX(keep1, keep2, P1, P2) \\\r\nFOR_EACH_2_KEEP_2_");
            
            #line 177 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i-2));
            
            #line default
            #line hidden
            this.Write("(X, keep1, keep2, ");
            
            #line 177 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var j=3;j<=i;j++){
            
            #line default
            #line hidden
            this.Write("P");
            
            #line 177 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture((j).ToString()+(j<i?", ":"")));
            
            #line default
            #line hidden
            
            #line 177 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write(")\r\n\r\n\r\n");
            
            #line 180 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write(@"
#define FOR_EACH_2_KEEP_2_1(...)

#define FOR_EACH_2_KEEP_2_0(...)

#define FOR_EACH_2_KEEP_2_2(X, keep1, keep2, P1, P2) \
    X(keep1, keep2, P1, P2) \

#ifdef _MSC_VER
#define FOR_EACH_2_KEEP_2(MACRO_TO_INVOKE, ...) C2(FOR_EACH_2_KEEP_2_, C2(DEC,C2(DEC,C1(COUNT_ARG(__VA_ARGS__))))) LPAREN MACRO_TO_INVOKE, __VA_ARGS__)
#else
#define FOR_EACH_2_KEEP_2(MACRO_TO_INVOKE, ...) C2(FOR_EACH_2_KEEP_2_, C2(DEC, C2(DEC,C1(COUNT_ARG(__VA_ARGS__))))) ( MACRO_TO_INVOKE, __VA_ARGS__)
#endif


#define FOR_EACH_2_0(...)

#define FOR_EACH_2_2(X, P1, P2) \
X(P1, P2)

");
            
            #line 201 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var i=4;i<=nMacroParameters;i+=2) {
            
            #line default
            #line hidden
            this.Write("#define FOR_EACH_2_");
            
            #line 202 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i));
            
            #line default
            #line hidden
            this.Write("(X, ");
            
            #line 202 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var j=1;j<=i;j++){
            
            #line default
            #line hidden
            this.Write("P");
            
            #line 202 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(j.ToString()+((j<i)?", ":"")));
            
            #line default
            #line hidden
            
            #line 202 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write(") \\\r\nX(P1, P2) \\\r\nFOR_EACH_2_");
            
            #line 204 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i-2));
            
            #line default
            #line hidden
            this.Write("(X, ");
            
            #line 204 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var j=3;j<=i;j++){
            
            #line default
            #line hidden
            this.Write("P");
            
            #line 204 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(j.ToString()+((j<i)?", ":"")));
            
            #line default
            #line hidden
            
            #line 204 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write(")\r\n\r\n");
            
            #line 206 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write("\r\n#define FOR_EACH_2_REVERSE_0(...)\r\n\r\n#define FOR_EACH_2_REVERSE_2(X, P1, P2) \\\r" +
                    "\nX(P1, P2)\r\n\r\n");
            
            #line 213 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var i=4;i<=nMacroParameters;i+=2) {
            
            #line default
            #line hidden
            this.Write("#define FOR_EACH_2_REVERSE_");
            
            #line 214 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i));
            
            #line default
            #line hidden
            this.Write("(X, ");
            
            #line 214 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var j=1;j<=i;j++){
            
            #line default
            #line hidden
            this.Write("P");
            
            #line 214 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(j.ToString()+((j<i)?", ":"")));
            
            #line default
            #line hidden
            
            #line 214 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write(") \\\r\nX(P");
            
            #line 215 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i-1));
            
            #line default
            #line hidden
            this.Write(", P");
            
            #line 215 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i));
            
            #line default
            #line hidden
            this.Write(") \\\r\nFOR_EACH_2_REVERSE_");
            
            #line 216 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i-2));
            
            #line default
            #line hidden
            this.Write("(X, ");
            
            #line 216 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var j=1;j<=i-2;j++){
            
            #line default
            #line hidden
            this.Write("P");
            
            #line 216 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(j.ToString()+((j<i-2)?", ":"")));
            
            #line default
            #line hidden
            
            #line 216 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write(")\r\n\r\n");
            
            #line 218 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write("\r\n#define FOR_EACH_1_COUNTED_0(...)\r\n\r\n#define FOR_EACH_1_COUNTED_1(X, P1) \\\r\n   " +
                    " X(1, P1)\r\n\r\n");
            
            #line 225 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var i=2;i<=nMacroParameters;i++) {
            
            #line default
            #line hidden
            this.Write("#define FOR_EACH_1_COUNTED_");
            
            #line 226 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i));
            
            #line default
            #line hidden
            this.Write("(X, ");
            
            #line 226 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var j=1;j<=i;j++){
            
            #line default
            #line hidden
            this.Write("P");
            
            #line 226 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(j.ToString()+((j<i)?", ":"")));
            
            #line default
            #line hidden
            
            #line 226 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write(") \\\r\nX(");
            
            #line 227 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i));
            
            #line default
            #line hidden
            this.Write(", P1) \\\r\nFOR_EACH_1_COUNTED_");
            
            #line 228 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i-1));
            
            #line default
            #line hidden
            this.Write("(X, ");
            
            #line 228 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var j=2;j<=i;j++){
            
            #line default
            #line hidden
            this.Write("P");
            
            #line 228 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(j.ToString()+((j<i)?", ":"")));
            
            #line default
            #line hidden
            
            #line 228 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write(")\r\n\r\n");
            
            #line 230 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write("\r\n#define FOR_EACH_2_COUNTED_0(...)\r\n\r\n#define FOR_EACH_2_COUNTED_2(X, P1, P2) \\\r" +
                    "\n    X(2, P1, P2)\r\n\r\n");
            
            #line 237 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var i=4;i<=nMacroParameters;i+=2) {
            
            #line default
            #line hidden
            this.Write("#define FOR_EACH_2_COUNTED_");
            
            #line 238 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i));
            
            #line default
            #line hidden
            this.Write("(X, ");
            
            #line 238 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var j=1;j<=i;j++){
            
            #line default
            #line hidden
            this.Write("P");
            
            #line 238 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(j.ToString()+((j<i)?", ":"")));
            
            #line default
            #line hidden
            
            #line 238 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write(") \\\r\nX(");
            
            #line 239 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i));
            
            #line default
            #line hidden
            this.Write(", P1, P2) \\\r\nFOR_EACH_2_COUNTED_");
            
            #line 240 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i-2));
            
            #line default
            #line hidden
            this.Write("(X, ");
            
            #line 240 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var j=3;j<=i;j++){
            
            #line default
            #line hidden
            this.Write("P");
            
            #line 240 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(j.ToString()+((j<i)?", ":"")));
            
            #line default
            #line hidden
            
            #line 240 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write(")\r\n\r\n");
            
            #line 242 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write("\r\n#ifdef _MSC_VER\r\n#define FOR_EACH_2(MACRO_TO_INVOKE, ...) C2(FOR_EACH_2_, C1(CO" +
                    "UNT_ARG(__VA_ARGS__))) LPAREN MACRO_TO_INVOKE, __VA_ARGS__)\r\n/*the COUNTED breed" +
                    " of FOR_EACH macro invokes a macro with 3 parameters: 1st being the count of inv" +
                    "ocation. For example.\r\nFOR_EACH_2_COUNTER(MACRO, a,b,c,d,e,f) will result in \r\nM" +
                    "ACRO(6, a,b)\r\nMACRO(4, c,d)\r\nMACRO(2, e,f)\r\nThis macro exists because we need a " +
                    "\"stop condition\" in outputting COMMA... when calling a function f(a,b,c,d) canno" +
                    "t be f(a,b,c,d,) <=doesn\'t compile (as opposed to enum definition)\r\n*/\r\n#define " +
                    "FOR_EACH_2_COUNTED(MACRO_TO_INVOKE, ...) C2(FOR_EACH_2_COUNTED_, C1(COUNT_ARG(__" +
                    "VA_ARGS__))) LPAREN MACRO_TO_INVOKE, __VA_ARGS__)\r\n#define FOR_EACH_1_COUNTED(MA" +
                    "CRO_TO_INVOKE, ...) C2(FOR_EACH_1_COUNTED_, C1(COUNT_ARG(__VA_ARGS__))) LPAREN M" +
                    "ACRO_TO_INVOKE, __VA_ARGS__)\r\n\r\n/*FOR_EACH_2_REVERSE acts just like FOR_EACH_2, " +
                    "but in reverse order. Example:\r\nFOR_EACH_2_REVERSE(X,a,b,c,d,e,f) => X(e,f) X(c," +
                    "d) X (a, b) in this order */\r\n#define FOR_EACH_2_REVERSE(MACRO_TO_INVOKE, ...) C" +
                    "2(FOR_EACH_2_REVERSE_, C1(COUNT_ARG(__VA_ARGS__))) LPAREN MACRO_TO_INVOKE, __VA_" +
                    "ARGS__)\r\n#else\r\n#define FOR_EACH_2(MACRO_TO_INVOKE, ...) C2(FOR_EACH_2_, C1(COUN" +
                    "T_ARG(__VA_ARGS__))) ( MACRO_TO_INVOKE, __VA_ARGS__)\r\n#define FOR_EACH_2_COUNTED" +
                    "(MACRO_TO_INVOKE, ...) C2(FOR_EACH_2_COUNTED_, C1(COUNT_ARG(__VA_ARGS__))) ( MAC" +
                    "RO_TO_INVOKE,  __VA_ARGS__)\r\n#define FOR_EACH_1_COUNTED(MACRO_TO_INVOKE, ...) C2" +
                    "(FOR_EACH_1_COUNTED_, C1(COUNT_ARG(__VA_ARGS__))) ( MACRO_TO_INVOKE,  __VA_ARGS_" +
                    "_)\r\n#define FOR_EACH_2_REVERSE(MACRO_TO_INVOKE, ...) C2(FOR_EACH_2_REVERSE_, C1(" +
                    "COUNT_ARG(__VA_ARGS__))) ( MACRO_TO_INVOKE, __VA_ARGS__)\r\n#endif\r\n\r\n#ifdef _MSC_" +
                    "VER\r\n#define EXPAND_OR_C1(x) x\r\n#else\r\n#define EXPAND_OR_C1(...) __VA_ARGS__\r\n#e" +
                    "ndif\r\n\r\n#define EXPAND_ARGS(...) __VA_ARGS__\r\n#define EXPAND_TWICE(...) EXPAND_A" +
                    "RGS(__VA_ARGS__)\r\n\r\n#define DO_0(MACRO, ...) \\\r\nMACRO(0, __VA_ARGS__)\r\n\r\n");
            
            #line 278 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
for(var i=1;i<=nArithmetic;i++){
            
            #line default
            #line hidden
            this.Write("#define DO_");
            
            #line 279 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i));
            
            #line default
            #line hidden
            this.Write("(MACRO, ...) \\\r\nMACRO(");
            
            #line 280 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i));
            
            #line default
            #line hidden
            this.Write(", __VA_ARGS__) \\\r\nDO_");
            
            #line 281 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(i-1));
            
            #line default
            #line hidden
            this.Write("(MACRO, __VA_ARGS__)\r\n\r\n\r\n");
            
            #line 284 "D:\azure-c-shared-utility\tools\macro_utils_h_generator\macro_utils.tt"
}
            
            #line default
            #line hidden
            this.Write("\r\n#define DO(TIMES, MACRO, ...) C2(DO_, TIMES)(MACRO, __VA_ARGS__)\r\n\r\n\r\n/* we nee" +
                    "d some sort of macro that does:\r\nIF(0, \"true\", \"false\") => \"false\"\r\nIF(1, \"true\"" +
                    ", \"false\") => \"true\"\r\nIF(X, \"true\", \"false\") => \"true\"\r\n*/\r\n\r\n#define INTERNALIF" +
                    "(x) INTERNALIF##x\r\n#define INTERNALIF0\r\n\r\n#define ISZERO(x) COUNT_ARG(INTERNALIF" +
                    "(x))\r\n\r\n#define IF(condition, trueBranch, falseBranch) C2(IF,ISZERO(condition))(" +
                    "trueBranch, falseBranch)\r\n#define IF0(trueBranch, falseBranch) falseBranch\r\n#def" +
                    "ine IF1(trueBranch, falseBranch) trueBranch\r\n\r\n\r\n\r\n#define DEFINE_ENUMERATION_CO" +
                    "NSTANT(x) x,\r\n/*DEFINE_ENUM goes to header*/\r\n#define DEFINE_ENUM(enumName, ...)" +
                    " typedef enum C2(enumName, _TAG) { FOR_EACH_1(DEFINE_ENUMERATION_CONSTANT, __VA_" +
                    "ARGS__)} enumName; \\\r\n    extern const char* C2(enumName,Strings)(enumName value" +
                    "); \\\r\n    extern int C2(enumName, _FromString)(const char* enumAsString, enumNam" +
                    "e* destination);\r\n\r\n\r\n#define DEFINE_ENUMERATION_CONSTANT_AS_WIDESTRING(x) C2(L," +
                    " TOSTRING(x)) , \r\n#define DEFINE_ENUMERATION_CONSTANT_AS_STRING(x) TOSTRING(x) ," +
                    " \r\n/*DEFINE_ENUM_STRINGS goes to .c*/\r\n#define DEFINE_ENUM_STRINGS(enumName, ..." +
                    ") const char* C2(enumName, StringStorage)[COUNT_ARG(__VA_ARGS__)] = {FOR_EACH_1(" +
                    "DEFINE_ENUMERATION_CONSTANT_AS_STRING, __VA_ARGS__)}; \\\r\nconst char* C2(enumName" +
                    ",Strings)(enumName value)                   \\\r\n{                                " +
                    "                                  \\\r\n    if((int)value>=COUNT_ARG(__VA_ARGS__)) " +
                    "                        \\\r\n    {                                                " +
                    "              \\\r\n        /*this is an error case*/                              " +
                    "    \\\r\n        return NULL;                                               \\\r\n   " +
                    " }                                                              \\\r\n    else     " +
                    "                                                      \\\r\n    {                  " +
                    "                                            \\\r\n        return C2(enumName, Strin" +
                    "gStorage)[value];                 \\\r\n    }                                      " +
                    "                        \\\r\n}                                                    " +
                    "              \\\r\nint C2(enumName, _FromString)(const char* enumAsString, enumNam" +
                    "e* destination)  \\\r\n{                                                           " +
                    "                    \\\r\n    if(                                                  " +
                    "                       \\\r\n        (enumAsString==NULL) || (destination==NULL)   " +
                    "                          \\\r\n    )                                              " +
                    "                             \\\r\n    {                                           " +
                    "                                \\\r\n        return __FAILURE__;                  " +
                    "                                   \\\r\n    }                                     " +
                    "                                      \\\r\n    else                               " +
                    "                                         \\\r\n    {                               " +
                    "                                            \\\r\n        size_t i;                " +
                    "                                               \\\r\n        for(i=0;i<COUNT_ARG(__" +
                    "VA_ARGS__);i++)                                   \\\r\n        {                  " +
                    "                                                     \\\r\n            if(strcmp(en" +
                    "umAsString, C2(enumName, StringStorage)[i])==0)         \\\r\n            {        " +
                    "                                                           \\\r\n                *d" +
                    "estination = (enumName)i;                                     \\\r\n               " +
                    " return 0;                                                       \\\r\n            " +
                    "}                                                                   \\\r\n        }" +
                    "                                                                       \\\r\n      " +
                    "  return __FAILURE__;                                                     \\\r\n   " +
                    " }                                                                           \\\r\n" +
                    "}                                                                               " +
                    "\\\r\n\r\n#define ENUM_TO_STRING(enumName, enumValue) C2(enumName, Strings)(enumValue" +
                    ")\r\n#define STRING_TO_ENUM(stringValue, enumName, addressOfEnumVariable) C2(enumN" +
                    "ame, _FromString)(stringValue, addressOfEnumVariable)\r\n\r\n#define DEFINE_MICROMOC" +
                    "K_ENUM_TO_STRING(type, ...) MICROMOCK_ENUM_TO_STRING(type, FOR_EACH_1(DEFINE_ENU" +
                    "MERATION_CONSTANT_AS_WIDESTRING, __VA_ARGS__));\r\n\r\n#define EMPTY()\r\n#define DELA" +
                    "Y(id) id EMPTY LPAREN )\r\n\r\n#endif /*MACRO_UTILS_H*/\r\n");
            return this.GenerationEnvironment.ToString();
        }
    }
    
    #line default
    #line hidden
    #region Base class
    /// <summary>
    /// Base class for this transformation
    /// </summary>
    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "14.0.0.0")]
    public class macro_utilsBase
    {
        #region Fields
        private global::System.Text.StringBuilder generationEnvironmentField;
        private global::System.CodeDom.Compiler.CompilerErrorCollection errorsField;
        private global::System.Collections.Generic.List<int> indentLengthsField;
        private string currentIndentField = "";
        private bool endsWithNewline;
        private global::System.Collections.Generic.IDictionary<string, object> sessionField;
        #endregion
        #region Properties
        /// <summary>
        /// The string builder that generation-time code is using to assemble generated output
        /// </summary>
        protected System.Text.StringBuilder GenerationEnvironment
        {
            get
            {
                if ((this.generationEnvironmentField == null))
                {
                    this.generationEnvironmentField = new global::System.Text.StringBuilder();
                }
                return this.generationEnvironmentField;
            }
            set
            {
                this.generationEnvironmentField = value;
            }
        }
        /// <summary>
        /// The error collection for the generation process
        /// </summary>
        public System.CodeDom.Compiler.CompilerErrorCollection Errors
        {
            get
            {
                if ((this.errorsField == null))
                {
                    this.errorsField = new global::System.CodeDom.Compiler.CompilerErrorCollection();
                }
                return this.errorsField;
            }
        }
        /// <summary>
        /// A list of the lengths of each indent that was added with PushIndent
        /// </summary>
        private System.Collections.Generic.List<int> indentLengths
        {
            get
            {
                if ((this.indentLengthsField == null))
                {
                    this.indentLengthsField = new global::System.Collections.Generic.List<int>();
                }
                return this.indentLengthsField;
            }
        }
        /// <summary>
        /// Gets the current indent we use when adding lines to the output
        /// </summary>
        public string CurrentIndent
        {
            get
            {
                return this.currentIndentField;
            }
        }
        /// <summary>
        /// Current transformation session
        /// </summary>
        public virtual global::System.Collections.Generic.IDictionary<string, object> Session
        {
            get
            {
                return this.sessionField;
            }
            set
            {
                this.sessionField = value;
            }
        }
        #endregion
        #region Transform-time helpers
        /// <summary>
        /// Write text directly into the generated output
        /// </summary>
        public void Write(string textToAppend)
        {
            if (string.IsNullOrEmpty(textToAppend))
            {
                return;
            }
            // If we're starting off, or if the previous text ended with a newline,
            // we have to append the current indent first.
            if (((this.GenerationEnvironment.Length == 0) 
                        || this.endsWithNewline))
            {
                this.GenerationEnvironment.Append(this.currentIndentField);
                this.endsWithNewline = false;
            }
            // Check if the current text ends with a newline
            if (textToAppend.EndsWith(global::System.Environment.NewLine, global::System.StringComparison.CurrentCulture))
            {
                this.endsWithNewline = true;
            }
            // This is an optimization. If the current indent is "", then we don't have to do any
            // of the more complex stuff further down.
            if ((this.currentIndentField.Length == 0))
            {
                this.GenerationEnvironment.Append(textToAppend);
                return;
            }
            // Everywhere there is a newline in the text, add an indent after it
            textToAppend = textToAppend.Replace(global::System.Environment.NewLine, (global::System.Environment.NewLine + this.currentIndentField));
            // If the text ends with a newline, then we should strip off the indent added at the very end
            // because the appropriate indent will be added when the next time Write() is called
            if (this.endsWithNewline)
            {
                this.GenerationEnvironment.Append(textToAppend, 0, (textToAppend.Length - this.currentIndentField.Length));
            }
            else
            {
                this.GenerationEnvironment.Append(textToAppend);
            }
        }
        /// <summary>
        /// Write text directly into the generated output
        /// </summary>
        public void WriteLine(string textToAppend)
        {
            this.Write(textToAppend);
            this.GenerationEnvironment.AppendLine();
            this.endsWithNewline = true;
        }
        /// <summary>
        /// Write formatted text directly into the generated output
        /// </summary>
        public void Write(string format, params object[] args)
        {
            this.Write(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args));
        }
        /// <summary>
        /// Write formatted text directly into the generated output
        /// </summary>
        public void WriteLine(string format, params object[] args)
        {
            this.WriteLine(string.Format(global::System.Globalization.CultureInfo.CurrentCulture, format, args));
        }
        /// <summary>
        /// Raise an error
        /// </summary>
        public void Error(string message)
        {
            System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError();
            error.ErrorText = message;
            this.Errors.Add(error);
        }
        /// <summary>
        /// Raise a warning
        /// </summary>
        public void Warning(string message)
        {
            System.CodeDom.Compiler.CompilerError error = new global::System.CodeDom.Compiler.CompilerError();
            error.ErrorText = message;
            error.IsWarning = true;
            this.Errors.Add(error);
        }
        /// <summary>
        /// Increase the indent
        /// </summary>
        public void PushIndent(string indent)
        {
            if ((indent == null))
            {
                throw new global::System.ArgumentNullException("indent");
            }
            this.currentIndentField = (this.currentIndentField + indent);
            this.indentLengths.Add(indent.Length);
        }
        /// <summary>
        /// Remove the last indent that was added with PushIndent
        /// </summary>
        public string PopIndent()
        {
            string returnValue = "";
            if ((this.indentLengths.Count > 0))
            {
                int indentLength = this.indentLengths[(this.indentLengths.Count - 1)];
                this.indentLengths.RemoveAt((this.indentLengths.Count - 1));
                if ((indentLength > 0))
                {
                    returnValue = this.currentIndentField.Substring((this.currentIndentField.Length - indentLength));
                    this.currentIndentField = this.currentIndentField.Remove((this.currentIndentField.Length - indentLength));
                }
            }
            return returnValue;
        }
        /// <summary>
        /// Remove any indentation
        /// </summary>
        public void ClearIndent()
        {
            this.indentLengths.Clear();
            this.currentIndentField = "";
        }
        #endregion
        #region ToString Helpers
        /// <summary>
        /// Utility class to produce culture-oriented representation of an object as a string.
        /// </summary>
        public class ToStringInstanceHelper
        {
            private System.IFormatProvider formatProviderField  = global::System.Globalization.CultureInfo.InvariantCulture;
            /// <summary>
            /// Gets or sets format provider to be used by ToStringWithCulture method.
            /// </summary>
            public System.IFormatProvider FormatProvider
            {
                get
                {
                    return this.formatProviderField ;
                }
                set
                {
                    if ((value != null))
                    {
                        this.formatProviderField  = value;
                    }
                }
            }
            /// <summary>
            /// This is called from the compile/run appdomain to convert objects within an expression block to a string
            /// </summary>
            public string ToStringWithCulture(object objectToConvert)
            {
                if ((objectToConvert == null))
                {
                    throw new global::System.ArgumentNullException("objectToConvert");
                }
                System.Type t = objectToConvert.GetType();
                System.Reflection.MethodInfo method = t.GetMethod("ToString", new System.Type[] {
                            typeof(System.IFormatProvider)});
                if ((method == null))
                {
                    return objectToConvert.ToString();
                }
                else
                {
                    return ((string)(method.Invoke(objectToConvert, new object[] {
                                this.formatProviderField })));
                }
            }
        }
        private ToStringInstanceHelper toStringHelperField = new ToStringInstanceHelper();
        /// <summary>
        /// Helper to produce culture-oriented representation of an object as a string
        /// </summary>
        public ToStringInstanceHelper ToStringHelper
        {
            get
            {
                return this.toStringHelperField;
            }
        }
        #endregion
    }
    #endregion
}
