1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2  *
3  * Copyright (C) 2016 Richard Hughes <richard@hughsie.com>
4  *
5  * SPDX-License-Identifier: LGPL-2.1+
6  */
7 
8 #pragma once
9 
10 #if !defined (__APPSTREAM_GLIB_H_INSIDE__) && !defined (AS_COMPILATION)
11 #error "Only <appstream-glib.h> can be included directly."
12 #endif
13 
14 #include <glib.h>
15 
16 G_BEGIN_DECLS
17 
18 typedef gchar AsRefString;
19 
20 /**
21  * AsRefStringDebugFlags:
22  * @AS_REF_STRING_DEBUG_NONE:			No detailed debugging
23  * @AS_REF_STRING_DEBUG_DEDUPED:		Show detailed dedupe stats
24  * @AS_REF_STRING_DEBUG_DUPES:			Show detailed duplication stats
25  *
26  * The debug type flags.
27  **/
28 typedef enum {
29 	AS_REF_STRING_DEBUG_NONE	= 0,		/* Since: 0.6.16 */
30 	AS_REF_STRING_DEBUG_DEDUPED	= 1 << 0,	/* Since: 0.6.16 */
31 	AS_REF_STRING_DEBUG_DUPES	= 1 << 1,	/* Since: 0.6.16 */
32 	/*< private >*/
33 	AS_REF_STRING_DEBUG_LAST
34 } AsRefStringDebugFlags;
35 
36 #define as_ref_string_new_static(o)			(AsRefString *) (("\xff\xff\xff\xff" o) + 4)
37 
38 AsRefString	*as_ref_string_new			(const gchar	*str);
39 AsRefString	*as_ref_string_new_with_length		(const gchar	*str,
40 							 gsize		 len);
41 AsRefString	*as_ref_string_ref			(AsRefString	*rstr);
42 AsRefString	*as_ref_string_unref			(AsRefString	*rstr);
43 void		 as_ref_string_assign			(AsRefString	**rstr_ptr,
44 							 AsRefString	*rstr);
45 void		 as_ref_string_assign_safe		(AsRefString	**rstr_ptr,
46 							 const gchar	*str);
47 gchar		*as_ref_string_debug			(AsRefStringDebugFlags flags);
48 void		 as_ref_string_debug_start		(void);
49 void		 as_ref_string_debug_stop		(void);
50 
51 /* deprecated */
52 AsRefString	*as_ref_string_new_copy			(const gchar	*str);
53 AsRefString	*as_ref_string_new_copy_with_length	(const gchar	*str,
54 							 gsize		 len);
55 
56 G_DEFINE_AUTOPTR_CLEANUP_FUNC(AsRefString, as_ref_string_unref)
57 
58 G_END_DECLS
59