SAGA API  v9.5
saga_api.cpp
Go to the documentation of this file.
1 
3 // //
4 // SAGA //
5 // //
6 // System for Automated Geoscientific Analyses //
7 // //
8 // Application Programming Interface //
9 // //
10 // Library: SAGA_API //
11 // //
12 //-------------------------------------------------------//
13 // //
14 // saga_api.cpp //
15 // //
16 // Copyright (C) 2005 by Olaf Conrad //
17 // //
18 //-------------------------------------------------------//
19 // //
20 // This file is part of 'SAGA - System for Automated //
21 // Geoscientific Analyses'. //
22 // //
23 // This library is free software; you can redistribute //
24 // it and/or modify it under the terms of the GNU Lesser //
25 // General Public License as published by the Free //
26 // Software Foundation, either version 2.1 of the //
27 // License, or (at your option) any later version. //
28 // //
29 // This library is distributed in the hope that it will //
30 // be useful, but WITHOUT ANY WARRANTY; without even the //
31 // implied warranty of MERCHANTABILITY or FITNESS FOR A //
32 // PARTICULAR PURPOSE. See the GNU Lesser General Public //
33 // License for more details. //
34 // //
35 // You should have received a copy of the GNU Lesser //
36 // General Public License along with this program; if //
37 // not, see <http://www.gnu.org/licenses/>. //
38 // //
39 //-------------------------------------------------------//
40 // //
41 // contact: Olaf Conrad //
42 // Institute of Geography //
43 // University of Goettingen //
44 // Goldschmidtstr. 5 //
45 // 37077 Goettingen //
46 // Germany //
47 // //
48 // e-mail: oconrad@saga-gis.org //
49 // //
51 
52 //---------------------------------------------------------
53 #include "saga_api.h"
54 
55 
57 // //
58 // //
59 // //
61 
62 //---------------------------------------------------------
64 {
65  return( SG_T("SAGA Application Programming Interface - Version: ") SAGA_VERSION );
66 }
67 
68 
70 // //
71 // //
72 // //
74 
75 //---------------------------------------------------------
81 //---------------------------------------------------------
82 int SG_Compare_Version (const CSG_String &Version, int Major, int Minor, int Release)
83 {
84  int v;
85 
86  if( !Version .asInt(v) ) return( -1 );
87  if( v < Major ) return( -1 );
88  if( v > Major ) return( 1 );
89 
90  if( !Version.AfterFirst('.').asInt(v) ) return( -1 );
91  if( v < Minor ) return( -1 );
92  if( v > Minor ) return( 1 );
93 
94  if( !Version.AfterLast ('.').asInt(v) ) return( -1 );
95  if( v < Release ) return( -1 );
96  if( v > Release ) return( 1 );
97 
98  return( 0 );
99 }
100 
101 //---------------------------------------------------------
107 //---------------------------------------------------------
108 int SG_Compare_Version (const CSG_String &Version, const CSG_String &Release)
109 {
110  int v[3];
111 
112  if( !Release .asInt(v[0]) ) return( -1 );
113  if( !Release.AfterFirst('.').asInt(v[1]) ) return( -1 );
114  if( !Release.AfterLast ('.').asInt(v[2]) ) return( -1 );
115 
116  return( SG_Compare_Version(Version, v[0], v[1], v[2]) );
117 }
118 
119 //---------------------------------------------------------
124 //---------------------------------------------------------
125 int SG_Compare_SAGA_Version(int Major, int Minor, int Release)
126 {
127  if( Major < SAGA_MAJOR_VERSION ) return( -1 );
128  if( Major > SAGA_MAJOR_VERSION ) return( 1 );
129 
130  if( Minor < SAGA_MINOR_VERSION ) return( -1 );
131  if( Minor > SAGA_MINOR_VERSION ) return( 1 );
132 
133  if( Release < SAGA_RELEASE_NUMBER ) return( -1 );
134  if( Release > SAGA_RELEASE_NUMBER ) return( 1 );
135 
136  return( 0 );
137 }
138 
139 //---------------------------------------------------------
145 //---------------------------------------------------------
147 {
148  int v[3];
149 
150  if( !Version .asInt(v[0]) ) return( -1 );
151  if( !Version.AfterFirst('.').asInt(v[1]) ) return( -1 );
152  if( !Version.AfterLast ('.').asInt(v[2]) ) return( -1 );
153 
154  return( SG_Compare_SAGA_Version(v[0], v[1], v[2]) );
155 }
156 
157 
159 // //
160 // //
161 // //
163 
164 //---------------------------------------------------------
SG_T
#define SG_T(s)
Definition: api_core.h:537
SAGA_VERSION
#define SAGA_VERSION
Definition: saga_api.h:90
CSG_String::asInt
int asInt(void) const
Definition: api_string.cpp:722
saga_api.h
SAGA_RELEASE_NUMBER
#define SAGA_RELEASE_NUMBER
Definition: saga_api.h:89
SAGA_MAJOR_VERSION
#define SAGA_MAJOR_VERSION
Definition: saga_api.h:87
SAGA_API_Get_Version
const SG_Char * SAGA_API_Get_Version(void)
Definition: saga_api.cpp:63
CSG_String::AfterFirst
CSG_String AfterFirst(char Character) const
Definition: api_string.cpp:644
SG_Char
#define SG_Char
Definition: api_core.h:536
SAGA_MINOR_VERSION
#define SAGA_MINOR_VERSION
Definition: saga_api.h:88
CSG_String
Definition: api_core.h:563
SG_Compare_Version
int SG_Compare_Version(const CSG_String &Version, int Major, int Minor, int Release)
Definition: saga_api.cpp:82
CSG_String::AfterLast
CSG_String AfterLast(char Character) const
Definition: api_string.cpp:655
SG_Compare_SAGA_Version
int SG_Compare_SAGA_Version(int Major, int Minor, int Release)
Definition: saga_api.cpp:125