x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
Version.cpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\OgreMaxScene\Version.cpp
旋转
特效
属性
历史版本
/* * OgreMaxViewer - An Ogre 3D-based viewer for .scene and .mesh files * Copyright 2008 Derek Nedelman * * This code is available under the OgreMax Free License: * -You may use this code for any purpose, commercial or non-commercial. * -If distributing derived works (that use this source code) in binary or source code form, * you must give the following credit in your work's end-user documentation: * "Portions of this work provided by OgreMax (www.ogremax.com)" * * Derek Nedelman assumes no responsibility for any harm caused by using this code. * * OgreMaxViewer was written by Derek Nedelman and released at www.ogremax.com */ //Includes--------------------------------------------------------------------- #include "Version.hpp" #include
using namespace Ogre; using namespace OgreMax; //Implementation--------------------------------------------------------------- Version::Version() { for (int index = 0; index < MAX_COMPONENTS; index++) this->components[index] = 0; } Version::Version(int major, int minor, int patch) { this->components[MAJOR] = major; this->components[MINOR] = minor; this->components[PATCH] = patch; } Version::Version(const String& version) { size_t length = version.length(); size_t offset = 0; size_t foundAt; String component; int index = 0; while (index < MAX_COMPONENTS && offset < length) { //Extract the current component foundAt = version.find('.', offset); component = version.substr(offset); this->components[index++] = StringConverter::parseInt(component); //Break out if there is no next '.' if (foundAt == String::npos) break; //Move past the next '.' offset = foundAt + 1; } for (; index < MAX_COMPONENTS; index++) this->components[index] = 0; } int Version::GetMajor() const { return this->components[MAJOR]; } int Version::GetMinor() const { return this->components[MINOR]; } int Version::GetPatch() const { return this->components[PATCH]; } void Version::ToString(String& text) const { StringUtil::StrStreamType versionText; //Find the last non-zero component int lastNonzeroComponent = -1; for (int index = MAX_COMPONENTS - 1; index >= 0; index--) { if (this->components[index] != 0) { lastNonzeroComponent = index; break; } } //Output everything up to the last non-zero component if (lastNonzeroComponent >= 0) { for (int index = 0; index <= lastNonzeroComponent; index++) { versionText << this->components[index]; if (index < lastNonzeroComponent) versionText << "."; } } else { //All components are zero versionText << "0"; } text = versionText.str(); } String Version::ToString() const { String text; ToString(text); return text; } int Version::ToInt() const { int version = 0; int multiplier = 1; for (int index = 0; index < MAX_COMPONENTS; index++) { version += this->components[index] * multiplier; multiplier *= 100; } return version; } int Version::Compare(const Version& version1, const Version& version2) { return version1.ToInt() - version2.ToInt(); }
Version.cpp
网页地址
文件地址
上一页
10/10 下一页
下载
( 3 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.