Made a back BOOST :: XML

xiaoxiao2021-03-06  41

I have been worried about the ticket before the year, but I have to seal now a version developed before going to the holiday. I am really tired. The BT's study has been put down for two days. Recently, I have a few libraries about BT, it is watching, The Tracker of BT is really interesting. Be sure to figure out him, don't know what the method can improve the transmission speed of P2P ... Who has a good idea to share. Today, I use a copy of the version to study the serialization of Boost, especially XML serialized Dongdong, still have a lot of gains, I am afraid that I have forgotten, people are old, many Dongdong can't remember .... .. (1) Research on the work of the Boost library XML sequence to be prepared. Next, the next latest BOOST library remembers the 1.32 version, this version provides XML serialization support B.Windows VC7.0, This is a must, I have never been able to change my VC6. The result of compiling Boost's serialization is a lot of cockroaches. It is really no way. I have no way, I have to install VC7, the reason is VC6 template The support is not good, it is much farther than GCC, VC7 is strong ... In fact, VC7 is also very easy to use. c. Open the project file under BOOST / LIBS / Serialization / VC7IDE, then edit the Lib, D. Make a new engineering test to use my name XMLSER E. Remember to make the RTTI support of the project, I am because I am This is not selected, scratched for a long time, the specific setuprty page-> C / C -> Language-> Enable Run-Time Type Info must choose (YES), I just didn't pay attention to this, the result is in my serialization STD :: Vector INTS; time to die Dynamic_cast , interested can see a document about RTTI on MSDN, which is ready to write test code.

(2) Boost's XML serialized test code is best to do this to see the documentation provided by Boost, and it is best to see the example programs under Boost / Libs / Serialization / Example, but I recommend the most Don't use this code to do the test, one is more complicated, two is that you will not understand the implementation details, below is a step-by-step test code // xmlser.cpp: defines the entry point for the console application . / / #include #include #include #include #pragma comment (lib, "libboost_serialization.lib") class test {public: test (): mvalue (-1) {} template void serialize (archive & ar, unsigned int filever) {ar ​​& BOOST_SERIALIZATION_NVP (mvalue);} Int mvalue;}; int _tmain (int Argc, _tchar * argv []) {/ *** save archive * / {std :: vector INTS; test * a = new test; INTS.PUSH_BACK (100); INTS.PUSH_BACK (200); std :: OFSTREAM OFS ("Test.xml"); Boost :: Archive :: XML_Oarchive OA (OFS); int nvalue = 106; OA << boost_serialization_nvp (nvalue); OA << Boost_Serialization_nvp ( INTS); OA << boost_serialization_nvp (a); delete a;} / *** load from archive * / {std :: vector INTS; std: : IFStream OFS ("Test.xml"); Boost :: Archive :: XML_iarchive OA (OFS); INT NVALUE = 0; Test * a = null; OA >> Boost_Serialization_nvp (NVALUE); OA >> Boost_Serialization_nvp (INTS); OA >> boost_serialization_nvp (a); for (std :: vector :: item i = INTS.BEGIN (); i! = INTS.END (); i ) {printf ("the value of vector% D / n ", * i);}} return 0;} This is to explain that if you want to use the STL container of STL containers, you must include #include , Because this file defines Template Inline Void Serialize (Archive & Ar, std :: vector <

转载请注明原文地址:https://www.9cbs.com/read-60586.html

New Post(0)