BString Class Referencemetainfo file reader More...
Collaboration diagram for BString:
Detailed Descriptionmetainfo file reader
Definition at line 36 of file BString.h. Constructor & Destructor Documentation
Definition at line 53 of file BString.cpp. References m_current, and m_root. 00054 :m_bindex(0) 00055 ,m_root(0) 00056 ,m_current(NULL) 00057 ,m_state(0) 00058 ,m_strlen(0) 00059 ,m_str("") 00060 ,m_name("") 00061 ,m_bDictionary(false) // key-value pairs 00062 ,m_bList(false) // values 00063 ,m_bKey(false) // used when m_bDictionary is true 00064 { 00065 m_current = &m_root; 00066 }
Member Function Documentation
Definition at line 74 of file BString.cpp. References reg_char(). Referenced by MetainfoSocket::InitSession(), main(), and validate(). 00075 { 00076 char c; 00077 00078 fread(&c,1,1,fil); 00079 while (!feof(fil)) 00080 { 00081 if (!reg_char(c)) 00082 { 00083 break; 00084 } 00085 // 00086 fread(&c,1,1,fil); 00087 } 00088 }
Definition at line 91 of file BString.cpp. References reg_char(). 00092 { 00093 for (size_t i = 0; i < l; i++) 00094 { 00095 if (!reg_char(p[i])) 00096 { 00097 break; 00098 } 00099 } 00100 }
Definition at line 350 of file BString.cpp. References m_root. Referenced by GetBString(), GetInteger(), GetString(), MetainfoSocket::InitSession(), and main(). 00351 { 00352 ParseBT pa( (char *)path.c_str(), ".", 1); 00353 char slask[200]; 00354 BTObject *p = &m_root; 00355 BTList *l = dynamic_cast<BTList *>(p); 00356 // assert(l && l -> GetSize() == 1); 00357 if (!l || l -> GetSize() != 1) 00358 { 00359 throw(BTException("GetBTObject")); 00360 } 00361 p = l -> GetFirst(); 00362 pa.getword(slask); 00363 while (*slask) 00364 { 00365 BTDictionary *d = dynamic_cast<BTDictionary *>(p); 00366 // assert(d); 00367 if (!d) 00368 { 00369 throw(BTException("Not Dictionary")); 00370 } 00371 p = d -> Find(slask); 00372 if (!p) 00373 return NULL; 00374 pa.getword(slask); 00375 } 00376 return p; 00377 }
Definition at line 380 of file BString.cpp. References GetBTObject(). Referenced by MetainfoSocket::InitSession(), and main(). 00381 { 00382 BTObject *p = GetBTObject(str); 00383 return dynamic_cast<BTInteger *>(p); 00384 }
Definition at line 387 of file BString.cpp. References GetBTObject(). Referenced by MetainfoSocket::InitSession(), and main(). 00388 { 00389 BTObject *p = GetBTObject(str); 00390 return dynamic_cast<BTString *>(p); 00391 }
Definition at line 394 of file BString.cpp. References GetBTObject(), GetIndex(), and m_bstring. Referenced by GetHash(), and GetHashAsString(). 00395 { 00396 BTObject *p = GetBTObject(path); 00397 size_t begin = p -> GetIndex(); 00398 size_t length = p -> GetLength() + 1; 00399 std::string str = m_bstring.substr(begin,length); 00400 // printf("%s\n",printable(str).c_str()); 00401 return str; 00402 }
Definition at line 63 of file BString.h. References m_bindex. Referenced by GetBString(). 00063 { return m_bindex; }
Definition at line 405 of file BString.cpp. References GetBString(), and m_hash. Referenced by MetainfoSocket::InitSession(). 00406 { 00407 std::string tmp = GetBString( node ); 00408 SHA1( (unsigned char *)tmp.c_str(), tmp.size(), m_hash); 00409 return m_hash; 00410 }
Definition at line 413 of file BString.cpp. References GetBString(), m_hash, and m_hash_str. Referenced by MetainfoSocket::InitSession(), and main(). 00414 { 00415 std::string tmp = GetBString( node ); 00416 char slask[100]; 00417 SHA1( (unsigned char *)tmp.c_str(), tmp.size(), m_hash); 00418 *slask = 0; 00419 for (size_t i = 0; i < 20; i++) 00420 sprintf(slask + strlen(slask), "%02x", m_hash[i]); 00421 m_hash_str = slask; 00422 return m_hash_str; 00423 }
Referenced by read_buf(), and read_file().
Definition at line 232 of file BString.cpp. References m_bindex, m_current, and m_name. 00233 { 00234 BTDictionary *tmp = new BTDictionary(m_bindex); 00235 00236 tmp -> SetParent(m_current); 00237 00238 switch (m_current -> Type()) 00239 { 00240 case 'd': // dictionary 00241 m_current -> AddObject(m_name, tmp); 00242 m_current = tmp; 00243 m_name = ""; 00244 break; 00245 case 'l': // list 00246 m_current -> AddObject(tmp); 00247 m_current = tmp; 00248 break; 00249 default: 00250 // assert(!"no good"); 00251 throw(BTException("AddDictionary")); 00252 break; 00253 } 00254 }
Definition at line 257 of file BString.cpp. References m_bindex, m_current, and m_name. 00258 { 00259 BTList *tmp = new BTList(m_bindex); 00260 00261 tmp -> SetParent(m_current); 00262 00263 switch (m_current -> Type()) 00264 { 00265 case 'd': // dictionary 00266 m_current -> AddObject(m_name, tmp); 00267 m_current = tmp; 00268 m_name = ""; 00269 break; 00270 case 'l': // list 00271 m_current -> AddObject(tmp); 00272 m_current = tmp; 00273 break; 00274 default: 00275 // assert(!"no good"); 00276 throw(BTException("AddList")); 00277 break; 00278 } 00279 }
Definition at line 282 of file BString.cpp. References m_current, and m_name. 00283 { 00284 BTInteger *tmp = new BTInteger; 00285 00286 tmp -> SetParent(m_current); 00287 tmp -> SetValue(str); 00288 00289 switch (m_current -> Type()) 00290 { 00291 case 'd': // dictionary 00292 m_current -> AddObject(m_name, tmp); 00293 m_name = ""; 00294 break; 00295 case 'l': // list 00296 m_current -> AddObject(tmp); 00297 break; 00298 default: 00299 throw(BTException("AddInteger")); 00300 // assert(!"no good"); 00301 break; 00302 } 00303 }
Definition at line 306 of file BString.cpp. References m_current, and m_name. 00307 { 00308 if (m_current -> Type() == 'd' && m_name.size() == 0) 00309 { 00310 m_name = str; 00311 return; 00312 } 00313 BTString *tmp = new BTString; 00314 00315 tmp -> SetParent(m_current); 00316 tmp -> SetValue(str); 00317 00318 switch (m_current -> Type()) 00319 { 00320 case 'd': // dictionary 00321 m_current -> AddObject(m_name, tmp); 00322 m_name = ""; 00323 break; 00324 case 'l': // list 00325 m_current -> AddObject(tmp); 00326 break; 00327 default: 00328 throw(BTException("AddString")); 00329 // assert(!"no good"); 00330 break; 00331 } 00332 }
Member Data Documentation
Definition at line 78 of file BString.h. Referenced by AddDictionary(), AddInteger(), AddList(), AddString(), BString(), and End().
Definition at line 82 of file BString.h. Referenced by AddDictionary(), AddInteger(), AddList(), and AddString().
The documentation for this class was generated from the following files: |