33 #define OIIO_HAS_SPRINTF 1
39 #ifndef OIIO_FORMAT_IS_FMT
40 # define OIIO_FORMAT_IS_FMT 0
46 #ifdef OIIO_HIDE_FORMAT
47 # define OIIO_FORMAT_DEPRECATED OIIO_DEPRECATED("old style (printf-like) formatting version of this function is deprecated")
49 # define OIIO_FORMAT_DEPRECATED
55 #define OIIO_FMT_LOCALE_INDEPENDENT 1
83 template<
typename Str,
typename... Args>
120 template<
typename Str,
typename... Args>
123 #if FMT_VERSION >= 70000
132 template<
typename... Args>
141 template<
typename... Args>
152 #if OIIO_FORMAT_IS_FMT
170 template<
typename... Args>
176 template<
typename... Args>
177 inline void fprintf (FILE *file,
const char* fmt,
const Args&...
args)
182 template<
typename... Args>
183 inline void fprintf (std::ostream &file,
const char* fmt,
const Args&...
args)
201 template<
typename... Args>
202 inline void print (
const char* fmt,
const Args&...
args)
207 template<
typename... Args>
208 inline void print (FILE *file,
const char* fmt,
const Args&...
args)
213 template<
typename... Args>
214 inline void print (std::ostream &file,
const char* fmt,
const Args&...
args)
226 #if defined(__GNUC__) && !defined(__CUDACC__)
236 #if defined(__GNUC__) && !defined(__CUDACC__)
262 std::map<std::string, std::string> &
result);
453 template<
class Sequence>
456 std::ostringstream out;
457 out.imbue(std::locale::classic());
459 for (
auto&&
s : seq) {
460 if (! first && sep.size())
476 template<
class Sequence>
480 std::ostringstream out;
481 out.imbue(std::locale::classic());
483 for (
auto&&
s : seq) {
488 if (len && (--len == 0))
538 #define OIIO_STRUTIL_HAS_STOF 1
594 return static_cast<int64_t
>(
r);
600 return static_cast<uint64_t
>(
r);
655 template<
class T,
class Allocator>
660 size_t nvals = vals.size();
661 std::vector<string_view> valuestrings;
663 for (
size_t i = 0, e = valuestrings.size(); i < e; ++i) {
664 T v = from_string<T> (valuestrings[i]);
667 else if (valuestrings[i].
size()) {
669 vals[i] = from_string<T> (valuestrings[i]);
673 if (valuestrings.size() == 1 && nvals > 0) {
675 vals.resize (nvals, vals[0]);
677 return list.
size() ? (
int) valuestrings.size() : 0;
707 std::vector<T> vals (nvals,
val);
725 int& hour,
int&
min,
int& sec);
747 bool operator() (
const char *
a,
const char *
b)
const noexcept {
return strcmp (
a,
b) == 0; }
755 bool operator() (
const char *
a,
const char *
b)
const noexcept;
762 bool operator() (
const char *
a,
const char *
b)
const noexcept {
return strcmp (
a,
b) < 0; }
770 bool operator() (
const char *
a,
const char *
b)
const noexcept;
800 return c ==
' ' || c ==
'\n' || c ==
'\t' || c ==
'\r';
874 bool eat =
true) noexcept;
879 bool eat = true) noexcept;
940 bool eat=true) noexcept;
uint64_t from_string< uint64_t >(string_view s)
void print(const char *fmt, const Args &...args)
bool OIIO_UTIL_API parse_int(string_view &str, int &val, bool eat=true) noexcept
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
OIIO_FORMAT_DEPRECATED std::string format(const char *fmt, const Args &...args)
void printf(const char *fmt, const Args &...args)
std::string upper(string_view a)
Return an all-upper case version of a (locale-independent).
bool OIIO_UTIL_API iequals(string_view a, string_view b)
size_t operator()(string_view s) const
unsigned int from_string< unsigned int >(string_view s)
OIIO_UTIL_API bool scan_datetime(string_view str, int &year, int &month, int &day, int &hour, int &min, int &sec)
OIIO_UTIL_API std::vector< string_view > splitsv(string_view str, string_view sep="", int maxsplit=-1)
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
STATIC_INLINE size_t Hash(const char *s, size_t len)
bool OIIO_UTIL_API parse_char(string_view &str, char c, bool skip_whitespace=true, bool eat=true) noexcept
OIIO_UTIL_API bool string_is_int(string_view s)
UT_StringArray JOINTS head
std::string format(const Str &fmt, Args &&...args)
GLsizei const GLchar *const * string
GLsizei const GLfloat * value
void fprintf(FILE *file, const char *fmt, const Args &...args)
OIIO_UTIL_API unsigned int stoui(string_view s, size_t *pos=0, int base=10)
std::string to_string(const T &value)
size_t OIIO_UTIL_API irfind(string_view a, string_view b)
GLboolean GLboolean GLboolean GLboolean a
bool OIIO_UTIL_API istarts_with(string_view a, string_view b)
string_view OIIO_UTIL_API rstrip(string_view str, string_view chars=string_view())
OIIO_FORMAT_DEPRECATED std::string format(string_view fmt, const Args &...args)
bool OIIO_UTIL_API ends_with(string_view a, string_view b)
Does 'a' end with the string 'b', with a case-sensitive comparison?
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
**But if you need a result
bool OIIO_UTIL_API iends_with(string_view a, string_view b)
bool OIIO_UTIL_API icontains(string_view a, string_view b)
std::string OIIO_UTIL_API escape_chars(string_view unescaped)
string_view OIIO_UTIL_API lstrip(string_view str, string_view chars=string_view())
constexpr const_pointer data() const noexcept
string_view OIIO_UTIL_API parse_nested(string_view &str, bool eat=true) noexcept
bool OIIO_UTIL_API parse_string(string_view &str, string_view &val, bool eat=true, QuoteBehavior keep_quotes=DeleteQuotes) noexcept
OIIO_UTIL_API float stof(string_view s, size_t *pos=0)
basic_string_view< char > string_view
string_view OIIO_UTIL_API parse_line(string_view &str, bool eat=true) noexcept
constexpr size_type size() const noexcept
__attribute__((visibility("default")))
void OIIO_UTIL_API sync_output(FILE *file, string_view str)
OIIO_UTIL_API char * safe_strcpy(char *dst, string_view src, size_t size) noexcept
bool OIIO_UTIL_API iless(string_view a, string_view b)
static const size_type npos
int64_t from_string< int64_t >(string_view s)
OIIO_UTIL_API bool string_is_float(string_view s)
string_view OIIO_UTIL_API parse_while(string_view &str, string_view set, bool eat=true) noexcept
void OIIO_UTIL_API remove_trailing_whitespace(string_view &str) noexcept
std::string OIIO_UTIL_API vformat(const char *fmt, va_list ap)
std::string to_string(const char *value)
size_t OIIO_UTIL_API ifind(string_view a, string_view b)
void OIIO_UTIL_API to_lower(std::string &a)
bool OIIO_UTIL_API parse_values(string_view &str, string_view prefix, span< int > values, string_view sep="", string_view postfix="", bool eat=true) noexcept
float from_string< float >(string_view s)
size_t OIIO_UTIL_API rfind(string_view a, string_view b)
std::string OIIO_UTIL_API replace(string_view str, string_view pattern, string_view replacement, bool global=false)
bool OIIO_UTIL_API parse_float(string_view &str, float &val, bool eat=true) noexcept
float OIIO_UTIL_API strtof(const char *nptr, char **endptr=nullptr) noexcept
GLint GLint GLsizei GLint GLenum format
std::string OIIO_UTIL_API wordwrap(string_view src, int columns=80, int prefix=0, string_view sep=" ", string_view presep="")
OIIO_CONSTEXPR14 size_t strhash(size_t len, const char *s)
double from_string< double >(string_view s)
OIIO_UTIL_API double stod(string_view s, size_t *pos=0)
OIIO_UTIL_API int stoi(string_view s, size_t *pos=0, int base=10)
std::string OIIO_UTIL_API memformat(long long bytes, int digits=1)
OIIO_UTIL_API std::string excise_string_after_head(std::string &str, string_view head)
std::wstring OIIO_UTIL_API utf8_to_utf16(string_view utf8str) noexcept
GLboolean GLboolean GLboolean b
constexpr auto make_format_args(const Args &...args) -> format_arg_store< Context, Args...>
bool OIIO_UTIL_API contains_any_char(string_view a, string_view set)
Does 'a' contain any of the characters within set?
T from_string(string_view s)
void trim_whitespace(string_view &str) noexcept
size_t OIIO_UTIL_API find(string_view a, string_view b)
bool OIIO_UTIL_API parse_until_char(string_view &str, char c, bool eat=true) noexcept
bool string_is(string_view)
std::string OIIO_UTIL_API repeat(string_view str, int n)
Repeat a string formed by concatenating str n times.
std::string OIIO_UTIL_API unescape_chars(string_view escaped)
std::string OIIO_UTIL_API base64_encode(string_view str)
std::string join(const Sequence &seq, string_view sep="")
GLenum GLsizei GLsizei GLint * values
OIIO_UTIL_API size_t edit_distance(string_view a, string_view b, EditDistMetric metric=EditDistMetric::Levenshtein)
std::string lower(string_view a)
Return an all-upper case version of a (locale-independent).
int extract_from_list_string(std::vector< T, Allocator > &vals, string_view list, string_view sep=",")
bool OIIO_UTIL_API starts_with(string_view a, string_view b)
Does 'a' start with the string 'b', with a case-sensitive comparison?
bool ircontains(string_view a, string_view b)
constexpr size_type length() const noexcept
OIIO_UTIL_API std::vector< std::string > splits(string_view str, string_view sep="", int maxsplit=-1)
bool string_is< int >(string_view s)
bool string_is< float >(string_view s)
void OIIO_UTIL_API skip_whitespace(string_view &str) noexcept
**If you just want to fire and args
int from_string< int >(string_view s)
#define OIIO_FORMAT_DEPRECATED
std::string OIIO_UTIL_API vsprintf(const char *fmt, va_list ap)
string_view OIIO_UTIL_API parse_identifier(string_view &str, bool eat=true) noexcept
#define OIIO_NAMESPACE_END
auto sprintf(const S &fmt, const T &...args) -> std::basic_string< Char >
string_view OIIO_UTIL_API strip(string_view str, string_view chars=string_view())
void OIIO_UTIL_API split(string_view str, std::vector< string_view > &result, string_view sep=string_view(), int maxsplit=-1)
C++ functor for comparing two strings for equality of their characters.
bool OIIO_UTIL_API get_rest_arguments(const std::string &str, std::string &base, std::map< std::string, std::string > &result)
bool scan_values(string_view str, string_view prefix, span< int > values, string_view sep="", string_view postfix="") noexcept
std::string OIIO_UTIL_API utf16_to_utf8(const std::wstring &utf16str) noexcept
bool OIIO_UTIL_API contains(string_view a, string_view b)
Does 'a' contain the string 'b' within it?
void OIIO_UTIL_API utf8_to_unicode(string_view str, std::vector< uint32_t > &uvec)
void OIIO_UTIL_API to_upper(std::string &a)
std::string OIIO_UTIL_API concat(string_view s, string_view t)
string_view OIIO_UTIL_API parse_word(string_view &str, bool eat=true) noexcept
std::string OIIO_UTIL_API timeintervalformat(double secs, int digits=1)
C++ functor for comparing the ordering of two strings.
bool OIIO_UTIL_API parse_prefix(string_view &str, string_view prefix, bool eat=true) noexcept
bool rcontains(string_view a, string_view b)
string_view OIIO_UTIL_API parse_until(string_view &str, string_view set=" \t\r\n", bool eat=true) noexcept
#define OIIO_NAMESPACE_BEGIN
bool OIIO_UTIL_API parse_identifier_if(string_view &str, string_view id, bool eat=true) noexcept
bool parse_value(string_view &str, float &val, bool eat=true) noexcept
Synonym for parse_int.
double OIIO_UTIL_API strtod(const char *nptr, char **endptr=nullptr) noexcept