Adds further ext deps as-is binaries copies from customers env.
Qt6 Migration CI / migrate (push) Canceled after 0s
Qt6 Migration CI / migrate (push) Canceled after 0s
This commit is contained in:
3700 files changed
+2132394
No files matched your search
@@ -0,0 +1,75 @@
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
namespace ddkit {
|
||||
namespace utils {
|
||||
namespace callback {
|
||||
|
||||
template<class Actor, typename... Args>
|
||||
class Wrapper;
|
||||
|
||||
class Base {
|
||||
|
||||
public:
|
||||
virtual ~Base(){}
|
||||
|
||||
template<class Actor, typename... Args>
|
||||
void tryToInvoke(void (Actor::*func)(Args...), Args&&... args) {
|
||||
auto cb = dynamic_cast<Wrapper<Actor, Args...>*>(this);
|
||||
if(cb && cb->isFunction(func)){
|
||||
cb->invoke(args...);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<class Actor, typename... Args>
|
||||
class Wrapper : public Base {
|
||||
|
||||
public:
|
||||
using ActorType = Actor;
|
||||
using CallbackType = std::function<void(Args...)>;
|
||||
using ActorFunctionType = void (Actor::*)(Args...);
|
||||
|
||||
Wrapper() = delete;
|
||||
virtual ~Wrapper(){}
|
||||
|
||||
Wrapper(ActorFunctionType func, CallbackType cb)
|
||||
: m_actorFunction(func)
|
||||
, m_callback(cb)
|
||||
{
|
||||
}
|
||||
|
||||
bool isFunction(ActorFunctionType func){
|
||||
return m_actorFunction == func;
|
||||
}
|
||||
|
||||
void invoke(Args... args){
|
||||
m_callback(args...);
|
||||
}
|
||||
|
||||
private:
|
||||
friend class Base;
|
||||
|
||||
ActorFunctionType m_actorFunction;
|
||||
CallbackType m_callback;
|
||||
};
|
||||
|
||||
template<class Actor, typename... Args>
|
||||
Wrapper<Actor, Args...>* Callback(void (Actor::*pm)(Args...), std::function<void(Args...)> cb){
|
||||
return new Wrapper<Actor, Args...>(pm, cb);
|
||||
}
|
||||
|
||||
template<class Actor, typename... Args, typename Fn>
|
||||
Wrapper<Actor, Args...>* Callback(void (Actor::*pm)(Args...), const Fn& callback){
|
||||
return new Wrapper<Actor, Args...>(pm, std::function<void(Args...)>(callback));
|
||||
}
|
||||
|
||||
} // callback
|
||||
} // utils
|
||||
namespace callback = ddkit::utils::callback;
|
||||
} // ddkit
|
||||
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include <exception>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
namespace ddkit {
|
||||
namespace utils {
|
||||
namespace exceptions {
|
||||
|
||||
class GlobalHandler {
|
||||
|
||||
public:
|
||||
template<typename Exception> static void registerHandler(std::function<void(Exception&)> handler){
|
||||
instance().m_registeredHandlers.push_back([handler](std::exception_ptr exceptionPtr){
|
||||
try {
|
||||
std::rethrow_exception(exceptionPtr);
|
||||
} catch (Exception& e) {
|
||||
handler(e);
|
||||
} catch (...){
|
||||
// NO OP
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static void registerHandler(std::function<void(std::exception_ptr)> handler){
|
||||
instance().m_registeredHandlers.push_back(handler);
|
||||
}
|
||||
|
||||
private:
|
||||
std::terminate_handler m_previousHandler;
|
||||
std::vector<std::function<void(std::exception_ptr)>> m_registeredHandlers;
|
||||
|
||||
GlobalHandler();
|
||||
void handleException(const std::exception_ptr&);
|
||||
|
||||
static GlobalHandler& instance();
|
||||
static void terminateHandler();
|
||||
|
||||
};
|
||||
|
||||
} // namespace exceptions
|
||||
} // namespace utils
|
||||
} // namespace ddkit
|
||||
@@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
#include <iostream>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <cxxabi.h>
|
||||
#endif
|
||||
|
||||
//#define DDKIT_ENABLE_LIFETIME_LOGGER
|
||||
|
||||
namespace ddkit {
|
||||
namespace utils {
|
||||
namespace log {
|
||||
|
||||
|
||||
template <typename Type>
|
||||
class LifetimeLogger {
|
||||
public:
|
||||
LifetimeLogger() {
|
||||
#ifdef DDKIT_ENABLE_LIFETIME_LOGGER
|
||||
std::cerr << "Constructor of:\t" << typeName() << " @ " << this << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
~LifetimeLogger() {
|
||||
#ifdef DDKIT_ENABLE_LIFETIME_LOGGER
|
||||
std::cerr << "Destructor of: \t" << typeName() << " @ " << this << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
std::string typeName() const {
|
||||
#ifdef __GNUG__
|
||||
const char* mangled = typeid(Type).name();
|
||||
|
||||
int status = 0;
|
||||
char* name = abi::__cxa_demangle(mangled, nullptr, nullptr, &status);
|
||||
if(status == 0) {
|
||||
std::string demangledName(name);
|
||||
delete name;
|
||||
return demangledName;
|
||||
}
|
||||
return mangled;
|
||||
#else
|
||||
return typeid(Type).name();
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace log
|
||||
} // namespace utils
|
||||
} // namespace ddkit
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <functional>
|
||||
#include <fstream>
|
||||
#include <mutex>
|
||||
|
||||
#include "ddkit/utils/Logger.hpp"
|
||||
|
||||
namespace ddkit {
|
||||
namespace utils {
|
||||
namespace log {
|
||||
namespace sinks {
|
||||
|
||||
// writes all lines to std::ostream after applying ANSI color codes
|
||||
class OStreamSink : public Sink {
|
||||
|
||||
public:
|
||||
OStreamSink(const base::IConfig& config, std::ostream& stream);
|
||||
void write(Level level, const std::string& prefix, const std::string& line) override;
|
||||
|
||||
private:
|
||||
std::mutex m_writeMutex;
|
||||
bool m_doColorize;
|
||||
std::ostream& m_stream;
|
||||
static const Registrar<OStreamSink> s_registrarCerr;
|
||||
static const Registrar<OStreamSink> s_registrarCout;
|
||||
};
|
||||
|
||||
// writes all lines to logfile
|
||||
class FileSink : public Sink {
|
||||
|
||||
public:
|
||||
FileSink(const base::IConfig& config);
|
||||
void write(Level level, const std::string& prefix, const std::string& line) override;
|
||||
|
||||
private:
|
||||
void openFile();
|
||||
void rotateLog();
|
||||
void incrementFileRecursive(size_t count); // moves m_file<count> to m_file<count+1>
|
||||
|
||||
// log rotate settings
|
||||
bool m_rotateOnStartup;
|
||||
size_t m_rotateOnFileSize;
|
||||
size_t m_rotateOnLineCount;
|
||||
size_t m_rotateKeptFileCount;
|
||||
|
||||
size_t m_currentLinesInFile;
|
||||
|
||||
std::mutex m_writeMutex;
|
||||
std::mutex m_logRotateMutex;
|
||||
std::string m_filename;
|
||||
std::ofstream m_fh;
|
||||
static const Registrar<FileSink> s_registrar;
|
||||
};
|
||||
|
||||
} // namespace sinks
|
||||
} // namespace log
|
||||
} // namespace utils
|
||||
} // namespace ddkit
|
||||
+166
@@ -0,0 +1,166 @@
|
||||
#pragma once
|
||||
|
||||
#include "ddkit/utils/container.hpp"
|
||||
#include "ddkit/utils/system.hpp"
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <queue>
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
|
||||
// platforms either define __FUNCSIG__ (MSVC), or __PRETTY_FUNCTION__ (gcc, clang)
|
||||
#ifdef _WIN32
|
||||
#define DDKIT_LOG_FUNCSIG __FUNCSIG__
|
||||
#else
|
||||
#define DDKIT_LOG_FUNCSIG __PRETTY_FUNCTION__
|
||||
#endif
|
||||
|
||||
#define DDKIT_LOG_LOCATION (ddkit::utils::system::filename(std::string(__FILE__)) + ":" + __LINE__)
|
||||
#define DDKIT_LOG_LOCATION_STREAM ddkit::utils::system::filename(std::string(__FILE__)) << ":" << __LINE__ << ":" << DDKIT_LOG_FUNCSIG
|
||||
#define DDKIT_LOG_VAR_VALUE(val) #val << "==" << (val)
|
||||
|
||||
// Only for trace, there would be anyway a macro needed for line
|
||||
#define DDKIT_LOG_TRACE ddkit::utils::log::trace() << "(" << DDKIT_LOG_LOCATION_STREAM << ") "
|
||||
|
||||
namespace ddkit {
|
||||
namespace base {
|
||||
|
||||
class IConfig;
|
||||
class Config;
|
||||
}
|
||||
|
||||
namespace utils {
|
||||
namespace log {
|
||||
|
||||
enum class Level {
|
||||
None = 0x0, // 0b00000000
|
||||
Fatal = 0x1, // 0b00000001
|
||||
Error = 0x3, // 0b00000011
|
||||
Warn = 0x7, // 0b00000111
|
||||
Info = 0xF, // 0b00001111
|
||||
// ?? = 0x1F, // 0b00011111 RESERVED
|
||||
Debug = 0x3F, // 0b00111111
|
||||
// ?? = 0x7F, // 0b01111111 RESERVED
|
||||
Trace = 0xFF, // 0b11111111
|
||||
};
|
||||
|
||||
class Sink;
|
||||
typedef std::shared_ptr<Sink> SinkPtr;
|
||||
|
||||
class Logger {
|
||||
|
||||
using SinkFactoryFunction = std::function<SinkPtr(const base::IConfig&)>;
|
||||
|
||||
public:
|
||||
static void loadConfig(const base::Config&);
|
||||
static void registerSinkType(const std::string& id, const SinkFactoryFunction& factory);
|
||||
static void installSink(const std::string& id, const base::IConfig&);
|
||||
static void installSink(SinkPtr);
|
||||
static void write(Level, const std::string&);
|
||||
static void uninstallAllSinks();
|
||||
static Level getHighestUsedLevel();
|
||||
private:
|
||||
Logger();
|
||||
Logger(const Logger&) = delete;
|
||||
static Logger& instance();
|
||||
static std::string getPrefix(Level);
|
||||
|
||||
// shared_ptr/SinkPtr is used to circumvent the issue of having a collection of pure virtual class
|
||||
std::vector<SinkPtr> m_sinks;
|
||||
std::map<std::string, SinkFactoryFunction> m_sinkTypes;
|
||||
|
||||
// stored for performance reasons, aids in aborting early in LineBuilder if the log level isnt used
|
||||
Level mHighestLevel;
|
||||
};
|
||||
|
||||
class Sink {
|
||||
|
||||
public:
|
||||
template<class Type> class Registrar;
|
||||
Sink(const base::IConfig&);
|
||||
virtual ~Sink(){}
|
||||
virtual void write(Level level, const std::string& prefix, const std::string& line) = 0;
|
||||
|
||||
void setLevel(Level);
|
||||
void setLevel(const std::string&);
|
||||
Level getLevel() const;
|
||||
|
||||
private:
|
||||
Sink() = delete;
|
||||
|
||||
protected:
|
||||
Level m_level;
|
||||
};
|
||||
|
||||
template<class Type> class Sink::Registrar {
|
||||
|
||||
public:
|
||||
Registrar() = delete;
|
||||
// Registrar<FileSink>("file")
|
||||
Registrar(const std::string& id){
|
||||
Logger::registerSinkType(id, [](const base::IConfig& config){
|
||||
return std::make_shared<Type>(config);
|
||||
});
|
||||
}
|
||||
|
||||
// Registrar<OStreamSink>("cerr", std::cerr)
|
||||
template<class Param> Registrar(const std::string& id, Param& param){
|
||||
auto pRef = std::ref(param);
|
||||
Logger::registerSinkType(id, [pRef](const base::IConfig& config){
|
||||
return std::make_shared<Type>(config, pRef.get());
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/// @brief Stores a number of strings and writes them to log on destruction
|
||||
class LineBuilder {
|
||||
|
||||
public:
|
||||
LineBuilder(Level);
|
||||
LineBuilder() = delete;
|
||||
LineBuilder(const LineBuilder&) = delete;
|
||||
LineBuilder(LineBuilder&&);
|
||||
~LineBuilder();
|
||||
LineBuilder& operator<<(const std::string&);
|
||||
LineBuilder& operator<<(bool);
|
||||
|
||||
template<typename T> LineBuilder& operator<<(const T& value){
|
||||
if(Logger::getHighestUsedLevel() < m_level) return *this; // early abort for performance gains
|
||||
|
||||
m_line << value << " ";
|
||||
return *this;
|
||||
}
|
||||
|
||||
template<typename T> LineBuilder& operator<<(const std::vector<T>& vec){
|
||||
if(Logger::getHighestUsedLevel() < m_level) return *this; // early abort for performance gains
|
||||
|
||||
m_line << "[";
|
||||
for(auto it = vec.begin(); it != vec.end(); it++){
|
||||
*this << *it;
|
||||
if(vec.end() - it != 1){ // all except for the last element
|
||||
m_line << ", ";
|
||||
}
|
||||
}
|
||||
*this << "] ";
|
||||
return *this;
|
||||
}
|
||||
|
||||
private:
|
||||
Level m_level;
|
||||
std::ostringstream m_line;
|
||||
};
|
||||
|
||||
LineBuilder fatal();
|
||||
LineBuilder error();
|
||||
LineBuilder warn();
|
||||
LineBuilder info();
|
||||
LineBuilder debug();
|
||||
LineBuilder trace();
|
||||
|
||||
} // namespace log
|
||||
} // namespace utils
|
||||
|
||||
namespace log = ddkit::utils::log;
|
||||
|
||||
} // namespace ddkit
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "ddkit/utils/Logger.hpp"
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#define DDKIT_THROW_ON_FALSE(cond) \
|
||||
if (!(cond)) { \
|
||||
/*raise(SIGTRAP); */ \
|
||||
std::string msg = std::string("Assertion \"" #cond "\" failed in ") + __FILE__ + ":" + std::to_string(__LINE__); \
|
||||
ddkit::log::fatal() << msg; \
|
||||
throw std::logic_error(msg); \
|
||||
}
|
||||
|
||||
#define DDKIT_THROW_ON_FALSE_INFO(cond, info) \
|
||||
if (!(cond)) { \
|
||||
/*raise(SIGTRAP);*/ \
|
||||
std::string msg = std::string("Assertion \"" #cond "\" failed in ") + __FILE__ + ":" + std::to_string(__LINE__); \
|
||||
ddkit::log::fatal() << msg << " :" << std::string(info); \
|
||||
throw std::logic_error(msg + " :" + std::string(info)); \
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <ostream>
|
||||
#include <memory>
|
||||
|
||||
namespace ddkit {
|
||||
namespace utils {
|
||||
namespace container {
|
||||
|
||||
template <typename Container, typename Value>
|
||||
bool contains(Container container, Value value) {
|
||||
return std::find(container.begin(), container.end(), value) != container.end();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::vector<T> set2vector(std::set<T> p_set) {
|
||||
std::vector<T> r_vec;
|
||||
std::copy(p_set.begin(), p_set.end(), std::back_inserter(r_vec));
|
||||
return r_vec;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::set<T> vector2set(std::vector<T> p_vec) {
|
||||
std::set<T> r_set;
|
||||
std::copy(p_vec.begin(), p_vec.end(), std::inserter(r_set, r_set.begin()));
|
||||
return r_set;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
typename std::set<T> set_difference(typename std::set<T> const& minuend, typename std::set<T> const& subtrahend) {
|
||||
std::set<T> diff;
|
||||
std::set_difference(
|
||||
minuend.begin(),
|
||||
minuend.end(),
|
||||
subtrahend.begin(),
|
||||
subtrahend.end(),
|
||||
std::inserter(diff, diff.end()));
|
||||
return diff;
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
typename std::vector<T> vector_difference(typename std::vector<T> const& minuend, typename std::vector<T> const& subtrahend) {
|
||||
std::vector<T> diff;
|
||||
|
||||
std::copy_if(minuend.begin(), minuend.end(), std::back_inserter(diff), [subtrahend](const T& element) {
|
||||
return !contains(subtrahend, element);
|
||||
});
|
||||
return diff;
|
||||
}
|
||||
|
||||
inline std::string quotify(const std::string& input) { return "\"" + input+ "\""; }
|
||||
template<typename T> T quotify(T t) { return t; }
|
||||
|
||||
template <typename T>
|
||||
std::ostream& operator<<(std::ostream& s, std::vector<T> rhs) {
|
||||
bool isFirst = true;
|
||||
s << "[";
|
||||
for (auto const& i : rhs) {
|
||||
if (isFirst) isFirst = false;
|
||||
else s << ", ";
|
||||
s << quotify<T>(i);
|
||||
}
|
||||
s << "]";
|
||||
return s;
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
std::ostream& operator<<(std::ostream& s, std::pair<T, U> rhs) {
|
||||
return s << rhs.first << ":" << quotify<U>(rhs.second);
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
std::ostream& operator<<(std::ostream& s, std::map<T, U> rhs) {
|
||||
bool isFirst = true;
|
||||
s << "{";
|
||||
for (auto const& i : rhs) {
|
||||
if (isFirst) isFirst = false;
|
||||
else s << ", ";
|
||||
s << i;
|
||||
}
|
||||
s << "}";
|
||||
return s;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::ostream& operator<<(std::ostream& s, std::set<T> rhs) {
|
||||
bool isFirst = true;
|
||||
s << "[";
|
||||
for (auto const& i : rhs) {
|
||||
if (isFirst) isFirst = false;
|
||||
else s << ", ";
|
||||
s << quotify<T>(i);
|
||||
}
|
||||
s << "]";
|
||||
return s;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::ostream& operator<<(std::ostream& s, std::weak_ptr<T> rhs) {
|
||||
if(rhs.expired()){
|
||||
s << "<expired>";
|
||||
} else {
|
||||
s << rhs.lock();
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
} // container
|
||||
} // utils
|
||||
using ddkit::utils::container::operator<<;
|
||||
} // ddkit
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
|
||||
namespace ddkit {
|
||||
namespace utils {
|
||||
namespace types {
|
||||
|
||||
template <typename T>
|
||||
class Optional {
|
||||
|
||||
private:
|
||||
std::vector<T> &vec;
|
||||
|
||||
public:
|
||||
Optional(std::vector<T> &val) : vec(val) {}
|
||||
|
||||
Optional() = delete;
|
||||
|
||||
T& value() {
|
||||
if(vec.size()) {
|
||||
return vec[0];
|
||||
} else {
|
||||
throw std::out_of_range( "optional is empty" );
|
||||
}
|
||||
}
|
||||
|
||||
T value_or(T defVal) {
|
||||
return vec.size() ? vec[0] : (defVal);
|
||||
}
|
||||
|
||||
void reset() {
|
||||
if (vec.size()) {
|
||||
vec.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void set(const T &val) {
|
||||
if (vec.size()) {
|
||||
vec[0] = val;
|
||||
} else {
|
||||
vec.push_back(val);
|
||||
}
|
||||
}
|
||||
|
||||
bool has_value() const {
|
||||
return vec.size() ? true : false;
|
||||
}
|
||||
|
||||
std::vector<T> &operator*() {
|
||||
return vec[0];
|
||||
}
|
||||
|
||||
std::vector<T> *operator->() {
|
||||
return vec[0];
|
||||
}
|
||||
|
||||
Optional operator=(const T &val) {
|
||||
set(val);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
operator bool() const {
|
||||
return has_value();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace ddkit {
|
||||
namespace utils {
|
||||
namespace string {
|
||||
|
||||
bool beginsWith(const std::string& text, const std::string& prefix);
|
||||
bool endsWith(const std::string& text, const std::string& suffix);
|
||||
bool contains(const std::string& container, const std::string& containee);
|
||||
|
||||
void removePrefix(std::string& line, const std::string& prefix);
|
||||
void removePrefixIf(std::string& line, const std::string& prefix);
|
||||
void removeSuffix(std::string& line, const std::string& suffix);
|
||||
void removeSuffixIf(std::string& line, const std::string& suffix);
|
||||
|
||||
std::string trimLeft(const std::string& text);
|
||||
std::string trimRight(const std::string& text);
|
||||
std::string trim(const std::string& text);
|
||||
|
||||
std::string toLower(const std::string& text);
|
||||
std::string toUpper(const std::string& text);
|
||||
std::string toFirstUpper(const std::string& text);
|
||||
|
||||
std::string replace(std::string text, const std::string& from, const std::string& to);
|
||||
std::vector<std::string> split(const std::string& text, char delim);
|
||||
std::string join(const std::vector<std::string>&, const std::string& delimiter);
|
||||
|
||||
bool isInt(const std::string& text);
|
||||
int toInt(const std::string& text);
|
||||
bool isInt64(const std::string& text);
|
||||
int64_t toInt64(const std::string& text);
|
||||
|
||||
} // namespace string
|
||||
} // namespace utils
|
||||
} // namespace ddkit
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace ddkit {
|
||||
namespace utils {
|
||||
namespace system {
|
||||
|
||||
void sleep(int secs); // sleep seconds (instead of unix-sleep)
|
||||
void msSleep(int milliSecs); // sleep milliseconds (instead of unix-sleep)
|
||||
std::string getEnv(const std::string& var);
|
||||
std::string getEnv(const std::string& var, const std::string& defaultVal);
|
||||
bool setEnv(const std::string& name, const std::string& value);
|
||||
std::string dirname(std::string text); // "path/to/file.cpp" -> "path/to/"
|
||||
std::string filename(std::string text); // "path/to/file.cpp" -> "file" / "path/to/file.hpp" -> "file.hpp"
|
||||
std::string filenameBase(std::string text); // "path/to/file.xyz" -> "file.cpp" -> "file"
|
||||
int getProcessId();
|
||||
std::string getProcessName(); // "some_name"
|
||||
std::string getProcessNameWithPath(); // "/user/local/bin/some_name.exe"
|
||||
std::string getHostname();
|
||||
|
||||
std::string threadIdCurrent();
|
||||
|
||||
void blockSignals(); // blocks SIGINT/SIGHUP/SIGKILL for current thread. does nothing on windows
|
||||
void waitForSignal(); // waits for SIGINT/SIGHUP/SIGKILL, or windows ctrl-c
|
||||
|
||||
bool isFileReadable(const std::string& filename); // does a file exist and does open succeed?
|
||||
bool renameFile(const std::string& oldName, const std::string& newName);
|
||||
bool deleteFile(const std::string& name);
|
||||
void setNativeThreadName(const std::string& name);
|
||||
std::string getNativeThreadName();
|
||||
|
||||
} // namespace system
|
||||
} // namespace utils
|
||||
} // namespace ddkit
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
|
||||
|
||||
namespace ddkit {
|
||||
namespace utils {
|
||||
namespace time {
|
||||
|
||||
int64_t getCurrentUnixTimestamp();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user