|
VLink
2.0.0
A high-performance communication middleware
|
Loads a JSON rewrite table and substitutes VLink URLs at runtime. 更多...
#include <url_remap.h>
Public 成员函数 | |
| UrlRemap () noexcept | |
| Constructs an empty, unloaded instance. 更多... | |
| ~UrlRemap () noexcept | |
| Destroys the instance and clears caches. 更多... | |
| bool | load (const std::string &file_path) noexcept |
Parses file_path and installs the rewrite table. 更多... | |
| bool | unload () noexcept |
| Clears the rewrite table and the result cache. 更多... | |
| bool | reload (const std::string &file_path) noexcept |
Atomically unloads the current table and loads file_path. 更多... | |
| const std::string & | convert (const std::string &url) noexcept |
Translates url using the loaded rules; returns url unchanged on miss. 更多... | |
| void | set_enable_log (bool enable_log) noexcept |
| Toggles per-conversion INFO logging. 更多... | |
| bool | is_enable_log () const noexcept |
| Reports whether per-conversion logging is enabled. 更多... | |
| bool | is_valid () const noexcept |
| Reports whether a rewrite table has been successfully loaded. 更多... | |
| const std::string & | get_error_string () const noexcept |
| Returns the diagnostic message produced by the last failure. 更多... | |
Loads a JSON rewrite table and substitutes VLink URLs at runtime.
Each instance holds an ordered rewrite list, a result cache, and a status string used for diagnostics. Copy and assignment are disabled.
|
noexcept |
Constructs an empty, unloaded instance.
|
noexcept |
Destroys the instance and clears caches.
|
noexcept |
Translates url using the loaded rules; returns url unchanged on miss.
| url | Input URL to rewrite. |
url itself on a miss. The referent's lifetime depends on the path taken (the input url, the internal remap table, or the cache); copy it if you need to retain it.
|
inlinenoexcept |
Returns the diagnostic message produced by the last failure.
|
inlinenoexcept |
Reports whether per-conversion logging is enabled.
true when logging is currently enabled.
|
inlinenoexcept |
|
noexcept |
Parses file_path and installs the rewrite table.
| file_path | Absolute or relative path to a flat JSON object of string pairs. |
true on success; false when already loaded, the file is missing, unreadable, or contains invalid JSON. Errors are surfaced via get_error_string().
|
noexcept |
Atomically unloads the current table and loads file_path.
| file_path | Path of the replacement JSON file. |
true when the new file loaded successfully.
|
inlinenoexcept |
Toggles per-conversion INFO logging.
Details
| enable_log | true emits one log line per successful rewrite. |
|
noexcept |
Clears the rewrite table and the result cache.
true when the table was cleared; false when no table was loaded.