20 #ifndef LIBREPCB_CORE_WORKSPACELIBRARYDBWRITER_H 21 #define LIBREPCB_CORE_WORKSPACELIBRARYDBWRITER_H 26 #include "../fileio/filepath.h" 27 #include "../types/elementname.h" 29 #include <optional/tl/optional.hpp> 39 class ComponentCategory;
42 class PackageCategory;
91 bool deprecated,
const QByteArray& iconPng);
103 const Version& version,
bool deprecated,
104 const QByteArray& iconPng);
117 template <
typename ElementType>
119 const Version& version,
bool deprecated) {
120 static_assert(std::is_same<ElementType, Symbol>::value ||
121 std::is_same<ElementType, Package>::value ||
122 std::is_same<ElementType, Component>::value,
123 "Unsupported ElementType");
124 return addElement(getElementTable<ElementType>(), libId, fp, uuid, version,
140 template <
typename ElementType>
142 const Version& version,
bool deprecated,
143 const tl::optional<Uuid>& parent) {
144 static_assert(std::is_same<ElementType, ComponentCategory>::value ||
145 std::is_same<ElementType, PackageCategory>::value,
146 "Unsupported ElementType");
147 return addCategory(getElementTable<ElementType>(), libId, fp, uuid, version,
164 const Version& version,
bool deprecated,
const Uuid& component,
165 const Uuid& package);
176 template <
typename ElementType>
189 template <
typename ElementType>
205 template <
typename ElementType>
207 const tl::optional<ElementName>& name,
208 const tl::optional<QString>& description,
209 const tl::optional<QString>& keywords) {
210 return addTranslation(getElementTable<ElementType>(), elementId, locale,
211 name, description, keywords);
219 template <
typename ElementType>
232 template <
typename ElementType>
234 static_assert(std::is_same<ElementType, Symbol>::value ||
235 std::is_same<ElementType, Package>::value ||
236 std::is_same<ElementType, Component>::value ||
237 std::is_same<ElementType, Device>::value,
238 "Unsupported ElementType");
239 return addToCategory(getElementTable<ElementType>(), elementId, category);
250 template <
typename ElementType>
260 template <
typename ElementType>
269 const Uuid& uuid,
const Version& version,
bool deprecated);
271 const Uuid& uuid,
const Version& version,
bool deprecated,
272 const tl::optional<Uuid>& parent);
276 const QString& locale,
277 const tl::optional<ElementName>& name,
278 const tl::optional<QString>& description,
279 const tl::optional<QString>& keywords);
281 int addToCategory(
const QString& elementsTable,
int elementId,
282 const Uuid& category);
The Version class represents a version number in the format "1.42.7".
Definition: version.h:58
int addCategory(int libId, const FilePath &fp, const Uuid &uuid, const Version &version, bool deprecated, const tl::optional< Uuid > &parent)
addElement() specialized for categories
Definition: workspacelibrarydbwriter.h:141
SQLiteDatabase & mDb
Definition: workspacelibrarydbwriter.h:287
void updateLibrary(const FilePath &fp, const Uuid &uuid, const Version &version, bool deprecated, const QByteArray &iconPng)
Update library metadata.
Definition: workspacelibrarydbwriter.cpp:296
void removeAllTranslations()
Remove all translations for a library element type.
Definition: workspacelibrarydbwriter.h:220
int addDevice(int libId, const FilePath &fp, const Uuid &uuid, const Version &version, bool deprecated, const Uuid &component, const Uuid &package)
addElement() specialized for devices
Definition: workspacelibrarydbwriter.cpp:314
Definition: occmodel.cpp:76
static QString getCategoryTable() noexcept
Get the category table name of an element type.
Database write functions for librepcb::WorkspaceLibraryDb.
Definition: workspacelibrarydbwriter.h:55
int addToCategory(int elementId, const Uuid &category)
Add a library element to a category.
Definition: workspacelibrarydbwriter.h:233
~WorkspaceLibraryDbWriter() noexcept
Definition: workspacelibrarydbwriter.cpp:53
int addTranslation(int elementId, const QString &locale, const tl::optional< ElementName > &name, const tl::optional< QString > &description, const tl::optional< QString > &keywords)
Add a translation for a library element.
Definition: workspacelibrarydbwriter.h:206
QString filePathToString(const FilePath &fp) const noexcept
Definition: workspacelibrarydbwriter.cpp:500
void addInternalData(const QString &key, int value)
Add an integer value to the "internal" table.
Definition: workspacelibrarydbwriter.cpp:271
FilePath mLibrariesRoot
Definition: workspacelibrarydbwriter.h:286
This class represents absolute, well-formatted paths to files or directories.
Definition: filepath.h:127
void createAllTables()
Create all tables to initialize the database.
Definition: workspacelibrarydbwriter.cpp:60
The SQLiteDatabase class.
Definition: sqlitedatabase.h:43
int addLibrary(const FilePath &fp, const Uuid &uuid, const Version &version, bool deprecated, const QByteArray &iconPng)
Add a library.
Definition: workspacelibrarydbwriter.cpp:280
WorkspaceLibraryDbWriter & operator=(const WorkspaceLibraryDbWriter &rhs)=delete
The Uuid class is a replacement for QUuid to get UUID strings without {} braces.
Definition: uuid.h:56
WorkspaceLibraryDbWriter()=delete
static QString getElementTable() noexcept
Get the table name of an element type.
int addElement(int libId, const FilePath &fp, const Uuid &uuid, const Version &version, bool deprecated)
Add a library element.
Definition: workspacelibrarydbwriter.h:118
void removeAllElements()
Remove all library elements of a specific type.
Definition: workspacelibrarydbwriter.h:190
void removeElement(const FilePath &fp)
Remove a library element.
Definition: workspacelibrarydbwriter.h:177