Section containing core functions and classes. More...
Classes | |
class | array |
A wrapper for std::vector. More... | |
interface | arrayLike |
An interface for all objects that can be both iterated over and directly indexed. More... | |
class | circularBuffer |
A circular buffer of fixed size. Appending can be done indefinitely, as the index will just loop back around to the beginning. More... | |
class | circularIterator |
A custom iterator for circular buffers. More... | |
class | generator |
An arbitrary generator for producing sequential results on-the-fly. More... | |
class | generatorIter |
Custom iterator for generators to allow for range-based for loops. More... | |
struct | hash32gen |
A compile-time CRC32 hash function. More... | |
struct | hash32gen< size, size, dummy > |
The stopping specialization for the hash32 template. More... | |
interface | indexable |
A base interface for all objects whose elements can be directly indexed. More... | |
interface | iterable |
A base interface for all objects that can be iterated over. More... | |
class | memoize< R(Args...)> |
A memoization class that caches the results of a function. More... | |
class | refArray |
An extension of the core::array class which assumes all elements to be pointers. More... | |
class | sentinel |
A sentinel that stops a numeric generator when the value reaches a certain point. More... | |
interface | sizable |
An interface for getting an object's size. More... | |
class | sortedArray |
An extension of the core::array class which attempts to keep all data sorted. More... | |
class | sortedRefArray |
An extension of the core::sortedArray class, specialized for pointers. More... | |
class | string |
A template class for character strings. More... | |
class | stringIterator |
A class for iterating over each character in a string. More... | |
class | timeout |
A class for easily managing timing. More... | |
class | timer |
A class for easily managing timers. More... | |
struct | yield |
The return value for generator functions. More... | |
Typedefs | |
template<typename T > | |
using | deref_type = std::remove_const_t< std::remove_reference_t< decltype(*std::declval< decltype(std::declval< T >().begin())>())> > |
The type of the dereferenced value from an iterable. This is used to determine the type of value that the generator will yield. | |
template<typename T > | |
using | iter_type = std::remove_const_t< decltype(std::declval< T >().begin())> |
The type of the iterator for an iterable. This is used to determine the type of iterator that the generator will use. | |
Functions | |
bool | isUpperAlpha (uint32_t ch) noexcept |
Check if the given character is an uppercase alphabetic character. | |
bool | isLowerAlpha (uint32_t ch) noexcept |
Check if the given character is a lowercase alphabetic character. | |
bool | isUpper (uint32_t ch) noexcept |
Check if the given character is an uppercase character. | |
bool | isLower (uint32_t ch) noexcept |
Check if the given character is a lowercase character. | |
uint32_t | toUpper (uint32_t ch, bool camel=false) noexcept |
Convert the given character to uppercase. | |
uint32_t | toLower (uint32_t ch, bool alternate=false) noexcept |
Convert the given character to lowercase. | |
bool | isAlpha (uint32_t ch) noexcept |
Check if the given character is an alphabetic character. | |
int | numeralValue (uint32_t ch) noexcept |
Convert the given character to its respective numeral value. | |
uint32_t | numeral (int value) noexcept |
Convert the given value to its respective numeral character. | |
bool | isNumeric (uint32_t ch, int base=10) noexcept |
Check if the given character is numeric under the given base. | |
bool | isAlphaNumeric (uint32_t ch) noexcept |
Check if the given character is alphanumeric. | |
bool | isWhiteSpace (uint32_t ch) noexcept |
Check if the given character is white space. | |
int | toUTF8 (uint8_t *c, uint32_t chr) noexcept |
Convert a character to UTF-8 encoding. | |
int | lenToUTF8 (uint32_t chr) noexcept |
Get the length of the UTF-8 encoding for a character. | |
uint32_t | fromUTF8 (uint8_t *c) noexcept |
Convert a character from UTF-8 to UTF32 encoding. | |
int | lenFromUTF8 (uint8_t *c) noexcept |
Get the character length of a UTF-8 sequence. | |
bool | isUTF8 (uint8_t *c, int len) noexcept |
Get whether the characters are in valid UTF-8 format. | |
template<typename T > | |
generator< deref_type< T >, iter_type< T > > | generatorFrom (const T &list) |
Create a generator from an arbitrary iterable. | |
template<typename T > | |
generator< deref_type< T >, std::pair< T, iter_type< T > > > | generatorFrom (const T &&list) |
Create a generator from an arbitrary temporary iterable. | |
template<typename T > | |
generator< T, std::pair< array< T >, long > > | generatorFrom (std::initializer_list< T > list) |
Create a generator from an initializer list. | |
template<typename K , typename V > | |
generator< std::pair< K, V >, typename std::map< K, V >::const_iterator > | generatorFrom (const std::map< K, V > &map) |
Create a generator from a map. | |
template<typename K , typename V > | |
generator< std::pair< K, V >, std::pair< typename std::map< K, V >::const_iterator, std::map< K, V > > > | generatorFrom (std::map< K, V > &&map) |
Create a generator from a temporary map. | |
hash32 | crc32 (const char *str, int size) noexcept |
Computes the CRC32 hash of a string at runtime. | |
constexpr hash32 | crc32 (const char *str) noexcept |
template<typename T , encoding E> | |
string< E > | join (const iterable< T > &list, const string< E > &delim) noexcept |
Concatenate elements in an array into a string, separated by a delimiter. | |
template<typename T > | |
zstring | join (const iterable< T > &list, const zstring &delim) noexcept |
Concatenate elements in an array into a string, separated by a delimiter. | |
zstring | join (const std::vector< std::string > &list, const zstring &delim) noexcept |
Concatenate elements in an array into a string, separated by a delimiter. | |
template<typename T , encoding E> | |
string< E > | joinDeref (const iterable< T > &list, const string< E > &delim) noexcept |
Dereference elements in an array and concatenate them into a string, separated by a delimiter. | |
generator< long, long > | range (long begin, long end, long step=1) noexcept |
Generate a sequence of integers in a specified range. | |
generator< long, long > | range (long end) noexcept |
Generate a sequence of integers from 0 until the specified end point. | |
generator< long, long > | range (long begin, const sentinel &check, long step=1) noexcept |
Generate a sequence of integers in a specified range. | |
template<typename T > | |
std::enable_if< std::is_base_of< z::core::sizable, T >::value >::type | size (const T &object, size_t &bytes) noexcept |
Get the size of a sizable object. | |
template<typename T > | |
std::enable_if<!std::is_base_of< z::core::sizable, T >::value >::type | size (const T &object, size_t &bytes) noexcept |
Get the size of a non-sizable object or datatype. | |
template<encoding E> | |
array< string< E > > | split (const string< E > &input, const string< E > &delim="") noexcept |
Split a string into an array of strings according to a specified delimiter. | |
Variables | |
const sentinel | infinity |
A sentinel that tells numeric generators to run forever. | |
Section containing core functions and classes.
This section adds core functionality and is required as it is often referenced by other parts of the library. It can be used by itself, however, as it does not require any libraries besides STL.
using z::core::deref_type = typedef std::remove_const_t<std::remove_reference_t<decltype(*std::declval<decltype(std::declval<T>().begin())>())> > |
The type of the dereferenced value from an iterable. This is used to determine the type of value that the generator will yield.
T |
using z::core::iter_type = typedef std::remove_const_t<decltype(std::declval<T>().begin())> |
The type of the iterator for an iterable. This is used to determine the type of iterator that the generator will use.
T |
Computes the CRC32 hash of a string at runtime.
This function is not constexpr and can be used for strings that are not known at compile time.
str | The string to hash. |
size | The size of the string. |
Convert a character from UTF-8 to UTF32 encoding.
c | The UTF-8 sequence. Assumed to be a 4-item array. |
generator< std::pair< K, V >, typename std::map< K, V >::const_iterator > z::core::generatorFrom | ( | const std::map< K, V > & | map | ) |
Create a generator from a map.
K | The type of the key in the map. |
V | The type of the value in the map. |
map | The map to create a generator from. |
generator< deref_type< T >, std::pair< T, iter_type< T > > > z::core::generatorFrom | ( | const T && | list | ) |
Create a generator from an arbitrary temporary iterable.
T | The type of value that the iterable returns. |
list | The iterable to create a generator from. |
Create a generator from an arbitrary iterable.
T | The type of value that the iterable returns. |
list | The iterable to create a generator from. |
generator< T, std::pair< array< T >, long > > z::core::generatorFrom | ( | std::initializer_list< T > | list | ) |
Create a generator from an initializer list.
T | The type of value that the iterable returns. |
list | The initializer list to create a generator from. |
generator< std::pair< K, V >, std::pair< typename std::map< K, V >::const_iterator, std::map< K, V > > > z::core::generatorFrom | ( | std::map< K, V > && | map | ) |
Create a generator from a temporary map.
K | The type of the key in the map. |
V | The type of the value in the map. |
map | The map to create a generator from. |
Check if the given character is an alphabetic character.
ch | the character to check. |
Check if the given character is alphanumeric.
ch | The character to check. |
Check if the given character is a lowercase character.
ch | the character to check. |
Check if the given character is a lowercase alphabetic character.
This function differs from isLower() in that it only returns true for characters a-z
.
ch | the character to check. |
Check if the given character is numeric under the given base.
ch | The character to check. |
base | The base for this character. |
Check if the given character is an uppercase character.
ch | the character to check. |
Check if the given character is an uppercase alphabetic character.
This function differs from isUpper() in that it only returns true for characters A-Z
.
ch | the character to check. |
Get whether the characters are in valid UTF-8 format.
c | The character sequence. Assumed to have len characters. |
len | The characters in the sequence. Characters after the 4th will be ignored. |
Check if the given character is white space.
ch | The character to check. |
Concatenate elements in an array into a string, separated by a delimiter.
list | An iterable whose elements can implicitly convert to strings. |
delim | The delimiter to go between items. |
Concatenate elements in an array into a string, separated by a delimiter.
list | An iterable whose elements can implicitly convert to strings. |
delim | The delimiter to go between items. |
Concatenate elements in an array into a string, separated by a delimiter.
This is a specialization for joining a std::vector of std::strings into a single zstring.
list | A std::vector of std::string items. |
delim | The delimiter to go between items. |
Dereference elements in an array and concatenate them into a string, separated by a delimiter.
list | An iterable of pointers whose objects can implicitly convert to strings. |
delim | The delimiter to go between items. |
Get the character length of a UTF-8 sequence.
c | The UTF-8 sequence. Assumed to be a 4-item array. |
Get the length of the UTF-8 encoding for a character.
chr | The character to convert to UTF-8. |
Convert the given value to its respective numeral character.
0-9 give '0'-'9'. 10-36 give 'A'-'Z'.
value | the value to convert. |
Convert the given character to its respective numeral value.
'0'-'9' give 0-9. from 'A'-'Z' give 10-36. Case insensitive.
ch | the character to check. |
|
noexcept |
Generate a sequence of integers in a specified range.
begin | The beginning of the range (inclusive). |
check | The sentinel value that indicates when the end of the range has been reached. |
step | The step size. |
Generate a sequence of integers in a specified range.
begin | The beginning of the range (inclusive). |
end | The end of the range (exclusive). |
step | The step size. |
Generate a sequence of integers from 0 until the specified end point.
end | The end of the range (exclusive). |
|
inlinenoexcept |
Get the size of a sizable object.
Calls the object's size() method.
|
inlinenoexcept |
Get the size of a non-sizable object or datatype.
|
noexcept |
Split a string into an array of strings according to a specified delimiter.
input | The string to split into an array. |
delim | The delimiter that separates items. |
Convert the given character to lowercase.
ch | the character to convert. |
alternate | If true, use whatever alternate lowercase version a character has, if any (e.g. Σ →ς instead of Σ →σ ). |
Convert the given character to uppercase.
ch | the character to convert. |
camel | If true, convert characters with a camelCase version (e.g. NJ vs Nj vs nj ). If false, convert only to uppercase. |
Convert a character to UTF-8 encoding.
c | The UTF-8 sequence, returned by pointer. Assumed to be a 4-item array. |
chr | The character to convert to UTF-8. |