VLink 2.0.0
A high-performance communication middleware
Loading...
Searching...
No Matches
url_remap.h File Reference

JSON-driven URL remapping for VLink topic address translation. More...

#include <string>
#include <unordered_map>
#include <vector>
#include "../base/macros.h"
Include dependency graph for url_remap.h:

Go to the source code of this file.

Classes

 Loads a JSON remap file and translates VLink URL strings at runtime. More...

Namespaces

Detailed Description

JSON-driven URL remapping for VLink topic address translation.

UrlRemap loads a JSON configuration file that maps source URL patterns to target URL strings, enabling topic renaming at runtime without recompiling.

The JSON format is a flat object of key/value pairs:

{
"intra://sensor/lidar": "dds://vehicle/lidar",
"shm://camera/front": "zenoh://camera/front"
}
Matching algorithm
For each call to convert(), the remap list is searched in order. The first entry whose key is found as a substring of the input URL is selected, and its value is returned as the remapped URL. Results are cached in an internal unordered_map to avoid repeated linear scans.
Lifecycle
remap.load("/etc/vlink/remap.json");
std::string topic = remap.convert("intra://sensor/lidar");
// topic == "dds://vehicle/lidar"
remap.reload("/etc/vlink/new_remap.json");
Note
  • load() returns false (and sets the error string) if the file does not exist, cannot be parsed, or is already loaded.
  • unload() clears the remap table and the result cache.
  • convert() returns the original URL unchanged if is_valid() is false or no matching rule is found.