LibrePCB Developers Documentation
|
Database write functions for librepcb::WorkspaceLibraryDb. More...
#include <workspacelibrarydbwriter.h>
Public Member Functions | |
WorkspaceLibraryDbWriter ()=delete | |
WorkspaceLibraryDbWriter (const WorkspaceLibraryDbWriter &other)=delete | |
WorkspaceLibraryDbWriter (const FilePath &librariesRoot, SQLiteDatabase &db) | |
~WorkspaceLibraryDbWriter () noexcept | |
void | createAllTables () |
Create all tables to initialize the database. | |
void | addInternalData (const QString &key, int value) |
Add an integer value to the "internal" table. | |
int | addLibrary (const FilePath &fp, const Uuid &uuid, const Version &version, bool deprecated, const QByteArray &iconPng, const QString &manufacturer) |
Add a library. | |
void | updateLibrary (const FilePath &fp, const Uuid &uuid, const Version &version, bool deprecated, const QByteArray &iconPng, const QString &manufacturer) |
Update library metadata. | |
template<typename ElementType > | |
int | addElement (int libId, const FilePath &fp, const Uuid &uuid, const Version &version, bool deprecated, const QString &generatedBy) |
Add a library element. | |
template<typename ElementType > | |
int | addCategory (int libId, const FilePath &fp, const Uuid &uuid, const Version &version, bool deprecated, const std::optional< Uuid > &parent) |
addElement() specialized for categories | |
int | addDevice (int libId, const FilePath &fp, const Uuid &uuid, const Version &version, bool deprecated, const QString &generatedBy, const Uuid &component, const Uuid &package) |
addElement() specialized for devices | |
int | addPart (int devId, const QString &mpn, const QString &manufacturer) |
Add a part to a previously added device. | |
int | addPartAttribute (int partId, const Attribute &attribute) |
Add an attribute to a previously added part. | |
template<typename ElementType > | |
void | removeElement (const FilePath &fp) |
Remove a library element. | |
template<typename ElementType > | |
void | removeAllElements () |
Remove all library elements of a specific type. | |
template<typename ElementType > | |
int | addTranslation (int elementId, const QString &locale, const std::optional< ElementName > &name, const std::optional< QString > &description, const std::optional< QString > &keywords) |
Add a translation for a library element. | |
template<typename ElementType > | |
void | removeAllTranslations () |
Remove all translations for a library element type. | |
template<typename ElementType > | |
int | addToCategory (int elementId, const Uuid &category) |
Add a library element to a category. | |
template<typename ElementType > | |
int | addResource (int elementId, const QString &name, const QString &mediaType, const QUrl &url) |
Add a resource for a library element. | |
int | addAlternativeName (int pkgId, const ElementName &name, const SimpleString &reference) |
Add an alternative name to a previously added package. | |
WorkspaceLibraryDbWriter & | operator= (const WorkspaceLibraryDbWriter &rhs)=delete |
Static Public Member Functions | |
template<typename ElementType > | |
static QString | getElementTable () noexcept |
Get the table name of an element type. | |
template<typename ElementType > | |
static QString | getCategoryTable () noexcept |
Get the category table name of an element type. | |
template<> | |
QString | getElementTable () noexcept |
template<> | |
QString | getElementTable () noexcept |
template<> | |
QString | getElementTable () noexcept |
template<> | |
QString | getElementTable () noexcept |
template<> | |
QString | getElementTable () noexcept |
template<> | |
QString | getElementTable () noexcept |
template<> | |
QString | getElementTable () noexcept |
template<> | |
QString | getCategoryTable () noexcept |
template<> | |
QString | getCategoryTable () noexcept |
template<> | |
QString | getCategoryTable () noexcept |
template<> | |
QString | getCategoryTable () noexcept |
Private Member Functions | |
int | addElement (const QString &elementsTable, int libId, const FilePath &fp, const Uuid &uuid, const Version &version, bool deprecated, const QString &generatedBy) |
int | addCategory (const QString &categoriesTable, int libId, const FilePath &fp, const Uuid &uuid, const Version &version, bool deprecated, const std::optional< Uuid > &parent) |
void | removeElement (const QString &elementsTable, const FilePath &fp) |
void | removeAllElements (const QString &elementsTable) |
int | addTranslation (const QString &elementsTable, int elementId, const QString &locale, const std::optional< ElementName > &name, const std::optional< QString > &description, const std::optional< QString > &keywords) |
void | removeAllTranslations (const QString &elementsTable) |
int | addToCategory (const QString &elementsTable, int elementId, const Uuid &category) |
int | addResource (const QString &elementsTable, int elementId, const QString &name, const QString &mediaType, const QUrl &url) |
QString | filePathToString (const FilePath &fp) const noexcept |
Static Private Member Functions | |
static QString | nonEmptyOrNull (const QString &s) noexcept |
static QString | nonNull (const QString &s) noexcept |
Private Attributes | |
FilePath | mLibrariesRoot |
SQLiteDatabase & | mDb |
Database write functions for librepcb::WorkspaceLibraryDb.
|
delete |
|
delete |
WorkspaceLibraryDbWriter | ( | const FilePath & | librariesRoot, |
SQLiteDatabase & | db | ||
) |
|
noexcept |
void createAllTables | ( | ) |
Create all tables to initialize the database.
This has to be done only once, after creating a new database.
void addInternalData | ( | const QString & | key, |
int | value | ||
) |
Add an integer value to the "internal" table.
key | The key to add. |
value | The value to add. |
int addLibrary | ( | const FilePath & | fp, |
const Uuid & | uuid, | ||
const Version & | version, | ||
bool | deprecated, | ||
const QByteArray & | iconPng, | ||
const QString & | manufacturer | ||
) |
Add a library.
fp | Filepath of the library. |
uuid | UUID of the library. |
version | Version of the library. |
deprecated | Whether the library is deprecated or not. |
iconPng | Icon as a PNG. |
manufacturer | Name of the manufacturer of this library (optional). |
void updateLibrary | ( | const FilePath & | fp, |
const Uuid & | uuid, | ||
const Version & | version, | ||
bool | deprecated, | ||
const QByteArray & | iconPng, | ||
const QString & | manufacturer | ||
) |
Update library metadata.
fp | Filepath of the library to update. |
uuid | New UUID of the library. |
version | New version of the library. |
deprecated | Whether the library is deprecated or not. |
iconPng | New icon as a PNG. |
manufacturer | Name of the manufacturer of this library (optional). |
|
inline |
Add a library element.
ElementType | Type of element to add. |
libId | ID of the library containing this element. |
fp | Filepath of the element. |
uuid | UUID of the element. |
version | Version of the element. |
deprecated | Whether the element is deprecated or not. |
generatedBy | The generator name if generated or imported. |
|
inline |
addElement() specialized for categories
ElementType | Type of category to add. |
libId | ID of the library containing this category. |
fp | Filepath of the category. |
uuid | UUID of the category. |
version | Version of the category. |
deprecated | Whether the category is deprecated or not. |
parent | Parent of the category. |
int addDevice | ( | int | libId, |
const FilePath & | fp, | ||
const Uuid & | uuid, | ||
const Version & | version, | ||
bool | deprecated, | ||
const QString & | generatedBy, | ||
const Uuid & | component, | ||
const Uuid & | package | ||
) |
addElement() specialized for devices
libId | ID of the library containing this device. |
fp | Filepath of the device. |
uuid | UUID of the device. |
version | Version of the device. |
deprecated | Whether the device is deprecated or not. |
generatedBy | The generator name if generated or imported. |
component | Component UUID of the device. |
package | Package UUID of the device. |
int addPart | ( | int | devId, |
const QString & | mpn, | ||
const QString & | manufacturer | ||
) |
Add a part to a previously added device.
devId | ID of the device containing this part. |
mpn | Manufacturer part number. |
manufacturer | Manufacturer name. |
int addPartAttribute | ( | int | partId, |
const Attribute & | attribute | ||
) |
Add an attribute to a previously added part.
partId | ID of the part containing this attribute. |
attribute | Attribute to add. |
|
inline |
Remove a library element.
ElementType | Type of element to remove. |
fp | Filepath of the element to remove. |
|
inline |
Remove all library elements of a specific type.
ElementType | Type of elements to remove. |
|
inline |
Add a translation for a library element.
ElementType | Type of element to add translations. |
elementId | ID of the element to add translations. |
locale | Locale of the translations. |
name | Element name. |
description | Eleemnt description. |
keywords | Element keywords. |
|
inline |
Remove all translations for a library element type.
ElementType | Type of element to remove translationss. |
|
inline |
Add a library element to a category.
ElementType | Type of element to add to the category. |
elementId | ID of the element to add to the category. |
category | Category UUID. |
|
inline |
Add a resource for a library element.
ElementType | Type of element of the resource. |
elementId | ID of the element of the resource. |
name | Resource name |
mediaType | Resource media type. |
url | Resource URL. |
int addAlternativeName | ( | int | pkgId, |
const ElementName & | name, | ||
const SimpleString & | reference | ||
) |
Add an alternative name to a previously added package.
pkgId | ID of the package for this alternative name. |
name | Alternative name (mandatory). |
reference | Origin of the alternative name (optional). |
|
staticnoexcept |
Get the table name of an element type.
ElementType | Type of element to get the table name of. |
|
staticnoexcept |
Get the category table name of an element type.
ElementType | Type of element to get the category table name of. |
|
delete |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
privatenoexcept |
|
staticprivatenoexcept |
|
staticprivatenoexcept |
|
staticnoexcept |
|
staticnoexcept |
|
staticnoexcept |
|
staticnoexcept |
|
staticnoexcept |
|
staticnoexcept |
|
staticnoexcept |
|
staticnoexcept |
|
staticnoexcept |
|
staticnoexcept |
|
staticnoexcept |
|
private |
|
private |