2002-12-11 Havoc Pennington <hp@pobox.com>
[platform/upstream/dbus.git] / dbus / dbus-string.h
1 /* -*- mode: C; c-file-style: "gnu" -*- */
2 /* dbus-string.h String utility class (internal to D-BUS implementation)
3  * 
4  * Copyright (C) 2002  Red Hat, Inc.
5  *
6  * Licensed under the Academic Free License version 1.2
7  * 
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  * 
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  *
22  */
23
24 #ifndef DBUS_STRING_H
25 #define DBUS_STRING_H
26
27 #include <dbus/dbus-internals.h>
28 #include <dbus/dbus-memory.h>
29 #include <dbus/dbus-types.h>
30
31 DBUS_BEGIN_DECLS;
32
33 typedef struct DBusString DBusString;
34
35 struct DBusString
36 {
37   void *dummy1; /**< placeholder */
38   int   dummy2; /**< placeholder */
39   int   dummy3; /**< placeholder */
40   int   dummy4; /**< placeholder */
41   unsigned int dummy5 : 1; /** placeholder */
42   unsigned int dummy6 : 1; /** placeholder */
43   unsigned int dummy7 : 1; /** placeholder */
44 };
45
46 dbus_bool_t _dbus_string_init           (DBusString *str,
47                                          int         max_length);
48 void        _dbus_string_init_const     (DBusString *str,
49                                          const char *value);
50 void        _dbus_string_free           (DBusString *str);
51 void        _dbus_string_lock           (DBusString *str);
52
53 void        _dbus_string_get_data           (DBusString        *str,
54                                              char             **data_return);
55 void        _dbus_string_get_const_data     (const DBusString  *str,
56                                              const char       **data_return);
57 void        _dbus_string_get_data_len       (DBusString        *str,
58                                              char             **data_return,
59                                              int                start,
60                                              int                len);
61 void        _dbus_string_get_const_data_len (const DBusString  *str,
62                                              const char       **data_return,
63                                              int                start,
64                                              int                len);
65 dbus_bool_t _dbus_string_steal_data         (DBusString        *str,
66                                              char             **data_return);
67 dbus_bool_t _dbus_string_steal_data_len     (DBusString        *str,
68                                              char             **data_return,
69                                              int                start,
70                                              int                len);
71
72 int  _dbus_string_get_length         (const DBusString  *str);
73
74 dbus_bool_t _dbus_string_lengthen   (DBusString *str,
75                                      int         additional_length);
76 void        _dbus_string_shorten    (DBusString *str,
77                                      int         length_to_remove);
78 dbus_bool_t _dbus_string_set_length (DBusString *str,
79                                      int         length);
80
81 dbus_bool_t _dbus_string_append         (DBusString    *str,
82                                          const char    *buffer);
83 dbus_bool_t _dbus_string_append_len     (DBusString    *str,
84                                          const char    *buffer,
85                                          int            len);
86 dbus_bool_t _dbus_string_append_int     (DBusString    *str,
87                                          long           value);
88 dbus_bool_t _dbus_string_append_double  (DBusString    *str,
89                                          double         value);
90 dbus_bool_t _dbus_string_append_byte    (DBusString    *str,
91                                          unsigned char  byte);
92 dbus_bool_t _dbus_string_append_unichar (DBusString    *str,
93                                          dbus_unichar_t ch);
94
95
96 void        _dbus_string_delete     (DBusString       *str,
97                                      int               start,
98                                      int               len);
99 dbus_bool_t _dbus_string_move       (DBusString       *source,
100                                      int               start,
101                                      DBusString       *dest,
102                                      int               insert_at);
103 dbus_bool_t _dbus_string_copy       (const DBusString *source,
104                                      int               start,
105                                      DBusString       *dest,
106                                      int               insert_at);
107 dbus_bool_t _dbus_string_move_len   (DBusString       *source,
108                                      int               start,
109                                      int               len,
110                                      DBusString       *dest,
111                                      int               insert_at);
112 dbus_bool_t _dbus_string_copy_len   (const DBusString *source,
113                                      int               start,
114                                      int               len,
115                                      DBusString       *dest,
116                                      int               insert_at);
117
118
119 void       _dbus_string_get_unichar (const DBusString *str,
120                                      int               start,
121                                      dbus_unichar_t   *ch_return,
122                                      int              *end_return);
123
124 dbus_bool_t _dbus_string_parse_int    (const DBusString *str,
125                                        int               start,
126                                        long             *value_return,
127                                        int              *end_return);
128 dbus_bool_t _dbus_string_parse_double (const DBusString *str,
129                                        int               start,
130                                        double           *value,
131                                        int              *end_return);
132
133
134 DBUS_END_DECLS;
135
136 #endif /* DBUS_STRING_H */