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/farmhash.h>
#include "detail/fmt/ostream.h"
#include "detail/fmt/format.h"
#include "detail/fmt/printf.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 FMT_HEADER_ONLY
 
#define FMT_EXCEPTIONS   0
 
#define FMT_USE_GRISU   1
 
#define OIIO_HAS_SPRINTF   1
 
#define OIIO_FORMAT_IS_FMT   0
 
#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 }
 

Functions

void OIIO_API Strutil::sync_output (FILE *file, string_view str)
 
void OIIO_API Strutil::sync_output (std::ostream &file, string_view str)
 
template<typename... Args>
std::string Strutil::sprintf (const char *fmt, const Args &...args)
 
template<typename... Args>
std::string Strutil::fmt::format (const char *fmt, const Args &...args)
 
template<typename... Args>
std::string Strutil::old::format (const char *fmt, const Args &...args)
 
template<typename... Args>
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_API Strutil::vsprintf (const char *fmt, va_list ap)
 
std::string OIIO_API Strutil::vformat (const char *fmt, va_list ap)
 
std::string OIIO_API Strutil::memformat (long long bytes, int digits=1)
 
std::string OIIO_API Strutil::timeintervalformat (double secs, int digits=1)
 
bool OIIO_API Strutil::get_rest_arguments (const std::string &str, std::string &base, std::map< std::string, std::string > &result)
 
std::string OIIO_API Strutil::escape_chars (string_view unescaped)
 
std::string OIIO_API Strutil::unescape_chars (string_view escaped)
 
std::string OIIO_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_API Strutil::iequals (string_view a, string_view b)
 
bool OIIO_API Strutil::iless (string_view a, string_view b)
 
bool OIIO_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_API Strutil::istarts_with (string_view a, string_view b)
 
bool OIIO_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_API Strutil::iends_with (string_view a, string_view b)
 
bool OIIO_API Strutil::contains (string_view a, string_view b)
 Does 'a' contain the string 'b' within it? More...
 
bool OIIO_API Strutil::icontains (string_view a, string_view b)
 
void OIIO_API Strutil::to_lower (std::string &a)
 
void OIIO_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_API Strutil::strip (string_view str, string_view chars=string_view())
 
string_view OIIO_API Strutil::lstrip (string_view str, string_view chars=string_view())
 
string_view OIIO_API Strutil::rstrip (string_view str, string_view chars=string_view())
 
void OIIO_API Strutil::split (string_view str, std::vector< string_view > &result, string_view sep=string_view(), int maxsplit=-1)
 
void OIIO_API Strutil::split (string_view str, std::vector< std::string > &result, string_view sep=string_view(), int maxsplit=-1)
 
OIIO_API std::vector< std::stringStrutil::splits (string_view str, string_view sep="", int maxsplit=-1)
 
OIIO_API std::vector< string_viewStrutil::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_API Strutil::concat (string_view s, string_view t)
 
std::string OIIO_API Strutil::repeat (string_view str, int n)
 Repeat a string formed by concatenating str n times. More...
 
std::string OIIO_API Strutil::replace (string_view str, string_view pattern, string_view replacement, bool global=false)
 
float OIIO_API Strutil::strtof (const char *nptr, char **endptr=nullptr) noexcept
 
double OIIO_API Strutil::strtod (const char *nptr, char **endptr=nullptr) noexcept
 
OIIO_API int Strutil::stoi (string_view s, size_t *pos=0, int base=10)
 
unsigned int Strutil::stoui (string_view s, size_t *pos=0, int base=10)
 
OIIO_API float Strutil::stof (string_view s, size_t *pos=0)
 
OIIO_API float Strutil::stof (const std::string &s, size_t *pos=0)
 
OIIO_API float Strutil::stof (const char *s, size_t *pos=0)
 
OIIO_API double Strutil::stod (string_view s, size_t *pos=0)
 
OIIO_API double Strutil::stod (const std::string &s, size_t *pos=0)
 
OIIO_API double Strutil::stod (const char *s, size_t *pos=0)
 
OIIO_API bool Strutil::string_is_int (string_view s)
 
OIIO_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<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_API char * Strutil::safe_strcpy (char *dst, string_view src, size_t size) noexcept
 
void OIIO_API Strutil::skip_whitespace (string_view &str) noexcept
 
void OIIO_API Strutil::remove_trailing_whitespace (string_view &str) noexcept
 
void Strutil::trim_whitespace (string_view &str) noexcept
 
bool OIIO_API Strutil::parse_char (string_view &str, char c, bool skip_whitespace=true, bool eat=true) noexcept
 
bool OIIO_API Strutil::parse_until_char (string_view &str, char c, bool eat=true) noexcept
 
bool OIIO_API Strutil::parse_prefix (string_view &str, string_view prefix, bool eat=true) noexcept
 
bool OIIO_API Strutil::parse_int (string_view &str, int &val, bool eat=true) noexcept
 
bool OIIO_API Strutil::parse_float (string_view &str, float &val, bool eat=true) noexcept
 
bool OIIO_API Strutil::parse_string (string_view &str, string_view &val, bool eat=true, QuoteBehavior keep_quotes=DeleteQuotes) noexcept
 
string_view OIIO_API Strutil::parse_word (string_view &str, bool eat=true) noexcept
 
string_view OIIO_API Strutil::parse_identifier (string_view &str, bool eat=true) noexcept
 
string_view OIIO_API Strutil::parse_identifier (string_view &str, string_view allowed, bool eat=true) noexcept
 
bool OIIO_API Strutil::parse_identifier_if (string_view &str, string_view id, bool eat=true) noexcept
 
string_view OIIO_API Strutil::parse_until (string_view &str, string_view sep=" \t\r\n", bool eat=true) noexcept
 
string_view OIIO_API Strutil::parse_while (string_view &str, string_view set, bool eat=true) noexcept
 
string_view OIIO_API Strutil::parse_nested (string_view &str, bool eat=true) noexcept
 
OIIO_API std::string Strutil::excise_string_after_head (std::string &str, string_view head)
 
void OIIO_API Strutil::utf8_to_unicode (string_view str, std::vector< uint32_t > &uvec)
 
std::string OIIO_API Strutil::base64_encode (string_view str)
 

Detailed Description

String-related utilities, all in namespace Strutil.

Definition in file strutil.h.

Macro Definition Documentation

#define FMT_EXCEPTIONS   0

Definition at line 39 of file strutil.h.

#define FMT_HEADER_ONLY

Definition at line 36 of file strutil.h.

#define FMT_USE_GRISU   1

Definition at line 42 of file strutil.h.

#define OIIO_FMT_LOCALE_INDEPENDENT   1

Definition at line 62 of file strutil.h.

#define OIIO_FORMAT_IS_FMT   0

Definition at line 57 of file strutil.h.

#define OIIO_HAS_SPRINTF   1

Definition at line 52 of file strutil.h.

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

Definition at line 486 of file strutil.h.