7 #include "fwRuntime/Version.hpp" 9 #include "fwRuntime/RuntimeException.hpp" 11 #include <boost/lexical_cast.hpp> 12 #include <boost/regex.hpp> 36 if( version.empty() == false )
38 ::boost::regex regex(
"(\\d+)([-.](\\d+)){0,1}([-.](\\d+)){0,1}");
40 if( ::boost::regex_match(version, what, regex) )
42 const std::string& major = what[1].str();
43 const std::string& minor = what[3].str();
44 const std::string& patch = what[5].str();
46 assert(!major.empty());
49 m_major = ::boost::lexical_cast<
int>( major );
52 assert(!minor.empty());
55 m_minor = ::boost::lexical_cast<
int>( minor );
60 m_patch = ::boost::lexical_cast<
int>( patch );
86 std::ostringstream os;
95 if( m_defined && version.m_defined )
97 return m_major == version.m_major && m_minor == version.m_minor && m_patch == version.m_patch;
109 if(version.m_defined)
111 auto& res = os << version.m_major <<
"." << version.m_minor;
113 if(version.m_patch != -1)
115 res <<
"-" << version.m_patch;
122 return os <<
"version-not-defined";
FWRUNTIME_API Version()
Constructor.
Defines the runtime exception class.
The namespace fwRuntime contains classes to manage bundle, configuration element, extension point in ...
FWRUNTIME_API friend std::ostream & operator<<(std::ostream &os, const Version &version)
Return an ostream representation of a version.
FWRUNTIME_API bool operator==(const Version &version) const
Equality test.
Holds version information for libraries and bundles.
FWRUNTIME_API const std::string string() const
String converter.