mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-30 17:59:21 +00:00
feat(General): replace L_VERSION macro by makeVersion constexpr func (better and safe)
This commit is contained in:
parent
2f39f845d5
commit
593c48faaf
3 changed files with 20 additions and 16 deletions
|
|
@ -75,10 +75,10 @@ LINPHONE_BEGIN_NAMESPACE
|
|||
// Debug.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void l_assert (const char *condition, const char *file, int line);
|
||||
void lAssert (const char *condition, const char *file, int line);
|
||||
|
||||
#ifdef DEBUG
|
||||
#define L_ASSERT(CONDITION) ((CONDITION) ? static_cast<void>(0) : LinphonePrivate::l_assert(#CONDITION, __FILE__, __LINE__))
|
||||
#define L_ASSERT(CONDITION) ((CONDITION) ? static_cast<void>(0) : LinphonePrivate::lAssert(#CONDITION, __FILE__, __LINE__))
|
||||
#else
|
||||
#define L_ASSERT(CONDITION) static_cast<void>(false && (CONDITION))
|
||||
#endif
|
||||
|
|
@ -100,7 +100,9 @@ void l_assert (const char *condition, const char *file, int line);
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
// Define an integer version like: 0xXXYYZZ, XX=MAJOR, YY=MINOR, and ZZ=PATCH.
|
||||
#define L_VERSION(MAJOR, MINOR, PATCH) (((MAJOR) << 16) | ((MINOR) << 8) | (PATCH))
|
||||
constexpr unsigned int makeVersion (unsigned int major, unsigned int minor, unsigned int patch) {
|
||||
return ((major << 16) | (minor << 8) | patch);
|
||||
}
|
||||
|
||||
// Not available in C++11...
|
||||
template<typename T, typename... Args>
|
||||
|
|
|
|||
|
|
@ -36,11 +36,6 @@
|
|||
#include "main-db-key-p.h"
|
||||
#include "main-db-p.h"
|
||||
|
||||
#define DB_MODULE_VERSION_EVENTS L_VERSION(1, 0, 1)
|
||||
#define DB_MODULE_VERSION_FRIENDS L_VERSION(1, 0, 0)
|
||||
#define DB_MODULE_VERSION_LEGACY_FRIENDS_IMPORT L_VERSION(1, 0, 0)
|
||||
#define DB_MODULE_VERSION_LEGACY_HISTORY_IMPORT L_VERSION(1, 0, 0)
|
||||
|
||||
// =============================================================================
|
||||
|
||||
// See: http://soci.sourceforge.net/doc/3.2/exchange.html
|
||||
|
|
@ -52,6 +47,13 @@ using namespace std;
|
|||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
namespace {
|
||||
constexpr unsigned int ModuleVersionEvents = makeVersion(1, 0, 1);
|
||||
constexpr unsigned int ModuleVersionFriends = makeVersion(1, 0, 0);
|
||||
constexpr unsigned int ModuleVersionLegacyFriendsImport = makeVersion(1, 0, 0);
|
||||
constexpr unsigned int ModuleVersionLegacyHistoryImport = makeVersion(1, 0, 0);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
MainDb::MainDb (const shared_ptr<Core> &core) : AbstractDb(*new MainDbPrivate), CoreAccessor(core) {}
|
||||
|
|
@ -1160,7 +1162,7 @@ void MainDbPrivate::updateSchema () {
|
|||
soci::session *session = dbSession.getBackendSession();
|
||||
unsigned int version = getModuleVersion("events");
|
||||
|
||||
if (version < L_VERSION(1, 0, 1)) {
|
||||
if (version < makeVersion(1, 0, 1)) {
|
||||
*session << "ALTER TABLE chat_room_participant_device ADD COLUMN state TINYINT UNSIGNED DEFAULT 0";
|
||||
}
|
||||
}
|
||||
|
|
@ -1216,9 +1218,9 @@ void MainDbPrivate::importLegacyFriends (DbSession &inDbSession) {
|
|||
soci::session *inSession = inDbSession.getBackendSession();
|
||||
soci::transaction tr(*dbSession.getBackendSession());
|
||||
|
||||
if (getModuleVersion("legacy-friends-import") >= L_VERSION(1, 0, 0))
|
||||
if (getModuleVersion("legacy-friends-import") >= makeVersion(1, 0, 0))
|
||||
return;
|
||||
updateModuleVersion("legacy-friends-import", DB_MODULE_VERSION_LEGACY_FRIENDS_IMPORT);
|
||||
updateModuleVersion("legacy-friends-import", ModuleVersionLegacyFriendsImport);
|
||||
|
||||
if (!checkLegacyFriendsTableExists(*inSession))
|
||||
return;
|
||||
|
|
@ -1311,9 +1313,9 @@ void MainDbPrivate::importLegacyHistory (DbSession &inDbSession) {
|
|||
soci::transaction tr(*dbSession.getBackendSession());
|
||||
|
||||
unsigned int version = getModuleVersion("legacy-history-import");
|
||||
if (version >= L_VERSION(1, 0, 0))
|
||||
if (version >= makeVersion(1, 0, 0))
|
||||
return;
|
||||
updateModuleVersion("legacy-history-import", DB_MODULE_VERSION_LEGACY_HISTORY_IMPORT);
|
||||
updateModuleVersion("legacy-history-import", ModuleVersionLegacyHistoryImport);
|
||||
|
||||
if (!checkLegacyHistoryTableExists(*inSession))
|
||||
return;
|
||||
|
|
@ -1786,8 +1788,8 @@ void MainDb::init () {
|
|||
|
||||
d->updateSchema();
|
||||
|
||||
d->updateModuleVersion("events", DB_MODULE_VERSION_EVENTS);
|
||||
d->updateModuleVersion("friends", DB_MODULE_VERSION_FRIENDS);
|
||||
d->updateModuleVersion("events", ModuleVersionEvents);
|
||||
d->updateModuleVersion("friends", ModuleVersionFriends);
|
||||
}
|
||||
|
||||
bool MainDb::addEvent (const shared_ptr<EventLog> &eventLog) {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
|
||||
LINPHONE_BEGIN_NAMESPACE
|
||||
|
||||
void l_assert (const char *condition, const char *file, int line) {
|
||||
void lAssert (const char *condition, const char *file, int line) {
|
||||
lFatal() << "ASSERT: " << condition << " in " << file << " line " << line << ".";
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue