X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=libs%2Fversionlib.h;h=75704cf15d13ab97b8b50baef4766d045c67316e;hb=fba3b3fa800b29f40276b14aa995810df86148db;hp=368e5de62e0b7789f8d696284a9adc39fad84bb6;hpb=12b372f89ce109a4db9d510884fbe7d05af79870;p=xonotic%2Fnetradiant.git diff --git a/libs/versionlib.h b/libs/versionlib.h index 368e5de6..75704cf1 100644 --- a/libs/versionlib.h +++ b/libs/versionlib.h @@ -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 @@ -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 -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