Changeset 279 in dev for trunk/abdev/BasicCompiler_Common/src
- Timestamp:
- Aug 14, 2007, 3:22:02 AM (17 years ago)
- Location:
- trunk/abdev/BasicCompiler_Common/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler_Common/src/BoostSerializationSupport.cpp
r264 r279 115 115 return result; 116 116 } 117 template<class T_xml_schema> bool BoostSerializationSupport<T_xml_schema>::ReadXmlString( const std::string &xmlString ) 118 { 119 bool isSuccessful = false; 120 121 // 入力アーカイブの作成 122 std::istringstream iss( xmlString ); 123 124 try{ 125 boost::archive::xml_iarchive ia(iss); 126 127 // 文字列ストリームから読込 128 ia >> boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this ); 129 130 isSuccessful = true; 131 } 132 catch(...){ 133 // 失敗 134 } 135 136 if( !isSuccessful ) 137 { 138 return false; 139 } 140 141 return true; 142 } 143 template<class T_xml_schema> bool BoostSerializationSupport<T_xml_schema>::WriteXmlString( std::string &xmlString ) const 144 { 145 // 出力アーカイブの作成 146 std::ostringstream oss; 147 148 bool isSuccessful = false; 149 try{ 150 boost::archive::xml_oarchive oa(oss); 151 152 // 文字列ストリームに書き出し 153 oa << boost::serialization::make_nvp( RootTagName(), *(T_xml_schema *)this ); 154 155 isSuccessful = true; 156 } 157 catch( boost::archive::archive_exception e ) 158 { 159 echo( e.what() ); 160 } 161 catch(...){ 162 echo( "archive_exception以外の不明な例外" ); 163 } 164 165 if( !isSuccessful ) 166 { 167 return false; 168 } 169 170 xmlString = oss.str(); 171 172 return true; 173 } 117 174 118 175 template<class T_xml_schema> bool BoostSerializationSupport<T_xml_schema>::ReadBinary( const string &filePath, bool isShowExceptionMessage ) -
trunk/abdev/BasicCompiler_Common/src/ObjectModule.cpp
r276 r279 2 2 3 3 #include <Compiler.h> 4 5 enum ObjectModuleDataType 6 { 7 ObjectModuleDataTypeXml, 8 ObjectModuleDataTypeText, 9 ObjectModuleDataTypeBinaly, 10 }; 11 const ObjectModuleDataType objectModuleDataType = ObjectModuleDataTypeText; 12 4 13 5 14 void ObjectModule::StaticLink( ObjectModule &objectModule ) … … 15 24 dataTable.Add( objectModule.dataTable ); 16 25 } 26 27 bool ObjectModule::Read( const std::string &filePath ) 28 { 29 switch( objectModuleDataType ) 30 { 31 case ObjectModuleDataTypeXml: 32 return ReadXml( filePath ); 33 case ObjectModuleDataTypeText: 34 return ReadText( filePath ); 35 case ObjectModuleDataTypeBinaly: 36 return ReadBinary( filePath ); 37 default: 38 Jenga::Throw( "" ); 39 break; 40 } 41 return false; 42 } 43 bool ObjectModule::Write( const std::string &filePath ) const 44 { 45 switch( objectModuleDataType ) 46 { 47 case ObjectModuleDataTypeXml: 48 return WriteXml( filePath ); 49 case ObjectModuleDataTypeText: 50 return WriteText( filePath ); 51 case ObjectModuleDataTypeBinaly: 52 return WriteBinary( filePath ); 53 default: 54 Jenga::Throw( "" ); 55 break; 56 } 57 return false; 58 } 59 bool ObjectModule::ReadString( const std::string &str ) 60 { 61 switch( objectModuleDataType ) 62 { 63 case ObjectModuleDataTypeXml: 64 return ReadXmlString( str ); 65 case ObjectModuleDataTypeText: 66 return ReadTextString( str ); 67 case ObjectModuleDataTypeBinaly: 68 Jenga::Throw( "" ); 69 break; 70 default: 71 Jenga::Throw( "" ); 72 break; 73 } 74 return false; 75 } 76 bool ObjectModule::WriteString( std::string &str ) const 77 { 78 switch( objectModuleDataType ) 79 { 80 case ObjectModuleDataTypeXml: 81 return WriteXmlString( str ); 82 case ObjectModuleDataTypeText: 83 return WriteTextString( str ); 84 case ObjectModuleDataTypeBinaly: 85 Jenga::Throw( "" ); 86 break; 87 default: 88 Jenga::Throw( "" ); 89 break; 90 } 91 return false; 92 } -
trunk/abdev/BasicCompiler_Common/src/Source.cpp
r270 r279 13 13 #include <Compiler.h> 14 14 15 16 INCLUDEFILEINFO IncludeFileInfo;17 15 18 16 const string BasicSource::generateDirectiveName = "#generate"; … … 537 535 char temporary[MAX_PATH],temp2[MAX_PATH+255],*LayerDir[255]; 538 536 539 IncludeFileInfo.ppFileNames=(char **)calloc(sizeof(char *),1);540 extern char SourceFileName[MAX_PATH];541 IncludeFileInfo.ppFileNames[0]=(char *)malloc(lstrlen(SourceFileName)+1);542 lstrcpy(IncludeFileInfo.ppFileNames[0],SourceFileName);543 IncludeFileInfo.FilesNum=1;544 545 537 layer=0; 546 538 FileLayer[layer]=0; … … 548 540 LineNum=0; 549 541 542 if( includedFilesRelation.GetLineCounts() != 0 ) 543 { 544 Jenga::Throw( "インクルードファイル構造の初期値が不正" ); 545 } 546 547 // メインソースコード 548 extern char SourceFileName[MAX_PATH]; 549 FileLayer[layer] = includedFilesRelation.AddFile( SourceFileName ); 550 550 551 //参照ディレクトリ 551 552 LayerDir[0]=(char *)malloc(lstrlen(BasicCurDir)+1); … … 554 555 for(i=0;;i++){ 555 556 if(buffer[i]=='\0'){ 556 IncludeFileInfo.LineOfFile[LineNum]=-1;557 557 break; 558 558 } 559 559 if(buffer[i]=='\n'){ 560 IncludeFileInfo.LineOfFile[LineNum]=FileLayer[layer]; 561 LineNum++; 560 includedFilesRelation.AddLine( FileLayer[layer] ); 562 561 } 563 562 if(i>LastFileByte[layer]){ … … 624 623 } 625 624 626 IncludeFileInfo.ppFileNames=(char **)realloc(IncludeFileInfo.ppFileNames,(IncludeFileInfo.FilesNum+1)*sizeof(char *));627 IncludeFileInfo.ppFileNames[IncludeFileInfo.FilesNum]=(char *)malloc(lstrlen(temporary)+1);628 lstrcpy(IncludeFileInfo.ppFileNames[IncludeFileInfo.FilesNum],temporary);629 630 625 layer++; 631 FileLayer[layer]=IncludeFileInfo.FilesNum; 632 IncludeFileInfo.FilesNum++; 626 FileLayer[layer] = includedFilesRelation.AddFile( temporary ); 633 627 634 628 //#requireの場合では、既に読み込まれているファイルは読み込まないようにする … … 926 920 lstrcat( this->buffer, buffer ); 927 921 } 922 923 bool BasicSource::GetLineInfo( int sourceCodePos, int &line, std::string &filePath ) 924 { 925 int i2,i3,i4,i5; 926 927 char *buffer = GetBuffer(); 928 int i = sourceCodePos; 929 930 if(buffer[i]=='\n') i--; 931 for(i3=0,i2=0;i3<i;i3++){ 932 if(buffer[i3]=='\n') i2++; 933 if(buffer[i3]=='\0') return 0; 934 } 935 936 if( includedFilesRelation.GetLineCounts() < i2 ) 937 { 938 Jenga::Throw( "BasicSource::GetLineInfoメソッドで不正な行の情報を取得しようとした" ); 939 940 //ファイル・行番号を特定できなかった場合 941 line = -1; 942 filePath = ""; 943 return false; 944 } 945 946 i4=0; 947 while( includedFilesRelation.GetFileNumber( i2 ) != includedFilesRelation.GetFileNumber( i4 ) ) 948 { 949 i4++; 950 } 951 for(i3=0,i5=0;i5<i4;i3++){ 952 if(buffer[i3]=='\n') i5++; 953 if(buffer[i3]=='\0') return 0; 954 } 955 for(i5=0;i4<i2;i3++){ 956 if(buffer[i3]=='\n'){ 957 i4++; 958 i5++; 959 if( includedFilesRelation.GetFileNumber( i2 ) < includedFilesRelation.GetFileNumber( i4 ) ) 960 { 961 for( ;includedFilesRelation.GetFileNumber( i2 ) != includedFilesRelation.GetFileNumber( i4 ); i3++ ){ 962 if(buffer[i3]=='\n') i4++; 963 } 964 } 965 } 966 if(buffer[i3]=='\0') return 0; 967 } 968 969 //行番号をセット 970 line = i5; 971 972 //ファイル名をセット 973 filePath = includedFilesRelation.GetFilePath( i2 ); 974 975 return 1; 976 }
Note:
See TracChangeset
for help on using the changeset viewer.