論理回路シミュレータ
リビジョン | ee19ff67f9ae7d423a674d92ae9d3ae29f40c0df (tree) |
---|---|
日時 | 2017-07-13 08:16:26 |
作者 | OkaMitio <oka_mitio@yaho...> |
コミッター | OkaMitio |
Ver0.84のファイルフォーマット
@@ -5,6 +5,9 @@ | ||
5 | 5 | |
6 | 6 | extern HWND hMainWindow; |
7 | 7 | |
8 | +extern int filever; | |
9 | +extern void GetFileVer(std::ifstream &f); | |
10 | + | |
8 | 11 | namespace Edit |
9 | 12 | { |
10 | 13 | extern vector2D coordinates1; |
@@ -257,7 +260,7 @@ void Data::CopyRange(bool Erase,bool Copy) | ||
257 | 260 | _splitpath_s(ExePath,drive,MAX_PATH+1,dir,MAX_PATH+1,NULL,0,NULL,0); |
258 | 261 | _makepath_s(FileEdit,MAX_PATH+1,drive,dir,"FileUsedByEditingOfAst","log"); |
259 | 262 | std::ofstream f(FileEdit); |
260 | - f << "Ast0.8" << std::endl <<std::endl; | |
263 | + f << "Ast0.84" << std::endl <<std::endl; | |
261 | 264 | f << copy_data; |
262 | 265 | f.close(); |
263 | 266 | } |
@@ -275,20 +278,21 @@ void LoadCopiedData() | ||
275 | 278 | |
276 | 279 | if(f) |
277 | 280 | { |
278 | - char s[SIZE_OF_LABEL_NAME]; | |
279 | - f.getline(s,SIZE_OF_LABEL_NAME); | |
280 | - if(strcmp(s,"Ast0.8")==0) | |
281 | + GetFileVer(f); | |
282 | + if (filever == -1) | |
283 | + { | |
284 | + MessageBox(hMainWindow, "バージョンの異なるファイルです", "エラー", MB_OK); | |
285 | + } | |
286 | + else | |
281 | 287 | { |
282 | 288 | copy_data.Clear(); |
283 | 289 | f >> copy_data; |
284 | - if(!f.good()) | |
290 | + if (!f.good()) | |
285 | 291 | { |
286 | 292 | copy_data.Clear(); |
287 | - MessageBox(hMainWindow,"ファイルが壊れています","エラー",MB_OK); | |
293 | + MessageBox(hMainWindow, "ファイルが壊れています", "エラー", MB_OK); | |
288 | 294 | } |
289 | 295 | } |
290 | - else | |
291 | - MessageBox(hMainWindow,"バージョンの異なるファイルです","エラー",MB_OK); | |
292 | 296 | f.close(); |
293 | 297 | } |
294 | 298 | } |
@@ -3,6 +3,8 @@ | ||
3 | 3 | #include<iostream> |
4 | 4 | #include<fstream> |
5 | 5 | |
6 | +int filever; //バージョン 0:0.8 1:0.84 | |
7 | +const char *verstr[] = { "Ast0.8","Ast0.84" }; | |
6 | 8 | |
7 | 9 | |
8 | 10 | extern HWND hMainWindow; |
@@ -22,6 +24,14 @@ namespace FileIO | ||
22 | 24 | } |
23 | 25 | |
24 | 26 | |
27 | +void GetFileVer(std::ifstream &f) | |
28 | +{ | |
29 | + char s[SIZE_OF_LABEL_NAME]; | |
30 | + f.getline(s, SIZE_OF_LABEL_NAME); | |
31 | + filever = -1; | |
32 | + for (int i = 0; i < 2; i++)if (strcmp(s, verstr[i])==0)filever = i; | |
33 | +} | |
34 | + | |
25 | 35 | std::istream &operator>>(std::istream &stream,vector2D &v) |
26 | 36 | { |
27 | 37 | stream >> v.x >> v.y; |
@@ -278,7 +288,10 @@ std::istream &operator>>(std::istream &stream,Module &m) | ||
278 | 288 | { |
279 | 289 | unsigned int size; |
280 | 290 | |
281 | - m.d = RIGHT; | |
291 | + if (filever >= 1) | |
292 | + stream >> (int&)m.d; | |
293 | + else | |
294 | + m.d = RIGHT; | |
282 | 295 | |
283 | 296 | stream >> m.center; |
284 | 297 | stream >> m.internal_half_width; |
@@ -349,6 +362,7 @@ std::istream &operator>>(std::istream &stream,Module &m) | ||
349 | 362 | |
350 | 363 | std::ostream &operator<<(std::ostream &stream,Module m) |
351 | 364 | { |
365 | + stream << m.d << " "; | |
352 | 366 | stream << m.center << " "; |
353 | 367 | stream << m.internal_half_width << " "; |
354 | 368 | stream << m.internal_half_height << " "; |
@@ -536,7 +550,7 @@ bool SaveAs(Data d,char *szF,char *szFT) | ||
536 | 550 | if(GetSaveFileName(&ofn) == 0) return false; |
537 | 551 | |
538 | 552 | std::ofstream f(szF); |
539 | - f << "Ast0.8" << std::endl << std::endl; | |
553 | + f << "Ast0.84" << std::endl << std::endl; | |
540 | 554 | f << d; |
541 | 555 | f.close(); |
542 | 556 | return true; |
@@ -550,7 +564,7 @@ bool Save() | ||
550 | 564 | std::ofstream f(FileIO::szFile); |
551 | 565 | if(f) |
552 | 566 | { |
553 | - f << "Ast0.8" << std::endl << std::endl; | |
567 | + f << "Ast0.84" << std::endl << std::endl; | |
554 | 568 | f << main_data; |
555 | 569 | f.close(); |
556 | 570 | } |
@@ -563,29 +577,30 @@ bool LoadData() | ||
563 | 577 | std::ifstream f(FileIO::szFile); |
564 | 578 | if(f) |
565 | 579 | { |
566 | - char s[SIZE_OF_LABEL_NAME]; | |
567 | - f.getline(s,SIZE_OF_LABEL_NAME); | |
568 | - if(strcmp(s,"Ast0.8")==0) | |
580 | + GetFileVer(f); | |
581 | + if(filever==-1) | |
582 | + { | |
583 | + main_data.Clear(); | |
584 | + FileIO::szFile[0] = 0; | |
585 | + FileIO::szFileTitle[0] = 0; | |
586 | + MessageBox(hMainWindow, "扱えないファイルフォーマットのファイルです", "エラー", MB_OK); | |
587 | + f.close(); | |
588 | + return false; | |
589 | + } | |
590 | + else | |
569 | 591 | { |
570 | 592 | main_data.Clear(); |
571 | 593 | f >> main_data; |
572 | - if(!f.good()) | |
594 | + if (!f.good()) | |
573 | 595 | { |
574 | 596 | main_data.Clear(); |
575 | - FileIO::szFile[0]=0; | |
576 | - FileIO::szFileTitle[0]=0; | |
577 | - MessageBox(hMainWindow,"ファイルが壊れています","エラー",MB_OK); | |
597 | + FileIO::szFile[0] = 0; | |
598 | + FileIO::szFileTitle[0] = 0; | |
599 | + MessageBox(hMainWindow, "ファイルが壊れています", "エラー", MB_OK); | |
600 | + f.close(); | |
578 | 601 | return false; |
579 | 602 | } |
580 | 603 | } |
581 | - else | |
582 | - { | |
583 | - main_data.Clear(); | |
584 | - FileIO::szFile[0]=0; | |
585 | - FileIO::szFileTitle[0]=0; | |
586 | - MessageBox(hMainWindow,"ファイルフォーマットの異なるファイルです","エラー",MB_OK); | |
587 | - return false; | |
588 | - } | |
589 | 604 | f.close(); |
590 | 605 | } |
591 | 606 | return true; |
@@ -692,25 +707,26 @@ bool LoadModule() | ||
692 | 707 | |
693 | 708 | std::ifstream f(szFile_Modul); |
694 | 709 | if(!f)return false; |
695 | - | |
696 | - char s[SIZE_OF_LABEL_NAME]; | |
697 | - f.getline(s,SIZE_OF_LABEL_NAME); | |
698 | - if(strcmp(s,"Ast0.8")==0) | |
710 | + | |
711 | + GetFileVer(f); | |
712 | + if (filever == -1) | |
713 | + { | |
714 | + MessageBox(hMainWindow, "扱えないファイルフォーマットのファイルです", "エラー", MB_OK); | |
715 | + f.close(); | |
716 | + return false; | |
717 | + } | |
718 | + else | |
699 | 719 | { |
700 | 720 | Place::NewModule.Clear(); |
701 | 721 | f >> (Data&)Place::NewModule; |
702 | - if(!f.good()) | |
722 | + if (!f.good()) | |
703 | 723 | { |
704 | 724 | Place::NewModule.Clear(); |
705 | - MessageBox(hMainWindow,"ファイルが壊れています","エラー",MB_OK); | |
725 | + MessageBox(hMainWindow, "ファイルが壊れています", "エラー", MB_OK); | |
726 | + f.close(); | |
706 | 727 | return false; |
707 | 728 | } |
708 | 729 | } |
709 | - else | |
710 | - { | |
711 | - MessageBox(hMainWindow,"バージョンの異なるファイルです","エラー",MB_OK); | |
712 | - return false; | |
713 | - } | |
714 | 730 | f.close(); |
715 | 731 | |
716 | 732 | if(Place::NewModule.nInput()==0 || Place::NewModule.nOutput()==0) |