Exemplo n.º 1
0
    void pile::add_label(const string & label)
    {
	if(stack.empty())
	    throw Erange("pile::add_label", "Cannot add a label to an empty stack");

	if(label == "")
	    throw Erange("pile::add_label", "An empty string is an invalid label, cannot add it");

	if(look_for_label(label) != stack.end())
	    throw Erange("pile::add_label", "Label already used in stack, cannot add it");

	stack.back().labels.push_back(label);
    }
Exemplo n.º 2
0
    void pile::clear_label(const string & label)
    {
	if(label == "")
	    throw Erange("pile::clear_label", "Empty string is an invalid label, cannot clear it");
	vector<face>::iterator it = look_for_label(label);
	if(it != stack.end())
	{
	    list<string>::iterator lab = find(it->labels.begin(), it->labels.end(), label);
	    if(lab == it->labels.end())
		throw SRC_BUG;
	    it->labels.erase(lab);
	}
    }
Exemplo n.º 3
0
    generic_file *pile::get_by_label(const std::string & label)
    {
	if(label == "")
	    throw SRC_BUG;
	else
	{
	    vector<face>::iterator it = look_for_label(label);

	    if(it == stack.end())
		throw Erange("pile::get_by_label", "Label requested in generic_file stack is unknown");

	    if(it->ptr == NULL)
		throw SRC_BUG;

	    return it->ptr;
	}
    }
Exemplo n.º 4
0
    void pile::push(generic_file *f, const string & label)
    {
	face to_add;

	if(is_terminated())
	    throw SRC_BUG;

	if(f == NULL)
	    throw SRC_BUG;
	if(look_for_label(label) != stack.end())
	    throw Erange("pile::push", "Label already used while pushing a generic_file on a stack");
	if(stack.empty())
	    set_mode(f->get_mode());
	if(f->get_mode() != get_mode())
	    throw Erange("pile::push", "Adding to the stack of generic_file an object using an incompatible read/write mode");
	to_add.ptr = f;
	to_add.labels.clear();
	if(label != "")
	    to_add.labels.push_back(label);
	stack.push_back(to_add);
    }