Taskolib  1.4.4
SequenceName.h
Go to the documentation of this file.
1 
23 // SPDX-License-Identifier: LGPL-2.1-or-later
24 
25 #ifndef TASKOLIB_SEQUENCENAME_H_
26 #define TASKOLIB_SEQUENCENAME_H_
27 
28 #include <optional>
29 #include <string_view>
30 #include <string>
31 
32 namespace task {
33 
43 {
44 public:
46  static constexpr std::size_t max_length = 64;
47 
49  static const std::string_view valid_characters;
50 
51 
53  SequenceName() = default;
54 
60  explicit SequenceName(std::string_view str);
61 
66  static std::optional<SequenceName> from_string(std::string_view str);
67 
69  friend bool operator==(const SequenceName& a, const SequenceName& b)
70  {
71  return a.str_ == b.str_;
72  }
73 
75  friend bool operator!=(const SequenceName& a, const SequenceName& b)
76  {
77  return a.str_ != b.str_;
78  }
79 
81  const std::string& string() const noexcept { return str_; }
82 
83 private:
84  std::string str_;
85 
90  static std::string_view check_validity(std::string_view);
91 };
92 
93 } // namespace task
94 
95 #endif
The machine-readable name of a Sequence.
Definition: SequenceName.h:43
friend bool operator==(const SequenceName &a, const SequenceName &b)
Determine if two sequence names are equal.
Definition: SequenceName.h:69
static const std::string_view valid_characters
A string containing all of the valid characters of a sequence name.
Definition: SequenceName.h:49
friend bool operator!=(const SequenceName &a, const SequenceName &b)
Determine if two sequence names are different.
Definition: SequenceName.h:75
static std::optional< SequenceName > from_string(std::string_view str)
Create a sequence name from the given string, returning an empty optional if the string violates the ...
Definition: SequenceName.cc:60
static constexpr std::size_t max_length
Maximum number of bytes of a sequence name.
Definition: SequenceName.h:46
static std::string_view check_validity(std::string_view)
Throw an exception if the given string violates the length or character constraints of a sequence nam...
Definition: SequenceName.cc:40
SequenceName()=default
Default-construct an empty sequence name.
std::string str_
Definition: SequenceName.h:84
const std::string & string() const noexcept
Return the sequence name as a string.
Definition: SequenceName.h:81
Namespace task contains all Taskolib functions and classes.
Definition: CommChannel.h:33