field_iterator.h

00001
00002 /***************************************************************************
00003  *  field_iterator.h - Iterate over field of an interface or a message
00004  *
00005  *  Created: Fri Jul 16 17:12:30 2009
00006  *  Copyright  2006  Tim Niemueller [www.niemueller.de]
00007  *             2009  Daniel Beck
00008  *
00009  ****************************************************************************/
00010
00011 /*  This program is free software; you can redistribute it and/or modify
00012  *  it under the terms of the GNU General Public License as published by
00013  *  the Free Software Foundation; either version 2 of the License, or
00014  *  (at your option) any later version. A runtime exception applies to
00015  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00016  *
00017  *  This program is distributed in the hope that it will be useful,
00018  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  *  GNU Library General Public License for more details.
00021  *
00022  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00023  */
00024
00025 #ifndef __INTERFACE_FIELD_ITERATOR_H__
00026 #define __INTERFACE_FIELD_ITERATOR_H__
00027 
00028 #include <interface/types.h>
00029
00030 namespace fawkes {
00031 class Interface;
00032 class Message;
00033
00034 class InterfaceFieldIterator
00035 {
00036   friend class Interface;
00037   friend class Message;
00038
00039  public:
00040   InterfaceFieldIterator();
00041   InterfaceFieldIterator(const InterfaceFieldIterator &fit);
00042   ~InterfaceFieldIterator();
00043   InterfaceFieldIterator &        operator++ ();        // prefix
00044   InterfaceFieldIterator          operator++ (int inc); // postfix
00045   InterfaceFieldIterator &        operator+  (unsigned int i);
00046   InterfaceFieldIterator &        operator+= (unsigned int i);
00047   bool                   operator== (const InterfaceFieldIterator & fit) const;
00048   bool                   operator!= (const InterfaceFieldIterator & fit) const;
00049   const void *           operator*  () const;
00050   InterfaceFieldIterator &        operator=  (const InterfaceFieldIterator & fit);
00051
00052   interface_fieldtype_t  get_type() const;
00053   const char *           get_typename() const;
00054   const char *           get_name() const;
00055   const void *           get_value() const;
00056   const char *           get_value_string();
00057   size_t                 get_length() const;
00058   bool                   get_bool(unsigned int index = 0) const;
00059   int                    get_int(unsigned int index = 0) const;
00060   unsigned int           get_uint(unsigned int index = 0) const;
00061   long int               get_longint(unsigned int index = 0) const;
00062   unsigned long int      get_longuint(unsigned int index = 0) const;
00063   float                  get_float(unsigned int index = 0) const;
00064   unsigned char          get_byte(unsigned int index = 0) const;
00065   bool *                 get_bools() const;
00066   int *                  get_ints() const;
00067   unsigned int *         get_uints() const;
00068   long int *             get_longints() const;
00069   unsigned long int *    get_longuints() const;
00070   float *                get_floats() const;
00071   unsigned char *        get_bytes() const;
00072   const char *           get_string() const;
00073
00074   void                   set_bool(bool b, unsigned int index = 0);
00075   void                   set_int(int i, unsigned int index = 0);
00076   void                   set_uint(unsigned int i, unsigned int index = 0);
00077   void                   set_longint(long int i, unsigned int index = 0);
00078   void                   set_longuint(long unsigned int i, unsigned int index = 0);
00079   void                   set_float(float f, unsigned int index = 0);
00080   void                   set_byte(unsigned char b, unsigned int index = 0);
00081   void                   set_bools(bool *b);
00082   void                   set_ints(int *i);
00083   void                   set_uints(unsigned int *i);
00084   void                   set_longints(long int *i);
00085   void                   set_longuints(long unsigned int *i);
00086   void                   set_floats(float *f);
00087   void                   set_bytes(unsigned char* b);
00088   void                   set_string(const char* s);
00089
00090  protected:
00091   InterfaceFieldIterator(const interface_fieldinfo_t *info_list);
00092
00093  private:
00094   const interface_fieldinfo_t   *__infol;
00095   char                          *__value_string;
00096 };
00097
00098 }
00099
00100 #endif /* __INTERFACE_FIELD_ITERATOR_H__ */