Changeset 828 in dev for trunk/ab5.0/abdev/ab_common/include/Lexical/Source.h
- Timestamp:
- Mar 19, 2012, 1:59:48 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to
/branches/egtra merged eligible
-
Property svn:mergeinfo
set to
-
trunk/ab5.0/abdev
-
Property svn:ignore
set to
*.opensdf
*.sdf
*.suo
*.user
int
ipch
out
-
Property svn:ignore
set to
-
trunk/ab5.0/abdev/ab_common/include/Lexical/Source.h
r739 r828 21 21 { 22 22 } 23 IncludedFilesRelation(IncludedFilesRelation const& y) 24 : filePaths(y.filePaths) 25 , lineFileNumbers(y.lineFileNumbers) 26 { 27 } 28 IncludedFilesRelation(IncludedFilesRelation&& y) 29 : filePaths(std::move(y.filePaths)) 30 , lineFileNumbers(std::move(y.lineFileNumbers)) 31 { 32 } 23 33 ~IncludedFilesRelation() 24 34 { 35 } 36 IncludedFilesRelation& operator =(IncludedFilesRelation&& y) 37 { 38 filePaths = std::move(y.filePaths); 39 lineFileNumbers = std::move(y.lineFileNumbers); 40 return *this; 41 } 42 43 IncludedFilesRelation& operator =(IncludedFilesRelation const& y) 44 { 45 return *this = std::move(IncludedFilesRelation(y)); 25 46 } 26 47 … … 76 97 buffer[length] = 0; 77 98 } 99 Text(Text&& text) 100 : length( text.length ) 101 { 102 buffer = text.buffer; 103 text.buffer = static_cast<char*>(calloc(1, 1)); 104 text.length = 0; 105 } 106 Text& operator =(Text&& y) 107 { 108 SwapImpl(*this, y); 109 return *this; 110 } 111 Text& operator =(Text const& y) 112 { 113 return *this = std::move(Text(y)); 114 } 78 115 ~Text(){ 79 116 free( buffer ); … … 100 137 static void SlideString(char *buffer, int slide){ 101 138 memmove(buffer+slide, buffer, strlen(buffer)+1); 139 } 140 141 protected: 142 static void SwapImpl(Text& lhs, Text& rhs) 143 { 144 std::swap(lhs.buffer, rhs.buffer); 145 std::swap(lhs.length, rhs.length); 102 146 } 103 147 }; … … 192 236 { 193 237 } 238 BasicSource(BasicSource&& basicSource) 239 : Text(std::move(basicSource)) 240 , includedFilesRelation(std::move(basicSource.includedFilesRelation)) 241 { 242 } 194 243 BasicSource( const std::string &source ) 195 244 { … … 230 279 bool GetLineInfo( int sourceCodePos, int &line, std::string &fileName ) const; 231 280 232 void operator = ( const BasicSource &source ){ 281 BasicSource& operator =(const BasicSource &source) 282 { 233 283 Realloc( source.length ); 234 284 strcpy( buffer, source.buffer ); 285 return *this; 286 } 287 BasicSource& operator =(BasicSource&& source) 288 { 289 Text::SwapImpl(*this, source); 290 return *this; 235 291 } 236 292 … … 262 318 ar & boost::serialization::make_nvp("vector_BasicSource", boost::serialization::base_object<std::vector<BasicSource>>(*this)); 263 319 } 320 321 public: 322 BasicSources() {} 323 BasicSources(BasicSources&& y) : std::vector<BasicSource>(std::move(y)) {} 324 BasicSources(BasicSources const& y) : std::vector<BasicSource>(y) {} 325 BasicSources operator =(BasicSources&& y) 326 { 327 std::vector<BasicSource>::operator =(std::move(y)); 328 return *this; 329 } 330 BasicSources operator =(BasicSources const& y) 331 { 332 return *this = std::move(BasicSources(y)); 333 } 264 334 }; 265 335 … … 289 359 { 290 360 } 361 SourceCodePosition(SourceCodePosition const& y) 362 : relationalObjectModuleIndex(y.relationalObjectModuleIndex) 363 , pos(y.pos) 364 { 365 } 366 367 SourceCodePosition& operator =(SourceCodePosition const& y) 368 { 369 relationalObjectModuleIndex = y.relationalObjectModuleIndex; 370 pos = y.pos; 371 return *this; 372 } 291 373 292 374 int GetRelationalObjectModuleIndex() const;
Note:
See TracChangeset
for help on using the changeset viewer.