Pol  Revision:4b29d2b
bstruct.h
Go to the documentation of this file.
1 
9 #ifndef BSCRIPT_BSTRUCT_H
10 #define BSCRIPT_BSTRUCT_H
11 
12 #ifndef BSCRIPT_BOBJECT_H
13 #include "bobject.h"
14 #endif
15 
16 #include <iosfwd>
17 #include <map>
18 #include <string>
19 
20 #include "../clib/compilerspecifics.h"
21 #include "../clib/maputil.h"
22 #include "../clib/rawtypes.h"
23 
24 namespace Pol
25 {
26 namespace Bscript
27 {
28 class ContIterator;
29 class Executor;
30 } // namespace Bscript
31 } // namespace Pol
32 
33 namespace Pol
34 {
35 namespace Bscript
36 {
37 class BStruct : public BObjectImp
38 {
39 public:
40  BStruct();
41  BStruct( std::istream& is, unsigned size, BObjectType type );
42  static BObjectImp* unpack( std::istream& is );
43 
44  void addMember( const char* name, BObjectRef val );
45  void addMember( const char* name, BObjectImp* imp );
46 
47  const BObjectImp* FindMember( const char* name );
48 
49  size_t mapcount() const;
50 
51  typedef std::map<std::string, BObjectRef, Clib::ci_cmp_pred> Contents;
52  const Contents& contents() const;
53 
54 protected:
55  explicit BStruct( const BStruct& other, BObjectType type );
56  explicit BStruct( BObjectType type );
57 
58  virtual BObjectImp* copy() const POL_OVERRIDE;
59 
60  virtual char packtype() const;
61  virtual const char* typetag() const;
62  virtual void FormatForStringRep( std::ostream& os, const std::string& key,
63  const BObjectRef& bvalref ) const;
64 
65  virtual std::string getStringRep() const POL_OVERRIDE;
66  virtual size_t sizeEstimate() const POL_OVERRIDE;
67  virtual void packonto( std::ostream& os ) const POL_OVERRIDE;
68  virtual const char* typeOf() const POL_OVERRIDE;
69  virtual u8 typeOfInt() const POL_OVERRIDE;
70 
71  virtual ContIterator* createIterator( BObject* pIterVal ) POL_OVERRIDE;
72 
73  virtual BObjectRef OperSubscript( const BObject& obj ) POL_OVERRIDE;
74  virtual BObjectImp* call_method( const char* methodname, Executor& ex ) POL_OVERRIDE;
75  virtual BObjectImp* call_method_id( const int id, Executor& ex,
76  bool forcebuiltin = false ) POL_OVERRIDE;
77  virtual BObjectRef set_member( const char* membername, BObjectImp* value,
78  bool copy ) POL_OVERRIDE;
79  virtual BObjectRef get_member( const char* membername ) POL_OVERRIDE;
80  virtual BObjectRef operDotPlus( const char* name ) POL_OVERRIDE;
81  virtual BObjectRef operDotMinus( const char* name ) POL_OVERRIDE;
82  virtual BObjectRef operDotQMark( const char* name ) POL_OVERRIDE;
83  virtual BObjectImp* array_assign( BObjectImp* idx, BObjectImp* target, bool copy ) POL_OVERRIDE;
84 
85  friend class BStructIterator;
86 
87 private:
88  Contents contents_;
89  BStruct& operator=( const BStruct& ); // not implemented
90 };
91 }
92 }
93 #endif
unsigned char u8
Definition: rawtypes.h:25
#define POL_OVERRIDE
std::map< std::string, BObjectRef, Clib::ci_cmp_pred > Contents
Definition: bstruct.h:51
STL namespace.
std::string name
Definition: osmod.cpp:943
Definition: berror.cpp:12