Main Page   Class Hierarchy   Alphabetical List   Compound List   Examples  
version.h
00001 /***************************************************************************
00002     copyright            : (C) 2002-2008 by Stefano Barbato
00003     email                : stefano@codesink.org
00004 
00005     $Id: version.h,v 1.9 2008-10-07 11:06:26 tat Exp $
00006  ***************************************************************************/
00007 #ifndef _MIMETIC_VERSION_H_
00008 #define _MIMETIC_VERSION_H_
00009 #include <string>
00010 #include <iostream>
00011 
00012 namespace mimetic
00013 {
00014 struct Version;
00015 
00016 
00017 // library version
00018 extern const Version version;
00019 
00020 
00021 // major & minor are macro defined in /usr/include/sys/sysmacros.h (linux)
00022 // so we'll use maj & min instead
00023 
00024 /// A three levels version string class
00025 /** 
00026     format:
00027         maj.min[.build]
00028           \d+\.\d+(\.\d+)?
00029     es. 1.1, 1.23.5, 1.2.3, 1.2.3, 1.11
00030         22.1.3, 0.1.234
00031 */
00032 struct Version
00033 {
00034     typedef unsigned int ver_type;
00035     Version();
00036     Version(const std::string&);
00037     Version(ver_type, ver_type, ver_type build = 0);
00038     void maj(ver_type);
00039     void min(ver_type);
00040     void build(ver_type);
00041     ver_type maj() const;
00042     ver_type min() const;
00043     ver_type build() const;
00044     
00045     void set(ver_type, ver_type, ver_type build = 0);
00046     void set(const std::string&);
00047     std::string str() const;
00048 
00049     bool operator==(const Version&) const;
00050     bool operator!=(const Version&) const;
00051     bool operator<(const Version&) const;
00052     bool operator>(const Version&) const;
00053     bool operator<=(const Version&) const;
00054     bool operator>=(const Version&) const;
00055     friend std::ostream& operator<<(std::ostream&, const Version&);
00056 protected:
00057     ver_type m_maj, m_min, m_build;
00058 };
00059 
00060 }
00061 
00062 #endif
00063