7#ifndef ARGS__UTILS_HPP__INCLUDED
8#define ARGS__UTILS_HPP__INCLUDED
25#define DISABLE_COPY(Class) \
26 Class(const Class &) = delete; \
27 Class &operator=(const Class &) = delete;
34#define UNUSED(Var) (void)Var;
45constexpr typename std::add_const<T>::type &
asConst(T &t)
noexcept
58static inline bool isArgument(
const String &word)
60 return (word.find(
SL(
"--")) == 0);
68static inline bool isFlag(
const String &word)
70 if (!isArgument(word)) {
71 if (word.find(
SL(
'-')) == 0) {
84static inline bool isCorrectFlag(
const String &flag)
86 if (flag.empty() || flag.length() > 1) {
90 static const String availableSymbols(
92 "abcdefghijklmnopqrstuvwxyz"
93 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
95 return (availableSymbols.find(flag) != String::npos);
103static inline bool isCorrectName(
const String &name)
109 static const String availableSymbols(
111 "abcdefghijklmnopqrstuvwxyz"
112 "ABCDEFGHIJKLMNOPQRSTUVWXYZ-_"));
115 if (availableSymbols.find(c) == String::npos) {
128static inline bool isMisspelledName(
const String &misspelled,
131 if (!misspelled.empty() && !correct.empty()) {
135 std::sort(ms.begin(), ms.end());
136 std::sort(cs.begin(), cs.end());
144template<
typename T =
void>
constexpr std::add_const< T >::type & asConst(T &t) noexcept
Adds const to non-const objects.
std::string String
String type.
String::value_type Char
Char type.
static const String c_string