Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
43f3eba7bc20ee09506101533ed8ce01196757aa
[simgrid.git] / include / xbt / trim.h
1 /* xbt/trim.h -- Declarations of the functions ltrim(), rtrim() and trim()      */
2
3 /* Copyright (c) 2007 Cherier Malek. All rights reserved.                                       */
4
5 /* This program is free software; you can redistribute it and/or modify it
6  * under the terms of the license (GNU LGPL) which comes with this package. */
7
8
9 #ifndef XBT_TRIM_H
10 #define XBT_TRIM_H
11
12 #include "xbt/misc.h"
13
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17
18 /**  @brief Strip whitespace (or other characters) from the end of a string.
19  *
20  * The function rtrim() returns a string with whitespace stripped from the end of s. 
21  * By default (without the second parameter char_list), rtrim() will strip these characters :
22  *      
23  *      - " "           (ASCII 32       (0x20)) space. 
24  *      - "\t"          (ASCII 9        (0x09)) tab. 
25  *      - "\n"          (ASCII 10       (0x0A)) line feed. 
26  *      - "\r"          (ASCII 13       (0x0D)) carriage return. 
27  *      - "\0"          (ASCII 0        (0x00)) NULL. 
28  *      - "\x0B"        (ASCII 11       (0x0B)) vertical tab. 
29  *
30  * @param s The string to strip.
31  * @param char_list A string which contains the characters you want to strip.
32  *
33  * @return If the specified is NULL the function returns NULL. Otherwise the
34  * function returns the string with whitespace stripped from the end.
35  */
36 XBT_PUBLIC(char*)
37 rtrim(char* s, const char* char_list);
38
39 /**  @brief Strip whitespace (or other characters) from the beginning of a string.
40  *
41  * The function ltrim() returns a string with whitespace stripped from the beginning of s. 
42  * By default (without the second parameter char_list), ltrim() will strip these characters :
43  *      
44  *      - " "           (ASCII 32       (0x20)) space. 
45  *      - "\t"          (ASCII 9        (0x09)) tab. 
46  *      - "\n"          (ASCII 10       (0x0A)) line feed. 
47  *      - "\r"          (ASCII 13       (0x0D)) carriage return. 
48  *      - "\0"          (ASCII 0        (0x00)) NULL. 
49  *      - "\x0B"        (ASCII 11       (0x0B)) vertical tab. 
50  *
51  * @param s The string to strip.
52  * @param char_list A string which contains the characters you want to strip.
53  *
54  * @return If the specified is NULL the function returns NULL. Otherwise the
55  * function returns the string with whitespace stripped from the beginning.
56  */
57 XBT_PUBLIC(char*)
58 ltrim( char* s, const char* char_list);
59
60
61 /**  @brief Strip whitespace (or other characters) from the end and the begining of a string.
62  *
63  * The function trim() returns a string with whitespace stripped from the end and the begining of s. 
64  * By default (without the second parameter char_list), trim() will strip these characters :
65  *      
66  *      - " "           (ASCII 32       (0x20)) space. 
67  *      - "\t"          (ASCII 9        (0x09)) tab. 
68  *      - "\n"          (ASCII 10       (0x0A)) line feed. 
69  *      - "\r"          (ASCII 13       (0x0D)) carriage return. 
70  *      - "\0"          (ASCII 0        (0x00)) NULL. 
71  *      - "\x0B"        (ASCII 11       (0x0B)) vertical tab. 
72  *
73  * @param s The string to strip.
74  * @param char_list A string which contains the characters you want to strip.
75  *
76  * @return If the specified is NULL the function returns NULL. Otherwise the
77  * function returns the string with whitespace stripped from the end and the begining.
78  */
79 XBT_PUBLIC(char*) 
80 trim(char* s, const char* char_list);
81
82
83 #ifdef __cplusplus
84 }
85 #endif
86
87 #endif /* !XBT_TRIM_H */