コード例 #1
0
ファイル: xml.cs プロジェクト: Sciumo/gaigen
 /// <summary>
 /// Parses the attributes of the XML_G25_SPEC root element
 /// </summary>
 private static void ParseRootElementAttributes(Specification S, XmlAttributeCollection A)
 {
     // parse all attributes of the root element
     for (int i = 0; i < A.Count; i++)
     {
         switch (A[i].Name)
         {
             case XML_LICENSE:
                 S.SetLicense(A[i].Value);
                 break;
             case XML_COPYRIGHT:
                 S.m_copyright = A[i].Value;
                 break;
             case XML_LANGUAGE:
                 S.SetLanguage(A[i].Value);
                 break;
             case XML_NAMESPACE:
                 S.m_namespace = A[i].Value;
                 break;
             case XML_COORD_STORAGE:
                 if (A[i].Value == XML_ARRAY)
                     S.m_coordStorage = COORD_STORAGE.ARRAY;
                 else if (A[i].Value == XML_VARIABLES)
                     S.m_coordStorage = COORD_STORAGE.VARIABLES;
                 else throw new G25.UserException("XML parsing error: Unknown attribute value '" + A[i].Value + "' for attribute '" + XML_COORD_STORAGE + "'.");
                 break;
             case XML_DEFAULT_OPERATOR_BINDINGS:
                 if (A[i].Value.ToLower() == XML_TRUE)
                     S.SetDefaultOperatorBindings();
                 break;
             case XML_DIMENSION:
                 int dim;
                 try
                 {
                     dim = System.Int32.Parse(A[i].Value);
                 }
                 catch (System.Exception) { throw new G25.UserException("Invalid dimension for space of algebra: '" + A[i].Value + "'."); }
                 S.SetDimension(dim);
                 break;
             case XML_REPORT_USAGE:
                 S.m_reportUsage = (A[i].Value.ToLower() == XML_TRUE);
                 break;
             case XML_GMV_CODE:
                 if (A[i].Value.ToLower() == XML_RUNTIME)
                     S.m_gmvCodeGeneration = GMV_CODE.RUNTIME;
                 else if (A[i].Value.ToLower() == XML_EXPAND)
                     S.m_gmvCodeGeneration = GMV_CODE.EXPAND;
                 else throw new G25.UserException("Invalid value '" + A[i].Value + "' for attribute '" + XML_GMV_CODE + "'.");
                 break;
             case XML_PARSER:
                 if (A[i].Value.ToLower() == XML_NONE)
                     S.m_parserType = PARSER.NONE;
                 else if (A[i].Value.ToLower() == XML_ANTLR)
                     S.m_parserType = PARSER.ANTLR;
                 else if (A[i].Value.ToLower() == XML_BUILTIN)
                     S.m_parserType = PARSER.BUILTIN;
                 else throw new G25.UserException("Invalid value '" + A[i].Value + "' for attribute '" + XML_PARSER + "'.");
                 break;
             case XML_TEST_SUITE:
                 S.m_generateTestSuite = (A[i].Value.ToLower() == XML_TRUE);
                 break;
             default:
                 throw new G25.UserException("XML parsing error: Unknown XML attribute '" + A[i].Name + "' in root element '" + XML_G25_SPEC + "'.");
         }
     }
 }