Taskolib  1.3.3
Public Member Functions | Static Public Attributes | Static Private Member Functions | Private Attributes | Friends | List of all members
task::Tag Class Reference

Detailed Description

A tag used for categorizing sequences.

A tag consists of lowercase ASCII letters, digits, and hyphen characters. It must be at least 1 character long and has a maximum length given by the max_length member constant. Uppercase letters are automatically converted to lowercase when comparing or creating tags.

#include <Tag.h>

Public Member Functions

 Tag ()
 Default-construct a tag with the name "-". More...
 
 Tag (gul14::string_view name)
 Construct a tag with the specified name. More...
 
std::size_t size () const noexcept
 Return the length of the tag name. More...
 
const std::string & string () const noexcept
 Return the name of the tag as a string. More...
 

Static Public Attributes

static constexpr std::size_t max_length = 32
 Maximum number of bytes of a tag name. More...
 
static const gul14::string_view valid_characters { "abcdefghijklmnopqrstuvwxyz0123456789-" }
 A string containing all of the valid characters for a tag name. More...
 

Static Private Member Functions

static gul14::string_view check_validity (gul14::string_view)
 Throw an exception if the given string violates the length or character constraints of a tag name; otherwise, return the unmodified string view. More...
 

Private Attributes

std::string name_
 

Friends

bool operator== (const Tag &a, const Tag &b)
 Determine if two tags are equal. More...
 
bool operator!= (const Tag &a, const Tag &b)
 Determine if two tags are different. More...
 
bool operator< (const Tag &a, const Tag &b)
 Determine if tag a comes before tag b in a lexicographical comparison. More...
 
bool operator<= (const Tag &a, const Tag &b)
 Determine if tag a comes before or is equal to tag b in a lexicographical comparison. More...
 
bool operator> (const Tag &a, const Tag &b)
 Determine if tag a comes after tag b in a lexicographical comparison. More...
 
bool operator>= (const Tag &a, const Tag &b)
 Determine if tag a comes after or is equal to tag b in a lexicographical comparison. More...
 
std::string operator+ (const std::string &lhs, const Tag &rhs)
 Concatenate a string and a tag. More...
 
std::string operator+ (const Tag &lhs, const std::string &rhs)
 Concatenate a tag and a string. More...
 
std::string & operator+= (std::string &lhs, const Tag &rhs)
 Concatenate a string and a tag. More...
 
std::ostream & operator<< (std::ostream &stream, const Tag &tag)
 Output the tag name to the given stream. More...
 

Constructor & Destructor Documentation

◆ Tag() [1/2]

task::Tag::Tag ( )
inline

Default-construct a tag with the name "-".

◆ Tag() [2/2]

task::Tag::Tag ( gul14::string_view  name)
explicit

Construct a tag with the specified name.

Uppercase ASCII characters are automatically converted to lowercase.

Exceptions
Erroris thrown if the string is too long or if it contains invalid characters.

Member Function Documentation

◆ check_validity()

gul14::string_view task::Tag::check_validity ( gul14::string_view  name)
staticprivate

Throw an exception if the given string violates the length or character constraints of a tag name; otherwise, return the unmodified string view.

Uppercase ASCII characters are rejected.

References max_length, and valid_characters.

◆ size()

std::size_t task::Tag::size ( ) const
inlinenoexcept

Return the length of the tag name.

References name_.

◆ string()

const std::string& task::Tag::string ( ) const
inlinenoexcept

Return the name of the tag as a string.

References name_.

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const Tag a,
const Tag b 
)
friend

Determine if two tags are different.

◆ operator+ [1/2]

std::string operator+ ( const std::string &  lhs,
const Tag rhs 
)
friend

Concatenate a string and a tag.

◆ operator+ [2/2]

std::string operator+ ( const Tag lhs,
const std::string &  rhs 
)
friend

Concatenate a tag and a string.

◆ operator+=

std::string& operator+= ( std::string &  lhs,
const Tag rhs 
)
friend

Concatenate a string and a tag.

◆ operator<

bool operator< ( const Tag a,
const Tag b 
)
friend

Determine if tag a comes before tag b in a lexicographical comparison.

◆ operator<<

std::ostream& operator<< ( std::ostream &  stream,
const Tag tag 
)
friend

Output the tag name to the given stream.

◆ operator<=

bool operator<= ( const Tag a,
const Tag b 
)
friend

Determine if tag a comes before or is equal to tag b in a lexicographical comparison.

◆ operator==

bool operator== ( const Tag a,
const Tag b 
)
friend

Determine if two tags are equal.

◆ operator>

bool operator> ( const Tag a,
const Tag b 
)
friend

Determine if tag a comes after tag b in a lexicographical comparison.

◆ operator>=

bool operator>= ( const Tag a,
const Tag b 
)
friend

Determine if tag a comes after or is equal to tag b in a lexicographical comparison.

Member Data Documentation

◆ max_length

constexpr std::size_t task::Tag::max_length = 32
staticconstexpr

Maximum number of bytes of a tag name.

Referenced by check_validity().

◆ name_

std::string task::Tag::name_
private

Referenced by size(), and string().

◆ valid_characters

const gul14::string_view task::Tag::valid_characters { "abcdefghijklmnopqrstuvwxyz0123456789-" }
static

A string containing all of the valid characters for a tag name.

Referenced by check_validity().


The documentation for this class was generated from the following files: