source: trunk/nom/class_c/nomstring.c

Last change on this file was 384, checked in by cinc, 17 years ago

Changed some types in method definitions.

File size: 5.8 KB
Line 
1/* ***** BEGIN LICENSE BLOCK *****
2 * Version: CDDL 1.0/LGPL 2.1
3 *
4 * The contents of this file are subject to the COMMON DEVELOPMENT AND
5 * DISTRIBUTION LICENSE (CDDL) Version 1.0 (the "License"); you may not use
6 * this file except in compliance with the License. You may obtain a copy of
7 * the License at http://www.sun.com/cddl/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Original Code is "NOM" Netlabs Object Model
15 *
16 * The Initial Developer of the Original Code is
17 * netlabs.org: Chris Wohlgemuth <cinc-ml@netlabs.org>.
18 * Portions created by the Initial Developer are Copyright (C) 2006-2007
19 * the Initial Developer. All Rights Reserved.
20 *
21 * Contributor(s):
22 *
23 * Alternatively, the contents of this file may be used under the terms of
24 * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
25 * case the provisions of the LGPL are applicable instead of those above. If
26 * you wish to allow use of your version of this file only under the terms of
27 * the LGPL, and not to allow others to use your version of this file under
28 * the terms of the CDDL, indicate your decision by deleting the provisions
29 * above and replace them with the notice and other provisions required by the
30 * LGPL. If you do not delete the provisions above, a recipient may use your
31 * version of this file under the terms of any one of the CDDL or the LGPL.
32 *
33 * ***** END LICENSE BLOCK ***** */
34/*
35 * And remember, phase 3 is near...
36 */
37#ifndef NOM_NOMString_IMPLEMENTATION_FILE
38#define NOM_NOMString_IMPLEMENTATION_FILE
39#endif
40
41#if __OS2__
42#define INCL_DOS
43#include <os2.h>
44#endif /* __OS2__ */
45
46#include <nom.h>
47#include <nomtk.h>
48
49#include "nomstring.ih"
50
51
52NOMDLLEXPORT NOM_Scope NOMString* NOMLINK impl_NOMString_assign(NOMString* nomSelf,
53 const NOMString* nomString,
54 CORBA_Environment *ev)
55{
56 /* NOMStringData* nomThis = NOMStringGetData(nomSelf); */
57
58 NOMString_assignString(nomSelf, NOMString_queryString(nomString, NULL), NULL);
59 return nomSelf;
60}
61
62
63/* Assign a C string to this NOMString. An initially created NOMString object is empty. */
64NOMDLLEXPORT NOM_Scope NOMString* NOMLINK impl_NOMString_assignString(NOMString* nomSelf,
65 const CORBA_char* chrString,
66 CORBA_Environment *ev)
67{
68 NOMStringData* nomThis = NOMStringGetData(nomSelf);
69
70 g_string_assign(_gString, chrString); /* This copies the input string */
71 return nomSelf;
72}
73
74
75/* Returns the C string held by this NOMString. */
76NOMDLLEXPORT NOM_Scope string NOMLINK impl_NOMString_queryString(NOMString* nomSelf,
77 CORBA_Environment *ev)
78{
79 NOMStringData* nomThis = NOMStringGetData(nomSelf);
80
81 return _gString->str;
82}
83
84
85static PNOMString NOMLINK _appendString(NOMString* nomSelf, const CORBA_char * chrString,
86 CORBA_Environment *ev)
87{
88 NOMStringData* nomThis=NOMStringGetData(nomSelf);
89
90 g_string_append(_gString, chrString);
91
92 return nomSelf;
93}
94
95
96NOMDLLEXPORT NOM_Scope NOMString* NOMLINK impl_NOMString_append(NOMString* nomSelf,
97 const NOMString* nomString,
98 CORBA_Environment *ev)
99{
100 /* NOMStringData* nomThis = NOMStringGetData(nomSelf); */
101
102 return _appendString(nomSelf, NOMString_queryString(nomString, NULL), NULL);
103}
104
105
106static PNOMString NOMLINK _prependString(NOMString* nomSelf, const CORBA_char * chrString, CORBA_Environment *ev)
107{
108 NOMStringData* nomThis=NOMStringGetData(nomSelf);
109 g_string_prepend(_gString, chrString);
110
111 return nomSelf;
112}
113
114
115NOMDLLEXPORT NOM_Scope NOMString* NOMLINK impl_NOMString_prepend(NOMString* nomSelf,
116 const NOMString* nomString,
117 CORBA_Environment *ev)
118{
119 /* NOMStringData* nomThis = NOMStringGetData(nomSelf); */
120
121 return _prependString(nomSelf, NOMString_queryString(nomString, NULL), NULL);
122}
123
124
125NOMDLLEXPORT NOM_Scope gulong NOMLINK impl_NOMString_length(NOMString* nomSelf,
126 CORBA_Environment *ev)
127{
128 NOMStringData* nomThis = NOMStringGetData(nomSelf);
129
130 return _gString->len;
131}
132
133
134NOMDLLEXPORT NOM_Scope PNOMString NOMLINK impl_NOMString_truncate(NOMString* nomSelf,
135 const gulong ulNewLen,
136 CORBA_Environment *ev)
137{
138 NOMStringData* nomThis = NOMStringGetData(nomSelf);
139
140 g_string_truncate(_gString, ulNewLen);
141
142 return nomSelf;
143}
144
145
146NOMDLLEXPORT NOM_Scope NOMString* NOMLINK impl_NOMString_copy(NOMString* nomSelf,
147 CORBA_Environment *ev)
148{
149 /* NOMStringData* nomThis = NOMStringGetData(nomSelf); */
150 NOMString* nomRetval;
151
152 /* We don't know which class we're actually. So we can't just create a new NOMString here.
153 It is possible that we are called by a subclass. So use the instance method new() which takes
154 any subclassing into account. */
155 nomRetval=(PNOMString)NOMString_new(nomSelf, NULL);
156
157 NOMString_assign(nomRetval, nomSelf, ev);
158
159 return nomRetval;
160}
161
162
163NOMDLLEXPORT NOM_Scope void NOMLINK impl_NOMString_nomInit(NOMString* nomSelf,
164 CORBA_Environment *ev)
165{
166 NOMStringData* nomThis = NOMStringGetData(nomSelf);
167
168 /* call parent */
169 NOMString_nomInit_parent(nomSelf, ev);
170
171 /* Alloc a zero length GString */
172 _gString=g_string_new("");
173}
174
Note: See TracBrowser for help on using the repository browser.