Package
Const STD: String cdbobjectmanager: getdetails ()
{
STD: String STR;
If (getelementcount () = 0)
{
STR = "";
Return STR;
}
Sg_mgrstringmap.putint (STR, getelementcount (); // quantity
Sg_mgrstringmap.putint (STR, getattributecount (); // number of attributes
For (iterator iter = begin (); iter! = End (); ++ ITER)
{
Cdbobject * pobject = ITER-> second;
If (pobject)
Pobject-> blobcompress (STR );
}
If (Str. Size ()> 1)
Str. Erase (Str. Size ()-1, 1 );
Return STR;
}
Int cdbobject: blobcompress (STD: string & strbuf)
{
Int nfieldsize = 0;
While (1)
{
Int nattrisize = getattribute (nfieldsize );
If (nattribute <0)
Break;
Putint (strbuf, nattriint );
Nfieldsize ++;
}
Return nfieldsize;
}
Int cpetegg: getattribute (INT nindex)
{
Switch (nindex)
{
Case 0:
Return getpeteggid ();
Break;
Case 1:
Return getpeteggtype ();
Break;
Case 2:
Return gethatchstarttime ();
Break;
Case 3:
Return gethatchendtime ();
Break;
Default:
Return-1;
}
}
Bool cpetegg: setattribute (INT nattribute, int nindex)
{
Switch (nindex)
{
Case 0:
Setpeteggid (nattribute );
Break;
Case 1:
Setpeteggtype (nattribute );
Break;
Case 2:
Sethatchstarttime (nattritime );
Break;
Case 3:
Sethatchendtime (nattritime );
Break;
Default:
Return false;
}
Return true;
}
Unpack
Int nqueryresult = pdbreader-> query (SQL _query_role_super, prole-> GETID ());
If (nqueryresult! = 0)
{
Return false;
}
Int nrow = pdbreader-> get_result_rows ();
If (nrow! = 1)
{
Return false;
}
Char * pvalue = NULL;
// Retrieve detailed records
Int nlen = pdbreader-> get_result (0, db_challenge_details, pvalue );
If (nlen> 0 & pvalue! = NULL)
{
Prole-> m_challenge.loadcompress (pvalue );
}
Nlen = pdbreader-> get_result (0, db_property_details, pvalue );
If (nlen> 0 & pvalue! = NULL)
{
Prole-> m_mgrobpropertymanager.baseloadcompress (pvalue );
}
Nlen = pdbreader-> get_result (0, db_pet_details, pvalue );
If (nlen> 0 & pvalue! = NULL)
{
Prole-> m_mgrpetmanager.baseloadcompress (pvalue );
}
Bool cdbobjectmanager: baseloadcompress (char * pvalue)
{
If (null = pvalue)
Return false;
STD: vector <STD: String> vecttmprecords; // All Information
STD: vector <int> vectattribute; // detailed information of each object
Stringsplit (vecttmprecords, pvalue, field_split );
Int nattributecount = 0;
Int ndbattributecount = 0;
Int ncount = 0;
Int nsize = vecttmprecords. Size ();
For (INT I = 0; I <nsize; I ++)
{
If (I = 0)
{
Ncount = string2int (vecttmprecords [I]); // The number of retrieved records.
}
Else if (I = 1)
{
Int nattrcount = string2int (vecttmprecords [I]); // Number of retrieved attributes
Ndbattributecount = nattrcount;
Int nallsize = int (ndbattributecount * ncount) + 2;
If (nsize! = Nallsize)
{
// Break;
}
}
Else
{
Getattribute (vectattribute, vecttmprecords [I]);
Nattributecount ++;
}
If (ndbattributecount> 0 & nattributecount = ndbattributecount)
{
// Break;
If (vectattribute. Size () <= 0)
{
Vectattribute. Clear ();
Nattributecount = 0;
Continue;
}
Int nid = vectattribute [0];
If (NID <= 0)
{
Vectattribute. Clear ();
Nattributecount = 0;
Continue;
}
/* Cdbobject * pobject = new cdbobject (DB: cdbobject: save_mode_normal, nroleid );
For (Int J = 0; j <vectattribute. Size (); j ++)
{
Pobject-> findfuc (vectattribute [J], J );
}
If (! Insert (NID, pobject ))
{
Delete pobject;
Pobject = NULL;
}*/
Newblobobject (vectattribute );
Vectattribute. Clear ();
Nattributecount = 0;
}
}
Return true;
}
Bool cpeteggmanager: newblobobject (STD: vector <int> & vectattribute)
{
If (vectattribute. Size () <1)
Return false;
Int nid = vectattribute [0];
If (NID <= 0)
Return false;
DB: cpetegg * ppetegg = New DB: cpetegg (DB: cpetegg: save_mode_normal, getroleid ());
If (ppetegg = NULL)
Return false;
For (Int J = 0; j <vectattribute. Size (); j ++)
{
Ppetegg-> setattribute (vectattribute [J], J );
}
If (! Insert (NID, ppetegg ))
{
Delete ppetegg;
Ppetegg = NULL;
}
Return true;
}