Revision | cb48a7e91de1ee9ad19fac02c5206040b8f5eeff (tree) |
---|---|
Zeit | 2013-07-23 11:29:46 |
Autor | Katsuhiko Nishimra <ktns.87@gmai...> |
Commiter | Katsuhiko Nishimra |
Reimplement MolDSException::Deserialization to load multiple exceptions. #31730
git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1413 1136aad2-a195-0410-b898-f5ea1d11b9d8
@@ -143,6 +143,19 @@ void MolDSException::serialize(Archive& ar, const unsigned int ver){ | ||
143 | 143 | this->backtracePtr[i]=reinterpret_cast<void*>(p); |
144 | 144 | } |
145 | 145 | } |
146 | + | |
147 | + bool hasnext = this->nextException.get() != NULL; | |
148 | + ar & hasnext; | |
149 | + MolDSException* pe = NULL; | |
150 | + if(Archive::is_saving::value){ | |
151 | + pe = this->nextException.get(); | |
152 | + } | |
153 | + if(hasnext){ | |
154 | + ar & pe; | |
155 | + } | |
156 | + if(!Archive::is_saving::value){ | |
157 | + this->nextException.reset(pe); | |
158 | + } | |
146 | 159 | } |
147 | 160 | |
148 | 161 | void MolDSException::Serialize(std::ostream& os){ |
@@ -157,6 +170,21 @@ MolDSException MolDSException::Deserialize(std::istream& is){ | ||
157 | 170 | boost::scoped_ptr<MolDSException> sp(p); |
158 | 171 | ia >> p; |
159 | 172 | sp.reset(p); |
160 | - return *p; | |
173 | + | |
174 | + while(!is.eof()){ | |
175 | + try{ | |
176 | + boost::archive::text_iarchive ia(is); | |
177 | + MolDSException* pnext = NULL; | |
178 | + ia >> pnext; | |
179 | + p->LastException()->nextException.reset(pnext); | |
180 | + p = pnext; | |
181 | + } | |
182 | + catch(...){ | |
183 | + p->LastException()->nextException.reset(); | |
184 | + break; | |
185 | + } | |
186 | + } | |
187 | + | |
188 | + return *sp.get(); | |
161 | 189 | } |
162 | 190 | } |
@@ -44,11 +44,22 @@ private: | ||
44 | 44 | void GetBacktrace(int bufsize); |
45 | 45 | size_t backtraceSize; |
46 | 46 | boost::shared_array<void*> backtracePtr; |
47 | + | |
47 | 48 | typedef std::map<int, int> intKeyValueMap_t; |
48 | 49 | intKeyValueMap_t intKeyValueMap; |
49 | 50 | //typedef std::map<int, other> otherKeyValueMap_t; |
50 | 51 | //otherKeyValueMap_t otherKeyValueMap; |
52 | + | |
51 | 53 | boost::shared_ptr<MolDSException> nextException; |
54 | + MolDSException* LastException(){ | |
55 | + if(this->nextException.get()==NULL){ | |
56 | + return this; | |
57 | + } | |
58 | + else{ | |
59 | + return this->nextException->LastException(); | |
60 | + } | |
61 | + } | |
62 | + | |
52 | 63 | friend class boost::serialization::access; |
53 | 64 | template<class Archive> |
54 | 65 | void serialize(Archive& ar, const unsigned int ver); |