BUG: Fix find_* search order with path suffixes
[cmake.git] / Source / cmXMLParser.h
blob018c7c72ad1d618dcd9ef385bb79a0c6b0241d46
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmXMLParser.h,v $
5 Language: C++
6 Date: $Date: 2007-07-26 18:36:06 $
7 Version: $Revision: 1.4 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #ifndef cmXMLParser_h
18 #define cmXMLParser_h
20 #include "cmStandardIncludes.h"
22 extern "C"
24 void cmXMLParserStartElement(void*, const char*, const char**);
25 void cmXMLParserEndElement(void*, const char*);
26 void cmXMLParserCharacterDataHandler(void*, const char*, int);
29 /** \class cmXMLParser
30 * \brief Helper class for performing XML parsing
32 * Superclass for all XML parsers.
34 class cmXMLParser
36 public:
37 cmXMLParser();
38 virtual ~cmXMLParser();
40 //! Parse given XML string
41 virtual int Parse(const char* string);
43 //! Parse given XML file
44 virtual int ParseFile(const char* file);
46 /**
47 * When parsing fragments of XML or streaming XML, use the following
48 * three methods. InitializeParser method initialize parser but does
49 * not perform any actual parsing. ParseChunk parses framgent of
50 * XML. This has to match to what was already parsed. CleanupParser
51 * finishes parsing. If there were errors, CleanupParser will report
52 * them.
54 virtual int InitializeParser();
55 virtual int ParseChunk(const char* inputString,
56 std::string::size_type length);
57 virtual int CleanupParser();
59 protected:
60 //! This variable is true if there was a parse error while parsing in
61 //chunks.
62 int ParseError;
64 //1 Expat parser structure. Exists only during call to Parse().
65 void* Parser;
67 /**
68 * Called before each block of input is read from the stream to check if
69 * parsing is complete. Can be replaced by subclasses to change the
70 * terminating condition for parsing. Parsing always stops when the end of
71 * file is reached in the stream.
74 virtual int ParsingComplete();
76 /**
77 * Called when a new element is opened in the XML source. Should be
78 * replaced by subclasses to handle each element. name = Name of new
79 * element. atts = Null-terminated array of attribute name/value pairs.
80 * Even indices are attribute names, and odd indices are values.
82 virtual void StartElement(const char* name, const char** atts);
84 //! Called at the end of an element in the XML source opened when
85 //StartElement was called.
86 virtual void EndElement(const char* name);
88 //! Called when there is character data to handle.
89 virtual void CharacterDataHandler(const char* data, int length);
91 //! Called by Parse to report an XML syntax error.
92 virtual void ReportXmlParseError();
94 //! Utility for convenience of subclasses. Wraps isspace C library
95 // routine.
96 static int IsSpace(char c);
98 //! Send the given buffer to the XML parser.
99 virtual int ParseBuffer(const char* buffer,
100 std::string::size_type length);
102 //! Send the given c-style string to the XML parser.
103 int ParseBuffer(const char* buffer);
105 //! Callbacks for the expat
106 friend void cmXMLParserStartElement(void*, const char*, const char**);
107 friend void cmXMLParserEndElement(void*, const char*);
108 friend void cmXMLParserCharacterDataHandler(void*, const char*, int);
111 #endif