Fawkes API  Fawkes Development Version
field_iterator.cpp
1 
2 /***************************************************************************
3  * field_iterator.cpp - Iterate over field of an interface or a message
4  *
5  * Created: Fri Jul 17 21:28:58 2009
6  * Copyright 2006 Tim Niemueller [www.niemueller.de]
7  * 2009 Daniel Beck
8  *
9  ****************************************************************************/
10 
11 /* This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version. A runtime exception applies to
15  * this software (see LICENSE.GPL_WRE file mentioned below for details).
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Library General Public License for more details.
21  *
22  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
23  */
24 
25 #include <interface/field_iterator.h>
26 #include <interface/interface.h>
27 
28 #include <core/exceptions/software.h>
29 #include <core/exceptions/system.h>
30 
31 #include <cstdlib>
32 #include <cstring>
33 #include <cstdio>
34 
35 namespace fawkes {
36 
37 /** @class InterfaceFieldIterator <interface/interface.h>
38  * Interface field iterator.
39  * This iterator is part of the BlackBoard introspection API. It can be used to
40  * iterate over all available fields and values of an interface without actually
41  * knowing the specific type of the interface.
42  * @author Tim Niemueller
43  */
44 
45 
46 /** Constructor.
47  * Creates an invalid iterator.
48  */
50 {
51  __interface = NULL;
52  __infol = NULL;
53  __value_string = NULL;
54 }
55 
56 
57 /** Constructor.
58  * This creates an iterator pointing to the given entry of the info list.
59  * @param interface interface this field iterator is assigned to
60  * @param info_list pointer to info list entry to start from
61  */
63  const interface_fieldinfo_t *info_list)
64 {
65  __interface = interface;
66  __infol = info_list;
67  __value_string = NULL;
68 }
69 
70 
71 /** Copy constructor.
72  * @param fit iterator to copy
73  */
75 {
76  __infol = fit.__infol;
77  if ( fit.__value_string ) {
78  __value_string = strdup(fit.__value_string);
79  } else {
80  __value_string = NULL;
81  }
82 }
83 
84 
85 /** Destructor. */
87 {
88  if ( __value_string ) free(__value_string);
89 }
90 
91 
92 /** Prefix increment.
93  * @return reference to this instance
94  */
97 {
98  if ( __infol != NULL ) {
99  __infol = __infol->next;
100  if ( __value_string ) free(__value_string);
101  __value_string = NULL;
102  }
103 
104  return *this;
105 }
106 
107 
108 /** Postfix increment operator.
109  * @param inc ignored
110  * @return instance before advancing to the next shared memory segment
111  */
114 {
115  InterfaceFieldIterator rv(*this);
116  ++(*this);
117  return rv;
118 }
119 
120 
121 /** Advance by i steps.
122  * @param i number of (matching) segments to advance.
123  * @return reference to this after advancing
124  */
127 {
128  for (unsigned int j = 0; j < i; ++j) {
129  ++(*this);
130  }
131  return *this;
132 }
133 
134 
135 /** Advance by i steps.
136  * @param i number of (matching) segments to advance.
137  * @return reference to this after advancing
138  */
141 {
142  for (unsigned int j = 0; j < i; ++j) {
143  ++(*this);
144  }
145  return *this;
146 }
147 
148 
149 /** Check iterators for equality.
150  * @param fi iterator to compare to
151  * @return true if iterators point to the the same field, false otherwise
152  */
153 bool
155 {
156  return (__infol == fi.__infol);
157 }
158 
159 
160 /** Check iterators for inequality.
161  * @param fi iterator to compare to
162  * @return true if iteraters point to the different fields, false otherwise
163  */
164 bool
166 {
167  return ! (*this == fi);
168 }
169 
170 
171 /** Get FieldHeader.
172  * @return shared memory header
173  */
174 const void *
176 {
177  if ( __infol == NULL ) {
178  throw NullPointerException("Cannot get value of end element");
179  } else {
180  return __infol->value;
181  }
182 }
183 
184 
185 /** Make this instance point to the same segment as fi.
186  * @param fi field iterator to compare
187  * @return reference to this instance
188  */
191 {
192  __interface = fi.__interface;
193  __infol = fi.__infol;
194 
195  return *this;
196 }
197 
198 
199 /** Get type of current field.
200  * @return field type
201  */
204 {
205  if ( __infol == NULL ) {
206  throw NullPointerException("Cannot get type of end element");
207  } else {
208  return __infol->type;
209  }
210 }
211 
212 
213 /** Get type of current field as string.
214  * @return field type as string
215  */
216 const char *
218 {
219  if ( __infol == NULL ) {
220  throw NullPointerException("Cannot get type of end element");
221  } else {
222  switch (__infol->type) {
223  case IFT_BOOL: return "bool";
224  case IFT_INT8: return "int8";
225  case IFT_UINT8: return "uint8";
226  case IFT_INT16: return "int16";
227  case IFT_UINT16: return "uint16";
228  case IFT_INT32: return "int32";
229  case IFT_UINT32: return "uint32";
230  case IFT_INT64: return "int64";
231  case IFT_UINT64: return "uint64";
232  case IFT_FLOAT: return "float";
233  case IFT_DOUBLE: return "double";
234  case IFT_BYTE: return "byte";
235  case IFT_STRING: return "string";
236  case IFT_ENUM: return __infol->enumtype;
237  default: return "unknown";
238  }
239  }
240 }
241 
242 
243 /** Get name of current field.
244  * @return field name
245  */
246 const char *
248 {
249  if ( __infol == NULL ) {
250  throw NullPointerException("Cannot get name of end element");
251  } else {
252  return __infol->name;
253  }
254 }
255 
256 
257 /** Get value of current field.
258  * @return field value
259  */
260 const void *
262 {
263  if ( __infol == NULL ) {
264  throw NullPointerException("Cannot get value of end element");
265  } else {
266  return __infol->value;
267  }
268 }
269 
270 
271 /** Get length of current field.
272  * @return length of field
273  */
274 size_t
276 {
277  if ( __infol == NULL ) {
278  throw NullPointerException("Cannot get length of end element");
279  } else {
280  return __infol->length;
281  }
282 }
283 
284 
285 /** Get value of current field as string.
286  * @return field value as string
287  */
288 const char *
290 {
291  if ( __infol == NULL ) {
292  throw NullPointerException("Cannot get value of end element");
293  } else {
294  if ( __value_string == NULL ) {
295  if ( __infol->length == 0 ) throw OutOfBoundsException("Field length out of bounds",
296  __infol->length, 1, (unsigned int)0xFFFFFFFF);
297 
298  char *tmp1 = strdup("");
299  char *tmp2;
300 
301  if ( __infol->type != IFT_STRING ) {
302  for (size_t i = 0; i < __infol->length; ++i) {
303  int rv = 0;
304  switch (__infol->type) {
305  case IFT_BOOL:
306  rv = asprintf(&tmp2, "%s%s", tmp1, (((bool *)__infol->value)[i]) ? "true" : "false");
307  break;
308  case IFT_INT8:
309  rv = asprintf(&tmp2, "%s%i", tmp1, ((int8_t *)__infol->value)[i]);
310  break;
311  case IFT_INT16:
312  rv = asprintf(&tmp2, "%s%i", tmp1, ((int16_t *)__infol->value)[i]);
313  break;
314  case IFT_INT32:
315  rv = asprintf(&tmp2, "%s%i", tmp1, ((int32_t *)__infol->value)[i]);
316  break;
317  case IFT_INT64:
318 #if (defined(__WORDSIZE) && __WORDSIZE == 64) || (defined(LONG_BIT) && LONG_BIT == 64)
319  rv = asprintf(&tmp2, "%s%li", tmp1, ((int64_t *)__infol->value)[i]);
320 #else
321  rv = asprintf(&tmp2, "%s%lli", tmp1, ((int64_t *)__infol->value)[i]);
322 #endif
323  break;
324  case IFT_UINT8:
325  rv = asprintf(&tmp2, "%s%u", tmp1, ((uint8_t *)__infol->value)[i]);
326  break;
327  case IFT_UINT16:
328  rv = asprintf(&tmp2, "%s%u", tmp1, ((uint16_t *)__infol->value)[i]);
329  break;
330  case IFT_UINT32:
331  rv = asprintf(&tmp2, "%s%u", tmp1, ((uint32_t *)__infol->value)[i]);
332  break;
333  case IFT_UINT64:
334 #if (defined(__WORDSIZE) && __WORDSIZE == 64) || (defined(LONG_BIT) && LONG_BIT == 64)
335  rv = asprintf(&tmp2, "%s%lu", tmp1, ((uint64_t *)__infol->value)[i]);
336 #else
337  rv = asprintf(&tmp2, "%s%llu", tmp1, ((uint64_t *)__infol->value)[i]);
338 #endif
339  break;
340  case IFT_FLOAT:
341  rv = asprintf(&tmp2, "%s%f", tmp1, ((float *)__infol->value)[i]);
342  break;
343  case IFT_DOUBLE:
344  rv = asprintf(&tmp2, "%s%f", tmp1, ((double *)__infol->value)[i]);
345  break;
346  case IFT_BYTE:
347  rv = asprintf(&tmp2, "%s%u", tmp1, ((uint8_t *)__infol->value)[i]);
348  break;
349  case IFT_STRING:
350  // cannot happen, caught with surrounding if statement
351 
352  case IFT_ENUM:
353  rv = asprintf(&tmp2, "%s%s", tmp1, __interface->enum_tostring(__infol->enumtype, ((int *)__infol->value)[i]));
354  break;
355  }
356 
357  if ( rv == -1 ) {
358  throw OutOfMemoryException("InterfaceFieldIterator::get_value_string(): asprintf() failed (1)");
359  }
360 
361  free(tmp1);
362  tmp1 = tmp2;
363  if ( (__infol->length > 1) && (i < __infol->length - 1) ) {
364  if (asprintf(&tmp2, "%s, ", tmp1) == -1) {
365  throw OutOfMemoryException("InterfaceFieldIterator::get_value_string(): asprintf() failed (2)");
366  }
367  free(tmp1);
368  tmp1 = tmp2;
369  }
370  }
371 
372  __value_string = tmp1;
373  } else {
374  // it's a string, or a small number
375  if ( __infol->length > 1 ) {
376  if (asprintf(&__value_string, "%s", (const char *)__infol->value) == -1) {
377  throw OutOfMemoryException("InterfaceFieldIterator::get_value_string(): asprintf() failed (3)");
378  }
379  } else {
380  if (asprintf(&__value_string, "%c", *((const char *)__infol->value)) == -1) {
381  throw OutOfMemoryException("InterfaceFieldIterator::get_value_string(): asprintf() failed (4)");
382  }
383  }
384  }
385  }
386  return __value_string;
387  }
388 }
389 
390 
391 /** Get value of current field as bool.
392  * @return field value
393  * @param index array index (only use if field is an array)
394  * @exception NullPointerException invalid iterator, possibly end iterator
395  * @exception TypeMismatchException thrown if field is not of type bool
396  * @exception OutOfBoundsException thrown if index is out of bounds
397  */
398 bool
399 InterfaceFieldIterator::get_bool(unsigned int index) const
400 {
401  if ( __infol == NULL ) {
402  throw NullPointerException("Cannot get value of end element");
403  } else if ( __infol->type != IFT_BOOL ) {
404  throw TypeMismatchException("Requested value is not of type bool");
405  } else if (index >= __infol->length) {
406  throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
407  } else {
408  return ((bool *)__infol->value)[index];
409  }
410 }
411 
412 
413 /** Get value of current field as integer.
414  * @return field value
415  * @param index array index (only use if field is an array)
416  * @exception NullPointerException invalid iterator, possibly end iterator
417  * @exception TypeMismatchException thrown if field is not of type int
418  * @exception OutOfBoundsException thrown if index is out of bounds
419  */
420 int8_t
421 InterfaceFieldIterator::get_int8(unsigned int index) const
422 {
423  if ( __infol == NULL ) {
424  throw NullPointerException("Cannot get value of end element");
425  } else if ( __infol->type != IFT_INT8 ) {
426  throw TypeMismatchException("Requested value is not of type int");
427  } else if (index >= __infol->length) {
428  throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
429  } else {
430  return ((int8_t *)__infol->value)[index];
431  }
432 }
433 
434 
435 /** Get value of current field as unsigned integer.
436  * @return field value
437  * @param index array index (only use if field is an array)
438  * @exception NullPointerException invalid iterator, possibly end iterator
439  * @exception TypeMismatchException thrown if field is not of type unsigned int
440  * @exception OutOfBoundsException thrown if index is out of bounds
441  */
442 uint8_t
443 InterfaceFieldIterator::get_uint8(unsigned int index) const
444 {
445  if ( __infol == NULL ) {
446  throw NullPointerException("Cannot get value of end element");
447  } else if ( __infol->type != IFT_UINT8 ) {
448  throw TypeMismatchException("Requested value is not of type unsigned int");
449  } else if (index >= __infol->length) {
450  throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
451  } else {
452  return ((uint8_t *)__infol->value)[index];
453  }
454 }
455 
456 /** Get value of current field as integer.
457  * @return field value
458  * @param index array index (only use if field is an array)
459  * @exception NullPointerException invalid iterator, possibly end iterator
460  * @exception TypeMismatchException thrown if field is not of type int
461  * @exception OutOfBoundsException thrown if index is out of bounds
462  */
463 int16_t
464 InterfaceFieldIterator::get_int16(unsigned int index) const
465 {
466  if ( __infol == NULL ) {
467  throw NullPointerException("Cannot get value of end element");
468  } else if ( __infol->type != IFT_INT16 ) {
469  throw TypeMismatchException("Requested value is not of type int");
470  } else if (index >= __infol->length) {
471  throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
472  } else {
473  return ((int16_t *)__infol->value)[index];
474  }
475 }
476 
477 
478 /** Get value of current field as unsigned integer.
479  * @return field value
480  * @param index array index (only use if field is an array)
481  * @exception NullPointerException invalid iterator, possibly end iterator
482  * @exception TypeMismatchException thrown if field is not of type unsigned int
483  * @exception OutOfBoundsException thrown if index is out of bounds
484  */
485 uint16_t
486 InterfaceFieldIterator::get_uint16(unsigned int index) const
487 {
488  if ( __infol == NULL ) {
489  throw NullPointerException("Cannot get value of end element");
490  } else if ( __infol->type != IFT_UINT16 ) {
491  throw TypeMismatchException("Requested value is not of type unsigned int");
492  } else if (index >= __infol->length) {
493  throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
494  } else {
495  return ((uint16_t *)__infol->value)[index];
496  }
497 }
498 
499 /** Get value of current field as integer.
500  * @return field value
501  * @param index array index (only use if field is an array)
502  * @exception NullPointerException invalid iterator, possibly end iterator
503  * @exception TypeMismatchException thrown if field is not of type int
504  * @exception OutOfBoundsException thrown if index is out of bounds
505  */
506 int32_t
507 InterfaceFieldIterator::get_int32(unsigned int index) const
508 {
509  if ( __infol == NULL ) {
510  throw NullPointerException("Cannot get value of end element");
511  } else if ( __infol->type != IFT_INT32 ) {
512  throw TypeMismatchException("Requested value is not of type int");
513  } else if (index >= __infol->length) {
514  throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
515  } else {
516  return ((int32_t *)__infol->value)[index];
517  }
518 }
519 
520 
521 /** Get value of current field as unsigned integer.
522  * @return field value
523  * @param index array index (only use if field is an array)
524  * @exception NullPointerException invalid iterator, possibly end iterator
525  * @exception TypeMismatchException thrown if field is not of type unsigned int
526  * @exception OutOfBoundsException thrown if index is out of bounds
527  */
528 uint32_t
529 InterfaceFieldIterator::get_uint32(unsigned int index) const
530 {
531  if ( __infol == NULL ) {
532  throw NullPointerException("Cannot get value of end element");
533  } else if ( __infol->type != IFT_UINT32 ) {
534  throw TypeMismatchException("Requested value is not of type unsigned int");
535  } else if (index >= __infol->length) {
536  throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
537  } else {
538  return ((uint32_t *)__infol->value)[index];
539  }
540 }
541 
542 /** Get value of current field as integer.
543  * @return field value
544  * @param index array index (only use if field is an array)
545  * @exception NullPointerException invalid iterator, possibly end iterator
546  * @exception TypeMismatchException thrown if field is not of type int
547  * @exception OutOfBoundsException thrown if index is out of bounds
548  */
549 int64_t
550 InterfaceFieldIterator::get_int64(unsigned int index) const
551 {
552  if ( __infol == NULL ) {
553  throw NullPointerException("Cannot get value of end element");
554  } else if ( __infol->type != IFT_INT64 ) {
555  throw TypeMismatchException("Requested value is not of type int");
556  } else if (index >= __infol->length) {
557  throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
558  } else {
559  return ((int64_t *)__infol->value)[index];
560  }
561 }
562 
563 
564 /** Get value of current field as unsigned integer.
565  * @return field value
566  * @param index array index (only use if field is an array)
567  * @exception NullPointerException invalid iterator, possibly end iterator
568  * @exception TypeMismatchException thrown if field is not of type unsigned int
569  * @exception OutOfBoundsException thrown if index is out of bounds
570  */
571 uint64_t
572 InterfaceFieldIterator::get_uint64(unsigned int index) const
573 {
574  if ( __infol == NULL ) {
575  throw NullPointerException("Cannot get value of end element");
576  } else if ( __infol->type != IFT_UINT64 ) {
577  throw TypeMismatchException("Requested value is not of type unsigned int");
578  } else if (index >= __infol->length) {
579  throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
580  } else {
581  return ((uint64_t *)__infol->value)[index];
582  }
583 }
584 
585 
586 /** Get value of current field as float.
587  * @return field value
588  * @param index array index (only use if field is an array)
589  * @exception NullPointerException invalid iterator, possibly end iterator
590  * @exception TypeMismatchException thrown if field is not of type float
591  * @exception OutOfBoundsException thrown if index is out of bounds
592  */
593 float
594 InterfaceFieldIterator::get_float(unsigned int index) const
595 {
596  if ( __infol == NULL ) {
597  throw NullPointerException("Cannot get value of end element");
598  } else if ( __infol->type != IFT_FLOAT ) {
599  throw TypeMismatchException("Requested value is not of type float");
600  } else if (index >= __infol->length) {
601  throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
602  } else {
603  return ((float *)__infol->value)[index];
604  }
605 }
606 
607 
608 /** Get value of current field as double.
609  * @return field value
610  * @param index array index (only use if field is an array)
611  * @exception NullPointerException invalid iterator, possibly end iterator
612  * @exception TypeMismatchException thrown if field is not of type float
613  * @exception OutOfBoundsException thrown if index is out of bounds
614  */
615 double
616 InterfaceFieldIterator::get_double(unsigned int index) const
617 {
618  if ( __infol == NULL ) {
619  throw NullPointerException("Cannot get value of end element");
620  } else if ( __infol->type != IFT_DOUBLE ) {
621  throw TypeMismatchException("Requested value is not of type double");
622  } else if (index >= __infol->length) {
623  throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
624  } else {
625  return ((double *)__infol->value)[index];
626  }
627 }
628 
629 
630 /** Get value of current field as byte.
631  * @return field value
632  * @param index array index (only use if field is an array)
633  * @exception NullPointerException invalid iterator, possibly end iterator
634  * @exception TypeMismatchException thrown if field is not of type byte
635  * @exception OutOfBoundsException thrown if index is out of bounds
636  */
637 uint8_t
638 InterfaceFieldIterator::get_byte(unsigned int index) const
639 {
640  if ( __infol == NULL ) {
641  throw NullPointerException("Cannot get value of end element");
642  } else if ( __infol->type != IFT_BYTE ) {
643  throw TypeMismatchException("Requested value is not of type byte");
644  } else if (index >= __infol->length) {
645  throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
646  } else {
647  return ((uint8_t *)__infol->value)[index];
648  }
649 }
650 
651 
652 /** Get value of current enum field as integer.
653  * @return field value
654  * @param index array index (only use if field is an array)
655  * @exception NullPointerException invalid iterator, possibly end iterator
656  * @exception TypeMismatchException thrown if field is not of type int
657  * @exception OutOfBoundsException thrown if index is out of bounds
658  */
659 int32_t
660 InterfaceFieldIterator::get_enum(unsigned int index) const
661 {
662  if ( __infol == NULL ) {
663  throw NullPointerException("Cannot get value of end element");
664  } else if ( __infol->type != IFT_ENUM ) {
665  throw TypeMismatchException("Requested value is not of type enum");
666  } else if (index >= __infol->length) {
667  throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
668  } else {
669  return ((int32_t *)__infol->value)[index];
670  }
671 }
672 
673 /** Get value of current field as bool array.
674  * @return field value
675  * @exception NullPointerException invalid iterator, possibly end iterator
676  * @exception TypeMismatchException thrown if field is not of type bool or field
677  * is not an array (length is 1)
678  */
679 bool *
681 {
682  if ( __infol == NULL ) {
683  throw NullPointerException("Cannot get value of end element");
684  } else if ( __infol->type != IFT_BOOL ) {
685  throw TypeMismatchException("Requested value is not of type bool");
686  } else if (__infol->length == 1) {
687  throw TypeMismatchException("Field %s is not an array", __infol->name);
688  } else {
689  return (bool *)__infol->value;
690  }
691 }
692 
693 
694 /** Get value of current field as integer array.
695  * @return field value
696  * @exception NullPointerException invalid iterator, possibly end iterator
697  * @exception TypeMismatchException thrown if field is not of type int or field
698  * is not an array (length is 1)
699  */
700 int8_t *
702 {
703  if ( __infol == NULL ) {
704  throw NullPointerException("Cannot get value of end element");
705  } else if ( __infol->type != IFT_INT8 ) {
706  throw TypeMismatchException("Requested value is not of type int");
707  } else {
708  return (int8_t *)__infol->value;
709  }
710 }
711 
712 
713 /** Get value of current field as unsigned integer array.
714  * @return field value
715  * @exception NullPointerException invalid iterator, possibly end iterator
716  * @exception TypeMismatchException thrown if field is not of type unsigned int
717  * or field is not an array (length is 1)
718  */
719 uint8_t *
721 {
722  if ( __infol == NULL ) {
723  throw NullPointerException("Cannot get value of end element");
724  } else if ( __infol->type != IFT_UINT8 ) {
725  throw TypeMismatchException("Requested value is not of type unsigned int");
726  } else {
727  return (uint8_t *)__infol->value;
728  }
729 }
730 
731 
732 /** Get value of current field as integer array.
733  * @return field value
734  * @exception NullPointerException invalid iterator, possibly end iterator
735  * @exception TypeMismatchException thrown if field is not of type int or field
736  * is not an array (length is 1)
737  */
738 int16_t *
740 {
741  if ( __infol == NULL ) {
742  throw NullPointerException("Cannot get value of end element");
743  } else if ( __infol->type != IFT_INT16 ) {
744  throw TypeMismatchException("Requested value is not of type int");
745  } else {
746  return (int16_t *)__infol->value;
747  }
748 }
749 
750 
751 /** Get value of current field as unsigned integer array.
752  * @return field value
753  * @exception NullPointerException invalid iterator, possibly end iterator
754  * @exception TypeMismatchException thrown if field is not of type unsigned int
755  * or field is not an array (length is 1)
756  */
757 uint16_t *
759 {
760  if ( __infol == NULL ) {
761  throw NullPointerException("Cannot get value of end element");
762  } else if ( __infol->type != IFT_UINT16 ) {
763  throw TypeMismatchException("Requested value is not of type unsigned int");
764  } else {
765  return (uint16_t *)__infol->value;
766  }
767 }
768 
769 
770 /** Get value of current field as integer array.
771  * @return field value
772  * @exception NullPointerException invalid iterator, possibly end iterator
773  * @exception TypeMismatchException thrown if field is not of type int or field
774  * is not an array (length is 1)
775  */
776 int32_t *
778 {
779  if ( __infol == NULL ) {
780  throw NullPointerException("Cannot get value of end element");
781  } else if ( __infol->type != IFT_INT32 ) {
782  throw TypeMismatchException("Requested value is not of type int");
783  } else {
784  return (int32_t *)__infol->value;
785  }
786 }
787 
788 
789 /** Get value of current field as unsigned integer array.
790  * @return field value
791  * @exception NullPointerException invalid iterator, possibly end iterator
792  * @exception TypeMismatchException thrown if field is not of type unsigned int
793  * or field is not an array (length is 1)
794  */
795 uint32_t *
797 {
798  if ( __infol == NULL ) {
799  throw NullPointerException("Cannot get value of end element");
800  } else if ( __infol->type != IFT_UINT32 ) {
801  throw TypeMismatchException("Requested value is not of type unsigned int");
802  } else {
803  return (uint32_t *)__infol->value;
804  }
805 }
806 
807 
808 /** Get value of current field as integer array.
809  * @return field value
810  * @exception NullPointerException invalid iterator, possibly end iterator
811  * @exception TypeMismatchException thrown if field is not of type int or field
812  * is not an array (length is 1)
813  */
814 int64_t *
816 {
817  if ( __infol == NULL ) {
818  throw NullPointerException("Cannot get value of end element");
819  } else if ( __infol->type != IFT_INT64 ) {
820  throw TypeMismatchException("Requested value is not of type int");
821  } else {
822  return (int64_t *)__infol->value;
823  }
824 }
825 
826 
827 /** Get value of current field as unsigned integer array.
828  * @return field value
829  * @exception NullPointerException invalid iterator, possibly end iterator
830  * @exception TypeMismatchException thrown if field is not of type unsigned int
831  * or field is not an array (length is 1)
832  */
833 uint64_t *
835 {
836  if ( __infol == NULL ) {
837  throw NullPointerException("Cannot get value of end element");
838  } else if ( __infol->type != IFT_UINT64 ) {
839  throw TypeMismatchException("Requested value is not of type unsigned int");
840  } else {
841  return (uint64_t *)__infol->value;
842  }
843 }
844 
845 
846 /** Get value of current field as float array.
847  * @return field value
848  * @exception NullPointerException invalid iterator, possibly end iterator
849  * @exception TypeMismatchException thrown if field is not of type float or field
850  * is not an array (length is 1)
851  */
852 float *
854 {
855  if ( __infol == NULL ) {
856  throw NullPointerException("Cannot get value of end element");
857  } else if ( __infol->type != IFT_FLOAT ) {
858  throw TypeMismatchException("Requested value is not of type float");
859  } else {
860  return (float *)__infol->value;
861  }
862 }
863 
864 
865 /** Get value of current field as double array.
866  * @return field value
867  * @exception NullPointerException invalid iterator, possibly end iterator
868  * @exception TypeMismatchException thrown if field is not of type double or field
869  * is not an array (length is 1)
870  */
871 double *
873 {
874  if ( __infol == NULL ) {
875  throw NullPointerException("Cannot get value of end element");
876  } else if ( __infol->type != IFT_DOUBLE ) {
877  throw TypeMismatchException("Requested value is not of type double");
878  } else {
879  return (double *)__infol->value;
880  }
881 }
882 
883 
884 /** Get value of current field as byte array.
885  * @return field value
886  * @exception NullPointerException invalid iterator, possibly end iterator
887  * @exception TypeMismatchException thrown if field is not of type byte or field
888  * is not an array (length is 1)
889  */
890 uint8_t *
892 {
893  if ( __infol == NULL ) {
894  throw NullPointerException("Cannot get value of end element");
895  } else if ( __infol->type != IFT_BYTE ) {
896  throw TypeMismatchException("Requested value is not of type byte");
897  } else {
898  return (uint8_t *)__infol->value;
899  }
900 }
901 
902 
903 /** Get value of current enum field as integer array.
904  * @return field value
905  * @exception NullPointerException invalid iterator, possibly end iterator
906  * @exception TypeMismatchException thrown if field is not of type int or field
907  * is not an array (length is 1)
908  */
909 int32_t *
911 {
912  if ( __infol == NULL ) {
913  throw NullPointerException("Cannot get value of end element");
914  } else if ( __infol->type != IFT_ENUM ) {
915  throw TypeMismatchException("Requested value is not of type enum");
916  } else {
917  return (int32_t *)__infol->value;
918  }
919 }
920 
921 
922 /** Get value of current field as string.
923  * @return field value
924  * @exception NullPointerException invalid iterator, possibly end iterator
925  * @exception TypeMismatchException thrown if field is not of type string
926  */
927 const char *
929 {
930  if ( __infol == NULL ) {
931  throw NullPointerException("Cannot get value of end element");
932  } else if ( __infol->type != IFT_STRING ) {
933  throw TypeMismatchException("Requested value is not of type string");
934  } else {
935  return (const char *)__infol->value;
936  }
937 }
938 
939 
940 /** Set value of current field as bool.
941  * @param v the new value
942  * @param index array index (only use if field is an array)
943  * @exception NullPointerException invalid iterator, possibly end iterator
944  * @exception TypeMismatchException thrown if field is not of type bool
945  * @exception OutOfBoundsException thrown if index is out of bounds
946  */
947 void
948 InterfaceFieldIterator::set_bool(bool v, unsigned int index)
949 {
950  if ( __infol == NULL ) {
951  throw NullPointerException("Cannot set value of end element");
952  } else if ( __infol->type != IFT_BOOL ) {
953  throw TypeMismatchException("Field to be written is not of type bool");
954  } else if (index >= __infol->length) {
955  throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
956  } else {
957  char* dst = (char *) __infol->value + index * sizeof(bool);
958  memcpy((void *) dst, &v, sizeof(bool));
959  }
960 }
961 
962 
963 /** Set value of current field as integer.
964  * @param v the new value
965  * @param index array index (only use if field is an array)
966  * @exception NullPointerException invalid iterator, possibly end iterator
967  * @exception TypeMismatchException thrown if field is not of type int
968  * @exception OutOfBoundsException thrown if index is out of bounds
969  */
970 void
971 InterfaceFieldIterator::set_int8(int8_t v, unsigned int index)
972 {
973  if ( __infol == NULL ) {
974  throw NullPointerException("Cannot set value of end element");
975  } else if ( __infol->type != IFT_INT8 ) {
976  throw TypeMismatchException("Field to be written is not of type int");
977  } else if (index >= __infol->length) {
978  throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
979  } else {
980  char* dst = (char *) __infol->value + index * sizeof(int8_t);
981  memcpy((void *) dst, &v, sizeof(int8_t));
982  }
983 }
984 
985 
986 /** Set value of current field as unsigned integer.
987  * @param v the new value
988  * @param index array index (only use if field is an array)
989  * @exception NullPointerException invalid iterator, possibly end iterator
990  * @exception TypeMismatchException thrown if field is not of type unsigned int
991  * @exception OutOfBoundsException thrown if index is out of bounds
992  */
993 void
994 InterfaceFieldIterator::set_uint8(uint8_t v, unsigned int index)
995 {
996  if ( __infol == NULL ) {
997  throw NullPointerException("Cannot set value of end element");
998  } else if ( __infol->type != IFT_UINT8 ) {
999  throw TypeMismatchException("Field to be written is not of type unsigned int");
1000  } else if (index >= __infol->length) {
1001  throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
1002  } else {
1003  char* dst = (char *) __infol->value + index * sizeof(uint8_t);
1004  memcpy((void *) dst, &v, sizeof(uint8_t));
1005  }
1006 }
1007 
1008 
1009 /** Set value of current field as integer.
1010  * @param v the new value
1011  * @param index array index (only use if field is an array)
1012  * @exception NullPointerException invalid iterator, possibly end iterator
1013  * @exception TypeMismatchException thrown if field is not of type int
1014  * @exception OutOfBoundsException thrown if index is out of bounds
1015  */
1016 void
1017 InterfaceFieldIterator::set_int16(int16_t v, unsigned int index)
1018 {
1019  if ( __infol == NULL ) {
1020  throw NullPointerException("Cannot set value of end element");
1021  } else if ( __infol->type != IFT_INT16 ) {
1022  throw TypeMismatchException("Field to be written is not of type int");
1023  } else if (index >= __infol->length) {
1024  throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
1025  } else {
1026  char* dst = (char *) __infol->value + index * sizeof(int16_t);
1027  memcpy((void *) dst, &v, sizeof(int16_t));
1028  }
1029 }
1030 
1031 
1032 /** Set value of current field as unsigned integer.
1033  * @param v the new value
1034  * @param index array index (only use if field is an array)
1035  * @exception NullPointerException invalid iterator, possibly end iterator
1036  * @exception TypeMismatchException thrown if field is not of type unsigned int
1037  * @exception OutOfBoundsException thrown if index is out of bounds
1038  */
1039 void
1040 InterfaceFieldIterator::set_uint16(uint16_t v, unsigned int index)
1041 {
1042  if ( __infol == NULL ) {
1043  throw NullPointerException("Cannot set value of end element");
1044  } else if ( __infol->type != IFT_UINT16 ) {
1045  throw TypeMismatchException("Field to be written is not of type unsigned int");
1046  } else if (index >= __infol->length) {
1047  throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
1048  } else {
1049  char* dst = (char *) __infol->value + index * sizeof(uint16_t);
1050  memcpy((void *) dst, &v, sizeof(uint16_t));
1051  }
1052 }
1053 
1054 
1055 /** Set value of current field as integer.
1056  * @param v the new value
1057  * @param index array index (only use if field is an array)
1058  * @exception NullPointerException invalid iterator, possibly end iterator
1059  * @exception TypeMismatchException thrown if field is not of type int
1060  * @exception OutOfBoundsException thrown if index is out of bounds
1061  */
1062 void
1063 InterfaceFieldIterator::set_int32(int32_t v, unsigned int index)
1064 {
1065  if ( __infol == NULL ) {
1066  throw NullPointerException("Cannot set value of end element");
1067  } else if ( __infol->type != IFT_INT32 ) {
1068  throw TypeMismatchException("Field to be written is not of type int");
1069  } else if (index >= __infol->length) {
1070  throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
1071  } else {
1072  char* dst = (char *) __infol->value + index * sizeof(int32_t);
1073  memcpy((void *) dst, &v, sizeof(int32_t));
1074  }
1075 }
1076 
1077 
1078 /** Set value of current field as unsigned integer.
1079  * @param v the new value
1080  * @param index array index (only use if field is an array)
1081  * @exception NullPointerException invalid iterator, possibly end iterator
1082  * @exception TypeMismatchException thrown if field is not of type unsigned int
1083  * @exception OutOfBoundsException thrown if index is out of bounds
1084  */
1085 void
1086 InterfaceFieldIterator::set_uint32(uint32_t v, unsigned int index)
1087 {
1088  if ( __infol == NULL ) {
1089  throw NullPointerException("Cannot set value of end element");
1090  } else if ( __infol->type != IFT_UINT32 ) {
1091  throw TypeMismatchException("Field to be written is not of type unsigned int");
1092  } else if (index >= __infol->length) {
1093  throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
1094  } else {
1095  char* dst = (char *) __infol->value + index * sizeof(uint32_t);
1096  memcpy((void *) dst, &v, sizeof(uint32_t));
1097  }
1098 }
1099 
1100 
1101 /** Set value of current field as integer.
1102  * @param v the new value
1103  * @param index array index (only use if field is an array)
1104  * @exception NullPointerException invalid iterator, possibly end iterator
1105  * @exception TypeMismatchException thrown if field is not of type int
1106  * @exception OutOfBoundsException thrown if index is out of bounds
1107  */
1108 void
1109 InterfaceFieldIterator::set_int64(int64_t v, unsigned int index)
1110 {
1111  if ( __infol == NULL ) {
1112  throw NullPointerException("Cannot set value of end element");
1113  } else if ( __infol->type != IFT_INT64 ) {
1114  throw TypeMismatchException("Field to be written is not of type int");
1115  } else if (index >= __infol->length) {
1116  throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
1117  } else {
1118  char* dst = (char *) __infol->value + index * sizeof(int64_t);
1119  memcpy((void *) dst, &v, sizeof(int64_t));
1120  }
1121 }
1122 
1123 
1124 /** Set value of current field as unsigned integer.
1125  * @param v the new value
1126  * @param index array index (only use if field is an array)
1127  * @exception NullPointerException invalid iterator, possibly end iterator
1128  * @exception TypeMismatchException thrown if field is not of type unsigned int
1129  * @exception OutOfBoundsException thrown if index is out of bounds
1130  */
1131 void
1132 InterfaceFieldIterator::set_uint64(uint64_t v, unsigned int index)
1133 {
1134  if ( __infol == NULL ) {
1135  throw NullPointerException("Cannot set value of end element");
1136  } else if ( __infol->type != IFT_UINT64 ) {
1137  throw TypeMismatchException("Field to be written is not of type unsigned int");
1138  } else if (index >= __infol->length) {
1139  throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
1140  } else {
1141  char* dst = (char *) __infol->value + index * sizeof(uint64_t);
1142  memcpy((void *) dst, &v, sizeof(uint64_t));
1143  }
1144 }
1145 
1146 
1147 /** Set value of current field as float.
1148  * @param v the new value
1149  * @param index array index (only use if field is an array)
1150  * @exception NullPointerException invalid iterator, possibly end iterator
1151  * @exception TypeMismatchException thrown if field is not of type float
1152  * @exception OutOfBoundsException thrown if index is out of bounds
1153  */
1154 void
1155 InterfaceFieldIterator::set_float(float v, unsigned int index)
1156 {
1157  if ( __infol == NULL ) {
1158  throw NullPointerException("Cannot set value of end element");
1159  } else if ( __infol->type != IFT_FLOAT ) {
1160  throw TypeMismatchException("Field to be written is not of type float");
1161  } else if (index >= __infol->length) {
1162  throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
1163  } else {
1164  char* dst = (char *) __infol->value + index * sizeof(float);
1165  memcpy((void *) dst, &v, sizeof(float));
1166  }
1167 }
1168 
1169 
1170 /** Set value of current field as double.
1171  * @param v the new value
1172  * @param index array index (only use if field is an array)
1173  * @exception NullPointerException invalid iterator, possibly end iterator
1174  * @exception TypeMismatchException thrown if field is not of type double
1175  * @exception OutOfBoundsException thrown if index is out of bounds
1176  */
1177 void
1178 InterfaceFieldIterator::set_double(double v, unsigned int index)
1179 {
1180  if ( __infol == NULL ) {
1181  throw NullPointerException("Cannot set value of end element");
1182  } else if ( __infol->type != IFT_DOUBLE ) {
1183  throw TypeMismatchException("Field to be written is not of type double");
1184  } else if (index >= __infol->length) {
1185  throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
1186  } else {
1187  char* dst = (char *) __infol->value + index * sizeof(double);
1188  memcpy((void *) dst, &v, sizeof(double));
1189  }
1190 }
1191 
1192 
1193 /** Set value of current field as byte.
1194  * @param v the new value
1195  * @param index array index (only use if field is an array)
1196  * @exception NullPointerException invalid iterator, possibly end iterator
1197  * @exception TypeMismatchException thrown if field is not of type byte
1198  * @exception OutOfBoundsException thrown if index is out of bounds
1199  */
1200 void
1201 InterfaceFieldIterator::set_byte(uint8_t v, unsigned int index)
1202 {
1203  if ( __infol == NULL ) {
1204  throw NullPointerException("Cannot set value of end element");
1205  } else if ( __infol->type != IFT_BYTE ) {
1206  throw TypeMismatchException("Field to be written is not of type byte");
1207  } else if (index >= __infol->length) {
1208  throw OutOfBoundsException("Field index out of bounds", index, 0, __infol->length);
1209  } else {
1210  char* dst = (char *) __infol->value + index * sizeof(uint8_t);
1211  memcpy((void *) dst, &v, sizeof(uint8_t));
1212  }
1213 }
1214 
1215 
1216 /** Set value of current field as bool array.
1217  * @param v an array of bools
1218  * @exception NullPointerException invalid iterator, possibly end iterator
1219  * @exception TypeMismatchException thrown if field is not of type bool or field
1220  * is not an array (length is 1)
1221  */
1222 void
1224 {
1225  if ( __infol == NULL ) {
1226  throw NullPointerException("Cannot set value of end element");
1227  } else if ( __infol->type != IFT_BOOL ) {
1228  throw TypeMismatchException("Field to be written is not of type bool");
1229  } else if (__infol->length == 1) {
1230  throw TypeMismatchException("Field %s is not an array", __infol->name);
1231  } else {
1232  memcpy(__infol->value, v, __infol->length * sizeof(bool));
1233  }
1234 }
1235 
1236 
1237 /** Set value of current field as integer array.
1238  * @param v an array of ints
1239  * @exception NullPointerException invalid iterator, possibly end iterator
1240  * @exception TypeMismatchException thrown if field is not of type int or field
1241  * is not an array (length is 1)
1242  */
1243 void
1245 {
1246  if ( __infol == NULL ) {
1247  throw NullPointerException("Cannot set value of end element");
1248  } else if ( __infol->type != IFT_INT8 ) {
1249  throw TypeMismatchException("Field to be written is not of type int");
1250  } else if (__infol->length == 1) {
1251  throw TypeMismatchException("Field %s is not an array", __infol->name);
1252  } else {
1253  memcpy(__infol->value, v, __infol->length * sizeof(int8_t));
1254  }
1255 }
1256 
1257 
1258 /** Set value of current field as unsigned integer array.
1259  * @param v an array of unsigned ints
1260  * @exception NullPointerException invalid iterator, possibly end iterator
1261  * @exception TypeMismatchException thrown if field is not of type unsigned int or field
1262  * is not an array (length is 1)
1263  */
1264 void
1266 {
1267  if ( __infol == NULL ) {
1268  throw NullPointerException("Cannot set value of end element");
1269  } else if ( __infol->type != IFT_UINT8 ) {
1270  throw TypeMismatchException("Field to be written is not of type unsigned int");
1271  } else if (__infol->length == 1) {
1272  throw TypeMismatchException("Field %s is not an array", __infol->name);
1273  } else {
1274  memcpy(__infol->value, v, __infol->length * sizeof(uint8_t));
1275  }
1276 }
1277 
1278 
1279 /** Set value of current field as integer array.
1280  * @param v an array of ints
1281  * @exception NullPointerException invalid iterator, possibly end iterator
1282  * @exception TypeMismatchException thrown if field is not of type int or field
1283  * is not an array (length is 1)
1284  */
1285 void
1287 {
1288  if ( __infol == NULL ) {
1289  throw NullPointerException("Cannot set value of end element");
1290  } else if ( __infol->type != IFT_INT16 ) {
1291  throw TypeMismatchException("Field to be written is not of type int");
1292  } else if (__infol->length == 1) {
1293  throw TypeMismatchException("Field %s is not an array", __infol->name);
1294  } else {
1295  memcpy(__infol->value, v, __infol->length * sizeof(int16_t));
1296  }
1297 }
1298 
1299 
1300 /** Set value of current field as unsigned integer array.
1301  * @param v an array of unsigned ints
1302  * @exception NullPointerException invalid iterator, possibly end iterator
1303  * @exception TypeMismatchException thrown if field is not of type unsigned int or field
1304  * is not an array (length is 1)
1305  */
1306 void
1308 {
1309  if ( __infol == NULL ) {
1310  throw NullPointerException("Cannot set value of end element");
1311  } else if ( __infol->type != IFT_UINT16 ) {
1312  throw TypeMismatchException("Field to be written is not of type unsigned int");
1313  } else if (__infol->length == 1) {
1314  throw TypeMismatchException("Field %s is not an array", __infol->name);
1315  } else {
1316  memcpy(__infol->value, v, __infol->length * sizeof(uint16_t));
1317  }
1318 }
1319 
1320 
1321 /** Set value of current field as integer array.
1322  * @param v an array of ints
1323  * @exception NullPointerException invalid iterator, possibly end iterator
1324  * @exception TypeMismatchException thrown if field is not of type int or field
1325  * is not an array (length is 1)
1326  */
1327 void
1329 {
1330  if ( __infol == NULL ) {
1331  throw NullPointerException("Cannot set value of end element");
1332  } else if ( __infol->type != IFT_INT32 ) {
1333  throw TypeMismatchException("Field to be written is not of type int");
1334  } else if (__infol->length == 1) {
1335  throw TypeMismatchException("Field %s is not an array", __infol->name);
1336  } else {
1337  memcpy(__infol->value, v, __infol->length * sizeof(int32_t));
1338  }
1339 }
1340 
1341 
1342 /** Set value of current field as unsigned integer array.
1343  * @param v an array of unsigned ints
1344  * @exception NullPointerException invalid iterator, possibly end iterator
1345  * @exception TypeMismatchException thrown if field is not of type unsigned int or field
1346  * is not an array (length is 1)
1347  */
1348 void
1350 {
1351  if ( __infol == NULL ) {
1352  throw NullPointerException("Cannot set value of end element");
1353  } else if ( __infol->type != IFT_UINT32 ) {
1354  throw TypeMismatchException("Field to be written is not of type unsigned int");
1355  } else if (__infol->length == 1) {
1356  throw TypeMismatchException("Field %s is not an array", __infol->name);
1357  } else {
1358  memcpy(__infol->value, v, __infol->length * sizeof(uint32_t));
1359  }
1360 }
1361 
1362 
1363 /** Set value of current field as integer array.
1364  * @param v an array of ints
1365  * @exception NullPointerException invalid iterator, possibly end iterator
1366  * @exception TypeMismatchException thrown if field is not of type int or field
1367  * is not an array (length is 1)
1368  */
1369 void
1371 {
1372  if ( __infol == NULL ) {
1373  throw NullPointerException("Cannot set value of end element");
1374  } else if ( __infol->type != IFT_INT64 ) {
1375  throw TypeMismatchException("Field to be written is not of type int");
1376  } else if (__infol->length == 1) {
1377  throw TypeMismatchException("Field %s is not an array", __infol->name);
1378  } else {
1379  memcpy(__infol->value, v, __infol->length * sizeof(int64_t));
1380  }
1381 }
1382 
1383 
1384 /** Set value of current field as unsigned integer array.
1385  * @param v an array of unsigned ints
1386  * @exception NullPointerException invalid iterator, possibly end iterator
1387  * @exception TypeMismatchException thrown if field is not of type unsigned int or field
1388  * is not an array (length is 1)
1389  */
1390 void
1392 {
1393  if ( __infol == NULL ) {
1394  throw NullPointerException("Cannot set value of end element");
1395  } else if ( __infol->type != IFT_UINT64 ) {
1396  throw TypeMismatchException("Field to be written is not of type unsigned int");
1397  } else if (__infol->length == 1) {
1398  throw TypeMismatchException("Field %s is not an array", __infol->name);
1399  } else {
1400  memcpy(__infol->value, v, __infol->length * sizeof(uint64_t));
1401  }
1402 }
1403 
1404 
1405 /** Set value of current field as float array.
1406  * @param v an array of floats
1407  * @exception NullPointerException invalid iterator, possibly end iterator
1408  * @exception TypeMismatchException thrown if field is not of type float or field
1409  * is not an array (length is 1)
1410  */
1411 void
1413 {
1414  if ( __infol == NULL ) {
1415  throw NullPointerException("Cannot set value of end element");
1416  } else if ( __infol->type != IFT_FLOAT ) {
1417  throw TypeMismatchException("Field to be written is not of type float");
1418  } else if (__infol->length == 1) {
1419  throw TypeMismatchException("Field %s is not an array", __infol->name);
1420  } else {
1421  memcpy(__infol->value, v, __infol->length * sizeof(float));
1422  }
1423 }
1424 
1425 /** Set value of current field as double array.
1426  * @param v an array of doubles
1427  * @exception NullPointerException invalid iterator, possibly end iterator
1428  * @exception TypeMismatchException thrown if field is not of type double or field
1429  * is not an array (length is 1)
1430  */
1431 void
1433 {
1434  if ( __infol == NULL ) {
1435  throw NullPointerException("Cannot set value of end element");
1436  } else if ( __infol->type != IFT_DOUBLE ) {
1437  throw TypeMismatchException("Field to be written is not of type double");
1438  } else if (__infol->length == 1) {
1439  throw TypeMismatchException("Field %s is not an array", __infol->name);
1440  } else {
1441  memcpy(__infol->value, v, __infol->length * sizeof(double));
1442  }
1443 }
1444 
1445 
1446 /** Set value of current field as byte array.
1447  * @param v an array of bytes
1448  * @exception NullPointerException invalid iterator, possibly end iterator
1449  * @exception TypeMismatchException thrown if field is not of type byte or field
1450  * is not an array (length is 1)
1451  */
1452 void
1454 {
1455  if ( __infol == NULL ) {
1456  throw NullPointerException("Cannot set value of end element");
1457  } else if ( __infol->type != IFT_BYTE ) {
1458  throw TypeMismatchException("Field to be written is not of type byte");
1459  } else if (__infol->length == 1) {
1460  throw TypeMismatchException("Field %s is not an array", __infol->name);
1461  } else {
1462  memcpy(__infol->value, v, __infol->length * sizeof(uint8_t));
1463  }
1464 }
1465 
1466 
1467 /** Set value of current field as string.
1468  * @param v a string
1469  * @exception NullPointerException invalid iterator, possibly end iterator
1470  * @exception TypeMismatchException thrown if field is not of type string
1471  */
1472 void
1474 {
1475  if ( __infol == NULL ) {
1476  throw NullPointerException("Cannot set value of end element");
1477  } else if ( __infol->type != IFT_STRING ) {
1478  throw TypeMismatchException("Field to be written is not of type string");
1479  } else {
1480  strncpy((char *) __infol->value, v, __infol->length);
1481  }
1482 }
1483 
1484 } // end namespace fawkes
64 bit integer field
Definition: types.h:41
Interface field iterator.
void set_int64(int64_t i, unsigned int index=0)
Set value of current field as integer.
const char * get_value_string()
Get value of current field as string.
const char * get_string() const
Get value of current field as string.
int32_t * get_int32s() const
Get value of current field as integer array.
void set_int64s(int64_t *i)
Set value of current field as integer array.
float get_float(unsigned int index=0) const
Get value of current field as float.
void set_bytes(uint8_t *b)
Set value of current field as byte array.
void set_float(float f, unsigned int index=0)
Set value of current field as float.
void set_uint64s(uint64_t *i)
Set value of current field as unsigned integer array.
bool operator==(const InterfaceFieldIterator &fit) const
Check iterators for equality.
int32_t * get_enums() const
Get value of current enum field as integer array.
void set_bool(bool b, unsigned int index=0)
Set value of current field as bool.
void set_bools(bool *b)
Set value of current field as bool array.
void set_int16(int16_t i, unsigned int index=0)
Set value of current field as integer.
InterfaceFieldIterator & operator=(const InterfaceFieldIterator &fit)
Make this instance point to the same segment as fi.
Interface field info list.
Definition: types.h:51
Fawkes library namespace.
const char * name
Name of this field.
Definition: types.h:54
InterfaceFieldIterator & operator+(unsigned int i)
Advance by i steps.
8 bit unsigned integer field
Definition: types.h:36
void set_uint16(uint16_t i, unsigned int index=0)
Set value of current field as unsigned integer.
const void * operator*() const
Get FieldHeader.
interface_fieldtype_t get_type() const
Get type of current field.
uint64_t get_uint64(unsigned int index=0) const
Get value of current field as unsigned integer.
16 bit unsigned integer field
Definition: types.h:38
void set_int8(int8_t i, unsigned int index=0)
Set value of current field as integer.
interface_fieldinfo_t * next
next field, NULL if last
Definition: types.h:57
uint8_t * get_uint8s() const
Get value of current field as unsigned integer array.
void set_uint8(uint8_t i, unsigned int index=0)
Set value of current field as unsigned integer.
string field
Definition: types.h:45
byte field, alias for uint8
Definition: types.h:46
A NULL pointer was supplied where not allowed.
Definition: software.h:34
uint8_t get_uint8(unsigned int index=0) const
Get value of current field as unsigned integer.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
bool operator!=(const InterfaceFieldIterator &fit) const
Check iterators for inequality.
16 bit integer field
Definition: types.h:37
void set_int32(int32_t i, unsigned int index=0)
Set value of current field as integer.
double * get_doubles() const
Get value of current field as double array.
int16_t * get_int16s() const
Get value of current field as integer array.
void * value
Current value of this field.
Definition: types.h:56
uint32_t * get_uint32s() const
Get value of current field as unsigned integer array.
void set_doubles(double *f)
Set value of current field as double array.
void set_double(double f, unsigned int index=0)
Set value of current field as double.
int8_t get_int8(unsigned int index=0) const
Get value of current field as integer.
int8_t * get_int8s() const
Get value of current field as integer array.
uint64_t * get_uint64s() const
Get value of current field as unsigned integer array.
bool * get_bools() const
Get value of current field as bool array.
void set_byte(uint8_t b, unsigned int index=0)
Set value of current field as byte.
InterfaceFieldIterator & operator++()
Prefix increment.
uint8_t get_byte(unsigned int index=0) const
Get value of current field as byte.
float * get_floats() const
Get value of current field as float array.
bool get_bool(unsigned int index=0) const
Get value of current field as bool.
interface_fieldtype_t type
type of this field
Definition: types.h:52
InterfaceFieldIterator & operator+=(unsigned int i)
Advance by i steps.
void set_string(const char *s)
Set value of current field as string.
64 bit unsigned integer field
Definition: types.h:42
void set_uint16s(uint16_t *i)
Set value of current field as unsigned integer array.
size_t length
Length of field (array, string)
Definition: types.h:55
void set_uint32(uint32_t i, unsigned int index=0)
Set value of current field as unsigned integer.
float field
Definition: types.h:43
double get_double(unsigned int index=0) const
Get value of current field as double.
const char * get_name() const
Get name of current field.
size_t get_length() const
Get length of current field.
32 bit integer field
Definition: types.h:39
virtual const char * enum_tostring(const char *enumtype, int val) const =0
Convert arbitrary enum value to string.
void set_int32s(int32_t *i)
Set value of current field as integer array.
const void * get_value() const
Get value of current field.
const char * enumtype
text representation of enum type
Definition: types.h:53
uint16_t * get_uint16s() const
Get value of current field as unsigned integer array.
void set_int8s(int8_t *i)
Set value of current field as integer array.
void set_floats(float *f)
Set value of current field as float array.
void set_uint8s(uint8_t *i)
Set value of current field as unsigned integer array.
void set_int16s(int16_t *i)
Set value of current field as integer array.
void set_uint64(uint64_t i, unsigned int index=0)
Set value of current field as unsigned integer.
const char * get_typename() const
Get type of current field as string.
int16_t get_int16(unsigned int index=0) const
Get value of current field as integer.
Index out of bounds.
Definition: software.h:88
boolean field
Definition: types.h:34
void set_uint32s(uint32_t *i)
Set value of current field as unsigned integer array.
int32_t get_enum(unsigned int index=0) const
Get value of current enum field as integer.
interface_fieldtype_t
Interface field type.
Definition: types.h:33
uint32_t get_uint32(unsigned int index=0) const
Get value of current field as unsigned integer.
int32_t get_int32(unsigned int index=0) const
Get value of current field as integer.
32 bit unsigned integer field
Definition: types.h:40
int64_t get_int64(unsigned int index=0) const
Get value of current field as integer.
field with interface specific enum type
Definition: types.h:47
8 bit integer field
Definition: types.h:35
System ran out of memory and desired operation could not be fulfilled.
Definition: system.h:32
int64_t * get_int64s() const
Get value of current field as integer array.
double field
Definition: types.h:44
uint16_t get_uint16(unsigned int index=0) const
Get value of current field as unsigned integer.
uint8_t * get_bytes() const
Get value of current field as byte array.