ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/vendor/pxys2-2.0.0/pxyscand/src/PXXMLXPathLoaderImp.h
Revision: 3252
Committed: Wed Apr 2 20:41:43 2014 UTC (11 years, 4 months ago) by michael
Content type: text/x-chdr
File size: 2413 byte(s)
Log Message:
- Imported pxys2-2.0.0

File Contents

# Content
1 /* Copyright (C) 2003 Stephane Thiell
2 *
3 * This file is part of pxyscand (from pxys)
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 *
19 */
20 #ifndef INCLUDED_PXXMLXPATHLOADERIMP_H_
21 #define INCLUDED_PXXMLXPATHLOADERIMP_H_
22
23 #include <exception>
24 #include <libxml/parser.h>
25 #include <libxml/xpath.h>
26
27 class PXXMLException : public std::exception
28 {
29 public:
30 PXXMLException(const char *inError, const char *inHint = 0) throw()
31 : mError(inError), mHint(inHint) {}
32 virtual ~PXXMLException() throw() {}
33
34 const char *GetErrorString() const { return mError; }
35 const char *GetHint() const { return mHint ? mHint : "n/a"; }
36 static void Throw(const char *inError, const char *inHint = 0)
37 { throw PXXMLException(inError, inHint); }
38
39 protected:
40 const char *mError, *mHint;
41 };
42
43 class StPXXPathContextNode
44 {
45 xmlNodePtr mNodeSave;
46 xmlNodePtr * mNodeHandle;
47
48 public:
49 StPXXPathContextNode(xmlNodePtr *inNodeSave, xmlNodePtr inNewNode)
50 : mNodeHandle(inNodeSave)
51 {
52 mNodeSave = *mNodeHandle;
53 *inNodeSave = inNewNode;
54 }
55 ~StPXXPathContextNode()
56 {
57 *mNodeHandle = mNodeSave;
58 }
59 };
60
61 class PXXMLXPathLoaderImp
62 {
63 public:
64 PXXMLXPathLoaderImp(const char *inFile);
65 virtual ~PXXMLXPathLoaderImp();
66
67 virtual xmlXPathObjectPtr Eval(const char *xpath);
68 virtual xmlXPathObjectPtr EvalUnique(const char *xpath);
69
70 virtual void GetAddress(const char *xpath, int idx, int mincnt,
71 const char *debugpath, struct in_addr *outAddr);
72 virtual int GetInteger(const char *xpath, int idx, int mincnt);
73 virtual xmlChar * CopyString(const char *xpath, int idx, int mincnt);
74
75 protected:
76 xmlDocPtr mDoc;
77 xmlXPathContextPtr mCx;
78 };
79
80 #endif /* INCLUDED_PXXMLXPATHLOADERIMP_H_ */