1 /**********************************************************
2  * Version $Id$
3  *********************************************************/
4 
5 ///////////////////////////////////////////////////////////
6 //                                                       //
7 //                         SAGA                          //
8 //                                                       //
9 //      System for Automated Geoscientific Analyses      //
10 //                                                       //
11 //           Application Programming Interface           //
12 //                                                       //
13 //                  Library: SAGA_API                    //
14 //                                                       //
15 //-------------------------------------------------------//
16 //                                                       //
17 //                    saga_api.cpp                       //
18 //                                                       //
19 //          Copyright (C) 2005 by Olaf Conrad            //
20 //                                                       //
21 //-------------------------------------------------------//
22 //                                                       //
23 // This file is part of 'SAGA - System for Automated     //
24 // Geoscientific Analyses'.                              //
25 //                                                       //
26 // This library is free software; you can redistribute   //
27 // it and/or modify it under the terms of the GNU Lesser //
28 // General Public License as published by the Free       //
29 // Software Foundation, either version 2.1 of the        //
30 // License, or (at your option) any later version.       //
31 //                                                       //
32 // This library is distributed in the hope that it will  //
33 // be useful, but WITHOUT ANY WARRANTY; without even the //
34 // implied warranty of MERCHANTABILITY or FITNESS FOR A  //
35 // PARTICULAR PURPOSE. See the GNU Lesser General Public //
36 // License for more details.                             //
37 //                                                       //
38 // You should have received a copy of the GNU Lesser     //
39 // General Public License along with this program; if    //
40 // not, see <http://www.gnu.org/licenses/>.              //
41 //                                                       //
42 //-------------------------------------------------------//
43 //                                                       //
44 //    contact:    Olaf Conrad                            //
45 //                Institute of Geography                 //
46 //                University of Goettingen               //
47 //                Goldschmidtstr. 5                      //
48 //                37077 Goettingen                       //
49 //                Germany                                //
50 //                                                       //
51 //    e-mail:     oconrad@saga-gis.org                   //
52 //                                                       //
53 ///////////////////////////////////////////////////////////
54 
55 //---------------------------------------------------------
56 
57 
58 ///////////////////////////////////////////////////////////
59 //														 //
60 //														 //
61 //														 //
62 ///////////////////////////////////////////////////////////
63 
64 //---------------------------------------------------------
65 #include "saga_api.h"
66 
67 
68 ///////////////////////////////////////////////////////////
69 //														 //
70 //														 //
71 //														 //
72 ///////////////////////////////////////////////////////////
73 
74 //---------------------------------------------------------
SAGA_API_Get_Version(void)75 const SG_Char *	SAGA_API_Get_Version(void)
76 {
77 	return( SG_T("SAGA Application Programming Interface - Version: ") SAGA_VERSION );
78 }
79 
80 
81 ///////////////////////////////////////////////////////////
82 //														 //
83 //														 //
84 //														 //
85 ///////////////////////////////////////////////////////////
86 
87 //---------------------------------------------------------
88 /**
89   * Compares two versions numbers.
90   * Returns -1 if it is less, 1 if it is greater or 0 if it is equal.
91   * Version string is assumed to have the form 'Major.Minor.Release'.
92 */
93 //---------------------------------------------------------
SG_Compare_Version(const CSG_String & Version,int Major,int Minor,int Release)94 int	SG_Compare_Version	(const CSG_String &Version, int Major, int Minor, int Release)
95 {
96 	int		v;
97 
98 	if( !Version                .asInt(v) )	return( -1 );
99 	if( v < Major   )	return( -1 );
100 	if( v > Major   )	return(  1 );
101 
102 	if( !Version.AfterFirst('.').asInt(v) )	return( -1 );
103 	if( v < Minor   )	return( -1 );
104 	if( v > Minor   )	return(  1 );
105 
106 	if( !Version.AfterLast ('.').asInt(v) )	return( -1 );
107 	if( v < Release )	return( -1 );
108 	if( v > Release )	return(  1 );
109 
110 	return( 0 );
111 }
112 
113 //---------------------------------------------------------
114 /**
115   * Compares two versions numbers.
116   * Returns -1 if it is less, 1 if it is greater or 0 if it is equal.
117   * Version strings are assumed to have the form 'Major.Minor.Release'.
118 */
119 //---------------------------------------------------------
SG_Compare_Version(const CSG_String & Version,const CSG_String & Release)120 int	SG_Compare_Version	(const CSG_String &Version, const CSG_String &Release)
121 {
122 	int	v[3];
123 
124 	if( !Release                .asInt(v[0]) )	return( -1 );
125 	if( !Release.AfterFirst('.').asInt(v[1]) )	return( -1 );
126 	if( !Release.AfterLast ('.').asInt(v[2]) )	return( -1 );
127 
128 	return( SG_Compare_Version(Version, v[0], v[1], v[2]) );
129 }
130 
131 //---------------------------------------------------------
132 /**
133   * Compares to current SAGA version and returns -1 if it is
134   * less, 1 if it is greater or 0 if it is equal.
135 */
136 //---------------------------------------------------------
SG_Compare_SAGA_Version(int Major,int Minor,int Release)137 int SG_Compare_SAGA_Version(int Major, int Minor, int Release)
138 {
139 	if( Major   < SAGA_MAJOR_VERSION  )	return( -1 );
140 	if( Major   > SAGA_MAJOR_VERSION  )	return(  1 );
141 
142 	if( Minor   < SAGA_MINOR_VERSION  )	return( -1 );
143 	if( Minor   > SAGA_MINOR_VERSION  )	return(  1 );
144 
145 	if( Release < SAGA_RELEASE_NUMBER )	return( -1 );
146 	if( Release > SAGA_RELEASE_NUMBER )	return(  1 );
147 
148 	return( 0 );
149 }
150 
151 //---------------------------------------------------------
152 /**
153   * Compares to current SAGA version and returns -1 if it is
154   * less, 1 if it is greater or 0 if it is equal.
155   * Version string is assumed to have the form 'Major.Minor.Release'.
156 */
157 //---------------------------------------------------------
SG_Compare_SAGA_Version(const CSG_String & Version)158 int SG_Compare_SAGA_Version(const CSG_String &Version)
159 {
160 	int	v[3];
161 
162 	if( !Version                .asInt(v[0]) )	return( -1 );
163 	if( !Version.AfterFirst('.').asInt(v[1]) )	return( -1 );
164 	if( !Version.AfterLast ('.').asInt(v[2]) )	return( -1 );
165 
166 	return( SG_Compare_SAGA_Version(v[0], v[1], v[2]) );
167 }
168 
169 
170 ///////////////////////////////////////////////////////////
171 //														 //
172 //														 //
173 //														 //
174 ///////////////////////////////////////////////////////////
175 
176 //---------------------------------------------------------
177