Changeset 279 in dev for trunk/abdev/BasicCompiler_Common/include/Source.h
- Timestamp:
- Aug 14, 2007, 3:22:02 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler_Common/include/Source.h
r268 r279 18 18 int FilesNum; 19 19 int LineOfFile[MAX_LEN]; 20 }; 21 22 class IncludedFilesRelation 23 { 24 std::vector<std::string> filePaths; 25 std::vector<int> lineFileNumbers; 26 27 // XMLシリアライズ用 28 private: 29 friend class boost::serialization::access; 30 template<class Archive> void serialize(Archive& ar, const unsigned int version) 31 { 32 trace_for_serialize( "serializing - IncludedFilesRelation" ); 33 34 ar & BOOST_SERIALIZATION_NVP( filePaths ); 35 ar & BOOST_SERIALIZATION_NVP( lineFileNumbers ); 36 } 37 38 public: 39 IncludedFilesRelation() 40 { 41 } 42 ~IncludedFilesRelation() 43 { 44 } 45 46 const int GetFileNumber( int lineNumber ) const 47 { 48 return lineFileNumbers[lineNumber]; 49 } 50 const std::string &GetFilePath( int lineNumber ) const 51 { 52 return filePaths[GetFileNumber( lineNumber )]; 53 } 54 const std::string &GetFilePathFromFileNumber( int fileNumber ) const 55 { 56 return filePaths[fileNumber]; 57 } 58 int GetFileCounts() const 59 { 60 return filePaths.size(); 61 } 62 63 int AddFile( const std::string &filePath ) 64 { 65 filePaths.push_back( filePath ); 66 return filePaths.size()-1; 67 } 68 void AddLine( int fileNumber ) 69 { 70 lineFileNumbers.push_back( fileNumber ); 71 } 72 73 int GetLineCounts() const 74 { 75 return lineFileNumbers.size(); 76 } 20 77 }; 21 78 … … 66 123 static const string generateDirectiveName; 67 124 125 IncludedFilesRelation includedFilesRelation; 126 127 // XMLシリアライズ用 128 private: 129 friend class boost::serialization::access; 130 BOOST_SERIALIZATION_SPLIT_MEMBER(); 131 template<class Archive> void load(Archive& ar, const unsigned int version) 132 { 133 trace_for_serialize( "serializing(load) - BasicSource" ); 134 135 std::string _buffer; 136 ar & BOOST_SERIALIZATION_NVP( _buffer ); 137 ar & BOOST_SERIALIZATION_NVP( length ); 138 ar & BOOST_SERIALIZATION_NVP( includedFilesRelation ); 139 140 // 読み込み後の処理 141 Realloc( length ); 142 for( int i=0; i<length; i++ ) 143 { 144 ULONG_PTR l1 = ( ( _buffer[i*3] >= 'a' ) ? ( _buffer[i*3] - 'a' + 0x0a ) : ( _buffer[i*3] - '0' ) ) * 0x10; 145 ULONG_PTR l2 = ( _buffer[i*3+1] >= 'a' ) ? ( _buffer[i*3+1] - 'a' + 0x0a ) : ( _buffer[i*3+1] - '0' ); 146 ULONG_PTR l = l1 + l2; 147 buffer[i] = static_cast<char>(l); 148 } 149 buffer[length] = 0; 150 } 151 template<class Archive> void save(Archive& ar, const unsigned int version) const 152 { 153 trace_for_serialize( "serializing(save) - BasicSource" ); 154 155 // 保存準備 156 char *tempCode = (char *)calloc( (length+1) * 3, 1 ); 157 for( int i=0; i<length; i++ ) 158 { 159 char temp[32]; 160 sprintf( temp, "%02x,", (unsigned char)buffer[i] ); 161 tempCode[i*3] = temp[0]; 162 tempCode[i*3+1] = temp[1]; 163 tempCode[i*3+2] = temp[2]; 164 } 165 166 std::string _buffer = tempCode; 167 free( tempCode ); 168 169 ar & BOOST_SERIALIZATION_NVP( _buffer ); 170 ar & BOOST_SERIALIZATION_NVP( length ); 171 ar & BOOST_SERIALIZATION_NVP( includedFilesRelation ); 172 } 173 174 private: 68 175 void Realloc( int newLength ){ 69 176 buffer = (char *)realloc( buffer, newLength + 255 ); … … 102 209 } 103 210 211 const IncludedFilesRelation &GetIncludedFilesRelation() const 212 { 213 return includedFilesRelation; 214 } 215 104 216 void SetBuffer( const char *buffer ); 105 217 … … 109 221 110 222 void Addition( const char *buffer ); 223 224 bool GetLineInfo( int sourceCodePos, int &line, std::string &fileName ); 111 225 112 226 void operator = ( const BasicSource &source ){
Note:
See TracChangeset
for help on using the changeset viewer.