iceoryx2
C++ Language Bindings
Loading...
Searching...
No Matches
file_name.hpp
Go to the documentation of this file.
1// Copyright (c) 2023 by Apex.AI Inc. All rights reserved.
2// Copyright (c) 2025 Contributors to the Eclipse Foundation
3//
4// See the NOTICE file(s) distributed with this work for additional
5// information regarding copyright ownership.
6//
7// This program and the accompanying materials are made available under the
8// terms of the Apache Software License 2.0 which is available at
9// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license
10// which is available at https://opensource.org/licenses/MIT.
11//
12// SPDX-License-Identifier: Apache-2.0 OR MIT
13
14#ifndef IOX2_BB_FILE_NAME_HPP
15#define IOX2_BB_FILE_NAME_HPP
16
20
21namespace iox2 {
22namespace bb {
23namespace platform {
24#ifdef _WIN32
25constexpr uint64_t IOX2_MAX_FILENAME_LENGTH = 128U;
26#else
27constexpr uint64_t IOX2_MAX_FILENAME_LENGTH = 255U;
28#endif
29} // namespace platform
30
31namespace detail {
33 const bb::StaticString<platform::IOX2_MAX_FILENAME_LENGTH>& value) noexcept -> bool;
35 -> bool;
36} // namespace detail
37
40class FileName : public SemanticString<FileName,
41 platform::IOX2_MAX_FILENAME_LENGTH,
42 detail::file_name_does_contain_invalid_content,
43 detail::file_name_does_contain_invalid_characters> {
48 using Parent::Parent;
49};
50
51namespace detail {
52inline auto
54 -> bool {
55 // NOLINTNEXTLINE(readability-use-anyofallof) not yet supported in all compilers
56 for (const char c : value.unchecked_access()) { // NOLINT(readability-identifier-length)
57 const bool is_small_letter { ASCII_A <= c && c <= ASCII_Z };
58 const bool is_capital_letter { ASCII_CAPITAL_A <= c && c <= ASCII_CAPITAL_Z };
59 const bool is_number { ASCII_0 <= c && c <= ASCII_9 };
60 const bool is_special_character { c == ASCII_DASH || c == ASCII_DOT || c == ASCII_COLON
61 || c == ASCII_UNDERSCORE };
62
63 if ((!is_small_letter && !is_capital_letter) && (!is_number && !is_special_character)) {
64 return true;
65 }
66 }
67
68 return false;
69}
70
71inline auto
77} // namespace detail
78} // namespace bb
79} // namespace iox2
80
81#endif // IOX2_BB_FILE_NAME_HPP
Represents a single file name. It is not allowed to contain any path elements like "....
Definition file_name.hpp:43
The SemanticString is a string which has an inner syntax and restrictions to valid content....
constexpr char ASCII_UNDERSCORE
auto file_name_does_contain_invalid_content(const bb::StaticString< platform::IOX2_MAX_FILENAME_LENGTH > &value) noexcept -> bool
Definition file_name.hpp:72
auto file_name_does_contain_invalid_characters(const bb::StaticString< platform::IOX2_MAX_FILENAME_LENGTH > &value) noexcept -> bool
Definition file_name.hpp:53
constexpr uint64_t IOX2_MAX_FILENAME_LENGTH
Definition file_name.hpp:27