~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/blender/blenlib/BLI_string.h

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 *  \ingroup bli
33
33
 */
34
34
 
 
35
#include <stdarg.h>
 
36
 
35
37
#ifdef __cplusplus
36
38
extern "C" {
37
39
#endif
38
40
 
39
 
        /**
40
 
         * Duplicates the cstring \a str into a newly mallocN'd
41
 
         * string and returns it.
42
 
         * 
43
 
         * \param str The string to be duplicated
44
 
         * \retval Returns the duplicated string
45
 
         */
46
 
char *BLI_strdup(const char *str);
47
 
 
48
 
        /**
49
 
         * Duplicates the first \a len bytes of cstring \a str 
50
 
         * into a newly mallocN'd string and returns it. \a str
51
 
         * is assumed to be at least len bytes long.
52
 
         * 
53
 
         * \param str The string to be duplicated
54
 
         * \param len The number of bytes to duplicate
55
 
         * \retval Returns the duplicated string
56
 
         */
57
 
char *BLI_strdupn(const char *str, const size_t len);
58
 
 
59
 
        /**
60
 
         * Appends the two strings, and returns new mallocN'ed string
61
 
         * \param str1 first string for copy
62
 
         * \param str2 second string for append
63
 
         * \retval Returns dst
64
 
         */
65
 
char *BLI_strdupcat(const char *str1, const char *str2);
66
 
 
67
 
        /** 
68
 
         * Like strncpy but ensures dst is always
69
 
         * '\0' terminated.
70
 
         * 
71
 
         * \param dst Destination for copy
72
 
         * \param src Source string to copy
73
 
         * \param maxncpy Maximum number of characters to copy (generally
74
 
         *   the size of dst)
75
 
         * \retval Returns dst
76
 
         */
77
 
char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy);
78
 
 
79
 
        /* Makes a copy of the text within the "" that appear after some text 'blahblah'
80
 
         * i.e. for string 'pose["apples"]' with prefix 'pose[', it should grab "apples"
81
 
         * 
82
 
         *      - str: is the entire string to chop
83
 
         *      - prefix: is the part of the string to leave out 
84
 
         *
85
 
         * Assume that the strings returned must be freed afterwards, and that the inputs will contain 
86
 
         * data we want...
87
 
         */
88
 
char *BLI_getQuotedStr(const char *str, const char *prefix);
89
 
 
90
 
        /**
91
 
         * Returns a copy of the cstring \a str into a newly mallocN'd
92
 
         * string with all instances of oldText replaced with newText,
93
 
         * and returns it.
94
 
         * 
95
 
         * \param str The string to replace occurrences of oldText in
96
 
         * \param oldText The text in the string to find and replace
97
 
         * \param newText The text in the string to find and replace
98
 
         * \retval Returns the duplicated string
99
 
         */
100
 
char *BLI_replacestr(char *str, const char *oldText, const char *newText);
101
 
 
102
 
        /* 
103
 
         * Replacement for snprintf
104
 
         */
105
 
size_t BLI_snprintf(char *buffer, size_t len, const char *format, ...)
106
 
#ifdef __GNUC__
107
 
__attribute__ ((format (printf, 3, 4)))
108
 
#endif
109
 
;
110
 
 
111
 
        /* 
112
 
         * Print formatted string into a newly mallocN'd string
113
 
         * and return it.
114
 
         */
115
 
char *BLI_sprintfN(const char *format, ...)
116
 
#ifdef __GNUC__
117
 
__attribute__ ((format (printf, 1, 2)))
118
 
#endif
119
 
;
120
 
 
121
 
size_t BLI_strescape(char *dst, const char *src, const size_t maxlen);
122
 
 
123
 
        /**
124
 
         * Compare two strings without regard to case.
125
 
         * 
126
 
         * \retval True if the strings are equal, false otherwise.
127
 
         */
128
 
int BLI_strcaseeq(const char *a, const char *b);
129
 
 
130
 
char *BLI_strcasestr(const char *s, const char *find);
131
 
int BLI_strcasecmp(const char *s1, const char *s2);
132
 
int BLI_strncasecmp(const char *s1, const char *s2, size_t len);
133
 
int BLI_natstrcmp(const char *s1, const char *s2);
134
 
size_t BLI_strnlen(const char *str, size_t maxlen);
135
 
void BLI_timestr(double _time, char *str); /* time var is global */
136
 
 
137
 
void BLI_ascii_strtolower(char *str, int len);
138
 
void BLI_ascii_strtoupper(char *str, int len);
 
41
/**
 
42
 * Duplicates the cstring \a str into a newly mallocN'd
 
43
 * string and returns it.
 
44
 *
 
45
 * \param str The string to be duplicated
 
46
 * \retval Returns the duplicated string
 
47
 */
 
48
char *BLI_strdup(const char *str)
 
49
#ifdef __GNUC__
 
50
__attribute__((warn_unused_result))
 
51
__attribute__((nonnull))
 
52
#endif
 
53
;
 
54
 
 
55
/**
 
56
 * Duplicates the first \a len bytes of cstring \a str
 
57
 * into a newly mallocN'd string and returns it. \a str
 
58
 * is assumed to be at least len bytes long.
 
59
 *
 
60
 * \param str The string to be duplicated
 
61
 * \param len The number of bytes to duplicate
 
62
 * \retval Returns the duplicated string
 
63
 */
 
64
char *BLI_strdupn(const char *str, const size_t len)
 
65
#ifdef __GNUC__
 
66
__attribute__((warn_unused_result))
 
67
__attribute__((nonnull))
 
68
#endif
 
69
;
 
70
 
 
71
/**
 
72
 * Appends the two strings, and returns new mallocN'ed string
 
73
 * \param str1 first string for copy
 
74
 * \param str2 second string for append
 
75
 * \retval Returns dst
 
76
 */
 
77
char *BLI_strdupcat(const char *__restrict str1, const char *__restrict str2)
 
78
#ifdef __GNUC__
 
79
__attribute__((warn_unused_result))
 
80
__attribute__((nonnull))
 
81
#endif
 
82
;
 
83
 
 
84
/**
 
85
 * Like strncpy but ensures dst is always
 
86
 * '\0' terminated.
 
87
 *
 
88
 * \param dst Destination for copy
 
89
 * \param src Source string to copy
 
90
 * \param maxncpy Maximum number of characters to copy (generally
 
91
 *   the size of dst)
 
92
 * \retval Returns dst
 
93
 */
 
94
char *BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy)
 
95
#ifdef __GNUC__
 
96
__attribute__((nonnull))
 
97
#endif
 
98
;
 
99
 
 
100
/**
 
101
 *Makes a copy of the text within the "" that appear after some text 'blahblah'
 
102
 * i.e. for string 'pose["apples"]' with prefix 'pose[', it should grab "apples"
 
103
 *
 
104
 *  - str: is the entire string to chop
 
105
 *      - prefix: is the part of the string to leave out
 
106
 *
 
107
 * Assume that the strings returned must be freed afterwards, and that the inputs will contain
 
108
 * data we want...
 
109
 */
 
110
char *BLI_str_quoted_substrN(const char *__restrict str, const char *__restrict prefix)
 
111
#ifdef __GNUC__
 
112
__attribute__((warn_unused_result))
 
113
__attribute__((nonnull))
 
114
#endif
 
115
;
 
116
 
 
117
/**
 
118
 * Returns a copy of the cstring \a str into a newly mallocN'd
 
119
 * string with all instances of oldText replaced with newText,
 
120
 * and returns it.
 
121
 *
 
122
 * \param str The string to replace occurrences of oldText in
 
123
 * \param oldText The text in the string to find and replace
 
124
 * \param newText The text in the string to find and replace
 
125
 * \retval Returns the duplicated string
 
126
 */
 
127
char *BLI_replacestr(char *__restrict str, const char *__restrict oldText, const char *__restrict newText)
 
128
#ifdef __GNUC__
 
129
__attribute__((warn_unused_result))
 
130
__attribute__((nonnull))
 
131
#endif
 
132
;
 
133
 
 
134
/*
 
135
 * Replacement for snprintf
 
136
 */
 
137
size_t BLI_snprintf(char *__restrict buffer, size_t len, const char *__restrict format, ...)
 
138
#ifdef __GNUC__
 
139
__attribute__ ((format(printf, 3, 4)))
 
140
__attribute__((nonnull))
 
141
#endif
 
142
;
 
143
 
 
144
/*
 
145
 * Replacement for vsnprintf
 
146
 */
 
147
size_t BLI_vsnprintf(char *__restrict buffer, size_t count, const char *__restrict format, va_list arg)
 
148
#ifdef __GNUC__
 
149
__attribute__ ((format(printf, 3, 0)))
 
150
#endif
 
151
;
 
152
 
 
153
/*
 
154
 * Print formatted string into a newly mallocN'd string
 
155
 * and return it.
 
156
 */
 
157
char *BLI_sprintfN(const char *__restrict format, ...)
 
158
#ifdef __GNUC__
 
159
__attribute__ ((format(printf, 1, 2)))
 
160
__attribute__((warn_unused_result))
 
161
__attribute__((nonnull))
 
162
#endif
 
163
;
 
164
 
 
165
size_t BLI_strescape(char *__restrict dst, const char *__restrict src, const size_t maxncpy)
 
166
#ifdef __GNUC__
 
167
__attribute__((nonnull))
 
168
#endif
 
169
;
 
170
 
 
171
/**
 
172
 * Compare two strings without regard to case.
 
173
 *
 
174
 * \retval True if the strings are equal, false otherwise.
 
175
 */
 
176
int BLI_strcaseeq(const char *a, const char *b)
 
177
#ifdef __GNUC__
 
178
__attribute__((warn_unused_result))
 
179
__attribute__((nonnull))
 
180
#endif
 
181
;
 
182
 
 
183
char *BLI_strcasestr(const char *s, const char *find)
 
184
#ifdef __GNUC__
 
185
__attribute__((warn_unused_result))
 
186
__attribute__((nonnull))
 
187
#endif
 
188
;
 
189
int BLI_strcasecmp(const char *s1, const char *s2)
 
190
#ifdef __GNUC__
 
191
__attribute__((warn_unused_result))
 
192
__attribute__((nonnull))
 
193
#endif
 
194
;
 
195
int BLI_strncasecmp(const char *s1, const char *s2, size_t len)
 
196
#ifdef __GNUC__
 
197
__attribute__((warn_unused_result))
 
198
__attribute__((nonnull))
 
199
#endif
 
200
;
 
201
int BLI_natstrcmp(const char *s1, const char *s2)
 
202
#ifdef __GNUC__
 
203
__attribute__((warn_unused_result))
 
204
__attribute__((nonnull))
 
205
#endif
 
206
;
 
207
size_t BLI_strnlen(const char *str, const size_t maxlen)
 
208
#ifdef __GNUC__
 
209
__attribute__((warn_unused_result))
 
210
__attribute__((nonnull))
 
211
#endif
 
212
;
 
213
void BLI_timestr(double _time, char *str)
 
214
#ifdef __GNUC__
 
215
__attribute__((nonnull))
 
216
#endif
 
217
; /* time var is global */
 
218
 
 
219
void BLI_ascii_strtolower(char *str, const size_t len)
 
220
#ifdef __GNUC__
 
221
__attribute__((nonnull))
 
222
#endif
 
223
;
 
224
void BLI_ascii_strtoupper(char *str, const size_t len)
 
225
#ifdef __GNUC__
 
226
__attribute__((nonnull))
 
227
#endif
 
228
;
139
229
 
140
230
#ifdef __cplusplus
141
231
}