|
Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
|
The bridge between stdio and a Sonde local socket server, which sonde-bridge and sonde bridge both run (design 0030). More...
#include "bridge.h"#include <QtCore/QCoreApplication>#include <QtCore/QDeadlineTimer>#include <QtCore/QElapsedTimer>#include <QtCore/QJsonArray>#include <QtCore/QJsonDocument>#include <QtCore/QJsonObject>#include <QtCore/QHash>#include <QtCore/QSet>#include <QtCore/QTimer>#include <QtNetwork/QLocalSocket>#include <cstdio>#include <iostream>#include <string>#include <thread>#include <utility>Classes | |
| class | Sonde::Bridge::anonymous_namespace{bridge.cpp}::Handshake |
| What the client set up on its connection, so it can be replayed to a restarted application. More... | |
| class | Sonde::Bridge::anonymous_namespace{bridge.cpp}::Bridge |
| Copies lines between stdin/stdout and a QLocalSocket. More... | |
| struct | Sonde::Bridge::anonymous_namespace{bridge.cpp}::Bridge::Held |
| A line from stdin held while the application is away (–reconnect). More... | |
Namespaces | |
| namespace | Sonde |
| Embeddable Model Context Protocol server for Qt applications. | |
Functions | |
| constexpr QLatin1StringView | Sonde::Bridge::anonymous_namespace{bridge.cpp}::kOwnIdPrefix ("sonde-bridge:") |
| Prefix of the ids the bridge uses for its own (replayed) requests. | |
| QList< QJsonObject > | Sonde::Bridge::anonymous_namespace{bridge.cpp}::messagesIn (const QByteArray &line) |
| The messages in a JSON-RPC line: one object, or the elements of a batch. | |
| QString | Sonde::Bridge::anonymous_namespace{bridge.cpp}::idKey (const QJsonValue &id) |
| An id as a hash key (its compact JSON text, so 1 and "1" differ). | |
| QHash< QString, QJsonValue > | Sonde::Bridge::anonymous_namespace{bridge.cpp}::messageIds (const QByteArray &line, bool requests) |
The ids of the requests (requests true: have a method) or responses (false: no method) in line, by idKey(). | |
| QByteArray | Sonde::Bridge::anonymous_namespace{bridge.cpp}::jsonLine (const QJsonObject &message) |
One line of JSON-RPC: message, compact, with a newline. | |
| QByteArray | Sonde::Bridge::anonymous_namespace{bridge.cpp}::notConnectedError (const QJsonValue &id, const QString &message) |
A JSON-RPC error response to id saying the application is not connected. | |
| QList< OptionDoc > | Sonde::Bridge::commandLineOptions () |
| sonde-bridge's options, in the order its help lists them. | |
| QString | Sonde::Bridge::commandLineDescription () |
| One line on what sonde-bridge does. | |
| std::pair< QString, QString > | Sonde::Bridge::commandLineArgument () |
| Its argument's name and description: the local server. | |
| std::optional< int > | Sonde::Bridge::holdSeconds (const QString &text) |
| The seconds in a –hold value: a number from 0 to kMaxHoldSeconds, or nothing. | |
| int | Sonde::Bridge::run (const QString &name, const RetryPolicy &policy) |
Connects to the local server name and copies lines between it and stdin and stdout, as policy says, until it is done. | |
The bridge between stdio and a Sonde local socket server, which sonde-bridge and sonde bridge both run (design 0030).
| int Sonde::Bridge::run | ( | const QString & | name, |
| const RetryPolicy & | policy ) |
Connects to the local server name and copies lines between it and stdin and stdout, as policy says, until it is done.
Needs a QCoreApplication, and runs its event loop. A thread stays blocked reading stdin, so the caller ends the process with std::_Exit() afterwards.