STFishFinder API  API version 0.0.0, Documentation version 3 -PRELIMINARY-
STFF-Version.h
Go to the documentation of this file.
1 ///
2 /// @file STFF-Version.h
3 ///
4 /// Header file for the STFF::Version class; also contains version macros
5 /// for the entire STFishFinder API.
6 ///
7 /// @copyright
8 /// Copyright (c) 2012-2015 Sifferman Technology, LLC. All rights reserved.
9 ///
10 
11 #ifndef STFF_Version_h_
12 #define STFF_Version_h_
13 
14 #include <cstdint>
15 
16 
17 ////////////////////////////////////////////////////////////////////////////
18 //
19 // STFishFinder API Version Macros
20 //
21 ////////////////////////////////////////////////////////////////////////////
22 
23 // The current version info for the STFishFinder API is defined here:
24 
25 #define API_VERSION_MAJOR 0
26 #define API_VERSION_MINOR 1
27 #define API_VERSION_PATCH 0
28 #define API_VERSION_PRERELEASE_STRING ""
29 #define API_VERSION_BUILD_METADATA_STRING ""
30 
31 
32 
33 ////////////////////////////////////////////////////////////////////////////
34 //
35 // STFF::Version class declaration
36 //
37 ////////////////////////////////////////////////////////////////////////////
38 
39 namespace STFF {
40 
41  ////////////////////////////////////////////////////////////////////////////
42  /// @class Version
43  /// The %Version class provides software version information.
44  ///
45  /// In the STFishFinder API, instances of the Version class are used to
46  /// provide version information for the API itself, and for the bootloader
47  /// and firmware in a connected black box fish finder.
48  ///
49  /// The version data in this class attempts to conform to the
50  /// Semantic Versioning Specification v2.0.0; see www.semver.org for an
51  /// explanation of how to interpret the meaning of a version number
52  /// change.
53  ///
54  /// @see STFishFinder::GetApiVersion()
55  /// @see STFishFinder::GetFirmwareVersion()
56  /// @see STFishFinder::GetBootloaderVersion()
57  ///
58  class Version {
59 
60  public:
61 
62  /// @var MaxStringLength
63  ///
64  /// Maximum size of character strings, including the terminating '\\0',
65  /// provided by certain Version getter member functions.
66  /// In the unlikely event a string were to exceed this length, it will
67  /// be truncated to this length by the getter function before storing
68  /// to the caller's buffer.
69  ///
70  static const uint16_t MaxStringLength = 256;
71 
72 
73  /// @fn GetMajor
74  ///
75  /// Provides the major version number, e.g., 1 for "1.2.3".
76  ///
77  /// @returns the major version number
78  ///
79  uint32_t GetMajor () const;
80 
81 
82  /// @fn GetMinor
83  ///
84  /// Provides the minor version number, e.g., 2 for "1.2.3".
85  ///
86  /// @returns the minor version number
87  ///
88  uint32_t GetMinor () const;
89 
90 
91  /// @fn GetPatch
92  ///
93  /// Provides the patch version number, e.g., 3 for "1.2.3".
94  ///
95  /// @returns the patch version number
96  ///
97  uint32_t GetPatch () const;
98 
99 
100  /// @fn GetPreReleaseString
101  ///
102  /// Provides the pre-release string component of the version.
103  ///
104  /// @param[out] pPreReleaseString
105  /// Pointer to buffer into which this function will store
106  /// a null-terminated C-style string containing the
107  /// pre-release component of the version.
108  /// The number of characters written, including the
109  /// terminating '\\0', will never exceed the value of
110  /// Version::MaxStringLength.
111  /// If this parameter is a null pointer,
112  /// then nothing will be written to the buffer.
113  ///
114  /// @param[out] pLength
115  /// Pointer to location into which this function will
116  /// store the number of characters in the string.
117  /// The value stored does not account for the terminating
118  /// '\\0'.
119  /// If this parameter is a null pointer, then no value
120  /// will be stored.
121  ///
122  /// @returns void
123  ///
124  /// @note The provided string does not include the hyphen ("-")
125  /// prefix to the pre-release string.
126  ///
127  /// @see MaxStringLength
128  ///
129  void GetPreReleaseString (char *pPreReleaseString, uint16_t *pLength) const;
130 
131 
132  /// @fn GetBuildMetadataString
133  ///
134  /// Provides the build metadata component of the version.
135  ///
136  /// @param[out] pBuildMetadata
137  /// Pointer to buffer into which this function will store
138  /// a null-terminated C-style string containing the
139  /// build metadata component of the version.
140  /// The number of characters written, including the
141  /// terminating '\\0', will never exceed the value of
142  /// Version::MaxStringLength.
143  /// If the @p pBuildMetadata parameter is a null pointer,
144  /// then nothing will be written to the buffer.
145  ///
146  /// @param[out] pLength
147  /// Pointer to location into which this function will
148  /// store the number of characters in the string.
149  /// The value stored does not account for the terminating
150  /// '\\0'.
151  /// If this parameter is a null pointer, then no value
152  /// will be stored.
153  ///
154  /// @returns void
155  ///
156  /// @note The returned string does not include the ("+")
157  /// prefix to the build metadata string.
158  ///
159  /// @see MaxStringLength
160  ///
161  void GetBuildMetadataString (char *pBuildMetadata, uint16_t *pLength) const;
162 
163 
164  /// @fn GetVersionString
165  ///
166  /// Provides the full version number as a string,
167  /// e.g., "1.2.3-prerelease+buildmetadata".
168  ///
169  /// @param[out] pVersion
170  /// Pointer to buffer into which this function will store
171  /// a null-terminated C-style string containing the
172  /// entire version string.
173  /// The number of characters written, including the
174  /// terminating '\\0', will never exceed the value of
175  /// Version::MaxStringLength.
176  /// If the @p pVersion parameter is a null pointer,
177  /// then nothing will be written to the buffer.
178  ///
179  /// @param[out] pLength
180  /// Pointer to location into which this function will
181  /// store the number of characters in the string.
182  /// The value stored does not account for the terminating
183  /// '\\0'.
184  /// If this parameter is a null pointer, then no value
185  /// will be stored.
186  ///
187  /// @returns void
188  ///
189  /// @see MaxStringLength
190  ///
191  void GetVersionString (char *pVersion, uint16_t *pLength) const;
192 
193 
194  /// @fn IsAtLeast (const Version *) const
195  ///
196  /// Compares a provided version against the actual version.
197  /// Returns true if the actual version is greater than or equal to
198  /// the provided version.
199  ///
200  /// @param[in] pCompareVersion
201  /// pointer to Version object containing the version
202  /// to be compared against
203  ///
204  /// @retval true
205  /// if the current API version >= *pCompareVersion.
206  ///
207  /// @retval false otherwise
208  ///
209  /// @note The precedence rules for the comparison operation
210  /// follow the conventions of Semantic Versioning v2.0.0,
211  /// described at www.semver.org.
212  ///
213  /// @note The build metadata field is not considered when
214  /// comparing precedence between versions.
215  ///
216  bool IsAtLeast (const Version *pCompareVersion) const;
217 
218 
219  /// @fn IsAtLeast (uint32_t, uint32_t, uint32_t, const char*) const
220  ///
221  /// Compares a provided version against the actual version.
222  /// Returns true if the actual version is greater than or equal to
223  /// the provided version.
224  ///
225  /// @param[in] major
226  /// the major version number to be compared,
227  /// e.g., 1 for "1.2.3"
228  ///
229  /// @param[in] minor
230  /// the minor version number to be compared,
231  /// e.g., 2 for "1.2.3"
232  ///
233  /// @param[in] patch
234  /// the patch version number to be compared,
235  /// e.g., 3 for "1.2.3"
236  ///
237  /// @param[in] pPreRelease
238  /// pointer to a buffer containing a null-terminated
239  /// C-style string representing the pre-release version
240  /// field to be compared.
241  /// If this parameter is null, then the pre-release string
242  /// is regarded as an empty string.
243  ///
244  /// @retval true
245  /// if the current API version >= (major.minor.patch-prerelease_version).
246  ///
247  /// @retval false otherwise
248  ///
249  /// @note The precedence rules for the comparison operation
250  /// follow the conventions of Semantic Versioning v2.0.0,
251  /// described at www.semver.org.
252  ///
253  /// @note The build metadata field is not considered when
254  /// comparing precedence between versions.
255  ///
256  bool IsAtLeast (uint32_t major,
257  uint32_t minor,
258  uint32_t patch,
259  const char* pPreRelease = 0) const;
260 
261 
262 #if 0
263  /// @fn GetCopyrightMessage
264  ///
265  /// Provides the Copyright Message for the associated software.
266  ///
267  /// @param[out] pCopyrightMessage
268  /// Pointer to buffer into which this function will store
269  /// a null-terminated C-style string containing the
270  /// copyright string.
271  /// To prevent the possibility of a buffer overrun,
272  /// ensure the provided buffer is at least
273  /// MaxCopyrightStringLength bytes long.
274  /// If the @p pCopyrightMessage parameter is a null pointer,
275  /// then nothing will be written to the buffer.
276  ///
277  /// @returns void
278  ///
279  void GetCopyrightMessage (char *pCopyrightMessage) const;
280 
281 
282  /// @var MaxCopyrightStringLength
283  ///
284  /// Static const var that contains the maximum possible length
285  /// of the character string provided by function
286  /// GetCopyrightMessage(), including the terminating \\0.
287  /// This value can be used to statically allocate a buffer that is
288  /// large enough to contain any string that might be provided by
289  /// GetCopyrightMessage().
290  ///
291  /// Example:
292  /// @code
293  /// char copyright [MaxCopyrightStringLength];
294  /// GetCopyrightMessage (copyright);
295  /// @endcode
296  ///
297  /// @see GetCopyrightMessage()
298  ///
299  static constexpr uint32_t MaxCopyrightStringLength;
300 #endif
301 
302 
303  /// @fn Version (uint32_t, uint32_t, uint32_t, const char*, uint32_t, const char*, uint32_t)
304  ///
305  /// Constructor for the Version class.
306  ///
307  /// @param[in] major
308  /// the major version number,
309  /// e.g., 1 for "1.2.3"
310  ///
311  /// @param[in] minor
312  /// the minor version number,
313  /// e.g., 2 for "1.2.3"
314  ///
315  /// @param[in] patch
316  /// the patch version number,
317  /// e.g., 3 for "1.2.3"
318  ///
319  /// @param[in] preReleaseString
320  /// pointer to a buffer containing a C-style string
321  /// representing the pre-release field of
322  /// the version.
323  /// If this parameter is null, then the pre-release string
324  /// is regarded as an empty string.
325  ///
326  /// @param[in] preReleaseLength
327  /// number of characters in @p preReleaseString.
328  ///
329  /// @param[in] buildMetadataString
330  /// pointer to a buffer containing a C-style string
331  /// representing the build metadata field of
332  /// the version.
333  /// If this parameter is null, then the pre-release string
334  /// is regarded as an empty string.
335  ///
336  /// @param[in] buildMetadataLength
337  /// number of characters in @p buildMetadataString.
338  ///
339  /// @returns N/A
340  ///
341  /// @see ~Version ()
342  ///
343  Version (uint32_t major,
344  uint32_t minor,
345  uint32_t patch,
346  const char *preReleaseString,
347  uint32_t preReleaseLength,
348  const char *buildMetadataString,
349  uint32_t buildMetadataLength);
350 
351 
352  /// @fn Version (const Version &)
353  ///
354  /// Copy constructor for the Version class.
355  ///
356  Version (const Version &);
357 
358 
359  /// @fn Version &operator= (const Version &)
360  ///
361  /// Assignment operator for the Version class.
362  ///
363  Version &operator= (const Version &);
364 
365 
366  /// @fn ~Version ()
367  ///
368  /// Destructor for the Version class.
369  ///
370  /// @see Version (uint32_t, uint32_t, uint32_t, const char*, uint32_t, const char*, uint32_t)
371  ///
372  ~Version ();
373 
374 
375  private:
376 
377  friend class STFishFinder;
378 
379  // Default ctor is inaccessible
380  Version ();
381 
382  class impl;
383  impl *m_pimpl;
384 
385  }; // class Version
386 
387 } // namespace STFF
388 
389 #endif // defined (STFF_Version_h_)
Version & operator=(const Version &)
Assignment operator for the Version class.
uint32_t GetPatch() const
Provides the patch version number, e.g., 3 for "1.2.3".
The Version class provides software version information.
Definition: STFF-Version.h:58
void GetBuildMetadataString(char *pBuildMetadata, uint16_t *pLength) const
Provides the build metadata component of the version.
bool IsAtLeast(const Version *pCompareVersion) const
Compares a provided version against the actual version.
uint32_t GetMinor() const
Provides the minor version number, e.g., 2 for "1.2.3".
void GetVersionString(char *pVersion, uint16_t *pLength) const
Provides the full version number as a string, e.g., "1.2.3-prerelease+buildmetadata".
This is the namespace containing the platform-independent STFishFinder API.
This is the main class for the STFishFinder API.
~Version()
Destructor for the Version class.
static const uint16_t MaxStringLength
Maximum size of character strings, including the terminating '\0', provided by certain Version getter...
Definition: STFF-Version.h:70
uint32_t GetMajor() const
Provides the major version number, e.g., 1 for "1.2.3".
void GetPreReleaseString(char *pPreReleaseString, uint16_t *pLength) const
Provides the pre-release string component of the version.