|
| const char * | libcamera::utils::basename (const char *path) |
| | Strip the directory prefix from the path.
|
| char * | libcamera::utils::secure_getenv (const char *name) |
| | Get an environment variable.
|
| std::string | libcamera::utils::dirname (const std::string &path) |
| | Identify the dirname portion of a path.
|
| template<typename T> |
| std::vector< typename T::key_type > | libcamera::utils::map_keys (const T &map) |
| | Retrieve the keys of a std::map<>.
|
| template<class InputIt1, class InputIt2> |
| unsigned int | libcamera::utils::set_overlap (InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2) |
| | Count the number of elements in the intersection of two ranges.
|
| struct timespec | libcamera::utils::duration_to_timespec (const duration &value) |
| | Convert a duration to a timespec.
|
| std::string | libcamera::utils::time_point_to_string (const time_point &time) |
| | Convert a time point to a string representation.
|
| template<typename T, std::enable_if_t< std::is_integral< T >::value > * = nullptr> |
| _hex | libcamera::utils::hex (T value, unsigned int width=0) |
| | Write an hexadecimal value to an output string.
|
| size_t | libcamera::utils::strlcpy (char *dst, const char *src, size_t size) |
| | Copy a string with a size limit.
|
| template<typename Container, typename UnaryOp> |
| std::string | libcamera::utils::join (const Container &items, const std::string &sep, UnaryOp op=nullptr) |
| | Join elements of a container in a string with a separator.
|
| details::StringSplitter | libcamera::utils::split (const std::string &str, const std::string &delim) |
| | Split a string based on a delimiter.
|
| std::string | libcamera::utils::toAscii (const std::string &str) |
| | Remove any non-ASCII characters from a string.
|
| std::string | libcamera::utils::libcameraBuildPath () |
| | Retrieve the path to the build directory.
|
| std::string | libcamera::utils::libcameraSourcePath () |
| | Retrieve the path to the source directory.
|
| constexpr unsigned int | libcamera::utils::alignDown (unsigned int value, unsigned int alignment) |
| | Align value down to alignment.
|
| constexpr unsigned int | libcamera::utils::alignUp (unsigned int value, unsigned int alignment) |
| | Align value up to alignment.
|
| template<typename T> |
| details::reverse_adapter< T > | libcamera::utils::reverse (T &&iterable) |
| | Wrap an iterable to reverse iteration in a range-based loop.
|
|
template<typename T> |
| auto | libcamera::utils::enumerate (T &iterable) -> details::enumerate_adapter< decltype(iterable.begin())> |
| template<typename T> |
| decltype(auto) | libcamera::utils::abs_diff (const T &a, const T &b) |
| | Calculates the absolute value of the difference between two elements.
|
| double | libcamera::utils::strtod (const char *__restrict nptr, char **__restrict endptr) |
| | Convert a string to a double independently of the current locale.
|
| template<class Enum> |
| constexpr std::underlying_type_t< Enum > | libcamera::utils::to_underlying (Enum e) noexcept |
| | Convert an enumeration to its underlygin type.
|
Miscellaneous utility functions.
template<typename T, std::enable_if_t< std::is_integral< T >::value > * = nullptr>
| _hex libcamera::utils::hex |
( |
T | value, |
|
|
unsigned int | width = 0 ) |
Write an hexadecimal value to an output string.
- Parameters
-
| value | The value |
| width | The width |
Return an object of unspecified type such that, if os is the name of an output stream of type std::ostream, and T is an integer type, then the expression
will output the value to the stream in hexadecimal form with the base prefix and the filling character set to '0'. The field width is set to width if specified to a non-zero value, or to the native width of type T otherwise. The os stream configuration is not modified.
template<typename Container, typename UnaryOp>
| std::string libcamera::utils::join |
( |
const Container & | items, |
|
|
const std::string & | sep, |
|
|
UnaryOp | op = nullptr ) |
Join elements of a container in a string with a separator.
- Parameters
-
| [in] | items | The container |
| [in] | sep | The separator to add between elements |
| [in] | op | A function that converts individual elements to strings |
This function joins all elements in the items container into a string and returns it. The sep separator is added between elements. If the container elements are not implicitly convertible to std::string, the op function shall be provided to perform conversion of elements to std::string.
- Returns
- A string that concatenates all elements in the container
| std::string libcamera::utils::libcameraBuildPath |
( |
| ) |
|
Retrieve the path to the build directory.
During development, it is useful to run libcamera binaries directly from the build directory without installing them. This function helps components that need to locate resources in the build tree, such as IPA modules or IPA proxy workers, by providing them with the path to the root of the build directory. Callers can then use it to complement or override searches in system-wide directories.
If libcamera has been installed, the build directory path is not available and this function returns an empty string.
- Returns
- The path to the build directory if running from a build, or an empty string otherwise
| std::string libcamera::utils::libcameraSourcePath |
( |
| ) |
|
Retrieve the path to the source directory.
During development, it is useful to run libcamera binaries directly from the build directory without installing them. This function helps components that need to locate resources in the source tree, such as IPA configuration files, by providing them with the path to the root of the source directory. Callers can then use it to complement or override searches in system-wide directories.
If libcamera has been installed, the source directory path is not available and this function returns an empty string.
- Returns
- The path to the source directory if running from a build directory, or an empty string otherwise
template<class InputIt1, class InputIt2>
| unsigned int libcamera::utils::set_overlap |
( |
InputIt1 | first1, |
|
|
InputIt1 | last1, |
|
|
InputIt2 | first2, |
|
|
InputIt2 | last2 ) |
Count the number of elements in the intersection of two ranges.
Count the number of elements in the intersection of the sorted ranges [first1, last1) and [first1, last2). Elements are compared using operator< and the ranges must be sorted with respect to the same.
- Returns
- The number of elements in the intersection of the two ranges