![]() |
Spicy
|
Classes | |
| class | Cache |
| class | SourceCodePreprocessor |
| class | Uniquer |
Functions | |
| void | cannot_be_reached () __attribute__((noreturn)) |
| template<typename T > | |
| std::string | typename_ () |
| template<typename... Args> | |
| std::string | fmt (const char *fmt, const Args &... args) |
| template<typename X , typename F > | |
| auto | transform_to_vector (const std::set< X > &x, F f) |
| template<typename C , typename F > | |
| auto | filter (const C &x, F f) |
| template<typename T , typename TIter = decltype(std::begin(std::declval<T>())), typename = decltype(std::end(std::declval<T>()))> | |
| constexpr auto | enumerate (T &&iterable) |
| std::vector< std::string > | split (std::string s, const std::string &delim=" ") |
| std::pair< std::string, std::string > | split1 (std::string s, const std::string &delim=" ") |
| std::pair< std::string, std::string > | rsplit1 (std::string s, const std::string &delim=" ") |
| template<typename T > | |
| std::vector< T > | slice (const std::vector< T > &v, int begin, int end=-1) |
| template<typename T > | |
| std::string | join (const T &l, const std::string &delim="") |
| template<typename T > | |
| std::string | join (const std::initializer_list< T > &l, const std::string &delim="") |
| template<typename iterator > | |
| std::string | join (const iterator &begin, const iterator &end, const std::string &delim="") |
| std::string | prefixParts (const std::string &in, const std::string &prefix, const std::string &include_tag="") |
| std::vector< std::string > | flattenParts (const std::vector< std::string > &in) |
| std::string | replace (const std::string &s, const std::string &o, const std::string &n) |
| std::string | tolower (const std::string &s) |
| std::string | toupper (const std::string &s) |
| std::string | trim (const std::string &s) |
| std::string | rtrim (const std::string &s) |
| std::string | ltrim (const std::string &s) |
| bool | startsWith (const std::string &s, const std::string &prefix) |
| bool | endsWith (const std::string &s, const std::string &suffix) |
| uint64_t | hash (const std::string &str) |
| uint64_t | hash (const char *data, size_t len) |
| constexpr std::pair< intmax_t, intmax_t > | signed_integer_range (int width) |
| constexpr std::pair< uintmax_t, uintmax_t > | unsigned_integer_range (int width) |
| template<typename Error > | |
| uint64_t | chars_to_uint64 (const char *dgts, unsigned int base, Error handler) |
| template<typename Error > | |
| double | chars_to_double (const char *dgts, Error handler) |
| std::string | uitoa_n (uint64_t value, unsigned int base, int n=-1) |
| std::string | escapeBytesForCxx (std::string_view s) |
| std::string | toIdentifier (const std::string &s, bool ensure_non_keyword=false) |
| double | currentTime () |
| hilti::Result< hilti::rt::filesystem::path > | findInPaths (const hilti::rt::filesystem::path &file, const std::vector< hilti::rt::filesystem::path > &paths) |
| hilti::rt::filesystem::path | currentExecutable () |
| void | abort_with_backtrace () |
| template<class Iter , typename Result > | |
| auto | atoi_n (Iter s, Iter e, int base, Result *result) |
| template<typename A , typename B > | |
| std::list< std::pair< A, B > > | zip2 (const std::list< A > &lhs, const std::list< B > &rhs) |
| template<typename A , typename B > | |
| std::vector< std::pair< A, B > > | zip2 (const std::vector< A > &lhs, const std::vector< B > &rhs) |
| template<typename A , typename B > | |
| std::set< A > | map_keys (const std::map< A, B > &m) |
| template<typename A , typename B > | |
| std::set< B > | map_values (const std::map< A, B > &m) |
| template<typename A , typename B > | |
| std::set< A > | map_keys (const std::unordered_map< A, B > &m) |
| template<typename A , typename B > | |
| std::set< B > | map_values (const std::unordered_map< A, B > &m) |
| template<typename A , typename Compare = std::less<A>> | |
| std::set< A, Compare > | set_difference (const std::set< A, Compare > &a, const std::set< A, Compare > &b) |
| template<typename A , typename Compare = std::less<A>> | |
| std::set< A, Compare > | set_intersection (std::set< A, Compare > &a, std::set< A, Compare > &b) |
| template<typename A , typename Compare = std::less<A>> | |
| std::set< A, Compare > | set_union (const std::set< A, Compare > &a, const std::set< A, Compare > &b) |
| template<typename T > | |
| std::vector< T > | concat (std::vector< T > v1, const std::vector< T > &v2) |
| template<typename T > | |
| std::vector< T > & | append (std::vector< T > &v1, const std::vector< T > &v2) |
| template<typename T > | |
| std::vector< T > | remove_duplicates (std::vector< T > v) |
| template<typename T > | |
| std::string | uniqueIndex (const T &c, std::string hint) |
| bool | copyStream (std::istream &in, std::ostream &out) |
| std::optional< hilti::rt::filesystem::path > | cacheDirectory (const hilti::Configuration &configuration) |
API to measure execution times and frequency for code area.
| void hilti::util::abort_with_backtrace | ( | ) |
Dumps a backtrace to stderr and then aborts execution.
| std::vector<T>& hilti::util::append | ( | std::vector< T > & | v1, |
| const std::vector< T > & | v2 | ||
| ) |
Appends a vector to another one.
|
inline |
Parses an string into an integer value.
| std::optional< hilti::rt::filesystem::path > hilti::util::cacheDirectory | ( | const hilti::Configuration & | configuration | ) |
Computes path to directory for cached artifacts
| configuration | the configuration to use |
| void hilti::util::cannot_be_reached | ( | ) |
Aborts with an internal error saying we should not be where we are.
| double hilti::util::chars_to_double | ( | const char * | dgts, |
| Error | handler | ||
| ) |
Converts digits to double precision floating point.
| dgts | null-terminated chars: decimal floating-point or hexfloat format. |
| handler | an error-handling function object or lambda. |
| uint64_t hilti::util::chars_to_uint64 | ( | const char * | dgts, |
| unsigned int | base, | ||
| Error | handler | ||
| ) |
Converts digits to an unsigned integer relative to a given base.
| dgts | null-terminated chars: decimal digits, hexits or base-n-digits |
| base | base to use {0,2,3,...,36} (base 0 auto-detects like strtoull). |
| handler | an error-handling function object or lambda. |
| std::vector<T> hilti::util::concat | ( | std::vector< T > | v1, |
| const std::vector< T > & | v2 | ||
| ) |
Concatenates two vectors into a new one.
|
inline |
Copies the content of one stream into another one. Returns true if successful.
| hilti::rt::filesystem::path hilti::util::currentExecutable | ( | ) |
Returns the path of the current executable.
| double hilti::util::currentTime | ( | ) |
Returns the current time in seconds since the epoch.
| bool hilti::util::endsWith | ( | const std::string & | s, |
| const std::string & | suffix | ||
| ) |
Returns true if a string ends with another.
| constexpr auto hilti::util::enumerate | ( | T && | iterable | ) |
Python-style enumerate() that returns an iterable yielding pairs (index, val). From http://reedbeta.com/blog/python-like-enumerate-in-cpp17/.
|
inline |
Wrapper for escapeBytes that produces a valid C++ string literal.
| s | string to escape |
| auto hilti::util::filter | ( | const C & | x, |
| F | f | ||
| ) |
Filters a container through a boolean predicate.
| hilti::Result< hilti::rt::filesystem::path > hilti::util::findInPaths | ( | const hilti::rt::filesystem::path & | file, |
| const std::vector< hilti::rt::filesystem::path > & | paths | ||
| ) |
Search a file name inside a given set of paths.
| std::vector< std::string > hilti::util::flattenParts | ( | const std::vector< std::string > & | in | ) |
For each string in a vector, splits them into white-space delimited pieces, then joins all pieces into a single new vector of strings.
| in | vector with strings to each splits |
| std::string hilti::util::fmt | ( | const char * | fmt, |
| const Args &... | args | ||
| ) |
sprintf-style string formatting.
| uint64_t hilti::util::hash | ( | const std::string & | str | ) |
Returns a simple (non-crypto) hash value of a std::string.
| uint64_t hilti::util::hash | ( | const char * | data, |
| size_t | len | ||
| ) |
Returns a simple (non-crypto) hash value of a memory block.
| std::string hilti::util::join | ( | const T & | l, |
| const std::string & | delim = "" |
||
| ) |
Joins elements of a vector into a string, using a given delimiter to separate them.
| std::string hilti::util::join | ( | const std::initializer_list< T > & | l, |
| const std::string & | delim = "" |
||
| ) |
Joins elements of an initializer list into a string, using a given delimiter to separate them.
| std::string hilti::util::join | ( | const iterator & | begin, |
| const iterator & | end, | ||
| const std::string & | delim = "" |
||
| ) |
Joins elements of an iterable range into a string, using a given delimiter to separate then.
| std::string hilti::util::ltrim | ( | const std::string & | s | ) |
Returns a string with all leading white space removed.
| std::set<A> hilti::util::map_keys | ( | const std::map< A, B > & | m | ) |
Returns the keys of a map as a set.
| std::set<A> hilti::util::map_keys | ( | const std::unordered_map< A, B > & | m | ) |
Returns the keys of a map as a set.
| std::set<B> hilti::util::map_values | ( | const std::map< A, B > & | m | ) |
Returns the values of a map as a set.
| std::set<B> hilti::util::map_values | ( | const std::unordered_map< A, B > & | m | ) |
Returns the values of a map as a set.
| std::string hilti::util::prefixParts | ( | const std::string & | in, |
| const std::string & | prefix, | ||
| const std::string & | include_tag = "" |
||
| ) |
Splits a string into white-space-delimited pieces, prefixes each piece with another string, and then joins it all back together.
Optionally filters out strings with a specific tag: If an inclusion tag is specified, each string is inspected if it starts with !<tag>!. If it does, it's only included if tag == include_tag. Strings without tags are always included.
| in | string to split |
| prefix | prefix to add to each part |
| include_tag | filter tags |
| std::vector<T> hilti::util::remove_duplicates | ( | std::vector< T > | v | ) |
Remov duplicates from a vector without changing order.
| std::string hilti::util::replace | ( | const std::string & | s, |
| const std::string & | o, | ||
| const std::string & | n | ||
| ) |
Replaces all occurrences of one string with another.
| std::pair< std::string, std::string > hilti::util::rsplit1 | ( | std::string | s, |
| const std::string & | delim = " " |
||
| ) |
Splits a string once at the last occurrence of a delimiter. Leaves the 1st element of the result pair unset if the delimiter does not occur.
| std::string hilti::util::rtrim | ( | const std::string & | s | ) |
Returns a string with all trailing white space removed.
| std::set<A, Compare> hilti::util::set_difference | ( | const std::set< A, Compare > & | a, |
| const std::set< A, Compare > & | b | ||
| ) |
Returns the difference of two sets. This is a convenience wrapper around std::set_difference.
| std::set<A, Compare> hilti::util::set_intersection | ( | std::set< A, Compare > & | a, |
| std::set< A, Compare > & | b | ||
| ) |
Returns the intersection of two sets. This is a convenience wrapper around std::set_intersection.
| std::set<A, Compare> hilti::util::set_union | ( | const std::set< A, Compare > & | a, |
| const std::set< A, Compare > & | b | ||
| ) |
Returns the union of two sets. This is a convenience wrapper around std::set_union.
| constexpr std::pair<intmax_t, intmax_t> hilti::util::signed_integer_range | ( | int | width | ) |
Returns the valid value range for a signed integer of a given width. Supports only standard widths 8/16/32/64.
| std::vector<T> hilti::util::slice | ( | const std::vector< T > & | v, |
| int | begin, | ||
| int | end = -1 |
||
| ) |
Returns a subrange of a vector, specified through zero-based indices. If indices are out of range, they are cut back to start/end of input.
| v | vector to slice |
| begin | 1st index; if negative, counts from end Python-style |
| end | one beyond last index; if negative, counts from end Python-style |
| std::vector< std::string > hilti::util::split | ( | std::string | s, |
| const std::string & | delim = " " |
||
| ) |
Splits a string at all occurrences of a delimiter.
| std::pair< std::string, std::string > hilti::util::split1 | ( | std::string | s, |
| const std::string & | delim = " " |
||
| ) |
Splits a string once at the 1st occurrence of a delimiter. Leaves the 2nd element of the result pair unset if the delimiter does not occur.
|
inline |
Returns true if a string begins with another.
| std::string hilti::util::toIdentifier | ( | const std::string & | s, |
| bool | ensure_non_keyword = false |
||
| ) |
Turns an arbitrary string into something that can be used as C-level identifier.
| s | string to convert. |
| ensure_non_keyword | if true, the returned ID will be expanded to make sure it won't accidentally match a compiler keyword. |
| std::string hilti::util::tolower | ( | const std::string & | s | ) |
Returns a lower-case version of a string.
| std::string hilti::util::toupper | ( | const std::string & | s | ) |
Returns a upper-case version of a string.
| auto hilti::util::transform_to_vector | ( | const std::set< X > & | x, |
| F | f | ||
| ) |
Applies a function to each element of a set, returning a vector with the results.
| std::string hilti::util::trim | ( | const std::string & | s | ) |
Returns a string with all leading & trailing white space removed.
| std::string hilti::util::typename_ | ( | ) |
Returns a type's demangled C++ name.
| std::string hilti::util::uitoa_n | ( | uint64_t | value, |
| unsigned int | base, | ||
| int | n = -1 |
||
| ) |
Converts an integer into a string relative to a given base.
| value | value to convert |
| base | base to use |
| n | The maximum number of characters to include. If the final string would be longer than this, it's cut off. If smaller than zero, includes all. |
| std::string hilti::util::uniqueIndex | ( | const T & | c, |
| std::string | hint | ||
| ) |
Given an associative container and an index hint, returns a new index value that doesn't exist in the container yet. If the hint itself doesn't exist yet, it's returned directly.
| constexpr std::pair<uintmax_t, uintmax_t> hilti::util::unsigned_integer_range | ( | int | width | ) |
Returns the valid value range for an unsigned integer of a given width. Supports only standard widths 8/16/32/64.
| std::list<std::pair<A, B> > hilti::util::zip2 | ( | const std::list< A > & | lhs, |
| const std::list< B > & | rhs | ||
| ) |
Pairs up the elements of two lists.
From http://stackoverflow.com/questions/10420380/c-zip-variadic-templates.
| std::vector<std::pair<A, B> > hilti::util::zip2 | ( | const std::vector< A > & | lhs, |
| const std::vector< B > & | rhs | ||
| ) |
Pairs up the elements of two vectors.
From http://stackoverflow.com/questions/10420380/c-zip-variadic-templates.
1.8.13