00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <interface/field_iterator.h>
00026
00027 #include <core/exceptions/software.h>
00028 #include <core/exceptions/system.h>
00029
00030 #include <cstdlib>
00031 #include <cstring>
00032 #include <cstdio>
00033
00034 namespace fawkes {
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 InterfaceFieldIterator::InterfaceFieldIterator()
00049 {
00050 __infol = NULL;
00051 __value_string = NULL;
00052 }
00053
00054
00055
00056
00057
00058
00059 InterfaceFieldIterator::InterfaceFieldIterator(const interface_fieldinfo_t *info_list)
00060 {
00061 __infol = info_list;
00062 __value_string = NULL;
00063 }
00064
00065
00066
00067
00068
00069 InterfaceFieldIterator::InterfaceFieldIterator(const InterfaceFieldIterator &fit)
00070 {
00071 __infol = fit.__infol;
00072 if ( fit.__value_string ) {
00073 __value_string = strdup(fit.__value_string);
00074 } else {
00075 __value_string = NULL;
00076 }
00077 }
00078
00079
00080
00081 InterfaceFieldIterator::~InterfaceFieldIterator()
00082 {
00083 if ( __value_string ) free(__value_string);
00084 }
00085
00086
00087
00088
00089
00090 InterfaceFieldIterator &
00091 InterfaceFieldIterator::operator++()
00092 {
00093 if ( __infol != NULL ) {
00094 __infol = __infol->next;
00095 if ( __value_string ) free(__value_string);
00096 __value_string = NULL;
00097 }
00098
00099 return *this;
00100 }
00101
00102
00103
00104
00105
00106
00107 InterfaceFieldIterator
00108 InterfaceFieldIterator::operator++(int inc)
00109 {
00110 InterfaceFieldIterator rv(*this);
00111 ++(*this);
00112 return rv;
00113 }
00114
00115
00116
00117
00118
00119
00120 InterfaceFieldIterator &
00121 InterfaceFieldIterator::operator+(unsigned int i)
00122 {
00123 for (unsigned int j = 0; j < i; ++j) {
00124 ++(*this);
00125 }
00126 return *this;
00127 }
00128
00129
00130
00131
00132
00133
00134 InterfaceFieldIterator &
00135 InterfaceFieldIterator::operator+=(unsigned int i)
00136 {
00137 for (unsigned int j = 0; j < i; ++j) {
00138 ++(*this);
00139 }
00140 return *this;
00141 }
00142
00143
00144
00145
00146
00147
00148 bool
00149 InterfaceFieldIterator::operator==(const InterfaceFieldIterator & fi) const
00150 {
00151 return (__infol == fi.__infol);
00152 }
00153
00154
00155
00156
00157
00158
00159 bool
00160 InterfaceFieldIterator::operator!=(const InterfaceFieldIterator & fi) const
00161 {
00162 return ! (*this == fi);
00163 }
00164
00165
00166
00167
00168
00169 const void *
00170 InterfaceFieldIterator::operator*() const
00171 {
00172 if ( __infol == NULL ) {
00173 throw NullPointerException("Cannot get value of end element");
00174 } else {
00175 return __infol->value;
00176 }
00177 }
00178
00179
00180
00181
00182
00183
00184 InterfaceFieldIterator &
00185 InterfaceFieldIterator::operator=(const InterfaceFieldIterator & fi)
00186 {
00187 __infol = fi.__infol;
00188
00189 return *this;
00190 }
00191
00192
00193
00194
00195
00196 interface_fieldtype_t
00197 InterfaceFieldIterator::get_type() const
00198 {
00199 if ( __infol == NULL ) {
00200 throw NullPointerException("Cannot get type of end element");
00201 } else {
00202 return __infol->type;
00203 }
00204 }
00205
00206
00207
00208
00209
00210 const char *
00211 InterfaceFieldIterator::get_typename() const
00212 {
00213 if ( __infol == NULL ) {
00214 throw NullPointerException("Cannot get type of end element");
00215 } else {
00216 switch (__infol->type) {
00217 case IFT_BOOL: return "bool";
00218 case IFT_INT: return "int";
00219 case IFT_UINT: return "unsigned int";
00220 case IFT_LONGINT: return "long int";
00221 case IFT_LONGUINT: return "long unsigned int";
00222 case IFT_FLOAT: return "float";
00223 case IFT_BYTE: return "byte";
00224 case IFT_STRING: return "string";
00225 default: return "unknown";
00226 }
00227 }
00228 }
00229
00230
00231
00232
00233
00234 const char *
00235 InterfaceFieldIterator::get_name() const
00236 {
00237 if ( __infol == NULL ) {
00238 throw NullPointerException("Cannot get name of end element");
00239 } else {
00240 return __infol->name;
00241 }
00242 }
00243
00244
00245
00246
00247
00248 const void *
00249 InterfaceFieldIterator::get_value() const
00250 {
00251 if ( __infol == NULL ) {
00252 throw NullPointerException("Cannot get value of end element");
00253 } else {
00254 return __infol->value;
00255 }
00256 }
00257
00258
00259
00260
00261
00262 size_t
00263 InterfaceFieldIterator::get_length() const
00264 {
00265 if ( __infol == NULL ) {
00266 throw NullPointerException("Cannot get length of end element");
00267 } else {
00268 return __infol->length;
00269 }
00270 }
00271
00272
00273
00274
00275
00276 const char *
00277 InterfaceFieldIterator::get_value_string()
00278 {
00279 if ( __infol == NULL ) {
00280 throw NullPointerException("Cannot get value of end element");
00281 } else {
00282 if ( __value_string == NULL ) {
00283 if ( __infol->length == 0 ) throw OutOfBoundsException("Field length out of bounds",
00284 __infol->length, 1, (unsigned int)0xFFFFFFFF);
00285
00286 char *tmp1 = strdup("");
00287 char *tmp2;
00288
00289 if ( __infol->type != IFT_STRING ) {
00290 for (size_t i = 0; i < __infol->length; ++i) {
00291 int rv = 0;
00292 switch (__infol->type) {
00293 case IFT_BOOL:
00294 rv = asprintf(&tmp2, "%s%s", tmp1, (((bool *)__infol->value)[i]) ? "true" : "false");
00295 break;
00296 case IFT_INT:
00297 rv = asprintf(&tmp2, "%s%i", tmp1, ((int *)__infol->value)[i]);
00298 break;
00299 case IFT_UINT:
00300 rv = asprintf(&tmp2, "%s%u", tmp1, ((unsigned int *)__infol->value)[i]);
00301 break;
00302 case IFT_LONGINT:
00303 rv = asprintf(&tmp2, "%s%li", tmp1, ((long int *)__infol->value)[i]);
00304 break;
00305 case IFT_LONGUINT:
00306 rv = asprintf(&tmp2, "%s%lu", tmp1, ((long unsigned int *)__infol->value)[i]);
00307 break;
00308 case IFT_FLOAT:
00309 rv = asprintf(&tmp2, "%s%f", tmp1, ((float *)__infol->value)[i]);
00310 break;
00311 case IFT_BYTE:
00312 rv = asprintf(&tmp2, "%s%u", tmp1, ((unsigned char *)__infol->value)[i]);
00313 break;
00314 case IFT_STRING:
00315
00316 break;
00317 }
00318
00319 if ( rv == -1 ) {
00320 throw OutOfMemoryException("InterfaceFieldIterator::get_value_string(): asprintf() failed (1)");
00321 }
00322
00323 free(tmp1);
00324 tmp1 = tmp2;
00325 if ( (__infol->length > 1) && (i < __infol->length - 1) ) {
00326 if (asprintf(&tmp2, "%s, ", tmp1) == -1) {
00327 throw OutOfMemoryException("InterfaceFieldIterator::get_value_string(): asprintf() failed (2)");
00328 }
00329 free(tmp1);
00330 tmp1 = tmp2;
00331 }
00332 }
00333
00334 __value_string = tmp1;
00335 } else {
00336
00337 if ( __infol->length > 1 ) {
00338 if (asprintf(&__value_string, "%s", (const char *)__infol->value) == -1) {
00339 throw OutOfMemoryException("InterfaceFieldIterator::get_value_string(): asprintf() failed (3)");
00340 }
00341 } else {
00342 if (asprintf(&__value_string, "%c", *((const char *)__infol->value)) == -1) {
00343 throw OutOfMemoryException("InterfaceFieldIterator::get_value_string(): asprintf() failed (4)");
00344 }
00345 }
00346 }
00347 }
00348 return __value_string;
00349 }
00350 }
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360 bool
00361 InterfaceFieldIterator::get_bool(unsigned int index) const
00362 {
00363 if ( __infol == NULL ) {
00364 throw NullPointerException("Cannot get value of end element");
00365 } else if ( __infol->type != IFT_BOOL ) {
00366 throw TypeMismatchException("Requested value is not of type bool");
00367 } else if (index >= __infol->length) {
00368 throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
00369 } else {
00370 return ((bool *)__infol->value)[index];
00371 }
00372 }
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382 int
00383 InterfaceFieldIterator::get_int(unsigned int index) const
00384 {
00385 if ( __infol == NULL ) {
00386 throw NullPointerException("Cannot get value of end element");
00387 } else if ( __infol->type != IFT_INT ) {
00388 throw TypeMismatchException("Requested value is not of type int");
00389 } else if (index >= __infol->length) {
00390 throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
00391 } else {
00392 return ((int *)__infol->value)[index];
00393 }
00394 }
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404 unsigned int
00405 InterfaceFieldIterator::get_uint(unsigned int index) const
00406 {
00407 if ( __infol == NULL ) {
00408 throw NullPointerException("Cannot get value of end element");
00409 } else if ( __infol->type != IFT_UINT ) {
00410 throw TypeMismatchException("Requested value is not of type unsigned int");
00411 } else if (index >= __infol->length) {
00412 throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
00413 } else {
00414 return ((unsigned int *)__infol->value)[index];
00415 }
00416 }
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426 long int
00427 InterfaceFieldIterator::get_longint(unsigned int index) const
00428 {
00429 if ( __infol == NULL ) {
00430 throw NullPointerException("Cannot get value of end element");
00431 } else if ( __infol->type != IFT_LONGINT ) {
00432 throw TypeMismatchException("Requested value is not of type long int");
00433 } else if (index >= __infol->length) {
00434 throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
00435 } else {
00436 return ((long int *)__infol->value)[index];
00437 }
00438 }
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448 unsigned long int
00449 InterfaceFieldIterator::get_longuint(unsigned int index) const
00450 {
00451 if ( __infol == NULL ) {
00452 throw NullPointerException("Cannot get value of end element");
00453 } else if ( __infol->type != IFT_LONGUINT ) {
00454 throw TypeMismatchException("Requested value is not of type unsigned long int");
00455 } else if (index >= __infol->length) {
00456 throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
00457 } else {
00458 return ((unsigned long int *)__infol->value)[index];
00459 }
00460 }
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470 float
00471 InterfaceFieldIterator::get_float(unsigned int index) const
00472 {
00473 if ( __infol == NULL ) {
00474 throw NullPointerException("Cannot get value of end element");
00475 } else if ( __infol->type != IFT_FLOAT ) {
00476 throw TypeMismatchException("Requested value is not of type float");
00477 } else if (index >= __infol->length) {
00478 throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
00479 } else {
00480 return ((float *)__infol->value)[index];
00481 }
00482 }
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492 unsigned char
00493 InterfaceFieldIterator::get_byte(unsigned int index) const
00494 {
00495 if ( __infol == NULL ) {
00496 throw NullPointerException("Cannot get value of end element");
00497 } else if ( __infol->type != IFT_BYTE ) {
00498 throw TypeMismatchException("Requested value is not of type float");
00499 } else if (index >= __infol->length) {
00500 throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
00501 } else {
00502 return ((unsigned char *)__infol->value)[index];
00503 }
00504 }
00505
00506
00507
00508
00509
00510
00511
00512
00513 bool *
00514 InterfaceFieldIterator::get_bools() const
00515 {
00516 if ( __infol == NULL ) {
00517 throw NullPointerException("Cannot get value of end element");
00518 } else if ( __infol->type != IFT_BOOL ) {
00519 throw TypeMismatchException("Requested value is not of type bool");
00520 } else if (__infol->length == 1) {
00521 throw TypeMismatchException("Field %s is not an array", __infol->name);
00522 } else {
00523 return (bool *)__infol->value;
00524 }
00525 }
00526
00527
00528
00529
00530
00531
00532
00533
00534 int *
00535 InterfaceFieldIterator::get_ints() const
00536 {
00537 if ( __infol == NULL ) {
00538 throw NullPointerException("Cannot get value of end element");
00539 } else if ( __infol->type != IFT_INT ) {
00540 throw TypeMismatchException("Requested value is not of type int");
00541 } else {
00542 return (int *)__infol->value;
00543 }
00544 }
00545
00546
00547
00548
00549
00550
00551
00552
00553 unsigned int *
00554 InterfaceFieldIterator::get_uints() const
00555 {
00556 if ( __infol == NULL ) {
00557 throw NullPointerException("Cannot get value of end element");
00558 } else if ( __infol->type != IFT_UINT ) {
00559 throw TypeMismatchException("Requested value is not of type unsigned int");
00560 } else {
00561 return (unsigned int *)__infol->value;
00562 }
00563 }
00564
00565
00566
00567
00568
00569
00570
00571
00572 long int *
00573 InterfaceFieldIterator::get_longints() const
00574 {
00575 if ( __infol == NULL ) {
00576 throw NullPointerException("Cannot get value of end element");
00577 } else if ( __infol->type != IFT_LONGINT ) {
00578 throw TypeMismatchException("Requested value is not of type long int");
00579 } else {
00580 return (long int *)__infol->value;
00581 }
00582 }
00583
00584
00585
00586
00587
00588
00589
00590
00591 unsigned long int *
00592 InterfaceFieldIterator::get_longuints() const
00593 {
00594 if ( __infol == NULL ) {
00595 throw NullPointerException("Cannot get value of end element");
00596 } else if ( __infol->type != IFT_LONGUINT ) {
00597 throw TypeMismatchException("Requested value is not of type unsigned long int");
00598 } else {
00599 return (unsigned long int *)__infol->value;
00600 }
00601 }
00602
00603
00604
00605
00606
00607
00608
00609
00610 float *
00611 InterfaceFieldIterator::get_floats() const
00612 {
00613 if ( __infol == NULL ) {
00614 throw NullPointerException("Cannot get value of end element");
00615 } else if ( __infol->type != IFT_FLOAT ) {
00616 throw TypeMismatchException("Requested value is not of type float");
00617 } else {
00618 return (float *)__infol->value;
00619 }
00620 }
00621
00622
00623
00624
00625
00626
00627
00628
00629 unsigned char *
00630 InterfaceFieldIterator::get_bytes() const
00631 {
00632 if ( __infol == NULL ) {
00633 throw NullPointerException("Cannot get value of end element");
00634 } else if ( __infol->type != IFT_BYTE ) {
00635 throw TypeMismatchException("Requested value is not of type float");
00636 } else {
00637 return (unsigned char *)__infol->value;
00638 }
00639 }
00640
00641
00642
00643
00644
00645
00646
00647 const char *
00648 InterfaceFieldIterator::get_string() const
00649 {
00650 if ( __infol == NULL ) {
00651 throw NullPointerException("Cannot get value of end element");
00652 } else if ( __infol->type != IFT_STRING ) {
00653 throw TypeMismatchException("Requested value is not of type string");
00654 } else {
00655 return (const char *)__infol->value;
00656 }
00657 }
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667 void
00668 InterfaceFieldIterator::set_bool(bool v, unsigned int index)
00669 {
00670 if ( __infol == NULL ) {
00671 throw NullPointerException("Cannot set value of end element");
00672 } else if ( __infol->type != IFT_BOOL ) {
00673 throw TypeMismatchException("Field to be written is not of type bool");
00674 } else if (index >= __infol->length) {
00675 throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
00676 } else {
00677 char* dst = (char *) __infol->value + index * sizeof(bool);
00678 memcpy((void *) dst, &v, sizeof(bool));
00679 }
00680 }
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690 void
00691 InterfaceFieldIterator::set_int(int v, unsigned int index)
00692 {
00693 if ( __infol == NULL ) {
00694 throw NullPointerException("Cannot set value of end element");
00695 } else if ( __infol->type != IFT_INT ) {
00696 throw TypeMismatchException("Field to be written is not of type int");
00697 } else if (index >= __infol->length) {
00698 throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
00699 } else {
00700 char* dst = (char *) __infol->value + index * sizeof(int);
00701 memcpy((void *) dst, &v, sizeof(int));
00702 }
00703 }
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713 void
00714 InterfaceFieldIterator::set_uint(unsigned int v, unsigned int index)
00715 {
00716 if ( __infol == NULL ) {
00717 throw NullPointerException("Cannot set value of end element");
00718 } else if ( __infol->type != IFT_UINT ) {
00719 throw TypeMismatchException("Field to be written is not of type unsigned int");
00720 } else if (index >= __infol->length) {
00721 throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
00722 } else {
00723 char* dst = (char *) __infol->value + index * sizeof(unsigned int);
00724 memcpy((void *) dst, &v, sizeof(unsigned int));
00725 }
00726 }
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736 void
00737 InterfaceFieldIterator::set_longint(long int v, unsigned int index)
00738 {
00739 if ( __infol == NULL ) {
00740 throw NullPointerException("Cannot set value of end element");
00741 } else if ( __infol->type != IFT_LONGINT ) {
00742 throw TypeMismatchException("Field to be written is not of type long int");
00743 } else if (index >= __infol->length) {
00744 throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
00745 } else {
00746 char* dst = (char *) __infol->value + index * sizeof(long int);
00747 memcpy((void *) dst, &v, sizeof(long int));
00748 }
00749 }
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759 void
00760 InterfaceFieldIterator::set_longuint(long unsigned int v, unsigned int index)
00761 {
00762 if ( __infol == NULL ) {
00763 throw NullPointerException("Cannot set value of end element");
00764 } else if ( __infol->type != IFT_LONGUINT ) {
00765 throw TypeMismatchException("Field to be written is not of type long unsigned int");
00766 } else if (index >= __infol->length) {
00767 throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
00768 } else {
00769 char* dst = (char *) __infol->value + index * sizeof(long unsigned int);
00770 memcpy((void *) dst, &v, sizeof(long unsigned int));
00771 }
00772 }
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782 void
00783 InterfaceFieldIterator::set_float(float v, unsigned int index)
00784 {
00785 if ( __infol == NULL ) {
00786 throw NullPointerException("Cannot set value of end element");
00787 } else if ( __infol->type != IFT_FLOAT ) {
00788 throw TypeMismatchException("Field to be written is not of type float");
00789 } else if (index >= __infol->length) {
00790 throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
00791 } else {
00792 char* dst = (char *) __infol->value + index * sizeof(float);
00793 memcpy((void *) dst, &v, sizeof(float));
00794 }
00795 }
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805 void
00806 InterfaceFieldIterator::set_byte(unsigned char v, unsigned int index)
00807 {
00808 if ( __infol == NULL ) {
00809 throw NullPointerException("Cannot set value of end element");
00810 } else if ( __infol->type != IFT_BYTE ) {
00811 throw TypeMismatchException("Field to be written is not of type byte");
00812 } else if (index >= __infol->length) {
00813 throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
00814 } else {
00815 char* dst = (char *) __infol->value + index * sizeof(unsigned char);
00816 memcpy((void *) dst, &v, sizeof(unsigned char ));
00817 }
00818 }
00819
00820
00821
00822
00823
00824
00825
00826
00827 void
00828 InterfaceFieldIterator::set_bools(bool *v)
00829 {
00830 if ( __infol == NULL ) {
00831 throw NullPointerException("Cannot set value of end element");
00832 } else if ( __infol->type != IFT_BOOL ) {
00833 throw TypeMismatchException("Field to be written is not of type bool");
00834 } else if (__infol->length == 1) {
00835 throw TypeMismatchException("Field %s is not an array", __infol->name);
00836 } else {
00837 memcpy(__infol->value, v, __infol->length * sizeof(bool));
00838 }
00839 }
00840
00841
00842
00843
00844
00845
00846
00847
00848 void
00849 InterfaceFieldIterator::set_ints(int *v)
00850 {
00851 if ( __infol == NULL ) {
00852 throw NullPointerException("Cannot set value of end element");
00853 } else if ( __infol->type != IFT_INT ) {
00854 throw TypeMismatchException("Field to be written is not of type int");
00855 } else if (__infol->length == 1) {
00856 throw TypeMismatchException("Field %s is not an array", __infol->name);
00857 } else {
00858 memcpy(__infol->value, v, __infol->length * sizeof(int));
00859 }
00860 }
00861
00862
00863
00864
00865
00866
00867
00868
00869 void
00870 InterfaceFieldIterator::set_uints(unsigned int *v)
00871 {
00872 if ( __infol == NULL ) {
00873 throw NullPointerException("Cannot set value of end element");
00874 } else if ( __infol->type != IFT_UINT ) {
00875 throw TypeMismatchException("Field to be written is not of type unsigned int");
00876 } else if (__infol->length == 1) {
00877 throw TypeMismatchException("Field %s is not an array", __infol->name);
00878 } else {
00879 memcpy(__infol->value, v, __infol->length * sizeof(unsigned int));
00880 }
00881 }
00882
00883
00884
00885
00886
00887
00888
00889
00890 void
00891 InterfaceFieldIterator::set_longints(long int *v)
00892 {
00893 if ( __infol == NULL ) {
00894 throw NullPointerException("Cannot set value of end element");
00895 } else if ( __infol->type != IFT_LONGINT ) {
00896 throw TypeMismatchException("Field to be written is not of type long int");
00897 } else if (__infol->length == 1) {
00898 throw TypeMismatchException("Field %s is not an array", __infol->name);
00899 } else {
00900 memcpy(__infol->value, v, __infol->length * sizeof(long int));
00901 }
00902 }
00903
00904
00905
00906
00907
00908
00909
00910
00911 void
00912 InterfaceFieldIterator::set_longuints(long unsigned int *v)
00913 {
00914 if ( __infol == NULL ) {
00915 throw NullPointerException("Cannot set value of end element");
00916 } else if ( __infol->type != IFT_LONGUINT ) {
00917 throw TypeMismatchException("Field to be written is not of type long unsigned int");
00918 } else if (__infol->length == 1) {
00919 throw TypeMismatchException("Field %s is not an array", __infol->name);
00920 } else {
00921 memcpy(__infol->value, v, __infol->length * sizeof(long unsigned int));
00922 }
00923 }
00924
00925
00926
00927
00928
00929
00930
00931
00932 void
00933 InterfaceFieldIterator::set_floats(float *v)
00934 {
00935 if ( __infol == NULL ) {
00936 throw NullPointerException("Cannot set value of end element");
00937 } else if ( __infol->type != IFT_FLOAT ) {
00938 throw TypeMismatchException("Field to be written is not of type float");
00939 } else if (__infol->length == 1) {
00940 throw TypeMismatchException("Field %s is not an array", __infol->name);
00941 } else {
00942 memcpy(__infol->value, v, __infol->length * sizeof(float));
00943 }
00944 }
00945
00946
00947
00948
00949
00950
00951
00952
00953 void
00954 InterfaceFieldIterator::set_bytes(unsigned char *v)
00955 {
00956 if ( __infol == NULL ) {
00957 throw NullPointerException("Cannot set value of end element");
00958 } else if ( __infol->type != IFT_BYTE ) {
00959 throw TypeMismatchException("Field to be written is not of type byte");
00960 } else if (__infol->length == 1) {
00961 throw TypeMismatchException("Field %s is not an array", __infol->name);
00962 } else {
00963 memcpy(__infol->value, v, __infol->length * sizeof(unsigned char));
00964 }
00965 }
00966
00967
00968
00969
00970
00971
00972
00973 void
00974 InterfaceFieldIterator::set_string(const char *v)
00975 {
00976 if ( __infol == NULL ) {
00977 throw NullPointerException("Cannot set value of end element");
00978 } else if ( __infol->type != IFT_STRING ) {
00979 throw TypeMismatchException("Field to be written is not of type string");
00980 } else {
00981 strncpy((char *) __infol->value, v, __infol->length);
00982 }
00983 }
00984
00985 }