ACMX 2.136.0
Dual-Backend Real-Time GPU Video Synthesis
Loading...
Searching...
No Matches
input_validation.hpp
Go to the documentation of this file.
1#ifndef ACMXVK_INPUT_VALIDATION_HPP
2#define ACMXVK_INPUT_VALIDATION_HPP
3
4#include <cstddef>
5#include <cstdint>
6#include <filesystem>
7#include <istream>
8#include <string>
9#include <string_view>
10
11namespace acmxvk::input {
12
23
24 constexpr std::size_t MAX_ARGUMENT_BYTES = 8192;
25 constexpr std::size_t MAX_PATH_BYTES = 4096;
26 constexpr std::size_t MAX_DISPLAY_TEXT_BYTES = 1024;
27 constexpr std::size_t MAX_IDENTIFIER_BYTES = 64;
28 constexpr std::size_t MAX_TOKEN_BYTES = 128;
29 constexpr std::size_t MAX_STRUCTURED_VALUE_BYTES = 4096;
30 constexpr std::size_t MAX_CONFIGURATION_LINE_BYTES = 4096;
31 constexpr std::uintmax_t MAX_CONFIGURATION_FILE_BYTES = 4U * 1024U * 1024U;
32 constexpr std::size_t MAX_SHADER_ENTRIES = 16384;
33 constexpr std::size_t MAX_PLAYLIST_NODES = 1024;
34 constexpr std::size_t MAX_PLAYLIST_ENTRIES = 16384;
35 constexpr std::size_t MAX_MIDI_MAPPINGS = 4096;
36 constexpr std::size_t MAX_AUDIO_PLAYLIST_ENTRIES = 4096;
37
38 void validate_string(std::string_view value, StringKind kind,
39 std::string_view context, bool allow_empty = false);
40
42 const std::filesystem::path &path, std::string_view context,
43 std::uintmax_t maximum_bytes = MAX_CONFIGURATION_FILE_BYTES);
44
46 const std::filesystem::path &path, std::string_view context,
47 std::uintmax_t maximum_bytes = MAX_CONFIGURATION_FILE_BYTES,
48 std::size_t maximum_line_bytes = MAX_CONFIGURATION_FILE_BYTES);
49
50 void validate_spirv_file(const std::filesystem::path &path,
51 std::string_view context);
52
53 [[nodiscard]] std::string truncate_utf8(std::string_view value,
54 std::size_t maximum_bytes,
55 std::string_view suffix = "...");
56
57 [[nodiscard]] bool read_bounded_line(
58 std::istream &input, std::string &line, std::string_view context,
59 std::size_t line_number,
60 std::size_t maximum_bytes = MAX_CONFIGURATION_LINE_BYTES);
61
62} // namespace acmxvk::input
63
64#endif
constexpr std::size_t MAX_CONFIGURATION_LINE_BYTES
bool read_bounded_line(std::istream &input, std::string &line, std::string_view context, std::size_t line_number, std::size_t maximum_bytes)
constexpr std::size_t MAX_SHADER_ENTRIES
constexpr std::uintmax_t MAX_CONFIGURATION_FILE_BYTES
constexpr std::size_t MAX_AUDIO_PLAYLIST_ENTRIES
constexpr std::size_t MAX_PATH_BYTES
constexpr std::size_t MAX_PLAYLIST_NODES
void validate_file_size(const std::filesystem::path &path, std::string_view context, std::uintmax_t maximum_bytes)
constexpr std::size_t MAX_MIDI_MAPPINGS
void validate_spirv_file(const std::filesystem::path &path, std::string_view context)
constexpr std::size_t MAX_TOKEN_BYTES
constexpr std::size_t MAX_PLAYLIST_ENTRIES
constexpr std::size_t MAX_STRUCTURED_VALUE_BYTES
std::string truncate_utf8(std::string_view value, std::size_t maximum_bytes, std::string_view suffix)
constexpr std::size_t MAX_IDENTIFIER_BYTES
constexpr std::size_t MAX_ARGUMENT_BYTES
constexpr std::size_t MAX_DISPLAY_TEXT_BYTES
void validate_text_file(const std::filesystem::path &path, std::string_view context, std::uintmax_t maximum_bytes, std::size_t maximum_line_bytes)
void validate_string(std::string_view value, StringKind kind, std::string_view context, bool allow_empty)