tool_namespace.h

src/facade/tool_namespace.h

@file tool_namespace.h @brief gh#145: the bridge's tool namespace, as a pure pair of functions.

Owners: @tvanfossen

qualify_tool_name

std::string entropic::facade::qualify_tool_name(const std::string &prefix, const std::string &suffix)

Qualify a bare tool suffix with the configured namespace.

src/facade/tool_namespace.h:45

Show on the map →

Called by SCENARIO, ask_status_tool, ask_tool, no_args_tool, session_scoped_tool

Calls none

Source · 7 lines
inline std::string qualify_tool_name(const std::string& prefix,
                                     const std::string& suffix) {
    if (prefix.empty()) {
        return suffix;
    }
    return prefix + "." + suffix;
}
Activity · 3 steps
lines 47–47◇ if (prefix.empty())lines 48–48return suffix;lines 50–50return prefix + "." + suffix;

Requirements

REQ-BRIDGE-001

strip_tool_prefix

std::string entropic::facade::strip_tool_prefix(const std::string &prefix, const std::string &name)

Recover the bare suffix from a wire name.

src/facade/tool_namespace.h:70

Show on the map →

Called by SCENARIO, dispatch_tool

Calls none

Source · 11 lines
inline std::string strip_tool_prefix(const std::string& prefix,
                                     const std::string& name) {
    if (prefix.empty()) {
        return name;
    }
    const std::string qualified = prefix + ".";
    if (name.rfind(qualified, 0) != 0) {
        return name;
    }
    return name.substr(qualified.size());
}
Activity · 6 steps
lines 72–72◇ if (prefix.empty())lines 73–73return name;lines 75–75const std::string qualified = prefix + ".";lines 76–76◇ if (name.rfind(qualified, 0) != 0)lines 77–77return name;lines 79–79return name.substr(qualified.size());

Requirements

REQ-BRIDGE-001