Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleanups + newline at end of file
[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 SG_BEGIN_DECL()
15
16 /**  @brief Strip whitespace (or other characters) from the end of a string.
17  *
18  * The function rtrim() returns a string with whitespace stripped from the end of s. 
19  * By default (without the second parameter char_list), rtrim() will strip these characters :
20  *      
21  *      - " "           (ASCII 32       (0x20)) space. 
22  *      - "\t"          (ASCII 9        (0x09)) tab. 
23  *      - "\n"          (ASCII 10       (0x0A)) line feed. 
24  *      - "\r"          (ASCII 13       (0x0D)) carriage return. 
25  *      - "\0"          (ASCII 0        (0x00)) NULL. 
26  *      - "\x0B"        (ASCII 11       (0x0B)) vertical tab. 
27  *
28  * @param s The string to strip.
29  * @param char_list A string which contains the characters you want to strip.
30  *
31  * @return If the specified is NULL the function returns NULL. Otherwise the
32  * function returns the string with whitespace stripped from the end.
33  */
34 XBT_PUBLIC(char*)
35 rtrim(char* s, const char* char_list);
36
37 /**  @brief Strip whitespace (or other characters) from the beginning of a string.
38  *
39  * The function ltrim() returns a string with whitespace stripped from the beginning of s. 
40  * By default (without the second parameter char_list), ltrim() will strip these characters :
41  *      
42  *      - " "           (ASCII 32       (0x20)) space. 
43  *      - "\t"          (ASCII 9        (0x09)) tab. 
44  *      - "\n"          (ASCII 10       (0x0A)) line feed. 
45  *      - "\r"          (ASCII 13       (0x0D)) carriage return. 
46  *      - "\0"          (ASCII 0        (0x00)) NULL. 
47  *      - "\x0B"        (ASCII 11       (0x0B)) vertical tab. 
48  *
49  * @param s The string to strip.
50  * @param char_list A string which contains the characters you want to strip.
51  *
52  * @return If the specified is NULL the function returns NULL. Otherwise the
53  * function returns the string with whitespace stripped from the beginning.
54  */
55 XBT_PUBLIC(char*)
56 ltrim( char* s, const char* char_list);
57
58
59 /**  @brief Strip whitespace (or other characters) from the end and the begining of a string.
60  *
61  * The function trim() returns a string with whitespace stripped from the end and the begining of s. 
62  * By default (without the second parameter char_list), trim() will strip these characters :
63  *      
64  *      - " "           (ASCII 32       (0x20)) space. 
65  *      - "\t"          (ASCII 9        (0x09)) tab. 
66  *      - "\n"          (ASCII 10       (0x0A)) line feed. 
67  *      - "\r"          (ASCII 13       (0x0D)) carriage return. 
68  *      - "\0"          (ASCII 0        (0x00)) NULL. 
69  *      - "\x0B"        (ASCII 11       (0x0B)) vertical tab. 
70  *
71  * @param s The string to strip.
72  * @param char_list A string which contains the characters you want to strip.
73  *
74  * @return If the specified is NULL the function returns NULL. Otherwise the
75  * function returns the string with whitespace stripped from the end and the begining.
76  */
77 XBT_PUBLIC(char*) 
78 trim(char* s, const char* char_list);
79
80 SG_END_DECL()
81
82 #endif /* !XBT_TRIM_H */