Minor cleanup, reducing includes

This commit is contained in:
emeric
2025-03-27 17:26:51 +01:00
parent 6681f8b753
commit 6ba6034d87
14 changed files with 1012 additions and 858 deletions
+1
View File
@@ -5,6 +5,7 @@ add_library(lmsdatabase STATIC
impl/Cluster.cpp
impl/Db.cpp
impl/Directory.cpp
impl/IdType.cpp
impl/Image.cpp
impl/Listen.cpp
impl/MediaLibrary.cpp
+52
View File
@@ -0,0 +1,52 @@
/*
* Copyright (C) 2021 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#include "database/IdType.hpp"
#include <cassert>
#include <type_traits>
#include <Wt/Dbo/ptr.h>
namespace lms::db
{
static_assert(std::is_same_v<IdType::ValueType, Wt::Dbo::dbo_default_traits::IdType>);
IdType::IdType()
: _id{ Wt::Dbo::dbo_default_traits::invalidId() }
{
}
IdType::IdType(ValueType id)
: _id{ id }
{
}
bool IdType::isValid() const
{
return _id != Wt::Dbo::dbo_default_traits::invalidId();
}
std::string IdType::toString() const
{
assert(isValid());
return std::to_string(_id);
}
} // namespace lms::db
+6 -14
View File
@@ -19,9 +19,6 @@
#pragma once
#include <Wt/Dbo/ptr.h>
#include <cassert>
#include <functional>
#include <string>
namespace lms::db
@@ -29,24 +26,19 @@ namespace lms::db
class IdType
{
public:
using ValueType = Wt::Dbo::dbo_default_traits::IdType;
using ValueType = long long;
IdType() = default;
IdType(ValueType id)
: _id{ id } {}
IdType();
IdType(ValueType id);
bool isValid() const { return _id != Wt::Dbo::dbo_default_traits::invalidId(); }
std::string toString() const
{
assert(isValid());
return std::to_string(_id);
}
bool isValid() const;
std::string toString() const;
ValueType getValue() const { return _id; }
auto operator<=>(const IdType& other) const = default;
private:
Wt::Dbo::dbo_default_traits::IdType _id{ Wt::Dbo::dbo_default_traits::invalidId() };
ValueType _id;
};
#define LMS_DECLARE_IDTYPE(name) \