diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/eina/src/include/eina_inline_ustringshare.x | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/libraries/eina/src/include/eina_inline_ustringshare.x b/libraries/eina/src/include/eina_inline_ustringshare.x new file mode 100644 index 0000000..ace6fdc --- /dev/null +++ b/libraries/eina/src/include/eina_inline_ustringshare.x | |||
@@ -0,0 +1,93 @@ | |||
1 | /* EINA - EFL data type library | ||
2 | * Copyright (C) 2002-2008 Gustavo Sverzut Barbieri | ||
3 | Tom Hacohen | ||
4 | * | ||
5 | * This library is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU Lesser General Public | ||
7 | * License as published by the Free Software Foundation; either | ||
8 | * version 2.1 of the License, or (at your option) any later version. | ||
9 | * | ||
10 | * This library is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * Lesser General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU Lesser General Public | ||
16 | * License along with this library; | ||
17 | * if not, see <http://www.gnu.org/licenses/>. | ||
18 | */ | ||
19 | |||
20 | #ifndef EINA_USTRINGSHARE_INLINE_H_ | ||
21 | #define EINA_USTRINGSHARE_INLINE_H_ | ||
22 | |||
23 | #include "eina_unicode.h" | ||
24 | #include "eina_ustringshare.h" | ||
25 | |||
26 | /** | ||
27 | * @addtogroup Eina_UStringshare_Group Unicode Stringshare | ||
28 | * | ||
29 | * @{ | ||
30 | */ | ||
31 | |||
32 | /** | ||
33 | * Replace the previously stringshared pointer with new content. | ||
34 | * | ||
35 | * The string pointed by @a p_str should be previously stringshared or | ||
36 | * @c NULL and it will be eina_ustringshare_del(). The new string will | ||
37 | * be passed to eina_ustringshare_add() and then assigned to @c *p_str. | ||
38 | * | ||
39 | * @param p_str pointer to the stringhare to be replaced. Must not be | ||
40 | * @c NULL, but @c *p_str may be @c NULL as it is a valid | ||
41 | * stringshare handle. | ||
42 | * @param news new string to be stringshared, may be @c NULL. | ||
43 | * | ||
44 | * @return #EINA_TRUE if the strings were different and thus replaced, | ||
45 | * #EINA_FALSE if the strings were the same after shared. | ||
46 | */ | ||
47 | static inline Eina_Bool | ||
48 | eina_ustringshare_replace(const Eina_Unicode **p_str, const Eina_Unicode *news) | ||
49 | { | ||
50 | if (*p_str == news) return EINA_FALSE; | ||
51 | |||
52 | news = eina_ustringshare_add(news); | ||
53 | eina_ustringshare_del(*p_str); | ||
54 | if (*p_str == news) | ||
55 | return EINA_FALSE; | ||
56 | *p_str = news; | ||
57 | return EINA_TRUE; | ||
58 | } | ||
59 | |||
60 | /** | ||
61 | * Replace the previously stringshared pointer with a new content. | ||
62 | * | ||
63 | * The string pointed by @a p_str should be previously stringshared or | ||
64 | * @c NULL and it will be eina_ustringshare_del(). The new string will | ||
65 | * be passed to eina_ustringshare_add_length() and then assigned to @c *p_str. | ||
66 | * | ||
67 | * @param p_str pointer to the stringhare to be replaced. Must not be | ||
68 | * @c NULL, but @c *p_str may be @c NULL as it is a valid | ||
69 | * stringshare handle. | ||
70 | * @param news new string to be stringshared, may be @c NULL. | ||
71 | * @param slen The string size (<= strlen(str)). | ||
72 | * | ||
73 | * @return #EINA_TRUE if the strings were different and thus replaced, | ||
74 | * #EINA_FALSE if the strings were the same after shared. | ||
75 | */ | ||
76 | static inline Eina_Bool | ||
77 | eina_ustringshare_replace_length(const Eina_Unicode **p_str, const Eina_Unicode *news, unsigned int slen) | ||
78 | { | ||
79 | if (*p_str == news) return EINA_FALSE; | ||
80 | |||
81 | news = eina_ustringshare_add_length(news, slen); | ||
82 | eina_ustringshare_del(*p_str); | ||
83 | if (*p_str == news) | ||
84 | return EINA_FALSE; | ||
85 | *p_str = news; | ||
86 | return EINA_TRUE; | ||
87 | } | ||
88 | |||
89 | /** | ||
90 | * @} | ||
91 | */ | ||
92 | |||
93 | #endif /* EINA_USTRINGSHARE_INLINE_H_ */ | ||