-
Notifications
You must be signed in to change notification settings - Fork 5
/
string_tools.h
49 lines (42 loc) · 1.42 KB
/
string_tools.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
* Tools for string processing.
*
* @authors: Denis Chernikov, Vladislav Kuleykin
*/
#ifndef C_PARSER_STRING_TOOLS_H_INCLUDED
#define C_PARSER_STRING_TOOLS_H_INCLUDED
/// Are the given strings equal?
///
/// \param str1 First string for comparison
/// \param str2 Second string to compare with
/// \return `true' - strings contents are identical, `false' - otherwise
_Bool str_eq(char *str1, char *str2);
/// Wrap a given string into double quotes.
/// If the string contains special symbols, it escapes them.
/// Needs to be released.
///
/// \param str String to wrap
/// \return New string inside quotes
char *wrap_by_quotes(char *str);
/// Convert a constant string to an allocated memory.
/// Needs to be released.
///
/// \param str String to allocate memory for
/// \return Pointer in a heap to the copy of a given string
char *alloc_const_str(const char *str);
/// Concatenate an array of strings into one string.
/// Needs to be released.
///
/// \param array Array of strings
/// \param n Number of strings in array
/// \param delimiter Delimiter to be placed between strings
/// \return String of concatenated strings
char *concat_array(char **array, int n, char *delimiter);
/// Repeat given source `n' times.
/// Needs to be released.
///
/// \param n Number of repetitions
/// \param str String pattern to repeat
/// \return `str' repeated `n' times
char *repeat(int n, char *str);
#endif //C_PARSER_STRING_TOOLS_H_INCLUDED