Fix up a bunch of details in the docs.
[platform/upstream/glib.git] / gio / gfileattribute.h
1 /* GIO - GLib Input, Output and Streaming Library
2  * 
3  * Copyright (C) 2006-2007 Red Hat, Inc.
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 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
16  * Public License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  * Boston, MA 02111-1307, USA.
19  *
20  * Author: Alexander Larsson <alexl@redhat.com>
21  */
22
23 #ifndef __G_FILE_ATTRIBUTE_H__
24 #define __G_FILE_ATTRIBUTE_H__
25
26 #include <glib-object.h>
27
28 G_BEGIN_DECLS
29
30 /**
31  * GFileAttributeType:
32  * @G_FILE_ATTRIBUTE_TYPE_INVALID: indicates an invalid or uninitalized type.
33  * @G_FILE_ATTRIBUTE_TYPE_STRING: a null terminated UTF8 string.
34  * @G_FILE_ATTRIBUTE_TYPE_BYTE_STRING: a zero terminated string of non-zero bytes.
35  * @G_FILE_ATTRIBUTE_TYPE_BOOLEAN: a boolean value.
36  * @G_FILE_ATTRIBUTE_TYPE_UINT32: an unsigned 4-byte/32-bit integer.
37  * @G_FILE_ATTRIBUTE_TYPE_INT32: a signed 4-byte/32-bit integer.
38  * @G_FILE_ATTRIBUTE_TYPE_UINT64: an unsigned 8-byte/64-bit integer.
39  * @G_FILE_ATTRIBUTE_TYPE_INT64: a signed 8-byte/64-bit integer.
40  * @G_FILE_ATTRIBUTE_TYPE_OBJECT: a #GObject.
41  * 
42  * The data type for #GFileAttributeValue<!-- -->s. 
43  **/ 
44 typedef enum {
45   G_FILE_ATTRIBUTE_TYPE_INVALID = 0,
46   G_FILE_ATTRIBUTE_TYPE_STRING,
47   G_FILE_ATTRIBUTE_TYPE_BYTE_STRING, /* zero terminated string of non-zero bytes */
48   G_FILE_ATTRIBUTE_TYPE_BOOLEAN,
49   G_FILE_ATTRIBUTE_TYPE_UINT32,
50   G_FILE_ATTRIBUTE_TYPE_INT32,
51   G_FILE_ATTRIBUTE_TYPE_UINT64,
52   G_FILE_ATTRIBUTE_TYPE_INT64,
53   G_FILE_ATTRIBUTE_TYPE_OBJECT
54 } GFileAttributeType;
55
56 /**
57  * GFileAttributeFlags:
58  * @G_FILE_ATTRIBUTE_FLAGS_NONE: no flags set.
59  * @G_FILE_ATTRIBUTE_FLAGS_COPY_WITH_FILE: copy the attribute values when the file is copied.
60  * @G_FILE_ATTRIBUTE_FLAGS_COPY_WHEN_MOVED: copy the attribute values when the file is moved.
61  * 
62  * A flag specifying the behaviour of an attribute.
63  **/
64 typedef enum {
65   G_FILE_ATTRIBUTE_FLAGS_NONE = 0,
66   G_FILE_ATTRIBUTE_FLAGS_COPY_WITH_FILE = 1 << 0,
67   G_FILE_ATTRIBUTE_FLAGS_COPY_WHEN_MOVED = 1 << 1
68 } GFileAttributeFlags;
69
70 /**
71  * GFileAttributeStatus:
72  * @G_FILE_ATTRIBUTE_STATUS_UNSET: Attribute value is unset (empty).
73  * @G_FILE_ATTRIBUTE_STATUS_SET: Attribute value is set.
74  * @G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING: Indicates an error in setting the value.
75  * 
76  * Used by g_file_set_attributes_from_info() when setting file attributes.
77  **/
78 typedef enum {
79   G_FILE_ATTRIBUTE_STATUS_UNSET = 0,
80   G_FILE_ATTRIBUTE_STATUS_SET,
81   G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING
82 } GFileAttributeStatus;
83
84 #define G_FILE_ATTRIBUTE_VALUE_INIT {0}
85
86 /**
87  * GFileAttributeValue:
88  * @type: a #GFileAttributeType.
89  * @status: a #GFileAttributeStatus.
90  *
91  * Contains the value data for the Key-Value pair.
92  **/
93 typedef struct  {
94   GFileAttributeType type : 8;
95   GFileAttributeStatus status : 8;
96   union {
97     gboolean boolean;
98     gint32 int32;
99     guint32 uint32;
100     gint64 int64;
101     guint64 uint64;
102     char *string;
103     GQuark quark;
104     GObject *obj;
105   } u;
106 } GFileAttributeValue;
107
108 /**
109  * GFileAttributeInfo:
110  * @name: the name of the attribute.
111  * @type: the #GFileAttributeType type of the attribute.
112  * @flags: a set of #GFileAttributeFlags.
113  * 
114  * Information about a specific attribute. 
115  **/
116 typedef struct {
117   char *name;
118   GFileAttributeType type;
119   GFileAttributeFlags flags;
120 } GFileAttributeInfo;
121
122 /**
123  * GFileAttributeInfoList:
124  * @infos: an array of #GFileAttributeInfo<!-- -->s.
125  * @n_infos: the number of values in the array.
126  * 
127  * Acts as a lightweight registry for possible valid file attributes.
128  * The registry stores Key-Value pair formats as #GFileAttributeInfo<!-- -->s.
129  **/
130 typedef struct {
131   GFileAttributeInfo *infos;
132   int n_infos;
133 } GFileAttributeInfoList;
134
135 GFileAttributeValue *g_file_attribute_value_new             (void);
136 void                 g_file_attribute_value_free            (GFileAttributeValue *attr);
137 void                 g_file_attribute_value_clear           (GFileAttributeValue *attr);
138 void                 g_file_attribute_value_set             (GFileAttributeValue *attr,
139                                                              const GFileAttributeValue *new_value);
140 GFileAttributeValue *g_file_attribute_value_dup             (const GFileAttributeValue *other);
141
142 char *               g_file_attribute_value_as_string       (const GFileAttributeValue *attr);
143
144 const char *         g_file_attribute_value_get_string      (const GFileAttributeValue *attr);
145 const char *         g_file_attribute_value_get_byte_string (const GFileAttributeValue *attr);
146 gboolean             g_file_attribute_value_get_boolean     (const GFileAttributeValue *attr);
147 guint32              g_file_attribute_value_get_uint32      (const GFileAttributeValue *attr);
148 gint32               g_file_attribute_value_get_int32       (const GFileAttributeValue *attr);
149 guint64              g_file_attribute_value_get_uint64      (const GFileAttributeValue *attr);
150 gint64               g_file_attribute_value_get_int64       (const GFileAttributeValue *attr);
151 GObject *            g_file_attribute_value_get_object      (const GFileAttributeValue *attr);
152
153 void                 g_file_attribute_value_set_string      (GFileAttributeValue *attr,
154                                                              const char          *string);
155 void                 g_file_attribute_value_set_byte_string (GFileAttributeValue *attr,
156                                                              const char          *string);
157 void                 g_file_attribute_value_set_boolean     (GFileAttributeValue *attr,
158                                                              gboolean             value);
159 void                 g_file_attribute_value_set_uint32      (GFileAttributeValue *attr,
160                                                              guint32              value);
161 void                 g_file_attribute_value_set_int32       (GFileAttributeValue *attr,
162                                                              gint32               value);
163 void                 g_file_attribute_value_set_uint64      (GFileAttributeValue *attr,
164                                                              guint64              value);
165 void                 g_file_attribute_value_set_int64       (GFileAttributeValue *attr,
166                                                              gint64               value);
167 void                 g_file_attribute_value_set_object      (GFileAttributeValue *attr,
168                                                              GObject             *obj);
169
170 GFileAttributeInfoList *  g_file_attribute_info_list_new    (void);
171 GFileAttributeInfoList *  g_file_attribute_info_list_ref    (GFileAttributeInfoList *list);
172 void                      g_file_attribute_info_list_unref  (GFileAttributeInfoList *list);
173 GFileAttributeInfoList *  g_file_attribute_info_list_dup    (GFileAttributeInfoList *list);
174 const GFileAttributeInfo *g_file_attribute_info_list_lookup (GFileAttributeInfoList *list,
175                                                              const char             *name);
176 void                      g_file_attribute_info_list_add    (GFileAttributeInfoList *list,
177                                                              const char             *name,
178                                                              GFileAttributeType      type,
179                                                              GFileAttributeFlags     flags);
180
181 G_END_DECLS
182
183
184 #endif /* __G_FILE_INFO_H__ */