OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
name_validation.hpp
1#pragma once
2#include <ossia/detail/string_view.hpp>
3
4#include <string>
5#include <vector>
6namespace ossia
7{
8namespace net
9{
11OSSIA_EXPORT std::string& sanitize_device_name(std::string& name);
12OSSIA_EXPORT std::string& sanitize_name(std::string& name);
13OSSIA_EXPORT std::string sanitize_name(const std::string& s);
14OSSIA_EXPORT std::string sanitize_name(std::string&& s);
15OSSIA_EXPORT std::string sanitize_name(const char* s);
16OSSIA_EXPORT std::string
17sanitize_name(std::string name_base, const std::vector<std::string>& brethren);
18
22template <typename Char_T>
23bool is_valid_character_for_device(Char_T c)
24{
25 return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')
26 || (c == '.') || (c == '~') || (c == '_') || (c == '(') || (c == ')')
27 || (c == '-') || (c == ' ') || (c == '=');
28}
32template <typename Char_T>
33bool is_valid_character_for_name(Char_T c)
34{
35 return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')
36 || (c == '.') || (c == '~') || (c == '_') || (c == '(') || (c == ')')
37 || (c == '-') || (c == ':') || (c == ' ') || (c == '=');
38}
39
43constexpr std::string_view device_characters() noexcept
44{
45 constexpr_return(ossia::make_string_view("a-zA-Z0-9_~() .-"));
46}
47
51constexpr std::string_view name_characters() noexcept
52{
53 constexpr_return(ossia::make_string_view("a-zA-Z0-9_~(): .-"));
54}
55
59constexpr std::string_view path_characters() noexcept
60{
61 constexpr_return(ossia::make_string_view("/a-zA-Z0-9_~(): .-"));
62}
63
64constexpr std::string_view name_characters_no_instance() noexcept
65{
66 constexpr_return(ossia::make_string_view("a-zA-Z0-9_~(): -"));
67}
75constexpr std::string_view pattern_match_characters() noexcept
76{
77 constexpr_return(ossia::make_string_view("a-zA-Z0-9_~(): .*?,{}\\[\\]-"));
78}
79
87OSSIA_EXPORT
88bool is_brace_expansion(std::string_view);
89
97OSSIA_EXPORT std::vector<std::string> address_parts(std::string_view src);
98}
99}
Definition git_info.h:7