opennurbs_version_number.h
1 /* $NoKeywords: $ */
2 /*
3 //
4 // Copyright (c) 1993-2013 Robert McNeel & Associates. All rights reserved.
5 // OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6 // McNeel & Associates.
7 //
8 // THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9 // ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10 // MERCHANTABILITY ARE HEREBY DISCLAIMED.
11 //
12 // For complete openNURBS copyright information see <http://www.opennurbs.org>.
13 //
14 ////////////////////////////////////////////////////////////////
15 */
16 
17 #if !defined(OPENNURBS_VERSION_NUMBER_INC_)
18 #define OPENNURBS_VERSION_NUMBER_INC_
19 
20 /*
21 Description:
22  Create a 4-byte unsigned integer value that has desireable version
23  number properties.
24 
25 Parameters:
26  major_version - [in]
27  major_version >= 0 and major_version <= 63
28 
29  minor_version - [in]
30  minor_version >= 0 and minor_version <= 127
31 
32  year - [in]
33  year >= 2000 and year <= 2099
34 
35  month - [in]
36  month >= 1 and month <= 12
37 
38  day_of_month - [in]
39  day_of_month >= 1 and day_of_month <= ON_DaysInMonthOfGregorianYear(year,month)
40 
41  branch - [in]
42  >= 0 and <= 3
43  0 = developer build
44  1 = build system trunk branch build
45  2 = build system release candidate branch build
46  3 = build system release build
47 
48 Returns:
49  If the input values are valid, this returns
50  a 4-byte nonzero version number with the following properties:
51  verA = ON_VersionNumberConstruct(majorA,minorA,<timeA>,branchA)
52  verB = ON_VersionNumberConstruct(majorB,minorB,<timeB>,branchB)
53  - If majorA > majorB, then verA > verB.
54  - If majorA = majorB and minorA > minorB, then verA > verB.
55  - If majorA = majorB and minorA = minorB and
56  timeA > timeB, then verA > verB.
57  - If majorA = majorB, minorA = minorB, timeA = timeB, and
58  branchA > branchB, then verA > verB.
59  If any input is not valid, then zero is returned.
60 */
61 ON_DECL
62 unsigned int ON_VersionNumberConstruct(
63  unsigned int major_version,
64  unsigned int minor_version,
65  unsigned int year,
66  unsigned int month,
67  unsigned int day_of_month,
68  unsigned int branch
69  );
70 
71 /*
72 Parameters:
73  major_version - [in]
74  major_version >= 0 and major_version <= 63
75 
76 Returns:
77  The smallest possible non-zero version number
78  ON_VersionNumberConstruct() will create
79  for a specified major version with valid input.
80 */
81 ON_DECL
82 unsigned int ON_VersionNumberMinimum(
83  unsigned int major_version
84  );
85 
86 /*
87 Returns:
88  True if the version_number is a value created by
89  ON_VersionNumberConstruct().
90 Parameters:
91  version_number - [in]
92 */
93 ON_DECL
94 bool ON_VersionNumberIsValid(
95  unsigned int version_number
96  );
97 
98 /*
99 Parameters:
100  archive_3dm_version - [in]
101  If the context of the query is a version number from
102  an ON_BinaryArchive, then pass the value
103  of ON_BinaryArchive.Archive3dmVersion() here.
104  version_number - [in]
105  version number to test.
106 Returns:
107  True if the version number is in the
108  YYYYMMDDn format used by version 1,2,3,4,5
109  of opennurbs and the Rhino SDK.
110 */
111 ON_DECL
112 bool ON_VersionNumberIsYearMonthDateFormat(
113  unsigned int archive_3dm_version,
114  unsigned int version_number
115  );
116 
117 /*
118 Parameters:
119  major_version - [in]
120  >= 0 and < 64
121 Returns:
122  The smallest possible non-zero version number
123  ON_VersionNumberConstruct() will create
124  for a specified major version with valid input.
125 */
126 ON_DECL
127 unsigned int ON_VersionNumberFromYearMonthDateFormat(
128  unsigned int major_version,
129  unsigned int yyyy_mm_dd_n_version_number
130  );
131 
132 /*
133 Description:
134  Parse a version number created by ON_VersionNumberConstruct() to
135  recover the input parameters.
136 Parameters:
137  version_number - [in]
138  A version number created with ON_VersionNumberConstruct().
139 
140  version_major - [out]
141  version_major >= 0 and version_major <= 63
142 
143  version_minor - [out]
144  version_minor >= 0 and version_minor <= 127
145 
146  version_year - [out]
147  version_year >= 2000 and version_year <= 2099
148 
149  version_month - [out]
150  version_month >= 1 and version_month <= 12
151 
152  version_day_of_month - [out]
153  version_day_of_month >= 1 and version_day_of_month <= ON_DaysInMonthOfGregorianYear(year,month)
154 
155  version_branch - [out]
156  version_branch >= 0 and version_branch <= 3
157  0: developer build
158  1: build system trunk branch build
159  2: build system release candidate build
160  3: build system release build
161 
162 Remarks:
163  Any output parameter pointer may be null if you do not want that
164  information.
165 
166 Returns:
167  true:
168  The version_number parameter is a valid version number.
169  All output parameters are set.
170  false:
171  The version_number parameter is not a valid version number.
172  All output parameters are set to zero.
173 */
174 ON_DECL
175 bool ON_VersionNumberParse(
176  unsigned int version_number,
177  unsigned int* version_major,
178  unsigned int* version_minor,
179  unsigned int* version_year,
180  unsigned int* version_month,
181  unsigned int* version_day_of_month,
182  unsigned int* version_branch
183  );
184 
185 ON_DECL
186 const ON_String ON_VersionNumberToString(
187  unsigned int version_number,
188  bool bUnsignedFormat,
189  bool bDateFormat
190 );
191 
192 ON_DECL
193 const ON_wString ON_VersionNumberToWideString(
194  unsigned int version_number,
195  bool bUnsignedFormat,
196  bool bDateFormat
197 );
198 
199 ON_DECL
200 const ON_String ON_SdkVersionNumberToString(
201  unsigned int sdk_version_number,
202  unsigned int sdk_service_release_number
203 );
204 
205 ON_DECL
206 const ON_wString ON_SdkVersionNumberToWideString(
207  unsigned int sdk_version_number,
208  unsigned int sdk_service_release_number
209 );
210 
211 /*
212 Parameters:
213  major_version - [in]
214  major_version >= 0 and major_version <= 63
215 
216  minor_version - [in]
217  minor_version >= 0 and minor_version <= 127
218 
219  year - [in]
220  year >= 2000 and year <= 2099
221 
222  month - [in]
223  month >= 1 and month <= 12
224 
225  day_of_month - [in]
226  day_of_month >= 1 and day_of_month <= ON_DaysInMonthOfGregorianYear(year,month)
227 
228  hour - [in]
229  hour >= 0 and hour <= 23
230 
231  minute - [in]
232  minute >= 0 and minute <= 59
233 
234  branch - [in]
235  branch >= 0 and branch <= 3
236  0: developer build
237  1: build system trunk branch build
238  2: build system release candidate build
239  3: build system release build
240 
241  quartet_values - [out]
242  quartet_values[0] = major_version
243  quartet_values[1] = minor_version
244  quartet_values[2] = (year-2000)*1000 + ON_DayOfGregorianYear(year,month,day_of_month)
245  quartet_values[3] = hour*1000 + minute*100 + branch
246 
247 Returns:
248  0: failure because input is not valid
249  >0: value of ON_VersionNumberConstruct(major_version,minor_version,year,month,day_of_month,branch)
250 */
251 ON_DECL
252 unsigned int ON_GetVersionQuartet(
253  unsigned int major_version,
254  unsigned int minor_version,
255  unsigned int year,
256  unsigned int month,
257  unsigned int day_of_month,
258  unsigned int hour,
259  unsigned int minute,
260  unsigned int branch,
261  unsigned short quartet_values[4]
262  );
263 
264 /*
265 Description:
266  Get a null terminated string that describes the version information
267  as "major.,minor.yyddd.hhmmb".
268 Parameters:
269  major_version - [in]
270  major_version >= 0 and major_version <= 63
271 
272  minor_version - [in]
273  minor_version >= 0 and minor_version <= 127
274 
275  year - [in]
276  year >= 2000 and year <= 2099
277 
278  month - [in]
279  month >= 1 and month <= 12
280 
281  day_of_month - [in]
282  day_of_month >= 1 and day_of_month <= ON_DaysInMonthOfGregorianYear(year,month)
283 
284  hour - [in]
285  hour >= 0 and hour <= 23
286 
287  minute - [in]
288  minute >= 0 and minute <= 59
289 
290  branch - [in]
291  branch >= 0 and branch <= 3
292  0: developer build
293  1: build system trunk branch build
294  2: build system release candidate build
295  3: build system release build
296 
297  string_buffer_capacity - [in]
298  Number of available char elements in string_buffer[]
299 
300  string_buffer - [out]
301  If 0 == string_buffer_capacity or nullptr == string_buffer,
302  then the number of char elements in the version number as a string, not including a null terminator,
303  is returned and no changes are made to string_buffer.
304 
305  If string_buffer_capacity > 0 && nullptr != string_buffer,
306  then the version number as a string is returned in string_buffer.
307  All string_buffer[] elements after the version number string are set to zero.
308  (This is a safe and secure string function.)
309 Returns:
310  0: failure because input is not valid
311  >0: The number of char elements, not including a null terminator, in the version number as a string.
312 */
313 ON_DECL
314 unsigned int ON_GetVersionString(
315  unsigned int major_version,
316  unsigned int minor_version,
317  unsigned int year,
318  unsigned int month,
319  unsigned int day_of_month,
320  unsigned int hour,
321  unsigned int minute,
322  unsigned int branch,
323  size_t string_buffer_capacity,
324  char* string_buffer
325  );
326 
327 /*
328 Description:
329  Get a null terminated wide character string that describes the version information
330  as "major.minor.yyddd.hhmmb".
331 Parameters:
332  major_version - [in]
333  major_version >= 0 and major_version <= 63
334 
335  minor_version - [in]
336  minor_version >= 0 and minor_version <= 127
337 
338  year - [in]
339  year >= 2000 and year <= 2099
340 
341  month - [in]
342  month >= 1 and month <= 12
343 
344  day_of_month - [in]
345  day_of_month >= 1 and day_of_month <= ON_DaysInMonthOfGregorianYear(year,month)
346 
347  hour - [in]
348  hour >= 0 and hour <= 23
349 
350  minute - [in]
351  minute >= 0 and minute <= 59
352 
353  branch - [in]
354  branch >= 0 and branch <= 3
355  0: developer build
356  1: build system trunk branch build
357  2: build system release candidate build
358  3: build system release build
359 
360  string_buffer_capacity - [in]
361  Number of available char elements in string_buffer[]
362 
363  string_buffer - [out]
364  If 0 == string_buffer_capacity or nullptr == string_buffer,
365  then the number of wchar_t elements in the version number as a string, not including a null terminator,
366  is returned and no changes are made to string_buffer.
367 
368  If string_buffer_capacity > 0 && nullptr != string_buffer,
369  then the version number as a string is returned in string_buffer.
370  All string_buffer[] elements after the version number string are set to zero.
371  (This is a safe and secure string function.)
372 Returns:
373  0: failure because input is not valid
374  >0: The number of char elements, not including a null terminator, in the version number as a string.
375 */
376 ON_DECL
377 unsigned int ON_GetVersionWideString(
378  unsigned int major_version,
379  unsigned int minor_version,
380  unsigned int year,
381  unsigned int month,
382  unsigned int day_of_month,
383  unsigned int hour,
384  unsigned int minute,
385  unsigned int branch,
386  size_t string_buffer_capacity,
387  wchar_t* string_buffer
388  );
389 
390 #endif
Definition: opennurbs_string.h:2020
Definition: opennurbs_string.h:852