1 using System;
2 using System.Collections;
3
4
5
6
7
8 namespace System.Xml
9 {
10 public enum Flags : int
11 {
12 none = 0, debug = 1 << 0
13 }
14 public inline Flags operator&(Flags flags, Flags flag)
15 {
16 return cast<Flags>(cast<int>(flags) & cast<int>(flag));
17 }
18 public inline Flags operator|(Flags flags, Flags flag)
19 {
20 return cast<Flags>(cast<int>(flags) | cast<int>(flag));
21 }
22 public inline Flags operator~(Flags flags)
23 {
24 return cast<Flags>(~cast<int>(flags));
25 }
26 public void ParseXmlFile(const string& xmlFileName, XmlContentHandler* contentHandler)
27 {
28 ParseXmlFile(xmlFileName, contentHandler, Flags.none);
29 }
30 public void ParseXmlFile(const string& xmlFileName, XmlContentHandler* contentHandler, Flags flags)
31 {
32 string xmlContent = System.IO.File.ReadAllText(xmlFileName);
33 ParseXmlContent(xmlContent, xmlFileName, contentHandler, flags);
34 }
35 public void ParseXmlContent(const string& xmlContent, const string& systemId, XmlContentHandler* contentHandler)
36 {
37 ParseXmlContent(ToUtf32(xmlContent), systemId, contentHandler, Flags.none);
38 }
39 public void ParseXmlContent(const string& xmlContent, const string& systemId, XmlContentHandler* contentHandler, Flags flags)
40 {
41 ParseXmlContent(ToUtf32(xmlContent), systemId, contentHandler, flags);
42 }
43 public void ParseXmlContent(const ustring& xmlContent, const string& systemId, XmlContentHandler* contentHandler)
44 {
45 ParseXmlContent(xmlContent, systemId, contentHandler, Flags.none);
46 }
47 public void ParseXmlContent(const ustring& xmlContent, const string& systemId, XmlContentHandler* contentHandler, Flags flags)
48 {
49 System.Lex.XmlParsingLog debugLog(Console.Error());
50 TrivialLexer xmlLexer(xmlContent, systemId, 0);
51 xmlLexer.SetFlag(System.Lex.LexerFlags.farthestError);
52 xmlLexer.SetRuleNameListPtr(GetRuleNameList());
53 if ((flags & Flags.debug) != Flags.none)
54 {
55 xmlLexer.SetLog(&debugLog);
56 }
57 XmlProcessor xmlProcessor(xmlLexer, contentHandler);
58 XmlParser.Parse(xmlLexer, &xmlProcessor);
59 }
60 }