1 /* Dia -- an diagram creation/manipulation program
2 * Copyright (C) 1998 Alexander Larsson
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program 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
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 /* Separate functions to handle stereotypes in guillemots. */
24 #include "stereotype.h"
27 string_to_bracketted (gchar
*str
,
28 const char *start_bracket
,
29 const char *end_bracket
)
31 return g_strconcat (start_bracket
, (str
? str
: ""), end_bracket
, NULL
);
35 bracketted_to_string (gchar
*bracketted
,
36 const char *start_bracket
,
37 const char *end_bracket
)
39 const char *utfstart
, *utfend
, *utfstr
;
40 int start_len
, end_len
, str_len
;
42 if (!bracketted
) return NULL
;
44 utfstart
= start_bracket
;
47 start_len
= strlen (utfstart
);
48 end_len
= strlen (utfend
);
49 str_len
= strlen (bracketted
);
52 if (!strncmp (utfstr
, utfstart
, start_len
)) {
56 if (str_len
>= end_len
&& end_len
> 0) {
57 if (g_utf8_strrchr (utfstr
, str_len
, g_utf8_get_char (utfend
)))
60 return g_strndup (utfstr
, str_len
);
64 string_to_stereotype (gchar
*str
)
66 if ((str
) && str
[0] != '\0')
67 return string_to_bracketted(str
, UML_STEREOTYPE_START
, UML_STEREOTYPE_END
);
72 remove_stereotype_from_string (gchar
*stereotype
)
75 char *tmp
= bracketted_to_string (stereotype
,
76 UML_STEREOTYPE_START
, UML_STEREOTYPE_END
);
85 stereotype_to_string (gchar
*stereotype
)
87 return bracketted_to_string(stereotype
,
88 UML_STEREOTYPE_START
, UML_STEREOTYPE_END
);