125 lines
4.2 KiB
C++
Executable File
125 lines
4.2 KiB
C++
Executable File
// Copyright Onix Solutions Limited [OnixS]. All rights reserved.
|
|
//
|
|
// This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
|
|
// and international copyright treaties.
|
|
//
|
|
// Access to and use of the software is governed by the terms of the applicable OnixS Software
|
|
// Services Agreement (the Agreement) and Customer end user license agreements granting
|
|
// a non-assignable, non-transferable and non-exclusive license to use the software
|
|
// for it's own data processing purposes under the terms defined in the Agreement.
|
|
//
|
|
// Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
|
|
// of this source code or associated reference material to any other location for further reproduction
|
|
// or redistribution, and any amendments to this copyright notice, are expressly prohibited.
|
|
//
|
|
// Any reproduction or redistribution for sale or hiring of the Software not in accordance with
|
|
// the terms of the Agreement is a violation of copyright law.
|
|
//
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#include "OnixS/CME/MDP3/Config.h"
|
|
|
|
namespace OnixS
|
|
{
|
|
namespace CME
|
|
{
|
|
namespace MDP3
|
|
{
|
|
/// Alias for the numeric component of version.
|
|
typedef unsigned short VersionComponent;
|
|
|
|
/// Identifies version of the product.
|
|
///
|
|
/// Provides access to single components which compound whole version,
|
|
/// comparing and serialization/deserialization facilities.
|
|
class
|
|
ONIXS_CME_MDP3_API
|
|
Version
|
|
{
|
|
public:
|
|
/// Initializes instances from all the components.
|
|
Version(
|
|
VersionComponent major,
|
|
VersionComponent minor,
|
|
VersionComponent improvement,
|
|
VersionComponent build);
|
|
|
|
/// Initializes as clone of other instance.
|
|
Version(const Version& other);
|
|
|
|
/// 'major' component of version.
|
|
VersionComponent major() const
|
|
{
|
|
return major_;
|
|
}
|
|
|
|
/// 'minor' component of version.
|
|
VersionComponent minor() const
|
|
{
|
|
return minor_;
|
|
}
|
|
|
|
/// 'improvement' component of version.
|
|
VersionComponent improvement() const
|
|
{
|
|
return improvement_;
|
|
}
|
|
|
|
/// 'build number' component of version.
|
|
VersionComponent build() const
|
|
{
|
|
return build_;
|
|
}
|
|
|
|
/// Compares with other instance for equality.
|
|
bool operator ==(const Version&) const;
|
|
|
|
/// Compares with other instance for inequality.
|
|
bool operator !=(const Version&) const;
|
|
|
|
/// Checks whether the version is less then the other.
|
|
bool operator <(const Version&) const;
|
|
|
|
/// Checks whether the version is grater then the other.
|
|
bool operator >(const Version&) const;
|
|
|
|
/// Re-initializes instance as copy of other one.
|
|
Version& operator =(const Version&);
|
|
|
|
/// Serializes into point-separated presentation.
|
|
void toString(std::string&) const;
|
|
|
|
/// Serializes into point-separated presentation.
|
|
std::string toString() const
|
|
{
|
|
std::string str;
|
|
toString(str);
|
|
return str;
|
|
}
|
|
|
|
/// Extracts version from point-separated presentation.
|
|
/// Updates version parameter if buffer is parsed successfully.
|
|
static
|
|
bool
|
|
parse(
|
|
const char*,
|
|
size_t,
|
|
Version&);
|
|
|
|
/// Identifies current version of the product.
|
|
static Version current();
|
|
|
|
private:
|
|
VersionComponent major_;
|
|
VersionComponent minor_;
|
|
VersionComponent improvement_;
|
|
VersionComponent build_;
|
|
};
|
|
|
|
}
|
|
}
|
|
}
|