Blender  V3.3
string.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #pragma once
5 
6 #include <sstream>
7 #include <string.h>
8 #include <string>
9 
10 /* Use string view implementation from OIIO.
11  * Ideally, need to switch to `std::string_view`, but this first requires getting rid of using
12  * namespace OIIO as it causes symbol collision. */
13 #include <OpenImageIO/string_view.h>
14 
15 #include "util/vector.h"
16 
18 
19 using std::istringstream;
20 using std::ostringstream;
21 using std::string;
22 using std::stringstream;
23 using std::to_string;
24 
25 using OIIO::string_view;
26 
27 #ifdef __GNUC__
28 # define PRINTF_ATTRIBUTE __attribute__((format(printf, 1, 2)))
29 #else
30 # define PRINTF_ATTRIBUTE
31 #endif
32 
33 string string_printf(const char *format, ...) PRINTF_ATTRIBUTE;
34 
35 bool string_iequals(const string &a, const string &b);
36 void string_split(vector<string> &tokens,
37  const string &str,
38  const string &separators = "\t ",
39  bool skip_empty_tokens = true);
40 void string_replace(string &haystack, const string &needle, const string &other);
41 void string_replace_same_length(string &haystack, const string &needle, const string &other);
42 bool string_startswith(string_view s, string_view start);
43 bool string_endswith(string_view s, string_view end);
44 string string_strip(const string &s);
45 string string_remove_trademark(const string &s);
46 string string_from_bool(const bool var);
47 string to_string(const char *str);
48 string to_string(const float4 &v);
49 string string_to_lower(const string &s);
50 
51 /* Wide char strings are only used on Windows to deal with non-ASCII
52  * characters in file names and such. No reason to use such strings
53  * for something else at this moment.
54  *
55  * Please note that strings are expected to be in UTF-8 codepage, and
56  * if ANSI is needed then explicit conversion required.
57  */
58 #ifdef _WIN32
59 using std::wstring;
60 wstring string_to_wstring(const string &path);
61 string string_from_wstring(const wstring &path);
62 string string_to_ansi(const string &str);
63 #endif
64 
65 /* Make a string from a size in bytes in human readable form. */
66 string string_human_readable_size(size_t size);
67 /* Make a string from a unit-less quantity in human readable form. */
68 string string_human_readable_number(size_t num);
69 
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t
float float4[4]
ATTR_WARN_UNUSED_RESULT const BMVert * v
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
#define str(s)
format
Definition: logImageCore.h:38
static unsigned a[3]
Definition: RandGen.cpp:78
std::string to_string(const T &n)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
string string_remove_trademark(const string &s)
Definition: string.cpp:152
string string_printf(const char *format,...) PRINTF_ATTRIBUTE
Definition: string.cpp:22
string string_from_bool(const bool var)
Definition: string.cpp:167
string string_human_readable_size(size_t size)
Definition: string.cpp:229
bool string_iequals(const string &a, const string &b)
Definition: string.cpp:54
void string_split(vector< string > &tokens, const string &str, const string &separators="\t ", bool skip_empty_tokens=true)
Definition: string.cpp:67
bool string_endswith(string_view s, string_view end)
Definition: string.cpp:111
string string_strip(const string &s)
Definition: string.cpp:122
string to_string(const char *str)
Definition: string.cpp:175
bool string_startswith(string_view s, string_view start)
Definition: string.cpp:100
string string_human_readable_number(size_t num)
Definition: string.cpp:248
void string_replace_same_length(string &haystack, const string &needle, const string &other)
Definition: string.cpp:139
void string_replace(string &haystack, const string &needle, const string &other)
Definition: string.cpp:130
#define PRINTF_ATTRIBUTE
Definition: string.h:30
string string_to_lower(const string &s)
Definition: string.cpp:185