inline void texcoord_array_buffer<T>::set_components( unsigned int components )
{
    // check if the componets - here size are compatible with the buffer
    if( components <1 || components >4  )
        throw invalid_parameter("nyx::texcoord_array_buffer::setComponents: unsupported color buffer size.");
    else
        texcoord_array_buffer<T>::m_size = components;
}
Exemplo n.º 2
0
const number_format &number_format::from_builtin_id(std::size_t builtin_id)
{
    if (!is_builtin_format(builtin_id))
    {
        throw invalid_parameter();
    }

    return builtin_formats().at(builtin_id);
}
Exemplo n.º 3
0
number_format number_format::from_builtin_id(std::size_t builtin_id)
{
    if (builtin_formats().find(builtin_id) == builtin_formats().end())
    {
        throw invalid_parameter(); //("unknown id: " + std::to_string(builtin_id));
    }

    auto format_string = builtin_formats().at(builtin_id);
    return number_format(format_string, builtin_id);
}
Exemplo n.º 4
0
	void model::move_creature
		(const std::weak_ptr<creature>& c, int x, int y)
	{
		std::shared_ptr<creature> csp(c.lock());

		if (!csp)
		{
			std::cerr << "Invalid creature for movement." << std::endl;
			throw invalid_parameter();
		}

		map_.move_creature(csp, x, y);
	}
Exemplo n.º 5
0
inline void element_buffer<T>::set_components( unsigned int components )
{
    // check if the componets - here size are compatible with the buffer (here primitive type)
    switch( components )
    {
        case GL_POINTS :    element_buffer<T>::m_size = 1; break;
        case GL_LINES :     element_buffer<T>::m_size = 2; break;
        case GL_TRIANGLES : element_buffer<T>::m_size = 3; break;
        case GL_QUADS :     element_buffer<T>::m_size = 4; break;

        default:
            throw invalid_parameter("nyx::element_buffer::configure: unsupported element primitive.");
    }
    m_type = components;
}
Exemplo n.º 6
0
void worksheet::unmerge_cells(const range_reference &reference)
{
    auto match = std::find(d_->merged_cells_.begin(), d_->merged_cells_.end(), reference);

    if (match == d_->merged_cells_.end())
    {
        throw invalid_parameter();
    }

    d_->merged_cells_.erase(match);

    for (auto row : range(reference))
    {
        for (auto cell : row)
        {
            cell.merged(false);
        }
    }
}
Exemplo n.º 7
0
inline void buffer<T>::set_usage( unsigned int usage )
{
    // check the buffer usage
    switch( usage )
    {
        case GL_STREAM_DRAW :
        case GL_STREAM_READ :
        case GL_STREAM_COPY :
        case GL_STATIC_DRAW :
        case GL_STATIC_READ :
        case GL_STATIC_COPY :
        case GL_DYNAMIC_DRAW :
        case GL_DYNAMIC_READ :
        case GL_DYNAMIC_COPY :
            m_usage = usage;
            break;

        default:
            throw invalid_parameter("nyx::buffer::setUsage: unsupported buffer usage.");
    }
}
Exemplo n.º 8
0
void worksheet::create_named_range(const std::string &name, const range_reference &reference)
{
    try
    {
        auto temp = cell_reference::split_reference(name);

        // name is a valid reference, make sure it's outside the allowed range

        if (column_t(temp.first).index <= column_t("XFD").index && temp.second <= 1048576)
        {
            throw invalid_parameter(); //("named range name must be outside the range A1-XFD1048576");
        }
    }
    catch (xlnt::invalid_cell_reference&)
    {
        // name is not a valid reference, that's good
    }

    std::vector<named_range::target> targets;
    targets.push_back({*this, reference});

    d_->named_ranges_[name] = xlnt::named_range(name, targets);
}
Exemplo n.º 9
0
	std::weak_ptr<creature> model::create_creature
		(const creature_prototype& prototype, int x, int y)
	{
		std::shared_ptr<creature> c(new creature(prototype, x, y));

		if (x < 0 || y < 0 || x >= map_.size_x() || y >= map_.size_y())
		{
			std::cerr << "Invalid creature position." << std::endl;
			throw invalid_parameter();
		}

		creatures_.push_back(c);

		try
		{ map_.add_creature_to_tile(c); }
		catch (...)
		{
			creatures_.pop_back();
			throw;
		}

		return c;
	}