• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

修訂dfee4bd096028819be62772970142c41aaa07534 (tree)
時間2013-07-18 12:14:02
作者Katsuhiko Nishimra <ktns.87@gmai...>
CommiterKatsuhiko Nishimra

Log Message

Implement the serializer for MolDSException. #31716

git-svn-id: https://svn.sourceforge.jp/svnroot/molds/trunk@1404 1136aad2-a195-0410-b898-f5ea1d11b9d8

Change Summary

差異

--- a/src/base/MolDSException.cpp
+++ b/src/base/MolDSException.cpp
@@ -22,6 +22,9 @@
2222 #include<stdexcept>
2323 #include<iostream>
2424 #include<boost/format.hpp>
25+#include<boost/serialization/map.hpp>
26+#include<boost/archive/text_iarchive.hpp>
27+#include<boost/archive/text_oarchive.hpp>
2528 #include"MolDSException.h"
2629 #include"Enums.h"
2730 using namespace std;
@@ -90,4 +93,46 @@ const char* MolDSException::what() const throw(){
9093 str = ss.str();
9194 return str.c_str();
9295 }
96+
97+template<class Archive>
98+void MolDSException::serialize(Archive& ar, const unsigned int ver){
99+ ar & intKeyValueMap;
100+ // ar & otherKeyValueMap;
101+
102+ ar & backtraceSize;
103+ std::cerr << "backtraceSize:" << backtraceSize << std::endl;
104+ if(!Archive::is_saving::value){
105+ backtracePtr.reset(new void*[backtraceSize]);
106+ }
107+ for(int i; i<backtraceSize; i++){
108+ if(Archive::is_saving::value){
109+ intptr_t p = reinterpret_cast<intptr_t>(backtracePtr[i]);
110+ ar & p;
111+ std::cerr << "in: " << p << std::endl;
112+ }
113+ else{
114+ intptr_t p;
115+ ar & p;
116+ std::cerr << "out:" << p << std::endl;
117+ backtracePtr[i]=reinterpret_cast<void*>(p);
118+ }
119+ }
120+}
121+
122+void MolDSException::Serialize(std::ostream& os){
123+ boost::archive::text_oarchive oa(os);
124+ std::string what = domain_error::what();
125+ std::cerr << "what:" << what << std::endl;
126+ oa << what;
127+ oa << (*this);
128+}
129+
130+MolDSException MolDSException::Deserialize(std::istream& is){
131+ boost::archive::text_iarchive ia(is);
132+ std::string what;
133+ ia >> what;
134+ MolDSException e(what);
135+ ia >> e;
136+ return e;
137+}
93138 }
--- a/src/base/MolDSException.h
+++ b/src/base/MolDSException.h
@@ -20,6 +20,7 @@
2020 #define INCLUDED_MOLDSEXCEPTION
2121 #include<map>
2222 #include<boost/shared_array.hpp>
23+#include<boost/serialization/access.hpp>
2324 namespace MolDS_base{
2425 class MolDSException : public std::domain_error {
2526 public:
@@ -35,6 +36,8 @@ public:
3536 void SetKeyValue(int key, T value);
3637 bool HasKey(int key);
3738 virtual const char* what() const throw();
39+ void Serialize(std::ostream& os);
40+ static MolDSException Deserialize(std::istream& is);
3841 private:
3942 void GetBacktrace(int bufsize);
4043 size_t backtraceSize;
@@ -43,6 +46,9 @@ private:
4346 intKeyValueMap_t intKeyValueMap;
4447 //typedef std::map<int, other> otherKeyValueMap_t;
4548 //otherKeyValueMap_t otherKeyValueMap;
49+ friend class boost::serialization::access;
50+ template<class Archive>
51+ void serialize(Archive& ar, const unsigned int ver);
4652 };
4753 }
4854 #endif