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