Skip to content

add universal qt-free provider interface#67

Merged
iurimatias merged 1 commit into
masterfrom
remove_more_qt_2
May 22, 2026
Merged

add universal qt-free provider interface#67
iurimatias merged 1 commit into
masterfrom
remove_more_qt_2

Conversation

@iurimatias
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings May 22, 2026 21:33
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a “universal” (std/nlohmann::json-based) provider-side interface alongside the existing Qt (QString/QVariant) provider interface, and factors Qt↔︎nlohmann JSON conversion helpers into a shared utility to support Qt-free provider implementations.

Changes:

  • Added LogosProviderObject “Std” virtuals (callMethodStd/getMethodsStd/setEventListenerStd) plus Qt-bridge helpers to delegate between Qt and universal APIs.
  • Introduced logos_json_convert.{h,cpp} to centralize QVariant↔︎nlohmann and method-metadata-to-JSON conversion.
  • Updated build/packaging (CMake + Nix) and refactored logos_api_client.cpp to use the shared conversion helpers.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
nix/include.nix Adds the new json conversion source/header to the Nix packaging file list.
cpp/logos_provider_object.h Extends the provider interface with universal (std/json) virtuals and bridge helpers.
cpp/logos_provider_object.cpp Implements default universal virtuals and the Qt↔︎Std bridge helper logic.
cpp/logos_json_convert.h Declares shared Qt↔︎nlohmann conversion APIs and LogosMethodMetadata.
cpp/logos_json_convert.cpp Implements shared conversion functions and method metadata JSON formatting.
cpp/logos_api_client.cpp Replaces local helper implementations with calls into logos_json_convert.
cpp/CMakeLists.txt Adds the new conversion files to the build and installs the header.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

virtual ~LogosProviderObject() = default;

using EventCallback = std::function<void(const QString&, const QVariantList&)>;
using UniversalEventCallback = std::function<void(const std::string&, const std::string&)>;
Comment on lines +50 to +58
QVariantList qData;
QJsonDocument doc = QJsonDocument::fromJson(
QByteArray::fromStdString(data));
if (doc.isArray()) {
for (const QJsonValue& v : doc.array())
qData.append(v.toVariant());
} else {
qData.append(QString::fromStdString(data));
}
Comment on lines 22 to +30
// Module authors do NOT implement this directly — they inherit LogosProviderBase.
//
// Two parallel virtual interfaces:
// Qt interface: callMethod / getMethods / setEventListener (pure virtual)
// Universal interface: callMethodStd / getMethodsStd / setEventListenerStd (defaulted)
//
// Providers override ONE set. Those going Qt-free override the Std versions
// and delegate the Qt ones via the provided callMethodStdBridge / getMethodsStdBridge
// helpers (one-line overrides).
Comment on lines +60 to +70
if (j.is_null())
return QVariant();
if (j.is_boolean())
return QVariant(j.get<bool>());
if (j.is_number_integer())
return QVariant(static_cast<qlonglong>(j.get<int64_t>()));
if (j.is_number_float())
return QVariant(j.get<double>());
if (j.is_string())
return QVariant(QString::fromStdString(j.get<std::string>()));
if (j.is_object()) {
Comment on lines +88 to +96
if (arg.is_string())
result.append(QString::fromStdString(arg.get<std::string>()));
else if (arg.is_boolean())
result.append(arg.get<bool>());
else if (arg.is_number_integer())
result.append(static_cast<qlonglong>(arg.get<int64_t>()));
else if (arg.is_number_float())
result.append(arg.get<double>());
else if (arg.is_null())
add universal qt-free provider interface

address review
@iurimatias iurimatias merged commit 4e20614 into master May 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants