VLink 2.0.0
A high-performance communication middleware
载入中...
搜索中...
未找到
url_remap.h 文件参考

JSON-driven URL remapping for VLink topic address translation. 更多...

#include <string>
#include <unordered_map>
#include <vector>
#include "../base/macros.h"
url_remap.h 的引用(Include)关系图:

浏览该文件的源代码.

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

命名空间

详细描述

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");
注解
  • 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.