From 20f428b540ef06ba710671d322aa1f145332fa39 Mon Sep 17 00:00:00 2001 From: deva Date: Fri, 24 Jul 2009 08:17:30 +0000 Subject: Added some more tests to the Version class. Documented the header file. --- server/src/versionstr.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'server/src/versionstr.h') diff --git a/server/src/versionstr.h b/server/src/versionstr.h index a840bd2..ceed42f 100644 --- a/server/src/versionstr.h +++ b/server/src/versionstr.h @@ -41,15 +41,60 @@ #undef patch #endif +/** + * VersionStr class. + * It hold a version number and is capable of correct sorting, as well as string + * conversion both ways. + */ class VersionStr { public: + /** + * Constructor. + * @param v A std::string containing a version string on the form a.b or a.b.c + */ VersionStr(std::string v); + + /** + * Constructor. + * @param major A size_t containing the major version number. + * @param minor A size_t containing the minor version number. + * @param patch A size_t containing the patch level. + */ + VersionStr(size_t major = 0, size_t minor = 0, size_t patch = 0); + + /** + * Typecast to std::string operator. + * It simply converts the version numbers into a string of the form major.minor + * (if patch i 0) or major.minor.patch + */ operator std::string() const; + + /** + * Assignment from std::string operator. + * Same as in the VersionStr(std::string v) constructor. + */ void operator=(std::string v); + + /** + * Comparison operator. + * The version objects are sorted according to their major, minor and patch + * level numbers. + */ bool operator<(const VersionStr &other) const; + /** + * @return Major version number. + */ size_t major() const; + + /** + * @return Minor version number. + */ size_t minor() const; + + /** + * @return Patch level. + */ size_t patch() const; private: -- cgit v1.2.3