$darkmode
#include <trigger.hpp>
Public Member Functions | |
| InlineSchema (bool enabled) | |
| InlineSchema (std::string desc) | |
| InlineSchema (std::string desc, fable::JsonType type, bool required=true) | |
| InlineSchema (std::string desc, std::string format, bool required=true) | |
| const std::string & | description () const |
| fable::JsonType | type () const |
| bool | is_enabled () const |
| bool | is_required () const |
| std::string | usage (const std::string &name) const |
InlineSchema describes the schema of the inline format.
|
inlineexplicit |
Construct an implicit inline schema if enabled is true, i.e., one where only the name itself is sufficient.
If possible, it is recommended to use InlineSchema(std::string) instead. This constructor is primarily useful when you want to explicitly disable an inline schema.
|
inlineexplicit |
Construct an implicit inline schema with the given description.
| cloe::InlineSchema::InlineSchema | ( | std::string | desc, |
| fable::JsonType | type, | ||
| bool | required = true |
||
| ) |
Construct an inline schema that takes a particular primitive type.
The type may not be null, object, or array.
|
inline |
Construct an inline schema that takes a string with the given format.
This is only needed when further parsing of the string is applied. The format should describe the string that will directly parsed by the TriggerFactory::make(const std::string&) method.
The string should roughly follow the (extended) Backus-Naur form, as is known from many usage strings:
stop A single string "stop" <button> A button identifier, whatever that is [!]<button> A button identifier, prefixed optionally with "!" <string>,<float> A string, comma, and float <string>[,<float>] A string optionally followed by a comma and float <id>[,...] An array of ids, without a terminating comma
It's generally not possible to be readable and exact at the same time. There is some ambiguity that we just need to live with. Use some common sense here and see what is in use. Embedded quotes may help with the ambiguity but should be used sparingly (for now, as usage is often directly read from JSON).
|
inline |
Return the description of the inline schema.
|
inline |
Return whether the inline format can be used for this trigger.
The inline format is considered disabled when the argument type is null and yet required. This cannot after all be a useful call to make.
|
inline |
Return whether the single argument to the trigger is required.
Note: When no arguments are accepted and the trigger is enabled, false is returned. Therefore, !is_required() is all that is needed to ascertain that the name is sufficient, such as in "start" or "next".
|
inline |
Return the argument type of the inline schema.
If the type is fable::JsonType::null, then the schema takes no arguments, as is the case for many events, such as "start" or "stop".
| std::string cloe::InlineSchema::usage | ( | const std::string & | name | ) | const |
Return the usage of the inline schema.
If not enabled, then the empty string "" is returned. Otherwise, the return value takes one of the following forms:
NAME NAME=TYPE NAME[=TYPE] NAME=FORMAT NAME[=FORMAT]
For example:
stop time=float next[=float]
Note: The output of this method should not change given a certain name. It is thus a good candidate for caching should this datum be need, as the calculation is not particularly cheap.