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