1/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SkBML_WXMLParser_DEFINED
18#define SkBML_WXMLParser_DEFINED
19
20#include "SkString.h"
21#include "SkXMLParser.h"
22
23class SkStream;
24class SkWStream;
25
26class BML_WXMLParser : public SkXMLParser {
27public:
28    BML_WXMLParser(SkWStream& writer);
29    virtual ~BML_WXMLParser();
30    static void Write(SkStream& s, const char filename[]);
31
32  /** @cond UNIT_TEST */
33  SkDEBUGCODE(static void UnitTest();)
34  /** @endcond */
35private:
36    virtual bool onAddAttribute(const char name[], const char value[]);
37    virtual bool onEndElement(const char name[]);
38    virtual bool onStartElement(const char name[]);
39    BML_WXMLParser& operator=(const BML_WXMLParser& src);
40#ifdef SK_DEBUG
41    int fElemsCount, fElemsReused;
42    int fAttrsCount, fNamesReused, fValuesReused;
43#endif
44    SkWStream&  fWriter;
45    char*       fElems[256];
46    char*       fAttrNames[256];
47    char*       fAttrValues[256];
48
49    // important that these are U8, so we get automatic wrap-around
50    U8  fNextElem, fNextAttrName, fNextAttrValue;
51};
52
53#endif // SkBML_WXMLParser_DEFINED
54
55