Scarab  v2.11.1
Project 8 C++ Utility Library
version_pybind.hh
Go to the documentation of this file.
1 #ifndef VERSION_PYBIND_HH_
2 #define VERSION_PYBIND_HH_
3 
4 #include "version_semantic.hh"
5 
6 #include "pybind11/pybind11.h"
7 
8 namespace scarab_pybind
9 {
10 
11  std::list< std::string > export_version( pybind11::module& mod )
12  {
13  std::list< std::string > all_items;
14 
15  all_items.push_back( "VersionSemantic" );
16  pybind11::class_< scarab::version_semantic, std::shared_ptr< scarab::version_semantic > >( mod, "VersionSemantic", "data structure for representing semantic version information" )
17  .def( pybind11::init<>() )
18  .def( pybind11::init< unsigned, unsigned, unsigned >(),
19  pybind11::arg( "major"),
20  pybind11::arg( "minor"),
21  pybind11::arg( "patch"))
22  .def( pybind11::init< const scarab::version_semantic& >() )
23 
24  .def( "__eq__", &scarab::version_semantic::operator== )
25  .def( "__lt__", &scarab::version_semantic::operator< )
26  .def( "__gt__", &scarab::version_semantic::operator> )
27 
32 
34  [](scarab::version_semantic& an_obj, const std::string& a_package ) {an_obj.package() = a_package; } )
35  .def_property( "commit", (std::string& (scarab::version_semantic::*)()) &scarab::version_semantic::commit,
36  [](scarab::version_semantic& an_obj, const std::string& a_commit ) {an_obj.commit() = a_commit; } )
37 
38  .def_property( "exe_name", (std::string& (scarab::version_semantic::*)()) &scarab::version_semantic::exe_name,
39  [](scarab::version_semantic& an_obj, const std::string& an_exe ) {an_obj.exe_name() = an_exe; } )
40  .def_property( "hostname", (std::string& (scarab::version_semantic::*)()) &scarab::version_semantic::hostname,
41  [](scarab::version_semantic& an_obj, const std::string& a_hostname ) {an_obj.hostname() = a_hostname; } )
42  .def_property( "username", (std::string& (scarab::version_semantic::*)()) &scarab::version_semantic::username,
43  [](scarab::version_semantic& an_obj, const std::string& a_username ) {an_obj.username() = a_username; } )
44 
45  .def_property_readonly( "version_info", &scarab::version_semantic::version_info_string )
46 
47  .def( "parse", &scarab::version_semantic::parse, "parse a version string into this object" )
48  .def( "combine", &scarab::version_semantic::combine, pybind11::arg( "major" ), pybind11::arg( "minor" ), pybind11::arg( "patch" ), "combine integer represetnations of major, minor, and patch into object")
49  .def( "update_exe_host_user", &scarab::version_semantic::update_exe_host_user, "attempt to determine execution properties: executable name, username, hostname" )
50  ;
51 
52  return all_items;
53  }
54 
55 } /* namespace scarab_pybind */
56 
57 #endif /* VERSION_PYBIND_HH_ */
bool combine(unsigned a_maj_ver, unsigned a_min_ver, unsigned a_patch_ver)
class_ & def_property_readonly(const char *name, const Getter &fget, const Extra &...extra)
Uses return_value_policy::reference_internal by default.
Definition: pybind11.h:1219
virtual std::string version_info_string() const
Wrapper for Python extension modules.
Definition: pybind11.h:789
virtual const std::string & commit() const =0
virtual unsigned patch_version() const
virtual const std::string & version_str() const
virtual const std::string & package() const =0
virtual unsigned major_version() const
virtual unsigned minor_version() const
virtual const std::string & hostname() const =0
virtual const std::string & username() const =0
bool parse(const std::string &a_ver)
virtual const std::string & exe_name() const =0
class_ & def_property(const char *name, const Getter &fget, const Setter &fset, const Extra &...extra)
Uses return_value_policy::reference_internal by default.
Definition: pybind11.h:1244
bool typename Extra class_ & def(const char *name_, Func &&f, const Extra &... extra)
Definition: pybind11.h:1110
std::list< std::string > export_version(pybind11::module &mod)