Changeset 810 in dev for branches/egtra/ab5.0
- Timestamp:
- Feb 14, 2011, 12:58:25 AM (14 years ago)
- Location:
- branches/egtra/ab5.0/abdev/ab_common
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/egtra/ab5.0/abdev/ab_common/include/Lexical/Namespace.h
r750 r810 7 7 class NamespaceScopes : public std::vector<std::string> 8 8 { 9 typedef std::vector<std::string> Base; 9 10 // XMLシリアライズ用 10 11 private: … … 17 18 18 19 public: 19 NamespaceScopes(){} 20 NamespaceScopes() {} 21 NamespaceScopes(NamespaceScopes const& y) 22 : Base(y) 23 { 24 } 25 NamespaceScopes(NamespaceScopes&& y) 26 : Base(std::move(y)) 27 { 28 } 20 29 NamespaceScopes( const std::string &namespaceStr ); 21 30 NamespaceScopes( NamespaceScopes::const_iterator first, NamespaceScopes::const_iterator last ) 22 : std::vector<std::string>( first, last)31 : Base(first, last) 23 32 { 24 33 } 25 34 ~NamespaceScopes(){} 26 35 27 NamespaceScopes operator+ ( const NamespaceScopes &namespaceScopes ) const;28 29 36 void append( const NamespaceScopes &namespaceScopes ) 30 37 { 31 38 insert( end(), namespaceScopes.begin(), namespaceScopes.end() ); 39 } 40 41 NamespaceScopes& operator +=(const NamespaceScopes &namespaceScopes) 42 { 43 append(namespaceScopes); 44 return *this; 32 45 } 33 46 … … 77 90 }; 78 91 92 NamespaceScopes operator +(const NamespaceScopes &lhs, const NamespaceScopes &rhs); 93 79 94 inline bool operator ==( const NamespaceScopes &lhs, const NamespaceScopes &rhs ) 80 95 { … … 84 99 class NamespaceScopesCollection : public std::vector<NamespaceScopes> 85 100 { 101 typedef std::vector<NamespaceScopes> Base; 86 102 // XMLシリアライズ用 87 103 private: … … 93 109 94 110 public: 111 NamespaceScopesCollection() : Base() {} 112 NamespaceScopesCollection(NamespaceScopesCollection&& y) : Base(std::move(y)) {} 113 NamespaceScopesCollection(NamespaceScopesCollection const& y) : Base(y) {} 114 NamespaceScopesCollection& operator =(NamespaceScopesCollection&& y) 115 { 116 Base::operator =(std::move(y)); 117 return *this; 118 } 119 NamespaceScopesCollection& operator =(NamespaceScopesCollection const& y) 120 { 121 return operator =(NamespaceScopesCollection(y)); 122 } 95 123 bool IsExist( const NamespaceScopes &namespaceScopes ) const 96 124 { -
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 -
branches/egtra/ab5.0/abdev/ab_common/include/Lexical/Symbol.h
r637 r810 48 48 { 49 49 } 50 Symbol(Symbol&& symbol) 51 : namespaceScopes(std::move(symbol.namespaceScopes)) 52 , name(std::move(symbol.name)) 53 { 54 } 50 55 Symbol() 51 56 { 57 } 58 Symbol& operator =(Symbol&& symbol) 59 { 60 namespaceScopes = std::move(symbol.namespaceScopes); 61 name = std::move(symbol.name); 62 return *this; 63 } 64 Symbol& operator =(Symbol const& symbol) 65 { 66 return *this = Symbol(symbol); 52 67 } 53 68 -
branches/egtra/ab5.0/abdev/ab_common/src/Lexical/Namespace.cpp
r736 r810 16 16 std::string tempName = namespaceStr.substr( i, i2-i ); 17 17 18 push_back( tempName);18 push_back(std::move(tempName)); 19 19 20 20 if( i2 == std::string::npos ){ … … 26 26 } 27 27 28 NamespaceScopes NamespaceScopes::operator+ ( const NamespaceScopes &namespaceScopes ) const28 NamespaceScopes ActiveBasic::Common::Lexical::operator +(const NamespaceScopes &lhs, const NamespaceScopes &rhs) 29 29 { 30 NamespaceScopes result; 31 result.reserve( this->size() + namespaceScopes.size() ); 32 result = *this; 33 result.append( namespaceScopes ); 34 return result; 30 return NamespaceScopes(lhs) += rhs; 35 31 } 36 32
Note:
See TracChangeset
for help on using the changeset viewer.