]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - libs/versionlib.h
allow undo “make detail/structural”, <3 @SpiKe, thanks @Garux, fix #76
[xonotic/netradiant.git] / libs / versionlib.h
index 368e5de62e0b7789f8d696284a9adc39fad84bb6..75704cf15d13ab97b8b50baef4766d045c67316e 100644 (file)
@@ -1,25 +1,25 @@
 /*
-Copyright (C) 2001-2006, William Joseph.
-All Rights Reserved.
+   Copyright (C) 2001-2006, William Joseph.
+   All Rights Reserved.
 
-This file is part of GtkRadiant.
+   This file is part of GtkRadiant.
 
-GtkRadiant is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+   GtkRadiant is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
 
-GtkRadiant 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.
+   GtkRadiant 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 GtkRadiant; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-*/
+   You should have received a copy of the GNU General Public License
+   along with GtkRadiant; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
 
-#if !defined(INCLUDED_VERSIONLIB_H)
+#if !defined( INCLUDED_VERSIONLIB_H )
 #define INCLUDED_VERSIONLIB_H
 
 #include <cstddef>
@@ -29,63 +29,56 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 class Version
 {
 public:
-  int major;
-  int minor;
+int major;
+int minor;
 };
 
-inline bool operator<(const Version& version, const Version& other)
-{
-  return version.major < other.major || (!(other.major < version.major) && version.minor < other.minor);
+inline bool operator<( const Version& version, const Version& other ){
+       return version.major < other.major || ( !( other.major < version.major ) && version.minor < other.minor );
 }
 
 template<typename TextOutputStreamType>
-TextOutputStreamType& ostream_write(TextOutputStreamType& outputStream, const Version& version)
-{
-  return outputStream << version.major << '.' << version.minor;
+TextOutputStreamType& ostream_write( TextOutputStreamType& outputStream, const Version& version ){
+       return outputStream << version.major << '.' << version.minor;
 }
 
 /// \brief Returns true if \p version (code) is compatible with \p other (data).
-inline bool version_compatible(const Version& version, const Version& other)
-{
-  return version.major == other.major  // different major-versions are always incompatible
-    && !(version.minor < other.minor); // data minor-version is incompatible if greater than code minor-version
+inline bool version_compatible( const Version& version, const Version& other ){
+       return version.major == other.major // different major-versions are always incompatible
+                  && !( version.minor < other.minor ); // data minor-version is incompatible if greater than code minor-version
 }
 
-inline int string_range_parse_unsigned_decimal_integer(const char* first, const char* last)
-{
-  int result = 0;
-  for(; first != last; ++first)
-  {
-    result *= 10;
-    result += *first - '0';
-  }
-  return result;
+inline int string_range_parse_unsigned_decimal_integer( const char* first, const char* last ){
+       int result = 0;
+       for (; first != last; ++first )
+       {
+               result *= 10;
+               result += *first - '0';
+       }
+       return result;
 }
 
-inline Version version_parse(const char* versionString)
-{
-  Version version;
-  const char* endVersion = versionString + strlen(versionString);
-
-  const char* endMajor = strchr(versionString, '.');
-  if(endMajor == 0)
-  {
-    endMajor = endVersion;
-
-    version.minor = 0;
-  }
-  else
-  {
-    const char* endMinor = strchr(endMajor + 1, '.');
-    if(endMinor == 0)
-    {
-      endMinor = endVersion;
-    }
-    version.minor = string_range_parse_unsigned_decimal_integer(endMajor + 1, endMinor);
-  }
-  version.major = string_range_parse_unsigned_decimal_integer(versionString, endMajor);
-
-  return version;
+inline Version version_parse( const char* versionString ){
+       Version version;
+       const char* endVersion = versionString + strlen( versionString );
+
+       const char* endMajor = strchr( versionString, '.' );
+       if ( endMajor == 0 ) {
+               endMajor = endVersion;
+
+               version.minor = 0;
+       }
+       else
+       {
+               const char* endMinor = strchr( endMajor + 1, '.' );
+               if ( endMinor == 0 ) {
+                       endMinor = endVersion;
+               }
+               version.minor = string_range_parse_unsigned_decimal_integer( endMajor + 1, endMinor );
+       }
+       version.major = string_range_parse_unsigned_decimal_integer( versionString, endMajor );
+
+       return version;
 }
 
 #endif