guanaqo 1.0.0-alpha.27
Utilities for scientific software
Loading...
Searching...
No Matches
Strings & Parsing

Detailed Description

String utilities and portable parsing helpers.

Collaboration diagram for Strings & Parsing:

Files

file  duration-parse.hpp
 Duration parsing helpers.
file  from_chars-wrapper.hpp
 Portable wrapper around std::from_chars for integers and floats.
file  string-util.hpp
 String utilities for splitting, joining, and sorting.

Classes

struct  guanaqo::invalid_duration_value
struct  guanaqo::invalid_duration_units
struct  guanaqo::join_opt
struct  guanaqo::join_quote_opt

Functions

template<class Rep, class Period>
std::string_view guanaqo::parse_single_duration (std::chrono::duration< Rep, Period > &t, std::string_view s)
 Adds the first duration in the string s to the duration t.
template<class Rep, class Period>
void guanaqo::parse_duration (std::chrono::duration< Rep, Period > &t, std::string_view s)
 Adds the sum of the durations in the string s to the duration t.
template<class T>
std::from_chars_result guanaqo::from_chars (const char *first, const char *last, T &value, std::chars_format fmt=std::chars_format::general)
template<class T>
std::from_chars_result guanaqo::from_chars (const char *first, const char *last, T &value, int base=10)
template<class T, class... Args>
std::from_chars_result guanaqo::from_chars (const char *first, const char *last, T &value, std::chars_format fmt=std::chars_format::general)
template<class T, class... Args>
std::from_chars_result guanaqo::from_chars (const char *first, const char *last, T &value, int base=10)
auto guanaqo::split (std::string_view full, std::string_view tok)
 Split the string full on the first occurrence of tok.
auto guanaqo::split_second (std::string_view full, std::string_view tok)
 Split the string s on the first occurrence of tok.
std::string guanaqo::join (std::ranges::input_range auto strings, join_opt opt={})
 Join the list of strings into a single string, using the separator given by opt.
std::string guanaqo::join_quote (std::ranges::input_range auto strings, join_quote_opt opt={})
 Join the list of strings into a single string, using the separator given by opt.
void guanaqo::sort_case_insensitive (auto &range)
 Sort the given range of strings in-place in a case-insensitive manner.

Class Documentation

◆ guanaqo::join_opt

struct guanaqo::join_opt
Collaboration diagram for guanaqo::join_opt:
Class Members
string_view sep = ", "
string_view empty = "∅"

◆ guanaqo::join_quote_opt

struct guanaqo::join_quote_opt
Collaboration diagram for guanaqo::join_quote_opt:
Class Members
string_view sep = ", "
string_view empty = "∅"
string_view quote_left = "\""
string_view quote_right = "\""

Function Documentation

◆ parse_single_duration()

template<class Rep, class Period>
std::string_view guanaqo::parse_single_duration ( std::chrono::duration< Rep, Period > & t,
std::string_view s )

#include <guanaqo/duration-parse.hpp>

Adds the first duration in the string s to the duration t.

Definition at line 34 of file duration-parse.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_duration()

template<class Rep, class Period>
void guanaqo::parse_duration ( std::chrono::duration< Rep, Period > & t,
std::string_view s )

#include <guanaqo/duration-parse.hpp>

Adds the sum of the durations in the string s to the duration t.

Definition at line 77 of file duration-parse.hpp.

Here is the call graph for this function:

◆ from_chars() [1/4]

template<class T>
std::from_chars_result guanaqo::from_chars ( const char * first,
const char * last,
T & value,
std::chars_format fmt = std::chars_format::general )

#include <guanaqo/from_chars-wrapper.hpp>

Definition at line 51 of file from_chars-wrapper.hpp.

Here is the caller graph for this function:

◆ from_chars() [2/4]

template<class T>
std::from_chars_result guanaqo::from_chars ( const char * first,
const char * last,
T & value,
int base = 10 )

#include <guanaqo/from_chars-wrapper.hpp>

Definition at line 63 of file from_chars-wrapper.hpp.

◆ from_chars() [3/4]

template<class T, class... Args>
std::from_chars_result guanaqo::from_chars ( const char * first,
const char * last,
T & value,
std::chars_format fmt = std::chars_format::general )

#include <guanaqo/from_chars-wrapper.hpp>

Definition at line 75 of file from_chars-wrapper.hpp.

◆ from_chars() [4/4]

template<class T, class... Args>
std::from_chars_result guanaqo::from_chars ( const char * first,
const char * last,
T & value,
int base = 10 )

#include <guanaqo/from_chars-wrapper.hpp>

Definition at line 112 of file from_chars-wrapper.hpp.

◆ split()

auto guanaqo::split ( std::string_view full,
std::string_view tok )
inline

#include <guanaqo/string-util.hpp>

Split the string full on the first occurrence of tok.

Returns (s, "") if tok was not found.

Definition at line 21 of file string-util.hpp.

◆ split_second()

auto guanaqo::split_second ( std::string_view full,
std::string_view tok )
inline

#include <guanaqo/string-util.hpp>

Split the string s on the first occurrence of tok.

Returns ("", s) if tok was not found.

Definition at line 37 of file string-util.hpp.

◆ join()

std::string guanaqo::join ( std::ranges::input_range auto strings,
join_opt opt = {} )

#include <guanaqo/string-util.hpp>

Join the list of strings into a single string, using the separator given by opt.

See also
join_opt

Definition at line 60 of file string-util.hpp.

◆ join_quote()

std::string guanaqo::join_quote ( std::ranges::input_range auto strings,
join_quote_opt opt = {} )

#include <guanaqo/string-util.hpp>

Join the list of strings into a single string, using the separator given by opt.

Each original string is quoted using the quote strings specified by opt

See also
join_quote_opt

Definition at line 87 of file string-util.hpp.

◆ sort_case_insensitive()

void guanaqo::sort_case_insensitive ( auto & range)

#include <guanaqo/string-util.hpp>

Sort the given range of strings in-place in a case-insensitive manner.

Definition at line 109 of file string-util.hpp.