Skip to content
Snippets Groups Projects
Commit d6ac94e6 authored by Franck Dary's avatar Franck Dary
Browse files

deleted namespace brackets

parent 742b3673
Branches
No related tags found
No related merge requests found
...@@ -11,31 +11,28 @@ ...@@ -11,31 +11,28 @@
#include <ctime> #include <ctime>
#include <algorithm> #include <algorithm>
namespace util int util::printedLength(std::string_view s)
{
int printedLength(std::string_view s)
{ {
return splitAsUtf8(s).size(); return splitAsUtf8(s).size();
} }
std::string_view getFilenameFromPath(std::string_view s) std::string_view util::getFilenameFromPath(std::string_view s)
{ {
int indexOfSlash = s.find_last_of('/'); int indexOfSlash = s.find_last_of('/');
return {s.data()+indexOfSlash+1, s.size()-1-indexOfSlash}; return {s.data()+indexOfSlash+1, s.size()-1-indexOfSlash};
} }
bool isSeparator(utf8char c) bool util::isSeparator(utf8char c)
{ {
return c == ' ' || isIllegal(c); return c == ' ' || isIllegal(c);
} }
bool isIllegal(utf8char c) bool util::isIllegal(utf8char c)
{ {
return c == '\n' || c == '\t'; return c == '\n' || c == '\t';
} }
std::vector<std::string_view> split(std::string_view remaining, char delimiter) std::vector<std::string_view> util::split(std::string_view remaining, char delimiter)
{ {
std::vector<std::string_view> result; std::vector<std::string_view> result;
...@@ -52,7 +49,7 @@ std::vector<std::string_view> split(std::string_view remaining, char delimiter) ...@@ -52,7 +49,7 @@ std::vector<std::string_view> split(std::string_view remaining, char delimiter)
return result; return result;
} }
utf8string splitAsUtf8(std::string_view s) util::utf8string util::splitAsUtf8(std::string_view s)
{ {
utf8string result; utf8string result;
const char * beginPtr = s.data(); const char * beginPtr = s.data();
...@@ -78,28 +75,28 @@ utf8string splitAsUtf8(std::string_view s) ...@@ -78,28 +75,28 @@ utf8string splitAsUtf8(std::string_view s)
return result; return result;
} }
void warning(std::string_view message, const std::experimental::source_location & location) void util::warning(std::string_view message, const std::experimental::source_location & location)
{ {
fmt::print(stderr, "WARNING ({}) : {}\n", location, message); fmt::print(stderr, "WARNING ({}) : {}\n", location, message);
} }
void error(std::string_view message, const std::experimental::source_location & location) void util::error(std::string_view message, const std::experimental::source_location & location)
{ {
fmt::print(stderr, "ERROR ({}) : {}\n", location, message); fmt::print(stderr, "ERROR ({}) : {}\n", location, message);
exit(1); exit(1);
} }
void error(const std::exception & e, const std::experimental::source_location & location) void util::error(const std::exception & e, const std::experimental::source_location & location)
{ {
error(e.what(), location); error(e.what(), location);
} }
void myThrow(std::string_view message, const std::experimental::source_location & location) void util::myThrow(std::string_view message, const std::experimental::source_location & location)
{ {
throw std::invalid_argument(fmt::format("from ({}) {}", location, message)); throw std::invalid_argument(fmt::format("from ({}) {}", location, message));
} }
std::string int2HumanStr(int number) std::string util::int2HumanStr(int number)
{ {
std::string nb = std::to_string(number); std::string nb = std::to_string(number);
std::string result; std::string result;
...@@ -114,7 +111,7 @@ std::string int2HumanStr(int number) ...@@ -114,7 +111,7 @@ std::string int2HumanStr(int number)
return result; return result;
} }
bool doIfNameMatch(const std::regex & reg, const std::string & name, const std::function<void(const std::smatch &)> & f) bool util::doIfNameMatch(const std::regex & reg, const std::string & name, const std::function<void(const std::smatch &)> & f)
{ {
std::smatch sm; std::smatch sm;
std::regex_match(name, sm, reg); std::regex_match(name, sm, reg);
...@@ -124,7 +121,5 @@ bool doIfNameMatch(const std::regex & reg, const std::string & name, const std:: ...@@ -124,7 +121,5 @@ bool doIfNameMatch(const std::regex & reg, const std::string & name, const std::
f(sm); f(sm);
return true; return true;
}; }
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment