HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
strutil.h File Reference

String-related utilities, all in namespace Strutil. More...

#include <cstdio>
#include <map>
#include <sstream>
#include <string>
#include <vector>
#include <OpenImageIO/export.h>
#include <OpenImageIO/hash.h>
#include <OpenImageIO/oiioversion.h>
#include <OpenImageIO/platform.h>
#include <OpenImageIO/string_view.h>
#include <OpenImageIO/detail/fmt.h>
#include <OpenImageIO/detail/farmhash.h>
+ Include dependency graph for strutil.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Strutil::StringHash
 
struct  Strutil::StringEqual
 C++ functor for comparing two strings for equality of their characters. More...
 
struct  Strutil::StringIEqual
 
struct  Strutil::StringLess
 C++ functor for comparing the ordering of two strings. More...
 
struct  Strutil::StringILess
 

Namespaces

 Strutil
 String-related utilities.
 
 Strutil::fmt
 
 Strutil::old
 

Macros

#define OIIO_HAS_SPRINTF   1
 
#define OIIO_FORMAT_IS_FMT   0
 
#define OIIO_FORMAT_DEPRECATED
 
#define OIIO_FMT_LOCALE_INDEPENDENT   1
 
#define OIIO_STRUTIL_HAS_STOF   1 /* be able to test this */
 

Enumerations

enum  Strutil::QuoteBehavior { Strutil::DeleteQuotes, Strutil::KeepQuotes }
 
enum  Strutil::EditDistMetric { Strutil::EditDistMetric::Levenshtein }
 

Functions

void OIIO_UTIL_API Strutil::sync_output (FILE *file, string_view str)
 
void OIIO_UTIL_API Strutil::sync_output (std::ostream &file, string_view str)
 
template<typename Str , typename... Args>
std::string Strutil::fmt::format (const Str &fmt, Args &&...args)
 
template<typename... Args>
OIIO_FORMAT_DEPRECATED std::string Strutil::old::format (const char *fmt, const Args &...args)
 
template<typename... Args>
OIIO_FORMAT_DEPRECATED std::string Strutil::old::format (string_view fmt, const Args &...args)
 
template<typename... Args>
void Strutil::printf (const char *fmt, const Args &...args)
 
template<typename... Args>
void Strutil::fprintf (FILE *file, const char *fmt, const Args &...args)
 
template<typename... Args>
void Strutil::fprintf (std::ostream &file, const char *fmt, const Args &...args)
 
template<typename... Args>
void Strutil::print (const char *fmt, const Args &...args)
 
template<typename... Args>
void Strutil::print (FILE *file, const char *fmt, const Args &...args)
 
template<typename... Args>
void Strutil::print (std::ostream &file, const char *fmt, const Args &...args)
 
std::string OIIO_UTIL_API Strutil::vsprintf (const char *fmt, va_list ap)
 
std::string OIIO_UTIL_API Strutil::vformat (const char *fmt, va_list ap)
 
std::string OIIO_UTIL_API Strutil::memformat (long long bytes, int digits=1)
 
std::string OIIO_UTIL_API Strutil::timeintervalformat (double secs, int digits=1)
 
bool OIIO_UTIL_API Strutil::get_rest_arguments (const std::string &str, std::string &base, std::map< std::string, std::string > &result)
 
std::string OIIO_UTIL_API Strutil::escape_chars (string_view unescaped)
 
std::string OIIO_UTIL_API Strutil::unescape_chars (string_view escaped)
 
std::string OIIO_UTIL_API Strutil::wordwrap (string_view src, int columns=80, int prefix=0, string_view sep=" ", string_view presep="")
 
OIIO_CONSTEXPR14 size_t Strutil::strhash (size_t len, const char *s)
 
OIIO_CONSTEXPR14 size_t Strutil::strhash (string_view s)
 
bool OIIO_UTIL_API Strutil::iequals (string_view a, string_view b)
 
bool OIIO_UTIL_API Strutil::iless (string_view a, string_view b)
 
bool OIIO_UTIL_API Strutil::starts_with (string_view a, string_view b)
 Does 'a' start with the string 'b', with a case-sensitive comparison? More...
 
bool OIIO_UTIL_API Strutil::istarts_with (string_view a, string_view b)
 
bool OIIO_UTIL_API Strutil::ends_with (string_view a, string_view b)
 Does 'a' end with the string 'b', with a case-sensitive comparison? More...
 
bool OIIO_UTIL_API Strutil::iends_with (string_view a, string_view b)
 
size_t OIIO_UTIL_API Strutil::find (string_view a, string_view b)
 
size_t OIIO_UTIL_API Strutil::ifind (string_view a, string_view b)
 
size_t OIIO_UTIL_API Strutil::rfind (string_view a, string_view b)
 
size_t OIIO_UTIL_API Strutil::irfind (string_view a, string_view b)
 
bool OIIO_UTIL_API Strutil::contains (string_view a, string_view b)
 Does 'a' contain the string 'b' within it? More...
 
bool OIIO_UTIL_API Strutil::icontains (string_view a, string_view b)
 
bool Strutil::rcontains (string_view a, string_view b)
 
bool Strutil::ircontains (string_view a, string_view b)
 
bool OIIO_UTIL_API Strutil::contains_any_char (string_view a, string_view set)
 Does 'a' contain any of the characters within set? More...
 
void OIIO_UTIL_API Strutil::to_lower (std::string &a)
 
void OIIO_UTIL_API Strutil::to_upper (std::string &a)
 
std::string Strutil::lower (string_view a)
 Return an all-upper case version of a (locale-independent). More...
 
std::string Strutil::upper (string_view a)
 Return an all-upper case version of a (locale-independent). More...
 
string_view OIIO_UTIL_API Strutil::strip (string_view str, string_view chars=string_view())
 
string_view OIIO_UTIL_API Strutil::lstrip (string_view str, string_view chars=string_view())
 
string_view OIIO_UTIL_API Strutil::rstrip (string_view str, string_view chars=string_view())
 
void OIIO_UTIL_API Strutil::split (string_view str, std::vector< string_view > &result, string_view sep=string_view(), int maxsplit=-1)
 
void OIIO_UTIL_API Strutil::split (string_view str, std::vector< std::string > &result, string_view sep=string_view(), int maxsplit=-1)
 
OIIO_UTIL_API std::vector
< std::string
Strutil::splits (string_view str, string_view sep="", int maxsplit=-1)
 
OIIO_UTIL_API std::vector
< string_view
Strutil::splitsv (string_view str, string_view sep="", int maxsplit=-1)
 
template<class Sequence >
std::string Strutil::join (const Sequence &seq, string_view sep="")
 
template<class Sequence >
std::string Strutil::join (const Sequence &seq, string_view sep, size_t len)
 
std::string OIIO_UTIL_API Strutil::concat (string_view s, string_view t)
 
std::string OIIO_UTIL_API Strutil::repeat (string_view str, int n)
 Repeat a string formed by concatenating str n times. More...
 
std::string OIIO_UTIL_API Strutil::replace (string_view str, string_view pattern, string_view replacement, bool global=false)
 
float OIIO_UTIL_API Strutil::strtof (const char *nptr, char **endptr=nullptr) noexcept
 
double OIIO_UTIL_API Strutil::strtod (const char *nptr, char **endptr=nullptr) noexcept
 
OIIO_UTIL_API int Strutil::stoi (string_view s, size_t *pos=0, int base=10)
 
OIIO_UTIL_API unsigned int Strutil::stoui (string_view s, size_t *pos=0, int base=10)
 
OIIO_UTIL_API float Strutil::stof (string_view s, size_t *pos=0)
 
OIIO_UTIL_API float Strutil::stof (const std::string &s, size_t *pos=0)
 
OIIO_UTIL_API float Strutil::stof (const char *s, size_t *pos=0)
 
OIIO_UTIL_API double Strutil::stod (string_view s, size_t *pos=0)
 
OIIO_UTIL_API double Strutil::stod (const std::string &s, size_t *pos=0)
 
OIIO_UTIL_API double Strutil::stod (const char *s, size_t *pos=0)
 
OIIO_UTIL_API bool Strutil::string_is_int (string_view s)
 
OIIO_UTIL_API bool Strutil::string_is_float (string_view s)
 
template<typename T >
Strutil::from_string (string_view s)
 
template<>
int Strutil::from_string< int > (string_view s)
 
template<>
unsigned int Strutil::from_string< unsigned int > (string_view s)
 
template<>
float Strutil::from_string< float > (string_view s)
 
template<>
double Strutil::from_string< double > (string_view s)
 
template<>
int64_t Strutil::from_string< int64_t > (string_view s)
 
template<>
uint64_t Strutil::from_string< uint64_t > (string_view s)
 
template<typename T >
std::string Strutil::to_string (const T &value)
 
std::string Strutil::to_string (const std::string &value)
 
std::string Strutil::to_string (string_view value)
 
std::string Strutil::to_string (const char *value)
 
template<typename T >
bool Strutil::string_is (string_view)
 
template<>
bool Strutil::string_is< int > (string_view s)
 
template<>
bool Strutil::string_is< float > (string_view s)
 
template<class T , class Allocator >
int Strutil::extract_from_list_string (std::vector< T, Allocator > &vals, string_view list, string_view sep=",")
 
template<class T >
std::vector< T > Strutil::extract_from_list_string (string_view list, size_t nvals=0, T val=T(), string_view sep=",")
 
OIIO_UTIL_API bool Strutil::scan_datetime (string_view str, int &year, int &month, int &day, int &hour, int &min, int &sec)
 
std::wstring OIIO_UTIL_API Strutil::utf8_to_utf16 (string_view utf8str) noexcept
 
std::string OIIO_UTIL_API Strutil::utf16_to_utf8 (const std::wstring &utf16str) noexcept
 
OIIO_UTIL_API char * Strutil::safe_strcpy (char *dst, string_view src, size_t size) noexcept
 
bool Strutil::isspace (char c)
 
void OIIO_UTIL_API Strutil::skip_whitespace (string_view &str) noexcept
 
void OIIO_UTIL_API Strutil::remove_trailing_whitespace (string_view &str) noexcept
 
void Strutil::trim_whitespace (string_view &str) noexcept
 
bool OIIO_UTIL_API Strutil::parse_char (string_view &str, char c, bool skip_whitespace=true, bool eat=true) noexcept
 
bool OIIO_UTIL_API Strutil::parse_until_char (string_view &str, char c, bool eat=true) noexcept
 
bool OIIO_UTIL_API Strutil::parse_prefix (string_view &str, string_view prefix, bool eat=true) noexcept
 
bool OIIO_UTIL_API Strutil::parse_int (string_view &str, int &val, bool eat=true) noexcept
 
bool OIIO_UTIL_API Strutil::parse_float (string_view &str, float &val, bool eat=true) noexcept
 
bool Strutil::parse_value (string_view &str, float &val, bool eat=true) noexcept
 Synonym for parse_int. More...
 
bool Strutil::parse_value (string_view &str, int &val, bool eat=true) noexcept
 Synonym for parse_float. More...
 
bool OIIO_UTIL_API Strutil::parse_values (string_view &str, string_view prefix, span< int > values, string_view sep="", string_view postfix="", bool eat=true) noexcept
 
bool OIIO_UTIL_API Strutil::parse_values (string_view &str, string_view prefix, span< float > values, string_view sep="", string_view postfix="", bool eat=true) noexcept
 parse_values for int. More...
 
bool Strutil::scan_values (string_view str, string_view prefix, span< int > values, string_view sep="", string_view postfix="") noexcept
 
bool Strutil::scan_values (string_view str, string_view prefix, span< float > values, string_view sep="", string_view postfix="") noexcept
 
bool OIIO_UTIL_API Strutil::parse_string (string_view &str, string_view &val, bool eat=true, QuoteBehavior keep_quotes=DeleteQuotes) noexcept
 
string_view OIIO_UTIL_API Strutil::parse_word (string_view &str, bool eat=true) noexcept
 
string_view OIIO_UTIL_API Strutil::parse_identifier (string_view &str, bool eat=true) noexcept
 
string_view OIIO_UTIL_API Strutil::parse_identifier (string_view &str, string_view allowed, bool eat=true) noexcept
 
bool OIIO_UTIL_API Strutil::parse_identifier_if (string_view &str, string_view id, bool eat=true) noexcept
 
string_view OIIO_UTIL_API Strutil::parse_until (string_view &str, string_view set=" \t\r\n", bool eat=true) noexcept
 
string_view OIIO_UTIL_API Strutil::parse_while (string_view &str, string_view set, bool eat=true) noexcept
 
string_view OIIO_UTIL_API Strutil::parse_line (string_view &str, bool eat=true) noexcept
 
string_view OIIO_UTIL_API Strutil::parse_nested (string_view &str, bool eat=true) noexcept
 
OIIO_UTIL_API std::string Strutil::excise_string_after_head (std::string &str, string_view head)
 
void OIIO_UTIL_API Strutil::utf8_to_unicode (string_view str, std::vector< uint32_t > &uvec)
 
std::string OIIO_UTIL_API Strutil::base64_encode (string_view str)
 
OIIO_UTIL_API size_t Strutil::edit_distance (string_view a, string_view b, EditDistMetric metric=EditDistMetric::Levenshtein)
 

Detailed Description

String-related utilities, all in namespace Strutil.

Definition in file strutil.h.

Macro Definition Documentation

#define OIIO_FMT_LOCALE_INDEPENDENT   1

Definition at line 55 of file strutil.h.

#define OIIO_FORMAT_DEPRECATED

Definition at line 49 of file strutil.h.

#define OIIO_FORMAT_IS_FMT   0

Definition at line 40 of file strutil.h.

#define OIIO_HAS_SPRINTF   1

Definition at line 33 of file strutil.h.

#define OIIO_STRUTIL_HAS_STOF   1 /* be able to test this */

Definition at line 538 of file strutil.h.