45template <
typename T>
inline T
clamp(T min, T max, T val) {
46 return std::max<T>(min, std::min<T>(max, val));
59inline bool indirect_equal(
const std::vector<T>& v0,
const std::vector<T>& v1) {
60 return std::equal(v0.begin(), v0.end(), v1.begin(),
61 [](
const T& a,
const T& b) { return *a == *b; });
73inline bool indirect_equal(
const std::shared_ptr<T>& p0,
const std::shared_ptr<T>& p1) {
74 if (p0 !=
nullptr && p1 !=
nullptr)
77 return p0 ==
nullptr && p1 ==
nullptr;
88template <
typename T, const std::vector<std::shared_ptr<T>>& (T::*F)() const>
89inline void dfs(
const std::shared_ptr<T>& current,
90 std::function<
void(
const std::shared_ptr<T>&, std::size_t)> callback,
91 std::size_t level = 0) {
92 for (
auto child : ((current.get())->*F)()) {
94 callback(child, level);
95 dfs<T, F>(child, callback, level + 1);
Visibility/export macro for the shared library.
#define LIBKEEPASS_API
Marks a class, function or variable as part of the public ABI.
Definition export.hh:43
void dfs(const std::shared_ptr< T > ¤t, std::function< void(const std::shared_ptr< T > &, std::size_t)> callback, std::size_t level=0)
Definition util.hh:89
LIBKEEPASS_API std::string time_to_str(const std::time_t &time)
bool indirect_equal(const std::vector< T > &v0, const std::vector< T > &v1)
Definition util.hh:59
T clamp(T min, T max, T val)
Definition util.hh:45
LIBKEEPASS_API std::array< uint8_t, 16 > generate_uuid()
Generates a cryptographically random 128-bit UUID.