Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
Loading...
Searching...
No Matches
qmltemplates.cpp File Reference

The QML template libraries, their headers, and the trust store (design 0023). More...

#include "instance_p.h"
#include "qmltemplates_p.h"
#include "server_p.h"
#include "threadcheck_p.h"
#include "trust_p.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QCryptographicHash>
#include <QtCore/QDir>
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
#include <QtCore/QJsonArray>
#include <QtCore/QJsonDocument>
#include <QtCore/QJsonObject>
#include <QtCore/QMetaMethod>
#include <QtCore/QRegularExpression>
#include <QtCore/QSaveFile>
#include <QtCore/QStandardPaths>

Namespaces

namespace  Sonde
 Embeddable Model Context Protocol server for Qt applications.

Functions

bool Sonde::QmlTemplates::anonymous_namespace{qmltemplates.cpp}::parseObjectSlot (const QString &value, ObjectSlot *slot, QString *error)
 Parses an object: header value, "name[?] = spec", into slot.
qsizetype Sonde::QmlTemplates::anonymous_namespace{qmltemplates.cpp}::jsonValueEnd (QStringView s, qsizetype from)
 Where the JSON value that starts at from in s ends (one past it), or -1 if it doesn't end.
bool Sonde::QmlTemplates::anonymous_namespace{qmltemplates.cpp}::parseParamSlot (const QString &value, ParamSlot *slot, QString *error)
 Parses a param: header value, "name = <JSON> <description>", into slot.
bool Sonde::QmlTemplates::anonymous_namespace{qmltemplates.cpp}::addHeaderLine (const QString &key, const QString &value, Header *header, QString *error)
 Adds the header line key: value to header.
bool Sonde::QmlTemplates::anonymous_namespace{qmltemplates.cpp}::isInside (const QString &path, const QString &directory)
 Whether path is directory or inside it (both canonical).
std::optional< Header > Sonde::QmlTemplates::parseHeader (const QString &qml, QString *error)
 Reads the header at the top of qml.
bool Sonde::QmlTemplates::isTemplateName (const QString &name)
 Whether name can be a template's name: [a-z0-9][a-z0-9-]*, at most 64.
bool Sonde::QmlTemplates::isComponentName (const QString &name)
 Whether name can be a component's name: a QML type name, at most 64.
bool Sonde::QmlTemplates::isObjectName (const QString &name)
 Whether name can be the name of an object a template is given.
std::optional< QJsonObject > Sonde::QmlTemplates::windowParams (const Header *header, const QJsonObject &given, QString *error)
 The settings for a window from header's defaults and the call's given: unknown names and values of another type are errors (design 0034).
QList< CompiledLibrary > & Sonde::QmlTemplates::anonymous_namespace{qmltemplates.cpp}::applicationLibraries ()
 The libraries the application registered, in order (the GUI thread's).
QList< CompiledLibrary > Sonde::QmlTemplates::compiledLibraries ()
 The compiled-in libraries, in the order they are searched: the application's, in the order they were added, then Sonde's own.
Expected< void > Sonde::QmlTemplates::registerCompiledLibrary (const QString &name, const QString &root)
 Registers a compiled-in library (addTemplateLibrary()).
std::optional< LibraryFile > Sonde::QmlTemplates::readCompiledFile (const CompiledLibrary &library, const QString &name, bool component)
 Reads template or component name of compiled-in library library, if it has one by that name.
std::optional< LibraryFile > Sonde::QmlTemplates::findTemplate (const Locations &where, const QString &name)
 Finds template name: in the project library, the user library, then the compiled-in libraries, as ui_open does.
Locations Sonde::QmlTemplates::locate ()
 Finds the libraries and the trust file now, searching for the project library above the executable, then above the working directory.
QList< Trust::TrustedFile > Sonde::QmlTemplates::trusted (const QList< TrustFile > &files)
 files as the trust store records them.
LibraryFile Sonde::QmlTemplates::readLibraryFile (const Locations &where, const QString &name, Library library, bool component)
 Reads template or component name of library, with its header and trust.
bool Sonde::QmlTemplates::checkName (const QString &name, bool component, QString *error)
 Checks that name suits a template, or a component if component.
QString Sonde::QmlTemplates::untrustedReply (const QString &templateName, const QList< TrustFile > &files, const Locations &where)
 The refusal for files, with the commands that trust them.

Variables

constexpr QStringView Sonde::QmlTemplates::anonymous_namespace{qmltemplates.cpp}::kMarker = u"// sonde-template"
 The first line of every template.
constexpr qsizetype Sonde::QmlTemplates::anonymous_namespace{qmltemplates.cpp}::kMaxNameLength = 64
 Longest template or component name.
constexpr QStringView Sonde::QmlTemplates::anonymous_namespace{qmltemplates.cpp}::kSondeLibraryRoot = u":/sonde/instruments"
 Sonde's own compiled-in library: the instruments (design 0034).

Detailed Description

The QML template libraries, their headers, and the trust store (design 0023).

Function Documentation

◆ parseHeader()

std::optional< Header > Sonde::QmlTemplates::parseHeader ( const QString & qml,
QString * error )

Reads the header at the top of qml.

Returns
The header, or nothing with error set.

◆ windowParams()

std::optional< QJsonObject > Sonde::QmlTemplates::windowParams ( const Header * header,
const QJsonObject & given,
QString * error )

The settings for a window from header's defaults and the call's given: unknown names and values of another type are errors (design 0034).

Without a header (QML text), given as it is.