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

Detailed Description

A variable name is a string with limited functionality and some limitations on the allowed characters.

Basically, a variable name may only contain alphanumeric characters plus the underscore ("_"). It must start with a letter. Variable names are case sensitive and may not be more than 64 characters long.

#include <VariableName.h>

Public Types

using SizeType = std::string::size_type
 
using size_type = std::string::size_type
 

Public Member Functions

 VariableName (const char *name)
 Construct a variable name from a C string. More...
 
 VariableName (const std::string &name)
 Construct a variable name from a string. More...
 
 VariableName (std::string &&name)
 
SizeType length () const noexcept
 Return the length of the variable name string. More...
 
VariableNameoperator+= (gul14::string_view suffix)
 Append a suffix to a VariableName. More...
 
 operator const std::string & () const
 Convert the VariableName to a std::string. More...
 
SizeType size () const noexcept
 Return the length of the variable name string. More...
 
const std::string & string () const noexcept
 Return a const reference to the internal string member. More...
 

Private Attributes

std::string name_
 

Friends

bool operator== (const VariableName &a, const VariableName &b) noexcept
 Determine if two variable names are identical. More...
 
bool operator!= (const VariableName &a, const VariableName &b) noexcept
 Determine if two variable names differ. More...
 
bool operator< (const VariableName &a, const VariableName &b) noexcept
 Determine if the left variable name is lexicographically less than the right one. More...
 
bool operator> (const VariableName &a, const VariableName &b) noexcept
 Determine if the left variable name is lexicographically greater than the right one. More...
 
bool operator<= (const VariableName &a, const VariableName &b) noexcept
 Determine if the left variable name is lexicographically less than or equal to the right one. More...
 
bool operator>= (const VariableName &a, const VariableName &b) noexcept
 Determine if the left variable name is lexicographically greater than or equal to the right one. More...
 
std::string & operator+= (std::string &lhs, const VariableName &rhs)
 Append a VariableName to a std::string. More...
 
std::string operator+ (const VariableName &lhs, gul14::string_view rhs)
 Concatenate a VariableName and a string_view. More...
 
std::string operator+ (gul14::string_view lhs, const VariableName &rhs)
 Concatenate a string_view and a VariableName. More...
 

Member Typedef Documentation

◆ size_type

using task::VariableName::size_type = std::string::size_type

◆ SizeType

using task::VariableName::SizeType = std::string::size_type

Constructor & Destructor Documentation

◆ VariableName() [1/3]

task::VariableName::VariableName ( const char *  name)

Construct a variable name from a C string.

This constructor can be called implicitly to make the assignment of literal variable names easier.

Exceptions
Erroris thrown if the name is not a valid variable name.

References name_.

◆ VariableName() [2/3]

task::VariableName::VariableName ( const std::string &  name)
explicit

Construct a variable name from a string.

Exceptions
Erroris thrown if the name is not a valid variable name.

References name_.

◆ VariableName() [3/3]

task::VariableName::VariableName ( std::string &&  name)
explicit

References name_.

Member Function Documentation

◆ length()

SizeType task::VariableName::length ( ) const
inlinenoexcept

Return the length of the variable name string.

References name_.

◆ operator const std::string &()

task::VariableName::operator const std::string & ( ) const
inlineexplicit

Convert the VariableName to a std::string.

References name_.

◆ operator+=()

VariableName & task::VariableName::operator+= ( gul14::string_view  suffix)

Append a suffix to a VariableName.

Exceptions
Erroris thrown if the resulting variable name is not valid.

References name_.

◆ size()

SizeType task::VariableName::size ( ) const
inlinenoexcept

Return the length of the variable name string.

References name_.

◆ string()

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

Return a const reference to the internal string member.

References name_.

Friends And Related Function Documentation

◆ operator!=

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

Determine if two variable names differ.

◆ operator+ [1/2]

std::string operator+ ( const VariableName lhs,
gul14::string_view  rhs 
)
friend

Concatenate a VariableName and a string_view.

◆ operator+ [2/2]

std::string operator+ ( gul14::string_view  lhs,
const VariableName rhs 
)
friend

Concatenate a string_view and a VariableName.

◆ operator+=

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

Append a VariableName to a std::string.

◆ operator<

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

Determine if the left variable name is lexicographically less than the right one.

◆ operator<=

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

Determine if the left variable name is lexicographically less than or equal to the right one.

◆ operator==

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

Determine if two variable names are identical.

◆ operator>

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

Determine if the left variable name is lexicographically greater than the right one.

◆ operator>=

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

Determine if the left variable name is lexicographically greater than or equal to the right one.

Member Data Documentation

◆ name_

std::string task::VariableName::name_
private

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