~ubuntu-branches/ubuntu/intrepid/kdesdk/intrepid-updates

« back to all changes in this revision

Viewing changes to umbrello/umbrello/codegenerators/cppcodegenerator.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2008-05-28 10:11:43 UTC
  • mto: This revision was merged to the branch mainline in revision 37.
  • Revision ID: james.westby@ubuntu.com-20080528101143-gzc3styjz1b70zxu
Tags: upstream-4.0.80
ImportĀ upstreamĀ versionĀ 4.0.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
 
44
44
CPPCodeGenerator::~CPPCodeGenerator ( ) {
45
45
    // destroy all separately owned codedocuments (e.g. header docs)
46
 
    CodeDocument *doc;
47
 
    for (CodeDocumentListIt it(m_headercodedocumentVector);
48
 
                     (doc = it.current()) != NULL; ++it)
49
 
        delete doc;
 
46
    qDeleteAll(m_headercodedocumentVector);
50
47
    m_headercodedocumentVector.clear();
51
48
}
52
49
 
95
92
        doc->setID(tag);
96
93
    }
97
94
 
98
 
    if(m_codeDocumentDictionary.find(tag))
 
95
    if(m_codeDocumentDictionary.contains(tag))
99
96
        return false; // return false, we already have some object with this tag in the list
100
97
    else
101
98
        m_codeDocumentDictionary.insert(tag, doc);
114
111
    else
115
112
        return false;
116
113
 
117
 
    m_headercodedocumentVector.remove(remove_object);
 
114
    m_headercodedocumentVector.removeAll(remove_object);
118
115
    return true;
119
116
}
120
117
 
168
165
    docElement.setAttribute("language", "C++");
169
166
 
170
167
    CodeDocumentList * docList = getCodeDocumentList();
171
 
    for (CodeDocument * codeDoc = docList->first(); codeDoc; codeDoc= docList->next())
172
 
        codeDoc->saveToXMI(doc, docElement);
 
168
    CodeDocumentList::Iterator it  = docList->begin();
 
169
    CodeDocumentList::Iterator end  = docList->end();
 
170
    for ( ; it != end; ++it )
 
171
        (*it)->saveToXMI(doc, docElement);
173
172
 
174
 
    for (CodeDocument * hcodeDoc = m_headercodedocumentVector.first(); hcodeDoc; hcodeDoc=m_headercodedocumentVector.next())
175
 
        hcodeDoc->saveToXMI(doc, docElement);
 
173
    CodeDocumentList::Iterator it2  = m_headercodedocumentVector.begin();
 
174
    CodeDocumentList::Iterator end2  = m_headercodedocumentVector.end();
 
175
    for ( ; it2 != end2; ++it2 )
 
176
        (*it2)->saveToXMI(doc, docElement);
176
177
 
177
178
    root.appendChild( docElement );
178
179
}
184
185
void CPPCodeGenerator::syncCodeToDocument ( ) {
185
186
 
186
187
    CodeDocumentList * docList = getCodeDocumentList();
187
 
 
188
 
    for (CodeDocument * doc = docList->first(); doc; doc=docList->next())
189
 
        doc->synchronize();
190
 
 
191
 
    for (CodeDocument * hcodeDoc = m_headercodedocumentVector.first(); hcodeDoc; hcodeDoc=m_headercodedocumentVector.next())
192
 
        hcodeDoc->synchronize();
 
188
    CodeDocumentList::Iterator it  = docList->begin();
 
189
    CodeDocumentList::Iterator end  = docList->end();
 
190
    for ( ; it != end; ++it )
 
191
        (*it)->synchronize();
 
192
 
 
193
    CodeDocumentList::Iterator it2  = m_headercodedocumentVector.begin();
 
194
    CodeDocumentList::Iterator end2  = m_headercodedocumentVector.end();
 
195
    for ( ; it2 != end2; ++it2 )
 
196
        (*it2)->synchronize();
193
197
 
194
198
}
195
199
 
210
214
// both the header and source documents
211
215
void CPPCodeGenerator::writeCodeToFile ( UMLClassifierList & concepts) {
212
216
    CodeDocumentList docs;
213
 
    docs.setAutoDelete(false);
214
217
 
215
 
    for (UMLClassifier *concept= concepts.first(); concept; concept= concepts.next())
216
 
    {
 
218
    foreach (UMLClassifier* concept, concepts ) {
217
219
        CodeDocument * doc = findCodeDocumentByClassifier(concept);
218
220
        if(doc)
219
221
            docs.append(doc);
274
276
    // Walk through the document converting classifiers into
275
277
    // classifier code documents as needed (e.g only if doesn't exist)
276
278
    UMLClassifierList concepts = UMLApp::app()->getDocument()->getClassesAndInterfaces();
277
 
    for (UMLClassifier *c = concepts.first(); c; c = concepts.next())
278
 
    {
279
 
 
 
279
    foreach (UMLClassifier* c, concepts ) {
280
280
        // Doesn't exist? Then build one.
281
281
        CodeDocument * codeDoc = findCodeDocumentByClassifier(c);
282
282
        if (!codeDoc)
345
345
{
346
346
    m_createMakefile = false;
347
347
 
348
 
    UMLApp::app()->setPolicyExt ( new CPPCodeGenerationPolicy(UMLApp::app()->getConfig()) );
 
348
    UMLApp::app()->setPolicyExt ( new CPPCodeGenerationPolicy() );
349
349
 
350
350
    // load Classifier documents from parent document
351
351
    //initFromParentDocument();