Namespace podio::utils

namespace utils

Functions

std::vector<std::string> expand_glob(const std::string &pattern)

Expands a given glob pattern into a list of matching file paths.

This function takes a glob pattern as input and returns a vector of strings containing the paths that match the pattern. It supports standard glob rules extended with tilde expansion and brace expansion. If the pattern doesn’t contain any wildcards then it is placed in the returned vector as is. Paths that cannot be accessed are displayed on std::cerr, but the expansion process is not aborted. On platforms without <glob.h> no expansion is done and vector containing the original pattern is returned

Parameters:

pattern – The glob pattern to expand.

Throws:

std::runtime_error – If no matches are found or if there is an error during glob expansion.

Returns:

A vector of strings containing the matching file paths.

bool is_glob_pattern(const std::string &pattern)

Checks if a given pattern is a glob pattern.

This function determines whether the provided pattern contains any standard glob or brace expansion wildcards.

Parameters:

pattern – The pattern to check.

Returns:

true if the pattern is a glob pattern, false otherwise.

template<typename T>
void swap(MaybeSharedPtr<T> &a, MaybeSharedPtr<T> &b)
inline std::vector<std::string> sortAlphabeticaly(std::vector<std::string> strings)

Sort the input vector of strings alphabetically, case insensitive.

Parameters:

strings – The strings that should be sorted alphabetically

Returns:

A vector of strings sorted alphabetically, case insensitive

inline auto splitString(const std::string_view str, const char delim)

Split a string (view) at the delimiter and return a range of views.

Parameters:
  • str – The string to split

  • delim – The delimeter at which to split

Returns:

A range of views into the original view

Variables

static auto MarkOwned = detail::MarkOwnedTag{}
template<const std::string_view&... strs>
std::string_view static_concatenate_v = static_concatenate<strs...>::value

Variable template for concatenating a set of string_views into a single string_view at compile time.

template<typename T>
class MaybeSharedPtr
#include <podio/utilities/MaybeSharedPtr.h>

“Semi-smart” pointer class for pointers that at some point during their lifetime might hand over management to another entity.

E.g. Objects that are added to a collection will hand over the management of their Obj* to collection. In such a case two things need to be considered:

  • Other Objects with the same Obj* instance should not delete the managed Obj*, even if the last Object goes out of scope

  • Even if the managed Obj* is gone (e.g. collection has gone out of scope or was cleared), the remaining Object instances should still be able to gracefully destruct, even if they are at this point merely an “empty husk” The MaybeSharedPtr achieves this by having an optional control block that controls the lifetime of itself and potentially the managed Obj*.

Public Functions

MaybeSharedPtr() = delete

There are no empty MaybeSharedPtrs.

inline explicit MaybeSharedPtr(T *p)

Constructor from raw pointer.

Assumes someone else manages the pointer already

inline explicit MaybeSharedPtr(T *p, detail::MarkOwnedTag)

Constructor from a raw pointer assuming ownership in the process.

inline MaybeSharedPtr(const MaybeSharedPtr &other)

Copy constructor.

inline MaybeSharedPtr &operator=(MaybeSharedPtr other)

Assignment operator.

inline MaybeSharedPtr(MaybeSharedPtr &&other)

Move constructor.

inline ~MaybeSharedPtr()

Destructor.

inline T *get() const

Get a raw pointer to the managed pointer.

Do not change anything concerning the management of the pointer

inline T *release()

Get a raw pointer to the managed pointer and assume ownership.

inline operator bool() const
inline T *operator->()
inline const T *operator->() const
inline T &operator*()
inline const T &operator*() const

Friends

template<typename U>
friend void swap(MaybeSharedPtr<U> &a, MaybeSharedPtr<U> &b)
template<const std::string_view&... strs>
struct static_concatenate
#include <podio/utilities/StaticConcatenate.h>

Helper struct to concatenate a set of string_views into a single string_view at compile time.

Public Static Functions

static inline auto init_arr()

Public Static Attributes

static auto array = init_arr()
static auto value = std::string_view(array.data(), array.size() - 1)
template<typename ...T>
struct TypeList
#include <podio/utilities/TypeHelpers.h>