| 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 action_store.h |
| 27 | \author Yves Berquin |
| 28 | */ |
| 29 | |
| 30 | #ifndef __ACTION_STORE_H |
| 31 | #define __ACTION_STORE_H |
| 32 | |
| 33 | #include "tinyxml.h" |
| 34 | |
| 35 | namespace TinyXPath |
| 36 | { |
| 37 | |
| 38 | /// Action item for the XPath action placeholder |
| 39 | /// \n Able to store 1 quadruplet (3 integers and a string) |
| 40 | class action_item |
| 41 | { |
| 42 | public : |
| 43 | /// constructor |
| 44 | action_item (int i_in_1, int i_in_2, int i_in_3, const char * cp_string) : |
| 45 | i_1 (i_in_1), i_2 (i_in_2), i_3 (i_in_3), S_string (cp_string) |
| 46 | { |
| 47 | } |
| 48 | |
| 49 | /// Retrieve the set of values |
| 50 | void v_get (int & i_out_1, int & i_out_2, int & i_out_3, TIXML_STRING & S_out) |
| 51 | { |
| 52 | i_out_1 = i_1; |
| 53 | i_out_2 = i_2; |
| 54 | i_out_3 = i_3; |
| 55 | S_out = S_string; |
| 56 | } |
| 57 | |
| 58 | protected : |
| 59 | /// Integer triplet values |
| 60 | int i_1, i_2, i_3; |
| 61 | /// String value |
| 62 | TIXML_STRING S_string; |
| 63 | } ; |
| 64 | |
| 65 | /// The XPath action stack. Not a stack per se, only a placeholder |
| 66 | /// \n It's able to store quadruplets (3 integers and a string) |
| 67 | /// \n It allocates them by set of 100 |
| 68 | class action_store |
| 69 | { |
| 70 | public : |
| 71 | action_store (); |
| 72 | ~ action_store (); |
| 73 | /// add an element on the placeholder, given its details |
| 74 | void v_add (int i_1, int i_2, int i_3, const char * cp_string); |
| 75 | /// Get the current nb of stored elements |
| 76 | int i_get_size () {return i_size;} |
| 77 | /// Get one element from the placeholder |
| 78 | void v_get (int i_position, int & i_1, int & i_2, int & i_3, TIXML_STRING & S_out); |
| 79 | /// Get the current position. See i_position. |
| 80 | int i_get_position () {return i_position;} |
| 81 | /// Set the position to an arbitrary value. See i_position. |
| 82 | void v_set_position (int i_where) {i_position = i_where;} |
| 83 | /// Decrement the position. See i_position. |
| 84 | void v_dec_position () {i_position--;} |
| 85 | |
| 86 | protected : |
| 87 | /// Used number of elements |
| 88 | int i_size; |
| 89 | /// This value is informative and is not related |
| 90 | /// to the nb of elements in the placeholder |
| 91 | int i_position; |
| 92 | /// Nb of allocated elements |
| 93 | int i_alloc; |
| 94 | /// Pointers to the allocated elements |
| 95 | action_item ** aipp_list; |
| 96 | } ; |
| 97 | |
| 98 | } |
| 99 | |
| 100 | #endif |