Taskolib  1.3.3
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 <string>
29 
30 #include <gul14/optional.h>
31 #include <gul14/string_view.h>
32 
33 namespace task {
34 
44 {
45 public:
47  static constexpr std::size_t max_length = 64;
48 
50  static const gul14::string_view valid_characters;
51 
52 
54  SequenceName() = default;
55 
61  explicit SequenceName(gul14::string_view str);
62 
67  static gul14::optional<SequenceName> from_string(gul14::string_view str);
68 
70  friend bool operator==(const SequenceName& a, const SequenceName& b)
71  {
72  return a.str_ == b.str_;
73  }
74 
76  friend bool operator!=(const SequenceName& a, const SequenceName& b)
77  {
78  return a.str_ != b.str_;
79  }
80 
82  const std::string& string() const noexcept { return str_; }
83 
84 private:
85  std::string str_;
86 
91  static gul14::string_view check_validity(gul14::string_view);
92 };
93 
94 } // namespace task
95 
96 #endif
The machine-readable name of a Sequence.
Definition: SequenceName.h:44
friend bool operator==(const SequenceName &a, const SequenceName &b)
Determine if two sequence names are equal.
Definition: SequenceName.h:70
friend bool operator!=(const SequenceName &a, const SequenceName &b)
Determine if two sequence names are different.
Definition: SequenceName.h:76
static gul14::optional< SequenceName > from_string(gul14::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:47
SequenceName()=default
Default-construct an empty sequence name.
static gul14::string_view check_validity(gul14::string_view)
Throw an exception if the given string violates the length or character constraints of a sequence nam...
Definition: SequenceName.cc:40
std::string str_
Definition: SequenceName.h:85
static const gul14::string_view valid_characters
A string containing all of the valid characters of a sequence name.
Definition: SequenceName.h:50
const std::string & string() const noexcept
Return the sequence name as a string.
Definition: SequenceName.h:82
Namespace task contains all Taskolib functions and classes.
Definition: CommChannel.h:33