39 TEmulatedMapProxy::TEmulatedMapProxy(
const TEmulatedMapProxy& copy)
40 : TEmulatedCollectionProxy(copy)
43 if ( !(fSTL_type == ROOT::kSTLmap || fSTL_type == ROOT::kSTLmultimap) ) {
44 Fatal(
"TEmulatedMapProxy",
"Class %s is not a map-type!",fName.c_str());
48 TEmulatedMapProxy::TEmulatedMapProxy(
const char* cl_name, Bool_t silent)
49 : TEmulatedCollectionProxy(cl_name, silent)
52 if ( !(fSTL_type == ROOT::kSTLmap || fSTL_type == ROOT::kSTLmultimap) ) {
53 Fatal(
"TEmulatedMapProxy",
"Class %s is not a map-type!",fName.c_str());
57 TEmulatedMapProxy::~TEmulatedMapProxy()
62 TVirtualCollectionProxy* TEmulatedMapProxy::Generate()
const
65 if ( !fClass ) Initialize(kFALSE);
66 return new TEmulatedMapProxy(*
this);
69 void* TEmulatedMapProxy::At(UInt_t idx)
72 if ( fEnv && fEnv->fObject ) {
73 PCont_t c = PCont_t(fEnv->fObject);
74 return idx<(c->size()/fValDiff) ? ((
char*)&(*c->begin())) + idx*fValDiff : 0;
76 Fatal(
"TEmulatedMapProxy",
"At> Logic error - no proxy object set.");
80 UInt_t TEmulatedMapProxy::Size()
const
83 if ( fEnv && fEnv->fObject ) {
84 PCont_t c = PCont_t(fEnv->fObject);
85 return fEnv->fSize = (c->size()/fValDiff);
87 Fatal(
"TEmulatedMapProxy",
"Size> Logic error - no proxy object set.");
91 void TEmulatedMapProxy::ReadMap(UInt_t nElements, TBuffer &b)
94 Bool_t vsn3 = b.GetInfo() && b.GetInfo()->GetOldVersion()<=3;
96 Int_t off[2] = {0, fValOffset };
97 Value *v, *val[2] = { fKey, fVal };
101 char* temp = (
char*)At(0);
102 for ( idx = 0; idx < nElements; ++idx ) {
103 addr = temp + idx*fValDiff;
104 for ( loop=0; loop<2; loop++) {
106 helper = (StreamHelper*)addr;
111 switch(
int(v->fKind) ) {
112 case kBool_t: b >> helper->boolean;
break;
113 case kChar_t: b >> helper->s_char;
break;
114 case kShort_t: b >> helper->s_short;
break;
115 case kInt_t: b >> helper->s_int;
break;
116 case kLong_t: b >> helper->s_long;
break;
117 case kLong64_t: b >> helper->s_longlong;
break;
118 case kFloat_t: b >> helper->flt;
break;
119 case kFloat16_t: b >> f;
120 helper->flt = float(f);
break;
121 case kDouble_t: b >> helper->dbl;
break;
122 case kUChar_t: b >> helper->u_char;
break;
123 case kUShort_t: b >> helper->u_short;
break;
124 case kUInt_t: b >> helper->u_int;
break;
125 case kULong_t: b >> helper->u_long;
break;
126 case kULong64_t: b >> helper->u_longlong;
break;
127 case kDouble32_t:b >> f;
128 helper->dbl = double(f);
break;
132 Error(
"TEmulatedMapProxy",
"fType %d is not supported yet!\n",v->fKind);
136 b.StreamObject(helper,v->fType);
139 helper->read_std_string(b);
141 case kIsPointer|kIsClass:
142 helper->set(b.ReadObjectAny(v->fType));
144 case kIsPointer|kBIT_ISSTRING:
145 helper->read_std_string_pointer(b);
147 case kIsPointer|kBIT_ISTSTRING|kIsClass:
148 helper->read_tstring_pointer(vsn3,b);
155 void TEmulatedMapProxy::WriteMap(UInt_t nElements, TBuffer &b)
158 Value *v, *val[2] = { fKey, fVal };
159 int off[2] = { 0, fValOffset };
162 char* temp = (
char*)At(0);
163 for (UInt_t loop, idx = 0; idx < nElements; ++idx ) {
164 addr = temp + idx*fValDiff;
165 for ( loop = 0; loop<2; ++loop ) {
167 i = (StreamHelper*)addr;
172 switch(
int(v->fKind) ) {
173 case kBool_t: b << i->boolean;
break;
174 case kChar_t: b << i->s_char;
break;
175 case kShort_t: b << i->s_short;
break;
176 case kInt_t: b << i->s_int;
break;
177 case kLong_t: b << i->s_long;
break;
178 case kLong64_t: b << i->s_longlong;
break;
179 case kFloat_t: b << i->flt;
break;
180 case kFloat16_t: b << float(i->flt);
break;
181 case kDouble_t: b << i->dbl;
break;
182 case kUChar_t: b << i->u_char;
break;
183 case kUShort_t: b << i->u_short;
break;
184 case kUInt_t: b << i->u_int;
break;
185 case kULong_t: b << i->u_long;
break;
186 case kULong64_t: b << i->u_longlong;
break;
187 case kDouble32_t:b << float(i->dbl);
break;
191 Error(
"TEmulatedMapProxy",
"fType %d is not supported yet!\n",v->fKind);
195 b.StreamObject(i,v->fType);
198 TString(i->c_str()).Streamer(b);
200 case kIsPointer|kIsClass:
201 b.WriteObjectAny(i->ptr(),v->fType);
203 case kBIT_ISSTRING|kIsPointer:
204 i->write_std_string_pointer(b);
206 case kBIT_ISTSTRING|kIsClass|kIsPointer:
207 i->write_tstring_pointer(b);
214 void TEmulatedMapProxy::ReadBuffer(TBuffer &b,
void *obj,
const TClass *onfileClass)
218 SetOnFileClass((TClass*)onfileClass);
222 void TEmulatedMapProxy::ReadBuffer(TBuffer &b,
void *obj)
226 TPushPop env(
this,obj);
229 if ( fEnv->fObject ) {
230 Resize(nElements,
true);
232 if ( nElements > 0 ) {
233 ReadMap(nElements, b);
237 void TEmulatedMapProxy::Streamer(TBuffer &b)
240 if ( b.IsReading() ) {
241 UInt_t nElements = 0;
243 if ( fEnv->fObject ) {
244 Resize(nElements,
true);
246 if ( nElements > 0 ) {
247 ReadMap(nElements, b);
251 UInt_t nElements = fEnv->fObject ? Size() : 0;
253 if ( nElements > 0 ) {
254 WriteMap(nElements, b);