-
Notifications
You must be signed in to change notification settings - Fork 1
/
action_store.cpp
77 lines (61 loc) · 2.25 KB
/
action_store.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
www.sourceforge.net/projects/tinyxpath
Copyright (c) 2002-2004 Yves Berquin (yvesb@users.sourceforge.net)
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product documentation
would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/
/**
\file action_store.cpp
\author Yves Berquin
*/
#include "action_store.h"
#include <cassert>
using namespace std;
namespace TinyXPath {
/// Allocation unit
const int i_alloc_size = 100;
/// destructor
action_store::~action_store() {
if (_i_size) {
for (int i_item = 0; i_item < _i_size; i_item++) {
delete _aipp_list[i_item];
}
delete[] _aipp_list;
}
}
/// add an element on the placeholder, given its details
void action_store::v_add(int i_1, int i_2, int i_3, const char* cp_string) {
int i_new_size;
action_item** aipp_new_list;
if (_i_size == _i_alloc) {
i_new_size = _i_size + i_alloc_size;
aipp_new_list = new action_item*[i_new_size];
memset(aipp_new_list, 0, i_new_size * sizeof(action_item*));
if (_i_size) {
memcpy(aipp_new_list, _aipp_list, _i_size * sizeof(action_item*));
delete[] _aipp_list;
}
_aipp_list = aipp_new_list;
_i_alloc = i_new_size;
}
_aipp_list[_i_size++] = new action_item(i_1, i_2, i_3, cp_string);
}
/// Get one element from the placeholder
void action_store::v_get(int i_entry, int& i_1, int& i_2, int& i_3, string& S_out) const {
assert(i_entry >= 0 && i_entry < _i_size);
assert(_aipp_list[i_entry]);
_aipp_list[i_entry]->v_get(i_1, i_2, i_3, S_out);
}
} // namespace TinyXPath