Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

ruby_struct.hpp

00001 #ifndef Exc_Ruby__ruby_struct__hpp_
00002 #define Exc_Ruby__ruby_struct__hpp_
00003 
00004 #ident "$Id$"
00005 
00006 #include "ruby_array.hpp"
00007 #include "ruby_hash.hpp"
00008 #include "../ruby_type.hpp"
00009 
00010 namespace Exc_Ruby
00011 {
00012 
00013 class Ruby_Struct
00014   : public Ruby_Type<RStruct>
00015 {
00016 public:
00017   Ruby_Struct();
00018   virtual ~Ruby_Struct();
00019 
00020   void initialize(
00021       VALUE module,
00022       char const * name);
00023 
00024   Ruby_Struct & define_member(
00025       char const * name);
00026 
00027   size_t offset_of(char const * member) const;
00028 
00029   class Instance;
00030   friend class Instance;
00031 
00032 private:
00033   Ruby_Struct(Ruby_Struct const & s);
00034 
00035 private:
00036   Ruby_Array members_;
00037   Ruby_Hash member_offset_;
00038 
00039   VALUE members_value_;
00040   VALUE member_offset_value_;
00041 };
00042 
00043 
00044 class Ruby_Struct::Instance
00045   : public Ruby_Reference<
00046       RStruct,
00047       Exception_Safe_Builtin_Wrapper<RStruct, T_STRUCT> >
00048 {
00049 public:
00050   Instance(
00051       Ruby_Struct const & type,
00052       Ruby_Array args = Ruby_Array());
00053 
00054   Instance(
00055       Ruby_Struct const & type,
00056       VALUE s);
00057 
00058   // TODO: Need support for []=
00059   VALUE const operator[](char const * member);
00060 
00061   // TODO: Need support for []=
00062   VALUE const operator[](size_t index);
00063 
00064 private:
00065   Ruby_Struct const type_;
00066 };
00067 
00068 } // namespace Exc_Ruby
00069 
00070 #include "ruby_struct.ipp"
00071 
00072 #endif // Exc_Ruby__ruby_struct__hpp_
00073 

Generated on Sat Jan 1 12:02:20 2005 for Exceptional Ruby by doxygen 1.3.6