Changeset 810 in dev for branches/egtra/ab5.0/abdev/ab_common/include/Lexical/Source.h
- Timestamp:
- Feb 14, 2011, 12:58:25 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/egtra/ab5.0/abdev/ab_common/include/Lexical/Source.h
r739 r810 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 } 78 106 ~Text(){ 79 107 free( buffer ); … … 100 128 static void SlideString(char *buffer, int slide){ 101 129 memmove(buffer+slide, buffer, strlen(buffer)+1); 130 } 131 132 protected: 133 static void SwapImpl(Text& lhs, Text& rhs) 134 { 135 std::swap(lhs.buffer, rhs.buffer); 136 std::swap(lhs.length, rhs.length); 102 137 } 103 138 }; … … 192 227 { 193 228 } 229 BasicSource(BasicSource&& basicSource) 230 : Text(std::move(basicSource)) 231 , includedFilesRelation(std::move(basicSource.includedFilesRelation)) 232 { 233 } 194 234 BasicSource( const std::string &source ) 195 235 { … … 230 270 bool GetLineInfo( int sourceCodePos, int &line, std::string &fileName ) const; 231 271 232 void operator = ( const BasicSource &source ){ 272 BasicSource& operator =(const BasicSource &source) 273 { 233 274 Realloc( source.length ); 234 275 strcpy( buffer, source.buffer ); 276 return *this; 277 } 278 BasicSource& operator =(BasicSource&& source) 279 { 280 Text::SwapImpl(*this, source); 281 return *this; 235 282 } 236 283
Note:
See TracChangeset
for help on using the changeset viewer.