sfcc 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.rdoc +4 -0
- data/MIT-LICENSE +22 -0
- data/Manifest.txt +28 -0
- data/README.rdoc +60 -0
- data/Rakefile +32 -0
- data/TODO.rdoc +28 -0
- data/ext/sfcc/cim_class.c +274 -0
- data/ext/sfcc/cim_class.h +12 -0
- data/ext/sfcc/cim_client.c +862 -0
- data/ext/sfcc/cim_client.h +12 -0
- data/ext/sfcc/cim_enumeration.c +65 -0
- data/ext/sfcc/cim_enumeration.h +12 -0
- data/ext/sfcc/cim_instance.c +357 -0
- data/ext/sfcc/cim_instance.h +12 -0
- data/ext/sfcc/cim_object_path.c +419 -0
- data/ext/sfcc/cim_object_path.h +12 -0
- data/ext/sfcc/cim_string.c +64 -0
- data/ext/sfcc/cim_string.h +12 -0
- data/ext/sfcc/extconf.rb +8 -0
- data/ext/sfcc/sfcc.c +344 -0
- data/ext/sfcc/sfcc.h +87 -0
- data/lib/sfcc.rb +174 -0
- data/test/helper.rb +32 -0
- data/test/test_sfcc.rb +69 -0
- data/test/test_sfcc_cim_class.rb +53 -0
- data/test/test_sfcc_cim_client.rb +151 -0
- data/test/test_sfcc_cim_enumeration.rb +24 -0
- data/test/test_sfcc_cim_instance.rb +89 -0
- data/test/test_sfcc_cim_object_path.rb +85 -0
- metadata +152 -0
@@ -0,0 +1,419 @@
|
|
1
|
+
|
2
|
+
#include "cim_object_path.h"
|
3
|
+
|
4
|
+
static void
|
5
|
+
dealloc(CMPIObjectPath *object_path)
|
6
|
+
{
|
7
|
+
//SFCC_DEC_REFCOUNT(object_path);
|
8
|
+
}
|
9
|
+
|
10
|
+
/**
|
11
|
+
* call-seq:
|
12
|
+
* namespace=(ns)
|
13
|
+
*
|
14
|
+
* Set/replace the namespace component
|
15
|
+
*/
|
16
|
+
static VALUE set_namespace(VALUE self, VALUE val)
|
17
|
+
{
|
18
|
+
CMPIObjectPath *ptr = NULL;
|
19
|
+
CMPIStatus status;
|
20
|
+
Data_Get_Struct(self, CMPIObjectPath, ptr);
|
21
|
+
status = ptr->ft->setNameSpace(ptr, StringValuePtr(val));
|
22
|
+
if (!status.rc)
|
23
|
+
return val;
|
24
|
+
sfcc_rb_raise_if_error(status, "Can't set namespace");
|
25
|
+
return Qnil;
|
26
|
+
}
|
27
|
+
|
28
|
+
/**
|
29
|
+
* call-seq:
|
30
|
+
* namespace()
|
31
|
+
*
|
32
|
+
* Get the namespace component
|
33
|
+
*/
|
34
|
+
static VALUE namespace(VALUE self)
|
35
|
+
{
|
36
|
+
CMPIObjectPath *ptr = NULL;
|
37
|
+
CMPIString *cimstr = NULL;
|
38
|
+
CMPIStatus status;
|
39
|
+
Data_Get_Struct(self, CMPIObjectPath, ptr);
|
40
|
+
cimstr = ptr->ft->getNameSpace(ptr, &status);
|
41
|
+
if (!status.rc)
|
42
|
+
return cimstr ? rb_str_new2(cimstr->ft->getCharPtr(cimstr, NULL)) : Qnil;
|
43
|
+
sfcc_rb_raise_if_error(status, "Can't get namespace");
|
44
|
+
return Qnil;
|
45
|
+
}
|
46
|
+
|
47
|
+
/**
|
48
|
+
* call-seq:
|
49
|
+
* hostname=(ns)
|
50
|
+
*
|
51
|
+
* Set/replace the hostname component
|
52
|
+
*/
|
53
|
+
static VALUE set_hostname(VALUE self, VALUE val)
|
54
|
+
{
|
55
|
+
CMPIObjectPath *ptr = NULL;
|
56
|
+
Data_Get_Struct(self, CMPIObjectPath, ptr);
|
57
|
+
CMPIStatus status;
|
58
|
+
status = ptr->ft->setHostname(ptr, StringValuePtr(val));
|
59
|
+
if (!status.rc)
|
60
|
+
return val;
|
61
|
+
sfcc_rb_raise_if_error(status, "Can't set hostname");
|
62
|
+
return Qnil;
|
63
|
+
}
|
64
|
+
|
65
|
+
/**
|
66
|
+
* call-seq:
|
67
|
+
* hostname()
|
68
|
+
*
|
69
|
+
* Get the hostname component
|
70
|
+
*/
|
71
|
+
static VALUE hostname(VALUE self)
|
72
|
+
{
|
73
|
+
CMPIObjectPath *ptr = NULL;
|
74
|
+
CMPIString *cimstr = NULL;
|
75
|
+
CMPIStatus status;
|
76
|
+
Data_Get_Struct(self, CMPIObjectPath, ptr);
|
77
|
+
cimstr = ptr->ft->getHostname(ptr, &status);
|
78
|
+
if (!status.rc)
|
79
|
+
return cimstr ? rb_str_new2(cimstr->ft->getCharPtr(cimstr, NULL)) : Qnil;
|
80
|
+
sfcc_rb_raise_if_error(status, "Can't get hostname");
|
81
|
+
return Qnil;
|
82
|
+
}
|
83
|
+
|
84
|
+
/**
|
85
|
+
* call-seq:
|
86
|
+
* class_name=(ns)
|
87
|
+
* Set/replace the class name component
|
88
|
+
*/
|
89
|
+
static VALUE set_class_name(VALUE self, VALUE val)
|
90
|
+
{
|
91
|
+
CMPIObjectPath *ptr = NULL;
|
92
|
+
Data_Get_Struct(self, CMPIObjectPath, ptr);
|
93
|
+
ptr->ft->setClassName(ptr, StringValuePtr(val));
|
94
|
+
return val;
|
95
|
+
}
|
96
|
+
|
97
|
+
/**
|
98
|
+
* call-seq:
|
99
|
+
* class_name()
|
100
|
+
*
|
101
|
+
* Get the class name component
|
102
|
+
*/
|
103
|
+
static VALUE class_name(VALUE self)
|
104
|
+
{
|
105
|
+
CMPIObjectPath *ptr = NULL;
|
106
|
+
CMPIString *cimstr = NULL;
|
107
|
+
Data_Get_Struct(self, CMPIObjectPath, ptr);
|
108
|
+
cimstr = ptr->ft->getClassName(ptr, NULL);
|
109
|
+
return cimstr ? rb_str_new2(cimstr->ft->getCharPtr(cimstr, NULL)) : Qnil;
|
110
|
+
}
|
111
|
+
|
112
|
+
/**
|
113
|
+
* call-seq:
|
114
|
+
* add_key(name, value)
|
115
|
+
*
|
116
|
+
* adds a named key value
|
117
|
+
*/
|
118
|
+
static VALUE add_key(VALUE self, VALUE name, VALUE value)
|
119
|
+
{
|
120
|
+
CMPIObjectPath *ptr = NULL;
|
121
|
+
CMPIData data;
|
122
|
+
Data_Get_Struct(self, CMPIObjectPath, ptr);
|
123
|
+
data = sfcc_value_to_cimdata(value);
|
124
|
+
ptr->ft->addKey(ptr, StringValuePtr(name), &data.value, data.type);
|
125
|
+
return value;
|
126
|
+
}
|
127
|
+
|
128
|
+
/**
|
129
|
+
* call-seq:
|
130
|
+
* key(name)
|
131
|
+
*
|
132
|
+
* Gets a named key value
|
133
|
+
*/
|
134
|
+
static VALUE key(VALUE self, VALUE name)
|
135
|
+
{
|
136
|
+
CMPIObjectPath *ptr = NULL;
|
137
|
+
CMPIStatus status;
|
138
|
+
CMPIData data;
|
139
|
+
Data_Get_Struct(self, CMPIObjectPath, ptr);
|
140
|
+
data = ptr->ft->getKey(ptr, StringValuePtr(name), &status);
|
141
|
+
if ( !status.rc )
|
142
|
+
return sfcc_cimdata_to_value(data);
|
143
|
+
|
144
|
+
sfcc_rb_raise_if_error(status, "Can't retrieve key '%s'", StringValuePtr(name));
|
145
|
+
return Qnil;
|
146
|
+
}
|
147
|
+
|
148
|
+
/**
|
149
|
+
* call-seq:
|
150
|
+
* ObjectPath.each_key do |name, value|
|
151
|
+
* ...
|
152
|
+
* end
|
153
|
+
*
|
154
|
+
* enumerates properties yielding the key name and
|
155
|
+
* its value
|
156
|
+
*
|
157
|
+
*/
|
158
|
+
static VALUE each_key(VALUE self)
|
159
|
+
{
|
160
|
+
CMPIObjectPath *ptr = NULL;
|
161
|
+
CMPIStatus status;
|
162
|
+
int k=0;
|
163
|
+
int num_props=0;
|
164
|
+
CMPIString *key_name = NULL;
|
165
|
+
CMPIData data;
|
166
|
+
Data_Get_Struct(self, CMPIObjectPath, ptr);
|
167
|
+
|
168
|
+
num_props = ptr->ft->getKeyCount(ptr, &status);
|
169
|
+
if (!status.rc) {
|
170
|
+
for (; k < num_props; ++k) {
|
171
|
+
data = ptr->ft->getKeyAt(ptr, k, &key_name, &status);
|
172
|
+
if (!status.rc) {
|
173
|
+
rb_yield_values(2, (key_name ? rb_str_intern(rb_str_new2(key_name->ft->getCharPtr(key_name, NULL))) : Qnil), sfcc_cimdata_to_value(data));
|
174
|
+
}
|
175
|
+
else {
|
176
|
+
sfcc_rb_raise_if_error(status, "Can't retrieve key #%d", k);
|
177
|
+
}
|
178
|
+
if (key_name) CMRelease(key_name);
|
179
|
+
}
|
180
|
+
}
|
181
|
+
else {
|
182
|
+
sfcc_rb_raise_if_error(status, "Can't retrieve key count");
|
183
|
+
}
|
184
|
+
return Qnil;
|
185
|
+
}
|
186
|
+
|
187
|
+
/**
|
188
|
+
* call-seq:
|
189
|
+
* key_count()
|
190
|
+
*
|
191
|
+
* Gets the number of properties contained in this ObjectPath
|
192
|
+
*/
|
193
|
+
static VALUE key_count(VALUE self)
|
194
|
+
{
|
195
|
+
CMPIObjectPath *ptr = NULL;
|
196
|
+
Data_Get_Struct(self, CMPIObjectPath, ptr);
|
197
|
+
return UINT2NUM(ptr->ft->getKeyCount(ptr, NULL));
|
198
|
+
}
|
199
|
+
|
200
|
+
/**
|
201
|
+
* call-seq:
|
202
|
+
* set_namespace_from(object_path)
|
203
|
+
*
|
204
|
+
* Set/replace the namespace and classname components
|
205
|
+
* from +object_path+
|
206
|
+
*/
|
207
|
+
static VALUE set_namespace_from(VALUE self, VALUE object_path)
|
208
|
+
{
|
209
|
+
CMPIObjectPath *ptr = NULL;
|
210
|
+
CMPIObjectPath *src = NULL;
|
211
|
+
CMPIStatus status;
|
212
|
+
|
213
|
+
Data_Get_Struct(self, CMPIObjectPath, ptr);
|
214
|
+
Data_Get_Struct(object_path, CMPIObjectPath, src);
|
215
|
+
|
216
|
+
status = ptr->ft->setNameSpaceFromObjectPath(ptr, src);
|
217
|
+
|
218
|
+
if (!status.rc)
|
219
|
+
return self;
|
220
|
+
|
221
|
+
sfcc_rb_raise_if_error(status, "Can't set namespace");
|
222
|
+
return Qnil;
|
223
|
+
}
|
224
|
+
|
225
|
+
/**
|
226
|
+
* call-seq:
|
227
|
+
* set_host_and_namespace_from(object_path)
|
228
|
+
*
|
229
|
+
* Set/replace the hostname namespace and classname components
|
230
|
+
* from +object_path+
|
231
|
+
*/
|
232
|
+
static VALUE set_host_and_namespace_from(VALUE self, VALUE object_path)
|
233
|
+
{
|
234
|
+
CMPIObjectPath *ptr = NULL;
|
235
|
+
CMPIObjectPath *src = NULL;
|
236
|
+
CMPIStatus status;
|
237
|
+
|
238
|
+
Data_Get_Struct(self, CMPIObjectPath, ptr);
|
239
|
+
Data_Get_Struct(object_path, CMPIObjectPath, src);
|
240
|
+
|
241
|
+
status = ptr->ft->setHostAndNameSpaceFromObjectPath(ptr, src);
|
242
|
+
|
243
|
+
if (!status.rc)
|
244
|
+
return self;
|
245
|
+
|
246
|
+
sfcc_rb_raise_if_error(status, "Can't set namespace and hostname");
|
247
|
+
return Qnil;
|
248
|
+
}
|
249
|
+
|
250
|
+
/**
|
251
|
+
* call-seq:
|
252
|
+
* class_qualifier(qualifier_name)
|
253
|
+
*
|
254
|
+
* Get class qualifier value
|
255
|
+
*/
|
256
|
+
static VALUE class_qualifier(VALUE self, VALUE qualifier_name)
|
257
|
+
{
|
258
|
+
CMPIObjectPath *ptr = NULL;
|
259
|
+
CMPIStatus status;
|
260
|
+
CMPIData data;
|
261
|
+
memset(&status, 0, sizeof(CMPIStatus));
|
262
|
+
Data_Get_Struct(self, CMPIObjectPath, ptr);
|
263
|
+
data = ptr->ft->getClassQualifier(ptr, StringValuePtr(qualifier_name), &status);
|
264
|
+
if ( !status.rc )
|
265
|
+
return sfcc_cimdata_to_value(data);
|
266
|
+
|
267
|
+
sfcc_rb_raise_if_error(status, "Can't retrieve class qualifier '%s'", StringValuePtr(qualifier_name));
|
268
|
+
return Qnil;
|
269
|
+
}
|
270
|
+
|
271
|
+
/**
|
272
|
+
* call-seq:
|
273
|
+
* property_qualifier(property_name, qualifier_name)
|
274
|
+
*
|
275
|
+
* Get property qualifier value
|
276
|
+
*/
|
277
|
+
static VALUE property_qualifier(VALUE self, VALUE property_name, VALUE qualifier_name)
|
278
|
+
{
|
279
|
+
CMPIObjectPath *ptr = NULL;
|
280
|
+
CMPIStatus status;
|
281
|
+
CMPIData data;
|
282
|
+
memset(&status, 0, sizeof(CMPIStatus));
|
283
|
+
Data_Get_Struct(self, CMPIObjectPath, ptr);
|
284
|
+
data = ptr->ft->getPropertyQualifier(ptr, StringValuePtr(property_name),
|
285
|
+
StringValuePtr(qualifier_name), &status);
|
286
|
+
if ( !status.rc )
|
287
|
+
return sfcc_cimdata_to_value(data);
|
288
|
+
|
289
|
+
sfcc_rb_raise_if_error(status, "Can't retrieve property qualifier '%s' for property '%s'", StringValuePtr(qualifier_name), StringValuePtr(property_name));
|
290
|
+
return Qnil;
|
291
|
+
}
|
292
|
+
|
293
|
+
/**
|
294
|
+
* call-seq:
|
295
|
+
* method_qualifier(method_name, qualifier_name)
|
296
|
+
*
|
297
|
+
* Get method qualifier value
|
298
|
+
*/
|
299
|
+
static VALUE method_qualifier(VALUE self, VALUE method_name, VALUE qualifier_name)
|
300
|
+
{
|
301
|
+
CMPIObjectPath *ptr = NULL;
|
302
|
+
CMPIStatus status;
|
303
|
+
CMPIData data;
|
304
|
+
memset(&status, 0, sizeof(CMPIStatus));
|
305
|
+
Data_Get_Struct(self, CMPIObjectPath, ptr);
|
306
|
+
data = ptr->ft->getMethodQualifier(ptr, StringValuePtr(method_name),
|
307
|
+
StringValuePtr(qualifier_name), &status);
|
308
|
+
if ( !status.rc )
|
309
|
+
return sfcc_cimdata_to_value(data);
|
310
|
+
|
311
|
+
sfcc_rb_raise_if_error(status, "Can't retrieve method qualifier '%s' for method '%s'", StringValuePtr(qualifier_name), StringValuePtr(method_name));
|
312
|
+
return Qnil;
|
313
|
+
}
|
314
|
+
|
315
|
+
/**
|
316
|
+
* call-seq:
|
317
|
+
* parameter_qualifier(parameter_name, qualifier_name)
|
318
|
+
*
|
319
|
+
* Get parameter qualifier value
|
320
|
+
*/
|
321
|
+
static VALUE parameter_qualifier(VALUE self,
|
322
|
+
VALUE method_name,
|
323
|
+
VALUE parameter_name,
|
324
|
+
VALUE qualifier_name)
|
325
|
+
{
|
326
|
+
CMPIObjectPath *ptr = NULL;
|
327
|
+
CMPIStatus status;
|
328
|
+
CMPIData data;
|
329
|
+
memset(&status, 0, sizeof(CMPIStatus));
|
330
|
+
Data_Get_Struct(self, CMPIObjectPath, ptr);
|
331
|
+
data = ptr->ft->getParameterQualifier(ptr,
|
332
|
+
StringValuePtr(method_name),
|
333
|
+
StringValuePtr(parameter_name),
|
334
|
+
StringValuePtr(qualifier_name), &status);
|
335
|
+
if ( !status.rc )
|
336
|
+
return sfcc_cimdata_to_value(data);
|
337
|
+
|
338
|
+
sfcc_rb_raise_if_error(status, "Can't retrieve parameter qualifier '%s' for '%s'/'%s'", StringValuePtr(qualifier_name), StringValuePtr(method_name), StringValuePtr(parameter_name));
|
339
|
+
return Qnil;
|
340
|
+
}
|
341
|
+
|
342
|
+
/**
|
343
|
+
* call-seq:
|
344
|
+
* to_s
|
345
|
+
* Generates a well formed string representation of this ObjectPath
|
346
|
+
*/
|
347
|
+
static VALUE to_s(VALUE self)
|
348
|
+
{
|
349
|
+
CMPIObjectPath *ptr = NULL;
|
350
|
+
CMPIString *cimstr = NULL;
|
351
|
+
Data_Get_Struct(self, CMPIObjectPath, ptr);
|
352
|
+
cimstr = ptr->ft->toString(ptr, NULL);
|
353
|
+
return cimstr ? rb_str_new2(cimstr->ft->getCharPtr(cimstr, NULL)) : Qnil;
|
354
|
+
}
|
355
|
+
|
356
|
+
/**
|
357
|
+
* call-seq:
|
358
|
+
* new()
|
359
|
+
*
|
360
|
+
* Creates an object path from +namespace+ and +class_name+
|
361
|
+
*
|
362
|
+
*/
|
363
|
+
static VALUE new(VALUE klass, VALUE namespace, VALUE class_name)
|
364
|
+
{
|
365
|
+
CMPIStatus status;
|
366
|
+
CMPIObjectPath *ptr = NULL;
|
367
|
+
CMPIObjectPath *newop = NULL;
|
368
|
+
memset(&status, 0, sizeof(CMPIStatus));
|
369
|
+
ptr = newCMPIObjectPath(NIL_P(namespace) ? NULL : StringValuePtr(namespace),
|
370
|
+
NIL_P(class_name) ? NULL : StringValuePtr(class_name),
|
371
|
+
&status);
|
372
|
+
|
373
|
+
newop = ptr->ft->clone(ptr, &status);
|
374
|
+
ptr->ft->release(ptr);
|
375
|
+
|
376
|
+
if (!status.rc)
|
377
|
+
return Sfcc_wrap_cim_object_path(newop);
|
378
|
+
sfcc_rb_raise_if_error(status, "Can't create object path");
|
379
|
+
return Qnil;
|
380
|
+
}
|
381
|
+
|
382
|
+
VALUE
|
383
|
+
Sfcc_wrap_cim_object_path(CMPIObjectPath *object_path)
|
384
|
+
{
|
385
|
+
SFCC_INC_REFCOUNT(object_path);
|
386
|
+
return Data_Wrap_Struct(cSfccCimObjectPath, NULL, dealloc, object_path);
|
387
|
+
}
|
388
|
+
|
389
|
+
VALUE cSfccCimObjectPath;
|
390
|
+
void init_cim_object_path()
|
391
|
+
{
|
392
|
+
VALUE sfcc = rb_define_module("Sfcc");
|
393
|
+
VALUE cimc = rb_define_module_under(sfcc, "Cim");
|
394
|
+
|
395
|
+
/**
|
396
|
+
* an object path on the CIM namespace
|
397
|
+
*/
|
398
|
+
VALUE klass = rb_define_class_under(cimc, "ObjectPath", rb_cObject);
|
399
|
+
cSfccCimObjectPath = klass;
|
400
|
+
|
401
|
+
rb_define_singleton_method(klass, "new", new, 2);
|
402
|
+
rb_define_method(klass, "namespace=", set_namespace, 1);
|
403
|
+
rb_define_method(klass, "namespace", namespace, 0);
|
404
|
+
rb_define_method(klass, "hostname=", set_hostname, 1);
|
405
|
+
rb_define_method(klass, "hostname", hostname, 0);
|
406
|
+
rb_define_method(klass, "class_name=", set_class_name, 1);
|
407
|
+
rb_define_method(klass, "class_name", class_name, 0);
|
408
|
+
rb_define_method(klass, "add_key", add_key, 2);
|
409
|
+
rb_define_method(klass, "key", key, 1);
|
410
|
+
rb_define_method(klass, "each_key", each_key, 0);
|
411
|
+
rb_define_method(klass, "key_count", key_count, 0);
|
412
|
+
rb_define_method(klass, "set_namespace_from", set_namespace_from, 1);
|
413
|
+
rb_define_method(klass, "set_host_and_namespace_from", set_host_and_namespace_from, 1);
|
414
|
+
rb_define_method(klass, "class_qualifier", class_qualifier, 1);
|
415
|
+
rb_define_method(klass, "property_qualifier", property_qualifier, 2);
|
416
|
+
rb_define_method(klass, "method_qualifier", method_qualifier, 2);
|
417
|
+
rb_define_method(klass, "parameter_qualifier", parameter_qualifier, 3);
|
418
|
+
rb_define_method(klass, "to_s", to_s, 0);
|
419
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
|
2
|
+
#ifndef RUBY_NATIVE_SFCC_CIM_OBJECT_PATH_H
|
3
|
+
#define RUBY_NATIVE_SFCC_CIM_OBJECT_PATH_H
|
4
|
+
|
5
|
+
#include "sfcc.h"
|
6
|
+
|
7
|
+
void init_cim_object_path();
|
8
|
+
|
9
|
+
extern VALUE cSfccCimObjectPath;
|
10
|
+
VALUE Sfcc_wrap_cim_object_path(CMPIObjectPath *object_path);
|
11
|
+
|
12
|
+
#endif
|
@@ -0,0 +1,64 @@
|
|
1
|
+
#include "cim_string.h"
|
2
|
+
|
3
|
+
static void
|
4
|
+
dealloc(CMPIString *string)
|
5
|
+
{
|
6
|
+
SFCC_DEC_REFCOUNT(string);
|
7
|
+
}
|
8
|
+
|
9
|
+
/**
|
10
|
+
* call-seq:
|
11
|
+
* to_s
|
12
|
+
* Generates a well formed string representation of this String
|
13
|
+
*/
|
14
|
+
static VALUE to_s(VALUE self)
|
15
|
+
{
|
16
|
+
CMPIString *ptr = NULL;
|
17
|
+
char *str = NULL;
|
18
|
+
Data_Get_Struct(self, CMPIString, ptr);
|
19
|
+
str = ptr->ft->getCharPtr(ptr, NULL);
|
20
|
+
return str ? rb_str_new2(str) : Qnil;
|
21
|
+
}
|
22
|
+
|
23
|
+
/**
|
24
|
+
* call-seq
|
25
|
+
* new
|
26
|
+
* Creates a CIM string from a string value
|
27
|
+
*
|
28
|
+
*/
|
29
|
+
static VALUE new(VALUE klass, VALUE value)
|
30
|
+
{
|
31
|
+
CMPIStatus status;
|
32
|
+
CMPIString *newstr = NULL;
|
33
|
+
CMPIString *ptr = newCMPIString(StringValuePtr(value),
|
34
|
+
&status);
|
35
|
+
newstr = ptr->ft->clone(ptr, &status);
|
36
|
+
ptr->ft->release(ptr);
|
37
|
+
if (!status.rc)
|
38
|
+
return Sfcc_wrap_cim_string(newstr);
|
39
|
+
sfcc_rb_raise_if_error(status, "Can't create CIM string");
|
40
|
+
return Qnil;
|
41
|
+
}
|
42
|
+
|
43
|
+
VALUE
|
44
|
+
Sfcc_wrap_cim_string(CMPIString *string)
|
45
|
+
{
|
46
|
+
SFCC_INC_REFCOUNT(string);
|
47
|
+
return Data_Wrap_Struct(cSfccCimString, NULL, dealloc, string);
|
48
|
+
}
|
49
|
+
|
50
|
+
VALUE cSfccCimString;
|
51
|
+
void init_cim_string()
|
52
|
+
{
|
53
|
+
VALUE sfcc = rb_define_module("Sfcc");
|
54
|
+
VALUE cimc = rb_define_module_under(sfcc, "Cim");
|
55
|
+
|
56
|
+
/**
|
57
|
+
* a string in the CIM environemtn
|
58
|
+
*/
|
59
|
+
VALUE klass = rb_define_class_under(cimc, "String", rb_cObject);
|
60
|
+
cSfccCimString = klass;
|
61
|
+
|
62
|
+
rb_define_singleton_method(klass, "new", new, 1);
|
63
|
+
rb_define_method(klass, "to_s", to_s, 0);
|
64
|
+
}
|