2014-11-21 20:56:36 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// MuldeR's Utilities for Qt
|
2015-01-25 20:48:23 +01:00
|
|
|
// Copyright (C) 2004-2015 LoRd_MuldeR <MuldeR2@GMX.de>
|
2014-11-21 20:56:36 +01:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2.1 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
//
|
|
|
|
// http://www.gnu.org/licenses/lgpl-2.1.txt
|
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2014-12-20 23:47:06 +01:00
|
|
|
//MUtils
|
2014-11-21 20:56:36 +01:00
|
|
|
#include <MUtils/Version.h>
|
|
|
|
#include <MUtils/Global.h>
|
|
|
|
#include <MUtils/Exception.h>
|
2014-11-30 18:46:56 +01:00
|
|
|
#include <MUtils/OSSupport.h>
|
2014-12-20 23:47:06 +01:00
|
|
|
|
|
|
|
//Internal
|
|
|
|
#define MUTILS_INC_CONFIG 1
|
2014-11-25 22:32:20 +01:00
|
|
|
#include "Config.h"
|
2014-11-21 20:56:36 +01:00
|
|
|
|
2014-11-25 22:32:20 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// HELPER FUNCTIONS
|
2014-11-21 20:56:36 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
static const char *g_months_lut[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
|
|
|
|
2014-11-30 20:29:41 +01:00
|
|
|
static int month_str2int(const char *str)
|
2014-11-21 20:56:36 +01:00
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
for(int j = 0; j < 12; j++)
|
|
|
|
{
|
2014-12-03 22:21:53 +01:00
|
|
|
if(!_strnicmp(str, g_months_lut[j], 3))
|
2014-11-21 20:56:36 +01:00
|
|
|
{
|
|
|
|
ret = j+1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2014-11-30 20:29:41 +01:00
|
|
|
static const QDate decode_date_str(const char *const date_str) //Mmm dd yyyy
|
2014-11-21 20:56:36 +01:00
|
|
|
{
|
|
|
|
int date[3] = {0, 0, 0};
|
2014-11-30 20:29:41 +01:00
|
|
|
|
2014-12-03 22:21:53 +01:00
|
|
|
if(sscanf_s(date_str, "%*3s %2d %4d", &date[2], &date[0]) != 2)
|
|
|
|
{
|
|
|
|
MUTILS_THROW("Internal error: Date format could not be recognized!");
|
|
|
|
}
|
2014-11-24 19:35:32 +01:00
|
|
|
|
2014-12-03 22:21:53 +01:00
|
|
|
if((date[1] = month_str2int(date_str)) < 1)
|
2014-11-21 20:56:36 +01:00
|
|
|
{
|
|
|
|
MUTILS_THROW("Internal error: Date format could not be recognized!");
|
|
|
|
}
|
2014-12-03 22:21:53 +01:00
|
|
|
|
2014-11-25 02:17:11 +01:00
|
|
|
//qWarning("MUtils::Version::build_date: y=%d, m=%d, d=%d", date[0], date[1], date[2]);
|
2014-11-21 20:56:36 +01:00
|
|
|
return QDate(date[0], date[1], date[2]);
|
|
|
|
}
|
|
|
|
|
2014-11-30 20:29:41 +01:00
|
|
|
static const QTime decode_time_str(const char *const time_str) //hh:mm:ss
|
2014-11-24 19:35:32 +01:00
|
|
|
{
|
|
|
|
int time[3] = {0, 0, 0};
|
|
|
|
|
2014-12-03 22:21:53 +01:00
|
|
|
if(sscanf_s(time_str, "%2d:%2d:%2d", &time[0], &time[1], &time[2]) != 3)
|
2014-11-24 19:35:32 +01:00
|
|
|
{
|
|
|
|
MUTILS_THROW("Internal error: Time format could not be recognized!");
|
|
|
|
}
|
|
|
|
|
2014-11-25 02:17:11 +01:00
|
|
|
//qWarning("MUtils::Version::build_date: h=%d, m=%d, s=%d", time[0], time[1], time[2]);
|
2014-11-24 19:35:32 +01:00
|
|
|
return QTime(time[0], time[1], time[2]);
|
|
|
|
}
|
|
|
|
|
2014-11-21 20:56:36 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
2014-11-25 22:32:20 +01:00
|
|
|
// LIB VERSION
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
const QDate MUtils::Version::lib_build_date(void)
|
|
|
|
{
|
|
|
|
static const char *const BUILD_DATE = __DATE__;
|
|
|
|
return decode_date_str(BUILD_DATE);
|
|
|
|
}
|
|
|
|
|
|
|
|
const QTime MUtils::Version::lib_build_time(void)
|
|
|
|
{
|
|
|
|
static const char *const BUILD_TIME = __TIME__;
|
|
|
|
return decode_time_str(BUILD_TIME);
|
|
|
|
}
|
|
|
|
|
|
|
|
const quint32 &MUtils::Version::lib_version_major(void)
|
|
|
|
{
|
|
|
|
static const quint32 VERSION_MAJOR = VER_MUTILS_MAJOR;
|
|
|
|
return VERSION_MAJOR;
|
|
|
|
}
|
|
|
|
|
|
|
|
const quint32 &MUtils::Version::lib_version_minor(void)
|
|
|
|
{
|
|
|
|
static const quint32 VERSION_MINOR = (10 * VER_MUTILS_MINOR_HI) + VER_MUTILS_MINOR_LO;
|
|
|
|
return VERSION_MINOR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// APP VERSION
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
const QDate MUtils::Version::app_build_date(const char *const date_str)
|
|
|
|
{
|
|
|
|
return decode_date_str(date_str);
|
|
|
|
}
|
|
|
|
|
|
|
|
const QTime MUtils::Version::app_build_time(const char *const time_str)
|
|
|
|
{
|
|
|
|
return decode_time_str(time_str);
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|