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 <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 "fmt/ostream.h"
#include "fmt/format.h"
#include "fmt/printf.h"
#include <OpenImageIO/tinyformat.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_USE_FMT
 
#define FMT_HEADER_ONLY
 
#define OIIO_HAS_SPRINTF   1
 
#define OIIO_FORMAT_IS_FMT   0
 
#define OIIO_FMT_LOCALE_INDEPENDENT   0
 
#define TINYFORMAT_USE_VARIADIC_TEMPLATES
 
#define __attribute__(x)
 
#define OPENIMAGEIO_PRINTF_ARGS(fmtarg_pos, vararg_pos)   __attribute__ ((format (printf, fmtarg_pos, vararg_pos) ))
 
#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) OPENIMAGEIO_PRINTF_ARGS(1
 
std::string OIIO_API
std::string OIIO_API 
Strutil::vformat (const char *fmt, va_list ap) OPENIMAGEIO_PRINTF_ARGS(1
 
std::string OIIO_API
std::string OIIO_API
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="")
 
size_t Strutil::strhash (string_view s)
 Hash a string_view. More...
 
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)
 
string_view OIIO_API Strutil::strip (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="")
 
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)
 
double OIIO_API Strutil::strtod (const char *nptr, char **endptr=nullptr)
 
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)
 
template<>
std::string Strutil::to_string (const std::string &value)
 
template<>
std::string Strutil::to_string (const string_view &value)
 
std::string Strutil::to_string (const char *value)
 
std::string Strutil::to_string (int value)
 
std::string Strutil::to_string (size_t 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 >
int Strutil::extract_from_list_string (std::vector< T > &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)
 
void OIIO_API Strutil::skip_whitespace (string_view &str)
 
bool OIIO_API Strutil::parse_char (string_view &str, char c, bool skip_whitespace=true, bool eat=true)
 
bool OIIO_API Strutil::parse_until_char (string_view &str, char c, bool eat=true)
 
bool OIIO_API Strutil::parse_prefix (string_view &str, string_view prefix, bool eat=true)
 
bool OIIO_API Strutil::parse_int (string_view &str, int &val, bool eat=true)
 
bool OIIO_API Strutil::parse_float (string_view &str, float &val, bool eat=true)
 
bool OIIO_API Strutil::parse_string (string_view &str, string_view &val, bool eat=true, QuoteBehavior keep_quotes=DeleteQuotes)
 
string_view OIIO_API Strutil::parse_word (string_view &str, bool eat=true)
 
string_view OIIO_API Strutil::parse_identifier (string_view &str, bool eat=true)
 
string_view OIIO_API Strutil::parse_identifier (string_view &str, string_view allowed, bool eat=true)
 
bool OIIO_API Strutil::parse_identifier_if (string_view &str, string_view id, bool eat=true)
 
string_view OIIO_API Strutil::parse_until (string_view &str, string_view sep=" \t\r\n", bool eat=true)
 
string_view OIIO_API Strutil::parse_while (string_view &str, string_view set, bool eat=true)
 
string_view OIIO_API Strutil::parse_nested (string_view &str, bool eat=true)
 
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 __attribute__ (   x)
Examples:
HOM/_hdk_sample_hom_extensions.C.

Definition at line 94 of file strutil.h.

#define FMT_HEADER_ONLY

Definition at line 65 of file strutil.h.

#define OIIO_FMT_LOCALE_INDEPENDENT   0

Definition at line 85 of file strutil.h.

#define OIIO_FORMAT_IS_FMT   0

Definition at line 80 of file strutil.h.

#define OIIO_HAS_SPRINTF   1

Definition at line 75 of file strutil.h.

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

Definition at line 457 of file strutil.h.

#define OIIO_USE_FMT

Definition at line 57 of file strutil.h.

#define OPENIMAGEIO_PRINTF_ARGS (   fmtarg_pos,
  vararg_pos 
)    __attribute__ ((format (printf, fmtarg_pos, vararg_pos) ))

Definition at line 107 of file strutil.h.

#define TINYFORMAT_USE_VARIADIC_TEMPLATES

Definition at line 88 of file strutil.h.