root/trunk/xpath_static.d

Revision 27, 5.0 kB (checked in by yossarian, 2 years ago)

upgraded, now compiles without errors :)

Line 
1 /*
2 www.sourceforge.net/projects/tinyxpath
3 Copyright (c) 2002-2004 Yves Berquin (yvesb@users.sourceforge.net)
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any
7 damages arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any
10 purpose, including commercial applications, and to alter it and
11 redistribute it freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must
14 not claim that you wrote the original software. If you use this
15 software in a product, an acknowledgment in the product documentation
16 would be appreciated but is not required.
17
18 2. Altered source versions must be plainly marked as such, and
19 must not be misrepresented as being the original software.
20
21 3. This notice may not be removed or altered from any source
22 distribution.
23 */
24
25 /**
26     \file xpath_static.h
27     \author Yves Berquin
28 */
29
30     module xpath.xpath_static;
31     public import xpath.tinyxml;
32     private import xpath.xpath_processor;
33
34     // no check static functions
35     int i_xpath_int (TiXmlNode XNp_source_tree, char[] cp_xpath_expr)
36     {
37         auto xpath_processor xp_proc = new xpath_processor (XNp_source_tree, cp_xpath_expr);
38         return xp_proc.i_compute_xpath ();
39     }
40
41     double d_xpath_double (TiXmlNode XNp_source_tree, char[] cp_xpath_expr)
42     {
43         auto xpath_processor xp_proc = new xpath_processor (XNp_source_tree, cp_xpath_expr);
44         return xp_proc.d_compute_xpath ();
45     }
46     bool o_xpath_bool (TiXmlNode XNp_source_tree, char[] cp_xpath_expr)
47     {
48         auto xpath_processor xp_proc = new xpath_processor (XNp_source_tree, cp_xpath_expr);
49         return xp_proc.o_compute_xpath ();
50     }
51     char[] S_xpath_string (TiXmlNode XNp_source_tree, char[] cp_xpath_expr)
52     {
53         auto xpath_processor xp_proc = new xpath_processor(XNp_source_tree, cp_xpath_expr);
54         return xp_proc.S_compute_xpath();
55     }
56     TiXmlNode XNp_xpath_node (TiXmlNode XNp_source_tree, char[] cp_xpath_expr)
57     {
58         uint u_nb;
59
60         auto xpath_processor xp_proc = new xpath_processor(XNp_source_tree, cp_xpath_expr);
61         u_nb = xp_proc.u_compute_xpath_node_set();
62         if (! u_nb)
63             return null;
64         return xp_proc.XNp_get_xpath_node (0);
65     }
66
67    
68     TiXmlAttribute XAp_xpath_attribute (TiXmlNode XNp_source_tree, char[] cp_xpath_expr)
69     {
70         uint u_nb;
71
72         auto xpath_processor xp_proc = new xpath_processor(XNp_source_tree, cp_xpath_expr);
73         u_nb = xp_proc . u_compute_xpath_node_set ();
74         if (! u_nb)
75             return null;
76         return xp_proc . XAp_get_xpath_attribute (0);
77     }
78
79
80     // check static functions
81     bool o_xpath_int (TiXmlNode XNp_source_tree, char[] cp_xpath_expr, out int i_res, out char[] myerr)
82     {
83         auto xpath_processor xp_proc = new xpath_processor(XNp_source_tree, cp_xpath_expr);
84         i_res = xp_proc . i_compute_xpath ();
85         if (xp_proc.e_error != Errors.e_no_error)
86             myerr = FormatError(xp_proc.e_error);       
87         return (xp_proc.e_error == Errors.e_no_error);
88     }
89     bool o_xpath_double (TiXmlNode XNp_source_tree, char[] cp_xpath_expr, out double d_res)
90     {
91         char[] tmp;
92         return o_xpath_double(XNp_source_tree, cp_xpath_expr, d_res, tmp);
93     }
94
95     bool o_xpath_double (TiXmlNode XNp_source_tree, char[] cp_xpath_expr, out double d_res, out char[] myerr)
96     {
97         auto xpath_processor xp_proc = new xpath_processor(XNp_source_tree, cp_xpath_expr);
98         d_res = xp_proc . d_compute_xpath ();
99         if (xp_proc.e_error != Errors.e_no_error)
100             myerr = FormatError(xp_proc.e_error);       
101         return (xp_proc.e_error == Errors.e_no_error);
102     }
103     bool o_xpath_bool (TiXmlNode XNp_source_tree, char[] cp_xpath_expr, out bool b_res, out char[] myerr)
104     {
105         auto xpath_processor xp_proc = new xpath_processor(XNp_source_tree, cp_xpath_expr);
106         b_res = xp_proc . o_compute_xpath ();
107         if (xp_proc.e_error != Errors.e_no_error)
108             myerr = FormatError(xp_proc.e_error);       
109         return (xp_proc.e_error == Errors.e_no_error);
110     }
111     bool o_xpath_string (TiXmlNode XNp_source_tree, char[] cp_xpath_expr, out char[] S_res, out char[] myerr)
112     {
113         auto xpath_processor xp_proc = new xpath_processor(XNp_source_tree, cp_xpath_expr);
114         S_res = xp_proc . S_compute_xpath ();
115         if (xp_proc.e_error != Errors.e_no_error)
116             myerr = FormatError(xp_proc.e_error);
117         return (xp_proc.e_error == Errors.e_no_error);
118     }
119     bool o_xpath_node (TiXmlNode XNp_source_tree, char[] cp_xpath_expr, out TiXmlNode XNp_node)
120     {
121         uint u_nb;
122
123         auto xpath_processor xp_proc = new xpath_processor(XNp_source_tree, cp_xpath_expr);
124         u_nb = xp_proc . u_compute_xpath_node_set ();
125         if (! u_nb)
126             return false;
127         XNp_node = xp_proc . XNp_get_xpath_node (0);
128         return (xp_proc.e_error == Errors.e_no_error);
129     }
130
131    
132     bool o_xpath_attribute (TiXmlNode XNp_source_tree, char[] cp_xpath_expr, out TiXmlAttribute XAp_attrib)
133     {
134         uint u_nb;
135
136         auto xpath_processor xp_proc = new xpath_processor(XNp_source_tree, cp_xpath_expr);
137         u_nb = xp_proc . u_compute_xpath_node_set ();
138         if (! u_nb)
139             return false;
140         XAp_attrib = xp_proc . XAp_get_xpath_attribute (0);
141         return (xp_proc.e_error == Errors.e_no_error);
142     }
Note: See TracBrowser for help on using the browser.