[520] | 1 | #pragma warning(disable : 4996)
|
---|
| 2 |
|
---|
[522] | 3 | #include <map>
|
---|
[288] | 4 | #include <string>
|
---|
| 5 | #include <vector>
|
---|
| 6 | #include <fstream>
|
---|
[522] | 7 | #include <iostream>
|
---|
| 8 | #include <iomanip>
|
---|
| 9 | #include <ios>
|
---|
| 10 | #include <streambuf>
|
---|
| 11 | #include <sstream>
|
---|
[215] | 12 |
|
---|
[288] | 13 | #include <windows.h>
|
---|
| 14 | #include <stdio.h>
|
---|
| 15 | #include <string.h>
|
---|
| 16 | #include <math.h>
|
---|
| 17 | #include <commctrl.h>
|
---|
| 18 | #include <time.h>
|
---|
| 19 | #include <limits.h>
|
---|
| 20 | #include <shlobj.h>
|
---|
[522] | 21 | #include <process.h>
|
---|
| 22 | #include <fcntl.h>
|
---|
| 23 | #include <io.h>
|
---|
| 24 | #include <shlwapi.h>
|
---|
| 25 | #include <tchar.h>
|
---|
| 26 | #include <stdarg.h>
|
---|
[288] | 27 |
|
---|
| 28 | //boost libraries
|
---|
| 29 | #include <boost/foreach.hpp>
|
---|
| 30 |
|
---|
[215] | 31 | #include <boost/archive/xml_oarchive.hpp>
|
---|
| 32 | #include <boost/archive/xml_iarchive.hpp>
|
---|
| 33 | #include <boost/archive/text_oarchive.hpp>
|
---|
| 34 | #include <boost/archive/text_iarchive.hpp>
|
---|
| 35 | #include <boost/archive/binary_oarchive.hpp>
|
---|
| 36 | #include <boost/archive/binary_iarchive.hpp>
|
---|
| 37 | #include <boost/serialization/string.hpp>
|
---|
| 38 | #include <boost/serialization/access.hpp>
|
---|
| 39 | #include <boost/serialization/level.hpp>
|
---|
| 40 | #include <boost/serialization/vector.hpp>
|
---|
| 41 | #include <boost/serialization/map.hpp>
|
---|
| 42 | #include <boost/serialization/version.hpp>
|
---|
| 43 |
|
---|
[520] | 44 | #include <jenga/include/jenga.h>
|
---|
[215] | 45 |
|
---|
[751] | 46 | #include <abdev/ab_common/include/libs.h>
|
---|
| 47 |
|
---|
[215] | 48 | using namespace Jenga::Common;
|
---|
| 49 |
|
---|
| 50 | template<class T_xml_schema> void BoostSerializationSupport<T_xml_schema>::echo( const char *msg ) const
|
---|
| 51 | {
|
---|
| 52 | MessageBox( NULL, msg, "XMLシリアライズの例外", MB_OK );
|
---|
| 53 | }
|
---|
[523] | 54 | template<class T_xml_schema> bool BoostSerializationSupport<T_xml_schema>::ReadXml( std::istream& ifs, bool isShowExceptionMessage )
|
---|
[215] | 55 | {
|
---|
| 56 | bool isSuccessful = false;
|
---|
| 57 |
|
---|
| 58 | try{
|
---|
| 59 | boost::archive::xml_iarchive ia(ifs);
|
---|
| 60 |
|
---|
| 61 | // ファイルから読込
|
---|
| 62 | ia >> boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
|
---|
| 63 |
|
---|
| 64 | isSuccessful = true;
|
---|
| 65 | }
|
---|
| 66 | catch( boost::archive::archive_exception e )
|
---|
| 67 | {
|
---|
| 68 | if( isShowExceptionMessage )
|
---|
| 69 | {
|
---|
| 70 | echo( e.what() );
|
---|
| 71 | }
|
---|
| 72 | }
|
---|
| 73 | catch(...){
|
---|
| 74 | if( isShowExceptionMessage )
|
---|
| 75 | {
|
---|
| 76 | echo( "archive_exception以外の不明な例外" );
|
---|
| 77 | }
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | if( !isSuccessful )
|
---|
| 81 | {
|
---|
| 82 | return false;
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | return true;
|
---|
| 86 | }
|
---|
[523] | 87 | template<class T_xml_schema> bool BoostSerializationSupport<T_xml_schema>::WriteXml( std::ostream& ofs, bool isShowExceptionMessage ) const
|
---|
[215] | 88 | {
|
---|
| 89 | bool isSuccessful = false;
|
---|
| 90 |
|
---|
| 91 | try{
|
---|
| 92 | boost::archive::xml_oarchive oa(ofs);
|
---|
| 93 |
|
---|
| 94 | // ファイルに書き出し
|
---|
| 95 | oa << boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
|
---|
| 96 |
|
---|
| 97 | isSuccessful = true;
|
---|
| 98 | }
|
---|
| 99 | catch( boost::archive::archive_exception e )
|
---|
| 100 | {
|
---|
| 101 | if( isShowExceptionMessage )
|
---|
| 102 | {
|
---|
| 103 | echo( e.what() );
|
---|
| 104 | }
|
---|
| 105 | }
|
---|
| 106 | catch(...){
|
---|
| 107 | if( isShowExceptionMessage )
|
---|
| 108 | {
|
---|
| 109 | echo( "archive_exception以外の不明な例外" );
|
---|
| 110 | }
|
---|
| 111 | }
|
---|
| 112 |
|
---|
| 113 | if( !isSuccessful )
|
---|
| 114 | {
|
---|
| 115 | return false;
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | return true;
|
---|
| 119 | }
|
---|
[523] | 120 | template<class T_xml_schema> bool BoostSerializationSupport<T_xml_schema>::ReadXml( const std::string &xmlFilePath, bool isShowExceptionMessage )
|
---|
[215] | 121 | {
|
---|
| 122 | // 入力アーカイブの作成
|
---|
| 123 | std::ifstream ifs( xmlFilePath.c_str() );
|
---|
| 124 |
|
---|
| 125 | bool result = ReadXml(ifs,isShowExceptionMessage);
|
---|
| 126 |
|
---|
| 127 | // 入力を閉じる
|
---|
| 128 | ifs.close();
|
---|
| 129 |
|
---|
| 130 | return result;
|
---|
| 131 | }
|
---|
[523] | 132 | template<class T_xml_schema> bool BoostSerializationSupport<T_xml_schema>::WriteXml( const std::string &xmlFilePath, bool isShowExceptionMessage ) const
|
---|
[215] | 133 | {
|
---|
| 134 | // 出力アーカイブの作成
|
---|
| 135 | std::ofstream ofs( xmlFilePath.c_str() );
|
---|
| 136 |
|
---|
| 137 | bool result = WriteXml(ofs,isShowExceptionMessage);
|
---|
| 138 |
|
---|
| 139 | // 出力を閉じる
|
---|
| 140 | ofs.close();
|
---|
| 141 |
|
---|
| 142 | return result;
|
---|
| 143 | }
|
---|
[279] | 144 | template<class T_xml_schema> bool BoostSerializationSupport<T_xml_schema>::ReadXmlString( const std::string &xmlString )
|
---|
| 145 | {
|
---|
| 146 | bool isSuccessful = false;
|
---|
[215] | 147 |
|
---|
[279] | 148 | // 入力アーカイブの作成
|
---|
| 149 | std::istringstream iss( xmlString );
|
---|
| 150 |
|
---|
| 151 | try{
|
---|
| 152 | boost::archive::xml_iarchive ia(iss);
|
---|
| 153 |
|
---|
| 154 | // 文字列ストリームから読込
|
---|
| 155 | ia >> boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
|
---|
| 156 |
|
---|
| 157 | isSuccessful = true;
|
---|
| 158 | }
|
---|
| 159 | catch(...){
|
---|
| 160 | // 失敗
|
---|
| 161 | }
|
---|
| 162 |
|
---|
| 163 | if( !isSuccessful )
|
---|
| 164 | {
|
---|
| 165 | return false;
|
---|
| 166 | }
|
---|
| 167 |
|
---|
| 168 | return true;
|
---|
| 169 | }
|
---|
| 170 | template<class T_xml_schema> bool BoostSerializationSupport<T_xml_schema>::WriteXmlString( std::string &xmlString ) const
|
---|
| 171 | {
|
---|
| 172 | // 出力アーカイブの作成
|
---|
| 173 | std::ostringstream oss;
|
---|
| 174 |
|
---|
| 175 | bool isSuccessful = false;
|
---|
| 176 | try{
|
---|
| 177 | boost::archive::xml_oarchive oa(oss);
|
---|
| 178 |
|
---|
| 179 | // 文字列ストリームに書き出し
|
---|
| 180 | oa << boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
|
---|
| 181 |
|
---|
| 182 | isSuccessful = true;
|
---|
| 183 | }
|
---|
| 184 | catch( boost::archive::archive_exception e )
|
---|
| 185 | {
|
---|
| 186 | echo( e.what() );
|
---|
| 187 | }
|
---|
| 188 | catch(...){
|
---|
| 189 | echo( "archive_exception以外の不明な例外" );
|
---|
| 190 | }
|
---|
| 191 |
|
---|
| 192 | if( !isSuccessful )
|
---|
| 193 | {
|
---|
| 194 | return false;
|
---|
| 195 | }
|
---|
| 196 |
|
---|
| 197 | xmlString = oss.str();
|
---|
| 198 |
|
---|
| 199 | return true;
|
---|
| 200 | }
|
---|
| 201 |
|
---|
[523] | 202 | template<class T_xml_schema> bool BoostSerializationSupport<T_xml_schema>::ReadBinaryFile( const std::string &filePath, bool isShowExceptionMessage )
|
---|
[215] | 203 | {
|
---|
| 204 | // 入力アーカイブの作成
|
---|
[523] | 205 | std::ifstream ifs( filePath.c_str(), std::ios::in | std::ios::binary );
|
---|
[215] | 206 |
|
---|
| 207 | bool isSuccessful = false;
|
---|
| 208 | try{
|
---|
| 209 | boost::archive::binary_iarchive ia(ifs);
|
---|
| 210 |
|
---|
| 211 | // ファイルから読込
|
---|
| 212 | ia >> boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
|
---|
| 213 |
|
---|
| 214 | isSuccessful = true;
|
---|
| 215 | }
|
---|
| 216 | catch( boost::archive::archive_exception e )
|
---|
| 217 | {
|
---|
| 218 | if( isShowExceptionMessage )
|
---|
| 219 | {
|
---|
| 220 | echo( e.what() );
|
---|
| 221 | }
|
---|
| 222 | }
|
---|
| 223 | catch(...){
|
---|
| 224 | if( isShowExceptionMessage )
|
---|
| 225 | {
|
---|
| 226 | echo( "archive_exception以外の不明な例外" );
|
---|
| 227 | }
|
---|
| 228 | }
|
---|
| 229 |
|
---|
| 230 | // 入力を閉じる
|
---|
| 231 | ifs.close();
|
---|
| 232 |
|
---|
| 233 | if( !isSuccessful )
|
---|
| 234 | {
|
---|
| 235 | return false;
|
---|
| 236 | }
|
---|
| 237 |
|
---|
| 238 | return true;
|
---|
| 239 | }
|
---|
[523] | 240 | template<class T_xml_schema> bool BoostSerializationSupport<T_xml_schema>::WriteBinaryFile( const std::string &filePath, bool isShowExceptionMessage ) const
|
---|
[215] | 241 | {
|
---|
| 242 | // 出力アーカイブの作成
|
---|
[523] | 243 | std::ofstream ofs( filePath.c_str(), std::ios::out | std::ios::binary );
|
---|
[215] | 244 |
|
---|
| 245 | bool isSuccessful = false;
|
---|
| 246 | try{
|
---|
| 247 | boost::archive::binary_oarchive oa(ofs);
|
---|
| 248 |
|
---|
| 249 | // ファイルに書き出し
|
---|
| 250 | oa << boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
|
---|
| 251 |
|
---|
| 252 | isSuccessful = true;
|
---|
| 253 | }
|
---|
| 254 | catch( boost::archive::archive_exception e )
|
---|
| 255 | {
|
---|
| 256 | if( isShowExceptionMessage )
|
---|
| 257 | {
|
---|
| 258 | echo( e.what() );
|
---|
| 259 | }
|
---|
| 260 | }
|
---|
| 261 | catch(...){
|
---|
| 262 | if( isShowExceptionMessage )
|
---|
| 263 | {
|
---|
| 264 | echo( "archive_exception以外の不明な例外" );
|
---|
| 265 | }
|
---|
| 266 | }
|
---|
| 267 |
|
---|
| 268 | // 出力を閉じる
|
---|
| 269 | ofs.close();
|
---|
| 270 |
|
---|
| 271 | if( !isSuccessful )
|
---|
| 272 | {
|
---|
| 273 | return false;
|
---|
| 274 | }
|
---|
| 275 |
|
---|
| 276 | return true;
|
---|
| 277 | }
|
---|
| 278 |
|
---|
[322] | 279 | template<class T_xml_schema> bool BoostSerializationSupport<T_xml_schema>::ReadBinaryString( const std::string &binaryString )
|
---|
| 280 | {
|
---|
| 281 | bool isSuccessful = false;
|
---|
| 282 |
|
---|
| 283 | // 入力アーカイブの作成
|
---|
[523] | 284 | std::istringstream iss( binaryString, std::ios::in | std::ios::binary );
|
---|
[322] | 285 |
|
---|
| 286 | try{
|
---|
| 287 | boost::archive::binary_iarchive ia(iss);
|
---|
| 288 |
|
---|
| 289 | // 文字列ストリームから読込
|
---|
| 290 | ia >> boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
|
---|
| 291 |
|
---|
| 292 | isSuccessful = true;
|
---|
| 293 | }
|
---|
| 294 | catch( boost::archive::archive_exception e )
|
---|
| 295 | {
|
---|
| 296 | echo( e.what() );
|
---|
| 297 | }
|
---|
| 298 | catch(...){
|
---|
| 299 | echo( "archive_exception以外の不明な例外" );
|
---|
| 300 | }
|
---|
| 301 |
|
---|
| 302 | return isSuccessful;
|
---|
| 303 | }
|
---|
| 304 | template<class T_xml_schema> bool BoostSerializationSupport<T_xml_schema>::WriteBinaryString( std::string &binaryString ) const
|
---|
| 305 | {
|
---|
| 306 | // 出力アーカイブの作成
|
---|
[523] | 307 | std::ostringstream oss( "", std::ios::out | std::ios::binary );
|
---|
[322] | 308 |
|
---|
| 309 | bool isSuccessful = false;
|
---|
| 310 | try{
|
---|
| 311 | boost::archive::binary_oarchive oa(oss);
|
---|
| 312 |
|
---|
| 313 | // 文字列ストリームに書き出し
|
---|
| 314 | oa << boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
|
---|
| 315 |
|
---|
| 316 | isSuccessful = true;
|
---|
| 317 | }
|
---|
| 318 | catch( boost::archive::archive_exception e )
|
---|
| 319 | {
|
---|
| 320 | echo( e.what() );
|
---|
| 321 | }
|
---|
| 322 | catch(...){
|
---|
| 323 | echo( "archive_exception以外の不明な例外" );
|
---|
| 324 | }
|
---|
| 325 |
|
---|
| 326 | binaryString = oss.str();
|
---|
| 327 |
|
---|
| 328 | return isSuccessful;
|
---|
| 329 | }
|
---|
| 330 |
|
---|
[404] | 331 | /*
|
---|
| 332 | ビルドに時間がかかるので外しておく
|
---|
[523] | 333 | template<class T_xml_schema> bool BoostSerializationSupport<T_xml_schema>::ReadText( const std::string &filePath, bool isShowExceptionMessage )
|
---|
[215] | 334 | {
|
---|
| 335 | // 入力アーカイブの作成
|
---|
| 336 | std::ifstream ifs( filePath.c_str() );
|
---|
| 337 |
|
---|
| 338 | bool isSuccessful = false;
|
---|
| 339 | try{
|
---|
| 340 | boost::archive::text_iarchive ia(ifs);
|
---|
| 341 |
|
---|
| 342 | // ファイルから読込
|
---|
| 343 | ia >> boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
|
---|
| 344 |
|
---|
| 345 | isSuccessful = true;
|
---|
| 346 | }
|
---|
| 347 | catch( boost::archive::archive_exception e )
|
---|
| 348 | {
|
---|
| 349 | if( isShowExceptionMessage )
|
---|
| 350 | {
|
---|
| 351 | echo( e.what() );
|
---|
| 352 | }
|
---|
| 353 | }
|
---|
| 354 | catch(...){
|
---|
| 355 | if( isShowExceptionMessage )
|
---|
| 356 | {
|
---|
| 357 | echo( "archive_exception以外の不明な例外" );
|
---|
| 358 | }
|
---|
| 359 | }
|
---|
| 360 |
|
---|
| 361 | // 入力を閉じる
|
---|
| 362 | ifs.close();
|
---|
| 363 |
|
---|
| 364 | if( !isSuccessful )
|
---|
| 365 | {
|
---|
| 366 | return false;
|
---|
| 367 | }
|
---|
| 368 |
|
---|
| 369 | return true;
|
---|
| 370 | }
|
---|
[523] | 371 | template<class T_xml_schema> bool BoostSerializationSupport<T_xml_schema>::WriteText( const std::string &filePath, bool isShowExceptionMessage ) const
|
---|
[215] | 372 | {
|
---|
| 373 | // 出力アーカイブの作成
|
---|
| 374 | std::ofstream ofs( filePath.c_str() );
|
---|
| 375 |
|
---|
| 376 | bool isSuccessful = false;
|
---|
| 377 | try{
|
---|
| 378 | boost::archive::text_oarchive oa(ofs);
|
---|
| 379 |
|
---|
| 380 | // ファイルに書き出し
|
---|
| 381 | oa << boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
|
---|
| 382 |
|
---|
| 383 | isSuccessful = true;
|
---|
| 384 | }
|
---|
| 385 | catch( boost::archive::archive_exception e )
|
---|
| 386 | {
|
---|
| 387 | if( isShowExceptionMessage )
|
---|
| 388 | {
|
---|
| 389 | echo( e.what() );
|
---|
| 390 | }
|
---|
| 391 | }
|
---|
| 392 | catch(...){
|
---|
| 393 | if( isShowExceptionMessage )
|
---|
| 394 | {
|
---|
| 395 | echo( "archive_exception以外の不明な例外" );
|
---|
| 396 | }
|
---|
| 397 | }
|
---|
| 398 |
|
---|
| 399 | // 出力を閉じる
|
---|
| 400 | ofs.close();
|
---|
| 401 |
|
---|
| 402 | if( !isSuccessful )
|
---|
| 403 | {
|
---|
| 404 | return false;
|
---|
| 405 | }
|
---|
| 406 |
|
---|
| 407 | return true;
|
---|
| 408 | }
|
---|
| 409 |
|
---|
[264] | 410 | template<class T_xml_schema> bool BoostSerializationSupport<T_xml_schema>::ReadTextString( const std::string &textString )
|
---|
[215] | 411 | {
|
---|
| 412 | bool isSuccessful = false;
|
---|
| 413 |
|
---|
| 414 | // 入力アーカイブの作成
|
---|
[264] | 415 | std::istringstream iss( textString );
|
---|
[215] | 416 |
|
---|
| 417 | try{
|
---|
[264] | 418 | boost::archive::text_iarchive ia(iss);
|
---|
| 419 |
|
---|
| 420 | // 文字列ストリームから読込
|
---|
| 421 | ia >> boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
|
---|
| 422 |
|
---|
| 423 | isSuccessful = true;
|
---|
| 424 | }
|
---|
| 425 | catch(...){
|
---|
| 426 | // 失敗
|
---|
| 427 | }
|
---|
| 428 |
|
---|
| 429 | if( !isSuccessful )
|
---|
| 430 | {
|
---|
| 431 | return false;
|
---|
| 432 | }
|
---|
| 433 |
|
---|
| 434 | return true;
|
---|
| 435 | }
|
---|
| 436 | template<class T_xml_schema> bool BoostSerializationSupport<T_xml_schema>::WriteTextString( std::string &textString ) const
|
---|
| 437 | {
|
---|
| 438 | // 出力アーカイブの作成
|
---|
| 439 | std::ostringstream oss;
|
---|
| 440 |
|
---|
| 441 | bool isSuccessful = false;
|
---|
| 442 | try{
|
---|
| 443 | boost::archive::text_oarchive oa(oss);
|
---|
| 444 |
|
---|
| 445 | // 文字列ストリームに書き出し
|
---|
| 446 | oa << boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
|
---|
| 447 |
|
---|
| 448 | isSuccessful = true;
|
---|
| 449 | }
|
---|
| 450 | catch( boost::archive::archive_exception e )
|
---|
| 451 | {
|
---|
| 452 | echo( e.what() );
|
---|
| 453 | }
|
---|
| 454 | catch(...){
|
---|
| 455 | echo( "archive_exception以外の不明な例外" );
|
---|
| 456 | }
|
---|
| 457 |
|
---|
| 458 | if( !isSuccessful )
|
---|
| 459 | {
|
---|
| 460 | return false;
|
---|
| 461 | }
|
---|
| 462 |
|
---|
| 463 | textString = oss.str();
|
---|
| 464 |
|
---|
| 465 | return true;
|
---|
| 466 | }
|
---|
| 467 |
|
---|
| 468 | template<class T_xml_schema> bool BoostSerializationSupport<T_xml_schema>::ReadXmlFromString( const std::string &textString )
|
---|
| 469 | {
|
---|
| 470 | bool isSuccessful = false;
|
---|
| 471 |
|
---|
| 472 | // 入力アーカイブの作成
|
---|
| 473 | std::istringstream iss( textString );
|
---|
| 474 |
|
---|
| 475 | try{
|
---|
[215] | 476 | boost::archive::xml_iarchive ia(iss);
|
---|
| 477 |
|
---|
| 478 | // 文字列ストリームから読込
|
---|
| 479 | ia >> boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this );
|
---|
| 480 |
|
---|
| 481 | isSuccessful = true;
|
---|
| 482 | }
|
---|
| 483 | catch(...){
|
---|
| 484 | // 失敗
|
---|
| 485 | }
|
---|
| 486 |
|
---|
| 487 | if( !isSuccessful )
|
---|
| 488 | {
|
---|
| 489 | return false;
|
---|
| 490 | }
|
---|
| 491 |
|
---|
| 492 | return true;
|
---|
| 493 | }
|
---|
[404] | 494 | */
|
---|
[215] | 495 |
|
---|
| 496 |
|
---|
[256] | 497 | #include <logger.h>
|
---|
[477] | 498 | #include <Configuration.h>
|
---|
[636] | 499 | #include <abdev/ab_common/include/Lexical/Source.h>
|
---|
[256] | 500 |
|
---|
[215] | 501 | template class Jenga::Common::BoostSerializationSupport<LoggerSetting>;
|
---|
[477] | 502 | template class Jenga::Common::BoostSerializationSupport<Configuration>;
|
---|
[636] | 503 | template class Jenga::Common::BoostSerializationSupport<BasicSources>;
|
---|