skia2/include/xml/SkXMLParser.h

156 lines
3.9 KiB
C
Raw Normal View History

Automatic update of all copyright notices to reflect new license terms. I have manually examined all of these diffs and restored a few files that seem to require manual adjustment. The following files still need to be modified manually, in a separate CL: android_sample/SampleApp/AndroidManifest.xml android_sample/SampleApp/res/layout/layout.xml android_sample/SampleApp/res/menu/sample.xml android_sample/SampleApp/res/values/strings.xml android_sample/SampleApp/src/com/skia/sampleapp/SampleApp.java android_sample/SampleApp/src/com/skia/sampleapp/SampleView.java experimental/CiCarbonSampleMain.c experimental/CocoaDebugger/main.m experimental/FileReaderApp/main.m experimental/SimpleCocoaApp/main.m experimental/iOSSampleApp/Shared/SkAlertPrompt.h experimental/iOSSampleApp/Shared/SkAlertPrompt.m experimental/iOSSampleApp/SkiOSSampleApp-Base.xcconfig experimental/iOSSampleApp/SkiOSSampleApp-Debug.xcconfig experimental/iOSSampleApp/SkiOSSampleApp-Release.xcconfig gpu/src/android/GrGLDefaultInterface_android.cpp gyp/common.gypi gyp_skia include/ports/SkHarfBuzzFont.h include/views/SkOSWindow_wxwidgets.h make.bat make.py src/opts/memset.arm.S src/opts/memset16_neon.S src/opts/memset32_neon.S src/opts/opts_check_arm.cpp src/ports/SkDebug_brew.cpp src/ports/SkMemory_brew.cpp src/ports/SkOSFile_brew.cpp src/ports/SkXMLParser_empty.cpp src/utils/ios/SkImageDecoder_iOS.mm src/utils/ios/SkOSFile_iOS.mm src/utils/ios/SkStream_NSData.mm tests/FillPathTest.cpp Review URL: http://codereview.appspot.com/4816058 git-svn-id: http://skia.googlecode.com/svn/trunk@1982 2bbb7eff-a529-9590-31e7-b0007b416f81
2011-07-28 14:26:00 +00:00
/*
Automatic update of all copyright notices to reflect new license terms. I have manually examined all of these diffs and restored a few files that seem to require manual adjustment. The following files still need to be modified manually, in a separate CL: android_sample/SampleApp/AndroidManifest.xml android_sample/SampleApp/res/layout/layout.xml android_sample/SampleApp/res/menu/sample.xml android_sample/SampleApp/res/values/strings.xml android_sample/SampleApp/src/com/skia/sampleapp/SampleApp.java android_sample/SampleApp/src/com/skia/sampleapp/SampleView.java experimental/CiCarbonSampleMain.c experimental/CocoaDebugger/main.m experimental/FileReaderApp/main.m experimental/SimpleCocoaApp/main.m experimental/iOSSampleApp/Shared/SkAlertPrompt.h experimental/iOSSampleApp/Shared/SkAlertPrompt.m experimental/iOSSampleApp/SkiOSSampleApp-Base.xcconfig experimental/iOSSampleApp/SkiOSSampleApp-Debug.xcconfig experimental/iOSSampleApp/SkiOSSampleApp-Release.xcconfig gpu/src/android/GrGLDefaultInterface_android.cpp gyp/common.gypi gyp_skia include/ports/SkHarfBuzzFont.h include/views/SkOSWindow_wxwidgets.h make.bat make.py src/opts/memset.arm.S src/opts/memset16_neon.S src/opts/memset32_neon.S src/opts/opts_check_arm.cpp src/ports/SkDebug_brew.cpp src/ports/SkMemory_brew.cpp src/ports/SkOSFile_brew.cpp src/ports/SkXMLParser_empty.cpp src/utils/ios/SkImageDecoder_iOS.mm src/utils/ios/SkOSFile_iOS.mm src/utils/ios/SkStream_NSData.mm tests/FillPathTest.cpp Review URL: http://codereview.appspot.com/4816058 git-svn-id: http://skia.googlecode.com/svn/trunk@1982 2bbb7eff-a529-9590-31e7-b0007b416f81
2011-07-28 14:26:00 +00:00
* Copyright 2006 The Android Open Source Project
*
Automatic update of all copyright notices to reflect new license terms. I have manually examined all of these diffs and restored a few files that seem to require manual adjustment. The following files still need to be modified manually, in a separate CL: android_sample/SampleApp/AndroidManifest.xml android_sample/SampleApp/res/layout/layout.xml android_sample/SampleApp/res/menu/sample.xml android_sample/SampleApp/res/values/strings.xml android_sample/SampleApp/src/com/skia/sampleapp/SampleApp.java android_sample/SampleApp/src/com/skia/sampleapp/SampleView.java experimental/CiCarbonSampleMain.c experimental/CocoaDebugger/main.m experimental/FileReaderApp/main.m experimental/SimpleCocoaApp/main.m experimental/iOSSampleApp/Shared/SkAlertPrompt.h experimental/iOSSampleApp/Shared/SkAlertPrompt.m experimental/iOSSampleApp/SkiOSSampleApp-Base.xcconfig experimental/iOSSampleApp/SkiOSSampleApp-Debug.xcconfig experimental/iOSSampleApp/SkiOSSampleApp-Release.xcconfig gpu/src/android/GrGLDefaultInterface_android.cpp gyp/common.gypi gyp_skia include/ports/SkHarfBuzzFont.h include/views/SkOSWindow_wxwidgets.h make.bat make.py src/opts/memset.arm.S src/opts/memset16_neon.S src/opts/memset32_neon.S src/opts/opts_check_arm.cpp src/ports/SkDebug_brew.cpp src/ports/SkMemory_brew.cpp src/ports/SkOSFile_brew.cpp src/ports/SkXMLParser_empty.cpp src/utils/ios/SkImageDecoder_iOS.mm src/utils/ios/SkOSFile_iOS.mm src/utils/ios/SkStream_NSData.mm tests/FillPathTest.cpp Review URL: http://codereview.appspot.com/4816058 git-svn-id: http://skia.googlecode.com/svn/trunk@1982 2bbb7eff-a529-9590-31e7-b0007b416f81
2011-07-28 14:26:00 +00:00
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
Automatic update of all copyright notices to reflect new license terms. I have manually examined all of these diffs and restored a few files that seem to require manual adjustment. The following files still need to be modified manually, in a separate CL: android_sample/SampleApp/AndroidManifest.xml android_sample/SampleApp/res/layout/layout.xml android_sample/SampleApp/res/menu/sample.xml android_sample/SampleApp/res/values/strings.xml android_sample/SampleApp/src/com/skia/sampleapp/SampleApp.java android_sample/SampleApp/src/com/skia/sampleapp/SampleView.java experimental/CiCarbonSampleMain.c experimental/CocoaDebugger/main.m experimental/FileReaderApp/main.m experimental/SimpleCocoaApp/main.m experimental/iOSSampleApp/Shared/SkAlertPrompt.h experimental/iOSSampleApp/Shared/SkAlertPrompt.m experimental/iOSSampleApp/SkiOSSampleApp-Base.xcconfig experimental/iOSSampleApp/SkiOSSampleApp-Debug.xcconfig experimental/iOSSampleApp/SkiOSSampleApp-Release.xcconfig gpu/src/android/GrGLDefaultInterface_android.cpp gyp/common.gypi gyp_skia include/ports/SkHarfBuzzFont.h include/views/SkOSWindow_wxwidgets.h make.bat make.py src/opts/memset.arm.S src/opts/memset16_neon.S src/opts/memset32_neon.S src/opts/opts_check_arm.cpp src/ports/SkDebug_brew.cpp src/ports/SkMemory_brew.cpp src/ports/SkOSFile_brew.cpp src/ports/SkXMLParser_empty.cpp src/utils/ios/SkImageDecoder_iOS.mm src/utils/ios/SkOSFile_iOS.mm src/utils/ios/SkStream_NSData.mm tests/FillPathTest.cpp Review URL: http://codereview.appspot.com/4816058 git-svn-id: http://skia.googlecode.com/svn/trunk@1982 2bbb7eff-a529-9590-31e7-b0007b416f81
2011-07-28 14:26:00 +00:00
#ifndef SkXMLParser_DEFINED
#define SkXMLParser_DEFINED
#include "SkString.h"
class SkStream;
class SkDOM;
struct SkDOMNode;
class SkXMLParserError {
public:
enum ErrorCode {
kNoError,
kEmptyFile,
kUnknownElement,
kUnknownAttributeName,
kErrorInAttributeValue,
kDuplicateIDs,
kUnknownError
};
SkXMLParserError();
virtual ~SkXMLParserError();
ErrorCode getErrorCode() const { return fCode; }
virtual void getErrorString(SkString* str) const;
int getLineNumber() const { return fLineNumber; }
int getNativeCode() const { return fNativeCode; }
bool hasError() const { return fCode != kNoError || fNativeCode != -1; }
bool hasNoun() const { return fNoun.size() > 0; }
void reset();
void setCode(ErrorCode code) { fCode = code; }
void setNoun(const SkString& str) { fNoun.set(str); }
void setNoun(const char* ch) { fNoun.set(ch); }
void setNoun(const char* ch, size_t len) { fNoun.set(ch, len); }
protected:
ErrorCode fCode;
private:
int fLineNumber;
int fNativeCode;
SkString fNoun;
friend class SkXMLParser;
};
class SkXMLParser {
public:
SkXMLParser(SkXMLParserError* parserError = NULL);
virtual ~SkXMLParser();
/** Returns true for success
*/
bool parse(const char doc[], size_t len);
bool parse(SkStream& docStream);
bool parse(const SkDOM&, const SkDOMNode*);
static void GetNativeErrorString(int nativeErrorCode, SkString* str);
protected:
// override in subclasses; return true to stop parsing
virtual bool onStartElement(const char elem[]);
virtual bool onAddAttribute(const char name[], const char value[]);
virtual bool onEndElement(const char elem[]);
virtual bool onText(const char text[], int len);
public:
// public for ported implementation, not meant for clients to call
virtual bool startElement(const char elem[]);
virtual bool addAttribute(const char name[], const char value[]);
virtual bool endElement(const char elem[]);
virtual bool text(const char text[], int len);
void* fParser;
protected:
SkXMLParserError* fError;
private:
void reportError(void* parser);
};
#if 0
class SkXMLPullParser {
public:
SkXMLPullParser();
explicit SkXMLPullParser(SkStream*);
virtual ~SkXMLPullParser();
SkStream* getStream() const { return fStream; }
SkStream* setStream(SkStream* stream);
enum EventType {
ERROR = -1,
START_DOCUMENT,
END_DOCUMENT,
START_TAG,
END_TAG,
TEXT,
CDSECT,
ENTITY_REF,
IGNORABLE_WHITESPACE,
PROCESSING_INSTRUCTION,
COMMENT,
DOCDECL
};
EventType nextToken();
EventType getEventType() const { return fCurr.fEventType; }
struct AttrInfo {
const char* fName;
const char* fValue;
};
int getDepth() const { return fDepth; }
const char* getName();
int getAttributeCount();
void getAttributeInfo(int, AttrInfo*);
const char* getText();
bool isWhitespace();
protected:
virtual bool onEntityReplacement(const char name[],
SkString* replacement);
public:
struct Curr {
EventType fEventType;
const char* fName;
AttrInfo* fAttrInfos;
int fAttrInfoCount;
bool fIsWhitespace;
};
private:
// implemented in the porting layer
bool onInit(); // return false on failure
EventType onNextToken();
void onExit();
SkStream* fStream;
Curr fCurr;
int fDepth;
struct Impl;
Impl* fImpl;
};
#endif
#endif