| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> |
| <title>SGL: SkXMLParser.h Source File</title> |
| <link href="doxygen.css" rel="stylesheet" type="text/css"> |
| </head><body> |
| <!-- Generated by Doxygen 1.4.0 --> |
| <div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a></div> |
| <div class="nav"> |
| <a class="el" href="dir_000000.html">include</a> / <a class="el" href="dir_000001.html">skia</a></div> |
| <h1>SkXMLParser.h</h1><div class="fragment"><pre class="fragment">00001 <span class="preprocessor">#ifndef SkXMLParser_DEFINED</span> |
| 00002 <span class="preprocessor"></span><span class="preprocessor">#define SkXMLParser_DEFINED</span> |
| 00003 <span class="preprocessor"></span> |
| 00004 <span class="preprocessor">#include "SkMath.h"</span> |
| 00005 <span class="preprocessor">#include "SkString.h"</span> |
| 00006 |
| 00007 <span class="keyword">class </span>SkStream; |
| 00008 |
| 00009 <span class="keyword">class </span>SkDOM; |
| 00010 <span class="keyword">struct </span>SkDOMNode; |
| 00011 |
| 00012 <span class="keyword">class </span>SkXMLParserError { |
| 00013 <span class="keyword">public</span>: |
| 00014 <span class="keyword">enum</span> ErrorCode { |
| 00015 kNoError, |
| 00016 kEmptyFile, |
| 00017 kUnknownElement, |
| 00018 kUnknownAttributeName, |
| 00019 kErrorInAttributeValue, |
| 00020 kDuplicateIDs, |
| 00021 kUnknownError |
| 00022 }; |
| 00023 |
| 00024 SkXMLParserError(); |
| 00025 <span class="keyword">virtual</span> ~SkXMLParserError(); |
| 00026 ErrorCode getErrorCode()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> fCode; } |
| 00027 <span class="keyword">virtual</span> <span class="keywordtype">void</span> getErrorString(<a class="code" href="classSkString.html">SkString</a>* str) <span class="keyword">const</span>; |
| 00028 <span class="keywordtype">int</span> getLineNumber()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> fLineNumber; } |
| 00029 <span class="keywordtype">int</span> getNativeCode()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> fNativeCode; } |
| 00030 <span class="keywordtype">bool</span> hasError()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> fCode != kNoError || fNativeCode != -1; } |
| 00031 <span class="keywordtype">bool</span> hasNoun()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> fNoun.size() > 0; } |
| 00032 <span class="keywordtype">void</span> reset(); |
| 00033 <span class="keywordtype">void</span> setCode(ErrorCode code) { fCode = code; } |
| 00034 <span class="keywordtype">void</span> setNoun(<span class="keyword">const</span> <a class="code" href="classSkString.html">SkString</a>& str) { fNoun.set(str); } |
| 00035 <span class="keywordtype">void</span> setNoun(<span class="keyword">const</span> <span class="keywordtype">char</span>* ch) { fNoun.set(ch); } |
| 00036 <span class="keywordtype">void</span> setNoun(<span class="keyword">const</span> <span class="keywordtype">char</span>* ch, size_t len) { fNoun.set(ch, len); } |
| 00037 <span class="keyword">protected</span>: |
| 00038 ErrorCode fCode; |
| 00039 <span class="keyword">private</span>: |
| 00040 <span class="keywordtype">int</span> fLineNumber; |
| 00041 <span class="keywordtype">int</span> fNativeCode; |
| 00042 <a class="code" href="classSkString.html">SkString</a> fNoun; |
| 00043 <span class="keyword">friend</span> <span class="keyword">class </span>SkXMLParser; |
| 00044 }; |
| 00045 |
| 00046 <span class="keyword">class </span>SkXMLParser { |
| 00047 <span class="keyword">public</span>: |
| 00048 SkXMLParser(SkXMLParserError* parserError = nil); |
| 00049 <span class="keyword">virtual</span> ~SkXMLParser(); |
| 00050 |
| 00053 <span class="keywordtype">bool</span> parse(<span class="keyword">const</span> <span class="keywordtype">char</span> doc[], size_t len); |
| 00054 <span class="keywordtype">bool</span> parse(SkStream& docStream); |
| 00055 <span class="keywordtype">bool</span> parse(<span class="keyword">const</span> SkDOM&, <span class="keyword">const</span> SkDOMNode*); |
| 00056 |
| 00057 <span class="keyword">static</span> <span class="keywordtype">void</span> GetNativeErrorString(<span class="keywordtype">int</span> nativeErrorCode, <a class="code" href="classSkString.html">SkString</a>* str); |
| 00058 |
| 00059 <span class="keyword">protected</span>: |
| 00060 <span class="comment">// override in subclasses; return true to stop parsing</span> |
| 00061 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> onStartElement(<span class="keyword">const</span> <span class="keywordtype">char</span> elem[]); |
| 00062 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> onAddAttribute(<span class="keyword">const</span> <span class="keywordtype">char</span> name[], <span class="keyword">const</span> <span class="keywordtype">char</span> value[]); |
| 00063 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> onEndElement(<span class="keyword">const</span> <span class="keywordtype">char</span> elem[]); |
| 00064 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> onText(<span class="keyword">const</span> <span class="keywordtype">char</span> text[], <span class="keywordtype">int</span> len); |
| 00065 |
| 00066 <span class="keyword">public</span>: |
| 00067 <span class="comment">// public for ported implementation, not meant for clients to call</span> |
| 00068 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> startElement(<span class="keyword">const</span> <span class="keywordtype">char</span> elem[]); |
| 00069 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> addAttribute(<span class="keyword">const</span> <span class="keywordtype">char</span> name[], <span class="keyword">const</span> <span class="keywordtype">char</span> value[]); |
| 00070 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> endElement(<span class="keyword">const</span> <span class="keywordtype">char</span> elem[]); |
| 00071 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> text(<span class="keyword">const</span> <span class="keywordtype">char</span> text[], <span class="keywordtype">int</span> len); |
| 00072 <span class="keywordtype">void</span>* fParser; |
| 00073 <span class="keyword">protected</span>: |
| 00074 SkXMLParserError* fError; |
| 00075 <span class="keyword">private</span>: |
| 00076 <span class="keywordtype">void</span> reportError(<span class="keywordtype">void</span>* parser); |
| 00077 }; |
| 00078 |
| 00079 <span class="preprocessor">#endif</span> |
| </pre></div><hr size="1"><address style="align: right;"><small>Generated on Tue May 9 14:35:23 2006 for SGL by |
| <a href="http://www.doxygen.org/index.html"> |
| <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.0 </small></address> |
| </body> |
| </html> |