diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx index 64156bd03..bb8130a9e 100644 --- a/Source/cmDependsJavaParserHelper.cxx +++ b/Source/cmDependsJavaParserHelper.cxx @@ -52,8 +52,8 @@ void cmDependsJavaParserHelper::CurrentClass rname += this->Name; files->push_back(rname); std::vector::iterator it; - for ( it = this->NestedClasses.begin(); - it != this->NestedClasses.end(); + for ( it = this->NestedClasses->begin(); + it != this->NestedClasses->end(); ++ it ) { it->AddFileNamesForPrinting(files, rname.c_str(), sep); @@ -249,7 +249,7 @@ void cmDependsJavaParserHelper::EndClass() abort(); } this->CurrentDepth --; - parent->NestedClasses.push_back(*current); + parent->NestedClasses->push_back(*current); this->ClassStack.erase(this->ClassStack.end()-1, this->ClassStack.end()); } @@ -275,8 +275,8 @@ std::vector cmDependsJavaParserHelper::GetFilesProduced() std::vector files; CurrentClass* toplevel = &(*(this->ClassStack.begin())); std::vector::iterator it; - for ( it = toplevel->NestedClasses.begin(); - it != toplevel->NestedClasses.end(); + for ( it = toplevel->NestedClasses->begin(); + it != toplevel->NestedClasses->end(); ++ it ) { it->AddFileNamesForPrinting(&files, 0, "$"); diff --git a/Source/cmDependsJavaParserHelper.h b/Source/cmDependsJavaParserHelper.h index 171518e01..551e29b1c 100644 --- a/Source/cmDependsJavaParserHelper.h +++ b/Source/cmDependsJavaParserHelper.h @@ -70,14 +70,37 @@ public: private: class CurrentClass - { + { public: cmStdString Name; - std::vector NestedClasses; - CurrentClass() {} + std::vector* NestedClasses; + CurrentClass() + { + this->NestedClasses = new std::vector; + } + ~CurrentClass() + { + delete this->NestedClasses; + } + CurrentClass& operator=(CurrentClass const& c) + { + this->NestedClasses->clear(); + this->Name = c.Name; + std::copy( + c.NestedClasses->begin(), + c.NestedClasses->end(), + std::back_inserter( + *this->NestedClasses) + ); + return *this; + } + CurrentClass(CurrentClass const& c) + { + (*this) = c; + } void AddFileNamesForPrinting(std::vector *files, const char* prefix, const char* sep); - }; + }; cmStdString CurrentPackage; cmStdString::size_type InputBufferPos; cmStdString InputBuffer;