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. More... | |
void | addInternalData (const QString &key, int value) |
Add an integer value to the "internal" table. More... | |
int | addLibrary (const FilePath &fp, const Uuid &uuid, const Version &version, bool deprecated, const QByteArray &iconPng, const QString &manufacturer) |
Add a library. More... | |
void | updateLibrary (const FilePath &fp, const Uuid &uuid, const Version &version, bool deprecated, const QByteArray &iconPng, const QString &manufacturer) |
Update library metadata. More... | |
template<typename ElementType > | |
int | addElement (int libId, const FilePath &fp, const Uuid &uuid, const Version &version, bool deprecated) |
Add a library element. More... | |
template<typename ElementType > | |
int | addCategory (int libId, const FilePath &fp, const Uuid &uuid, const Version &version, bool deprecated, const tl::optional< Uuid > &parent) |
addElement() specialized for categories More... | |
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 More... | |
int | addPart (int devId, const QString &mpn, const QString &manufacturer) |
Add a part to a previously added device. More... | |
int | addPartAttribute (int partId, const Attribute &attribute) |
Add an attribute to a previously added part. More... | |
template<typename ElementType > | |
void | removeElement (const FilePath &fp) |
Remove a library element. More... | |
template<typename ElementType > | |
void | removeAllElements () |
Remove all library elements of a specific type. More... | |
template<typename ElementType > | |
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. More... | |
template<typename ElementType > | |
void | removeAllTranslations () |
Remove all translations for a library element type. More... | |
template<typename ElementType > | |
int | addToCategory (int elementId, const Uuid &category) |
Add a library element to a category. More... | |
template<typename ElementType > | |
int | addResource (int elementId, const QString &name, const QString &mediaType, const QUrl &url) |
Add a resource for a library element. More... | |
int | addAlternativeName (int pkgId, const ElementName &name, const SimpleString &reference) |
Add an alternative name to a previously added package. More... | |
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. More... | |
template<typename ElementType > | |
static QString | getCategoryTable () noexcept |
Get the category table name of an element type. More... | |
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) |
int | addCategory (const QString &categoriesTable, int libId, const FilePath &fp, const Uuid &uuid, const Version &version, bool deprecated, const tl::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 tl::optional< ElementName > &name, const tl::optional< QString > &description, const tl::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 | 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. |
|
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 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. |
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 |
|
staticnoexcept |
|
staticnoexcept |
|
staticnoexcept |
|
staticnoexcept |
|
staticnoexcept |
|
staticnoexcept |
|
staticnoexcept |
|
staticnoexcept |
|
staticnoexcept |
|
staticnoexcept |
|
staticnoexcept |
|
private |
|
private |