diff options
Diffstat (limited to 'sdo-cpp/branches/sdo-cpp-pre2.1/runtime/core/src/commonj/sdo/SAX2Parser.h')
-rw-r--r-- | sdo-cpp/branches/sdo-cpp-pre2.1/runtime/core/src/commonj/sdo/SAX2Parser.h | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/sdo-cpp/branches/sdo-cpp-pre2.1/runtime/core/src/commonj/sdo/SAX2Parser.h b/sdo-cpp/branches/sdo-cpp-pre2.1/runtime/core/src/commonj/sdo/SAX2Parser.h new file mode 100644 index 0000000000..fd11d98fde --- /dev/null +++ b/sdo-cpp/branches/sdo-cpp-pre2.1/runtime/core/src/commonj/sdo/SAX2Parser.h @@ -0,0 +1,117 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +#ifndef _SAX2PARSER_H_ +#define _SAX2PARSER_H_ + +#include "commonj/sdo/disable_warn.h" + +#include "commonj/sdo/SDOXMLString.h" +#include "commonj/sdo/SAX2Namespaces.h" +#include "commonj/sdo/SAX2Attributes.h" +#include "commonj/sdo/ParserErrorSetter.h" + + + +#include "sstream" +namespace commonj +{ + namespace sdo + { + + class parse_buf_element + { + + public: + char buf[1000]; + int len; + }; + +/** + * SAX2Parser holds the methods which will be called back. + * The implementation uses libxml, which provides callbacks for + * errors, warnings , elements etc. These methods correspond to thos + * callbacks. + * Callbacks from libxml to these C methods are converted into calls + * to the C++ equivalent (with some parameter manipulation + * In the callback methods the void* ctx is a pointer to 'this' SAX2Parser + */ + class SAX2Parser + { + + public: + + SAX2Parser(); + + SAX2Parser(ParserErrorSetter* insetter); + + virtual ~SAX2Parser(); + + virtual int parse (const char* filename); + virtual int parse_twice (const char* filename); + + virtual void startDocument(); + virtual void endDocument(); + + virtual void startElementNs( + const SDOXMLString& localname, + const SDOXMLString& prefix, + const SDOXMLString& URI, + const SAX2Namespaces& namespaces, + const SAX2Attributes& attributes); + + virtual void endElementNs( + const SDOXMLString& localname, + const SDOXMLString& prefix, + const SDOXMLString& URI); + + virtual void characters(const SDOXMLString& chars); + + virtual void warning(const char* msg, va_list args); + + virtual void fatalError(const char* msg, va_list args); + + virtual void error(const char* msg, va_list args); + + virtual void stream(std::istream& input); + virtual void stream_twice(std::istream& input); + + friend std::istream& operator>>(std::istream& input, SAX2Parser& parser); + + ParserErrorSetter* setter; + bool parserError; + + char messageBuffer[1024]; + + virtual const char* getCurrentFile() const; + virtual void setCurrentFile(const char* filename); + + private: + + char* currentFile; + + + }; + } // End - namespace sdo +} // End - namespace commonj + + +#endif //_SAX2PARSER_H_ |