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

The bridge between stdio and a Sonde local socket server: sonde-bridge runs it, and so does sonde bridge, in its own process (design 0030). More...

#include <QtCore/QList>
#include <QtCore/QString>
#include <optional>
#include <utility>

Go to the source code of this file.

Classes

struct  Sonde::Bridge::RetryPolicy
 How long to keep retrying a failed connection, and whether to survive a disconnection. More...
struct  Sonde::Bridge::OptionDoc
 One of sonde-bridge's command-line options, as its parser and sonde's man page for it describe it (design 0036). More...

Namespaces

namespace  Sonde
 Embeddable Model Context Protocol server for Qt applications.

Functions

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.

Variables

constexpr int Sonde::Bridge::kDefaultHoldSeconds = 15
 With –reconnect, how long a request sent while the application is away is held by default, in seconds.
constexpr int Sonde::Bridge::kMaxHoldSeconds = 3600
 The longest –hold allowed, in seconds.

Detailed Description

The bridge between stdio and a Sonde local socket server: sonde-bridge runs it, and so does sonde bridge, in its own process (design 0030).

QtCore and QtNetwork only, so sonde-bridge stays small enough for a container.

Function Documentation

◆ run()

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.

Returns
The exit status: 0 when done, 1 if the connection failed.