33 #include "../my_config.h"
45 class pile :
public generic_file
54 pile(
const pile & ref) :
generic_file(ref) { copy_from(ref); };
55 const pile & operator = (
const pile & ref) { detruit(); copy_from(ref);
return *
this; };
56 ~pile() { detruit(); };
67 void push(generic_file *f,
const std::string & label =
"");
78 template <
class T>
bool pop_and_close_if_type_is(T *ptr);
81 generic_file *top() {
if(stack.empty())
return NULL;
else return stack.back().ptr; };
84 generic_file *bottom() {
if(stack.empty())
return NULL;
else return stack[0].ptr; };
87 U_I size()
const {
return stack.size(); };
90 bool is_empty()
const {
return stack.empty(); };
93 void clear() { detruit(); };
98 template<
class T>
void find_first_from_top(T * & ref);
101 template<
class T>
void find_first_from_bottom(T * & ref);
123 void clear_label(
const std::string & label);
131 void add_label(
const std::string & label);
138 bool skip(
const infinint & pos);
140 bool skip_relative(S_I x);
141 infinint get_position();
142 void copy_to(generic_file & ref);
143 void copy_to(generic_file & ref, crc & value);
146 U_I inherited_read(
char *a, U_I size);
147 void inherited_write(
const char *a, U_I size);
148 void inherited_sync_write();
149 void inherited_terminate();
155 std::list<std::string> labels;
158 std::vector<face> stack;
160 void copy_from(
const pile & ref)
165 std::vector<face>::iterator look_for_label(
const std::string & label);
169 template <
class T>
bool pile::pop_and_close_if_type_is(T *ptr)
175 top = stack.back().ptr;
176 ptr =
dynamic_cast<T *
>(top);
190 template <
class T>
void pile::find_first_from_top(T * & ref)
193 for(std::vector<face>::reverse_iterator it = stack.rbegin(); it != stack.rend() && ref == NULL; ++it)
194 ref = dynamic_cast<T *>(it->ptr);
198 template <
class T>
void pile::find_first_from_bottom(T * & ref)
201 for(std::vector<face>::iterator it = stack.begin(); it != stack.end() && ref == NULL; ++it)
202 ref = dynamic_cast<T *>(it->ptr);