| 1 | /* |
| 2 | www.sourceforge.net/projects/tinyxpath |
| 3 | Copyright (c) 2002-2004 Yves Berquin ([email protected]) |
| 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_stream.cpp |
| 27 | \author Yves Berquin |
| 28 | Specialized byte stream for the TinyXPath project |
| 29 | */ |
| 30 | |
| 31 | #include "xpath_syntax.h" |
| 32 | #include "xpath_stream.h" |
| 33 | |
| 34 | namespace TinyXPath |
| 35 | { |
| 36 | |
| 37 | /// Redefinition of a token_syntax_decoder, with an xpath_stream pointer |
| 38 | /// \n We could have made this a double dependency on token_syntax_decoder and xpath_stream, |
| 39 | /// but this is not good pratice IMHO |
| 40 | class token_redef : public token_syntax_decoder |
| 41 | { |
| 42 | protected : |
| 43 | /// pointer to an xpath_stream instance |
| 44 | xpath_stream * xsp_stream; |
| 45 | public : |
| 46 | /// constructor |
| 47 | token_redef ( |
| 48 | xpath_stream * xsp_in) ///< Pointer to an xpath_stream instance |
| 49 | { |
| 50 | xsp_stream = xsp_in; |
| 51 | } |
| 52 | /// dispatcher of the xpath_stream::v_action |
| 53 | virtual void v_action (xpath_construct xc_rule, unsigned u_sub, unsigned u_variable = 0, const char * cp_literal = "") |
| 54 | { |
| 55 | xsp_stream -> v_action (xc_rule, u_sub, u_variable, cp_literal); |
| 56 | } |
| 57 | /// dispatcher of the xpath_stream::i_get_action_counter |
| 58 | virtual int i_get_action_counter () {return xsp_stream -> i_get_action_counter ();} |
| 59 | } ; |
| 60 | |
| 61 | /// xpath_stream constructor |
| 62 | xpath_stream::xpath_stream (const char * cp_in) : byte_stream (cp_in) |
| 63 | { |
| 64 | tlp_list = new token_redef (this); |
| 65 | } |
| 66 | |
| 67 | } |