/* vim: set sw=4 sts=4 et foldmethod=syntax : */

/*
 * Copyright (c) 2007 Piotr Jaroszyński <peper@gentoo.org>
 *
 * This file is part of the Paludis package manager. Paludis is free software;
 * you can redistribute it and/or modify it under the terms of the GNU General
 * Public License version 2, as published by the Free Software Foundation.
 *
 * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 * details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <paludis_python.hh>

#include <paludis/version_operator.hh>

namespace p = paludis;
namespace pp = paludis::python;
namespace bp = boost::python;

void expose_version_operator()
{
    static pp::register_exception<p::BadVersionOperatorError>
        BadVersionOperatorError("BadVersionOperatorError");

    bp::enum_<p::VersionOperatorValue>
        vov("VersionOperatorValue");
    vov.value("LESS_EQUAL", p::vo_less_equal);
    vov.value("LESS", p::vo_less);
    vov.value("EQUAL", p::vo_equal);
    vov.value("TILDE", p::vo_tilde);
    vov.value("GREATER", p::vo_greater);
    vov.value("GREATER_EQUAL", p::vo_greater_equal);
    vov.value("EQUAL_STAR", p::vo_equal_star);
    vov.value("TILDE_GREATER", p::vo_tilde_greater);
    vov.value("LAST", p::last_vo);

    bp::class_<p::VersionOperator>
        vo("VersionOperator",
                "An operator attached to a VersionSpec, validated.",
                bp::init<const p::VersionOperatorValue>("__init__(VersionOperatorValue)")
          );
    vo.def(bp::init<const std::string &>("__init__(string)"));
    vo.add_property("value", &p::VersionOperator::value,
            "[ro] VersionOperatorValue"
            );
    vo.def(bp::self_ns::str(bp::self));

    bp::implicitly_convertible<std::string, p::VersionOperator>();
    bp::implicitly_convertible<p::VersionOperatorValue, p::VersionOperator>();
}
