Home
Symple module

Command

Symple command message with a node path and action verb.

Command

#include <icy/symple/command.h>
class Command

Defined in src/symple/include/icy/symple/command.h:28

Inherits: Message

Symple command message with a node path and action verb.

The node field is a colon-delimited path (e.g. "camera:zoom:in"). Individual path segments can be retrieved with param().

List of all members

NameKindOwner
CommandfunctionDeclared here
CommandfunctionDeclared here
CommandfunctionDeclared here
~CommandfunctionDeclared here
nodefunctionDeclared here
actionfunctionDeclared here
setNodefunctionDeclared here
setActionfunctionDeclared here
validfunctionDeclared here
paramfunctionDeclared here
paramsfunctionDeclared here
matchesfunctionDeclared here
MessagefunctionInherited from Message
MessagefunctionInherited from Message
MessagefunctionInherited from Message
operator=functionInherited from Message
~MessagefunctionInherited from Message
clonefunctionInherited from Message
validfunctionInherited from Message
clearfunctionInherited from Message
clearDatafunctionInherited from Message
clearNotesfunctionInherited from Message
typefunctionInherited from Message
idfunctionInherited from Message
tofunctionInherited from Message
fromfunctionInherited from Message
toUserfunctionInherited from Message
toIdfunctionInherited from Message
fromUserfunctionInherited from Message
fromIdfunctionInherited from Message
statusfunctionInherited from Message
setTypefunctionInherited from Message
setTofunctionInherited from Message
setTofunctionInherited from Message
setTofunctionInherited from Message
setFromfunctionInherited from Message
setFromfunctionInherited from Message
setFromfunctionInherited from Message
setStatusfunctionInherited from Message
notesfunctionInherited from Message
setNotefunctionInherited from Message
addNotefunctionInherited from Message
datafunctionInherited from Message
datafunctionInherited from Message
setDatafunctionInherited from Message
setDatafunctionInherited from Message
setDatafunctionInherited from Message
setDatafunctionInherited from Message
setDatafunctionInherited from Message
removeDatafunctionInherited from Message
hasDatafunctionInherited from Message
readfunctionInherited from Message
readfunctionInherited from Message
writefunctionInherited from Message
isRequestfunctionInherited from Message
sizefunctionInherited from Message
printfunctionInherited from Message
classNamefunctionInherited from Message
datafunctionInherited from Message
hasDatafunctionInherited from Message
operator<<friendInherited from IPacket
opaquevariableInherited from IPacket
infovariableInherited from IPacket
flagsvariableInherited from IPacket
IPacketfunctionInherited from IPacket
IPacketfunctionInherited from IPacket
operator=functionInherited from IPacket
clonefunctionInherited from IPacket
~IPacketfunctionInherited from IPacket
readfunctionInherited from IPacket
writefunctionInherited from IPacket
sizefunctionInherited from IPacket
hasDatafunctionInherited from IPacket
datafunctionInherited from IPacket
constDatafunctionInherited from IPacket
classNamefunctionInherited from IPacket
printfunctionInherited from IPacket

Inherited from Message

KindNameDescription
functionMessageConstructs a new message with a random ID and type set to "message".
functionMessageConstructs a message from a JSON value; sets missing id/type fields.
functionMessageCopy constructor; preserves or generates id/type fields.
functionoperator=Defaulted assignment operator.
function~Message virtual
functionclone virtual const overrideReturns a heap-allocated copy of this message.
functionvalid virtual constReturns true if the message has both type and id fields.
functionclear virtualClears all JSON fields from this message.
functionclearData virtualClears the data sub-object.
functionclearNotes virtualClears the notes array.
functiontype constReturns the message type string (defaults to "message").
functionid constReturns the message ID string.
functionto constReturns the recipient address parsed from the to field.
functionfrom constReturns the sender address parsed from the from field.
functiontoUser constReturns the user component of the to address without constructing an Address.
functiontoId constReturns the id component of the to address without constructing an Address.
functionfromUser constReturns the user component of the from address without constructing an Address.
functionfromId constReturns the id component of the from address without constructing an Address.
functionstatus constReturns the HTTP status code, or -1 if not set.
functionsetTypeSets the message type field.
functionsetToSets the to field from a peer's address.
functionsetToSets the to field from an address object.
functionsetToSets the to field from an address string.
functionsetFromSets the from field from a peer's address.
functionsetFromSets the from field from an address object.
functionsetFromSets the from field from an address string.
functionsetStatusHTTP status codes are used to describe the message response. Throws std::invalid_argument if code is outside [101, 504].
functionnotesReturns a reference to the notes JSON array.
functionsetNoteReplaces all notes with a single note.
functionaddNoteAppends a note to the notes array.
functiondata constReturns a copy of the named data field.
functiondataReturns a reference to the named data field (creates it if absent).
functionsetDataCreates or replaces a named data field; returns a reference to it.
functionsetDataSets a named data field to a C-string value.
functionsetDataSets a named data field to a string value.
functionsetDataSets a named data field to a JSON value.
functionsetDataSets a named data field to an integer value.
functionremoveDataRemoves a named field from the data sub-object.
functionhasDataReturns true if the named field exists in the data sub-object.
functionread virtual overrideDeserialises the message from a raw buffer.
functionread virtualDeserialises the message from a JSON string.
functionwrite virtual const overrideSerialises the message as JSON into a buffer.
functionisRequest constReturns true if no status code has been set (i.e. status() == -1).
functionsize virtual const overrideReturns the serialised JSON size in bytes.
functionprint virtual const overridePretty-prints the message JSON to the given stream.
functionclassName virtual const inline overrideReturns the class name of this packet type for logging and diagnostics.
functiondata virtual const inlineThe packet data pointer for buffered packets.
functionhasData virtual const inlineReturns true if the packet has a non-null data pointer.

Inherited from IPacket

KindNameDescription
friendoperator<< inlineStream insertion operator; delegates to print().
variableopaqueOptional type-safe context data. Use std::any_cast to retrieve. Lifetime of the stored value is tied to the packet's lifetime.
variableinfoOptional extra information about the packet.
variableflagsProvides basic information about the packet.
functionIPacket inline
functionIPacket inlineCopy constructor; clones the info object if present.
functionoperator= inlineCopy assignment; clones the info object if present.
functionclone virtual constReturns a heap-allocated deep copy of this packet.
function~IPacket virtualDefaulted destructor.
functionread virtualRead/parse to the packet from the given input buffer. The number of bytes read is returned.
functionwrite virtual constCopy/generate to the packet given output buffer. The number of bytes written can be obtained from the buffer.
functionsize virtual const inlineThe size of the packet in bytes.
functionhasData virtual const inlineReturns true if the packet has a non-null data pointer.
functiondata virtual const inlineThe packet data pointer for buffered packets.
functionconstData virtual const inlineThe const packet data pointer for buffered packets.
functionclassName virtual constReturns the class name of this packet type for logging and diagnostics.
functionprint virtual const inlinePrints a human-readable representation to the given stream.

Public Methods

ReturnNameDescription
CommandConstructs an empty command with type set to "command".
CommandConstructs a command from a JSON value.
CommandCopy constructor.
std::stringnode constReturns the colon-delimited node path (e.g. "camera:zoom").
std::stringaction constReturns the action verb (defaults to "execute").
voidsetNodeSets the node path field.
voidsetActionSets the action verb field.
boolvalid virtual constReturns true if the base message is valid and the node field is set.
std::stringparam constReturns the nth colon-separated segment of the node path (1-based). Throws std::out_of_range if n exceeds the number of segments.
std::vector< std::string >paramsReturns all colon-separated segments of the node path.
boolmatches constReturns true if the node path matches the given pattern. Uses wildcard node matching via util::matchNodes.

Command

Command()

Defined in src/symple/include/icy/symple/command.h:32

Constructs an empty command with type set to "command".


Command

Command(const json::Value & root)

Defined in src/symple/include/icy/symple/command.h:36

Constructs a command from a JSON value.

Parameters

  • root JSON object to initialise from.

Command

Command(const Command & root)

Defined in src/symple/include/icy/symple/command.h:40

Copy constructor.

Parameters

  • root Source command.

node

const

std::string node() const

Defined in src/symple/include/icy/symple/command.h:45

Returns the colon-delimited node path (e.g. "camera:zoom").


action

const

std::string action() const

Defined in src/symple/include/icy/symple/command.h:48

Returns the action verb (defaults to "execute").


setNode

void setNode(std::string_view node)

Defined in src/symple/include/icy/symple/command.h:52

Sets the node path field.

Parameters

  • node Colon-delimited node path string.

setAction

void setAction(std::string_view action)

Defined in src/symple/include/icy/symple/command.h:56

Sets the action verb field.

Parameters

  • action Action string (e.g. "execute", "get", "set").

valid

virtual const

virtual bool valid() const

Defined in src/symple/include/icy/symple/command.h:59

Returns true if the base message is valid and the node field is set.

Reimplements

param

const

std::string param(int n) const

Defined in src/symple/include/icy/symple/command.h:65

Returns the nth colon-separated segment of the node path (1-based). Throws std::out_of_range if n exceeds the number of segments.

Parameters

  • n 1-based segment index.

Returns

The nth path segment.


params

std::vector< std::string > params()

Defined in src/symple/include/icy/symple/command.h:69

Returns all colon-separated segments of the node path.

Returns

Vector of path segment strings.


matches

const

bool matches(std::string_view xnode) const

Defined in src/symple/include/icy/symple/command.h:74

Returns true if the node path matches the given pattern. Uses wildcard node matching via util::matchNodes.

Parameters

  • xnode Pattern to match against (colon-delimited, supports wildcards).