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 #define __STD_LIMIT_MACROS
00031 #include <stdint.h>
00032 
00033 namespace fawkes {
00034 class Interface;
00035 class Message;
00036 
00037 class InterfaceFieldIterator
00038 {
00039   friend class Interface;
00040   friend class Message;
00041 
00042  public:
00043   InterfaceFieldIterator();
00044   InterfaceFieldIterator(const InterfaceFieldIterator &fit);
00045   ~InterfaceFieldIterator();
00046   InterfaceFieldIterator &        operator++ ();        // prefix
00047   InterfaceFieldIterator          operator++ (int inc); // postfix
00048   InterfaceFieldIterator &        operator+  (unsigned int i);
00049   InterfaceFieldIterator &        operator+= (unsigned int i);
00050   bool                   operator== (const InterfaceFieldIterator & fit) const;
00051   bool                   operator!= (const InterfaceFieldIterator & fit) const;
00052   const void *           operator*  () const;
00053   InterfaceFieldIterator &        operator=  (const InterfaceFieldIterator & fit);
00054   
00055   interface_fieldtype_t  get_type() const;
00056   const char *           get_typename() const;
00057   const char *           get_name() const;
00058   const void *           get_value() const;
00059   const char *           get_value_string();
00060   size_t                 get_length() const;
00061   bool                   get_bool(unsigned int index = 0) const;
00062   int8_t                 get_int8(unsigned int index = 0) const;
00063   uint8_t                get_uint8(unsigned int index = 0) const;
00064   int16_t                get_int16(unsigned int index = 0) const;
00065   uint16_t               get_uint16(unsigned int index = 0) const;
00066   int32_t                get_int32(unsigned int index = 0) const;
00067   uint32_t               get_uint32(unsigned int index = 0) const;
00068   int64_t                get_int64(unsigned int index = 0) const;
00069   uint64_t               get_uint64(unsigned int index = 0) const;
00070   float                  get_float(unsigned int index = 0) const;
00071   uint8_t                get_byte(unsigned int index = 0) const;
00072   bool *                 get_bools() const;
00073   int8_t *               get_int8s() const;
00074   uint8_t *              get_uint8s() const;
00075   int16_t *              get_int16s() const;
00076   uint16_t *             get_uint16s() const;
00077   int32_t *              get_int32s() const;
00078   uint32_t *             get_uint32s() const;
00079   int64_t *              get_int64s() const;
00080   uint64_t *             get_uint64s() const;
00081   float *                get_floats() const;
00082   uint8_t *              get_bytes() const;
00083   const char *           get_string() const;
00084 
00085   void                   set_bool(bool b, unsigned int index = 0);
00086   void                   set_int8(int8_t i, unsigned int index = 0);
00087   void                   set_uint8(uint8_t i, unsigned int index = 0);
00088   void                   set_int16(int16_t i, unsigned int index = 0);
00089   void                   set_uint16(uint16_t i, unsigned int index = 0);
00090   void                   set_int32(int32_t i, unsigned int index = 0);
00091   void                   set_uint32(uint32_t i, unsigned int index = 0);
00092   void                   set_int64(int64_t i, unsigned int index = 0);
00093   void                   set_uint64(uint64_t i, unsigned int index = 0);
00094   void                   set_float(float f, unsigned int index = 0);
00095   void                   set_byte(uint8_t b, unsigned int index = 0);
00096   void                   set_bools(bool *b);
00097   void                   set_int8s(int8_t *i);
00098   void                   set_uint8s(uint8_t *i);
00099   void                   set_int16s(int16_t *i);
00100   void                   set_uint16s(uint16_t *i);
00101   void                   set_int32s(int32_t *i);
00102   void                   set_uint32s(uint32_t *i);
00103   void                   set_int64s(int64_t *i);
00104   void                   set_uint64s(uint64_t *i);
00105   void                   set_floats(float *f);
00106   void                   set_bytes(uint8_t* b);
00107   void                   set_string(const char* s);
00108   
00109  protected:
00110   InterfaceFieldIterator(const Interface *interface,
00111                          const interface_fieldinfo_t *info_list);
00112   
00113  private:
00114   const interface_fieldinfo_t   *__infol;
00115   char                          *__value_string;
00116   const Interface               *__interface;
00117 };
00118 
00119 }
00120 
00121 #endif /* __INTERFACE_FIELD_ITERATOR_H__ */

Generated on Tue Feb 22 13:31:26 2011 for Fawkes API by  doxygen 1.4.7