VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
InstalledPlugins.hpp
Go to the documentation of this file.
1#pragma once
2
6#include <filesystem>
7#include <string>
8#include <string_view>
9#include <vector>
10
11namespace VoltMod
12{
13
14/** One parsed `plugin.json`. */
16{
17 std::string Name;
18 std::string Version;
19 std::string LogTag; ///< prefixes the plugin's log lines; its name unless the file says otherwise
20 std::string Description;
21 std::string Author;
22 std::string Website;
23 std::string License;
24 /** The level the plugin starts at; `volt log` changes it until the next load. */
26 std::vector<std::string> Dependencies; ///< Required: a missing one refuses this plugin.
27 /** The plugin loads without these and reaches them through the service exchange when present. */
28 std::vector<std::string> OptionalDependencies;
29};
30
31/** A plugin the host will not load, and the reason its log line gives. */
33{
34 std::string Name;
36};
37
38/** What the plugins directory holds: the manifests that parsed, and the ones that did not. */
40{
41 std::vector<PluginManifest> Plugins;
42 std::vector<RefusedPlugin> Refused;
43};
44
45/** SDK-free, so tests run it against a real plugins directory. */
46namespace InstalledPlugins
47{
48
49/** Every `<plugins>/<name>/plugin.json`. A directory without one is skipped silently; a malformed
50 * manifest, or one naming another plugin, is refused. */
51InstalledScan Discover(const std::filesystem::path& plugins);
52
53} // namespace InstalledPlugins
54
55/** Whether @p descriptor is one a host of @p hostVersion can load, with the reason it is not. */
57
58} // namespace VoltMod
InstalledScan Discover(const std::filesystem::path &plugins)
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56
Status ValidateDescriptor(const PluginDescriptor *descriptor, std::string_view hostVersion)
LogLevel
Definition Log.hpp:13
std::expected< void, Error > Status
Definition Result.hpp:67
One failure: a code to branch on, text for the log, and an optional translation key.
Definition Result.hpp:42
std::vector< PluginManifest > Plugins
std::vector< RefusedPlugin > Refused
std::string LogTag
prefixes the plugin's log lines; its name unless the file says otherwise
std::vector< std::string > OptionalDependencies
std::vector< std::string > Dependencies
Required: a missing one refuses this plugin.