Main Page   Class Hierarchy   Alphabetical List   Compound List   Examples  

version.h

00001 /***************************************************************************
00002     copyright            : (C) 2002-2005 by Stefano Barbato
00003     email                : [email protected]
00004 
00005     $Id: version_8h-source.html,v 1.4 2006-03-12 12:28:32 tat Exp $
00006  ***************************************************************************/
00007 
00008 /***************************************************************************
00009  *                                                                         *
00010  *   This program is free software; you can redistribute it and/or modify  *
00011  *   it under the terms of the GNU General Public License as published by  *
00012  *   the Free Software Foundation; either version 2 of the License, or     *
00013  *   (at your option) any later version.                                   *
00014  *                                                                         *
00015  ***************************************************************************/
00016 #ifndef _MIMETIC_VERSION_H_
00017 #define _MIMETIC_VERSION_H_
00018 #include <string>
00019 #include <iostream>
00020 
00021 namespace mimetic
00022 {
00023 struct Version;
00024 
00025 
00026 // library version
00027 extern const Version version;
00028 
00029 
00030 // major & minor are macro defined in /usr/include/sys/sysmacros.h (linux)
00031 // so we'll use maj & min instead
00032 
00033 /// A three levels version string class
00034 /** 
00035     format:
00036         maj.min[.build]
00037           \d+\.\d+(\.\d+)?
00038     es. 1.1, 1.23.5, 1.2.3, 1.2.3, 1.11
00039         22.1.3, 0.1.234
00040 */
00041 struct Version
00042 {
00043     typedef unsigned int ver_type;
00044     Version();
00045     Version(const std::string&);
00046     Version(ver_type, ver_type, ver_type build = 0);
00047     void maj(ver_type);
00048     void min(ver_type);
00049     void build(ver_type);
00050     ver_type maj() const;
00051     ver_type min() const;
00052     ver_type build() const;
00053     
00054     void set(ver_type, ver_type, ver_type build = 0);
00055     void set(const std::string&);
00056     std::string str() const;
00057 
00058     bool operator==(const Version&) const;
00059     bool operator!=(const Version&) const;
00060     bool operator<(const Version&) const;
00061     bool operator>(const Version&) const;
00062     bool operator<=(const Version&) const;
00063     bool operator>=(const Version&) const;
00064     friend std::ostream& operator<<(std::ostream&, const Version&);
00065 protected:
00066     ver_type m_maj, m_min, m_build;
00067 };
00068 
00069 }
00070 
00071 #endif
00072