23 #include <kdatastream.h> 26 template<
class MapContainer>
27 bool eachCanUpdate(
const MapContainer& old,
const MapContainer& newMap ) {
28 if( old.size() != newMap.size() )
return false;
30 typename MapContainer::const_iterator oldIt = old.begin();
31 typename MapContainer::const_iterator newIt = newMap.begin();
32 while( oldIt != old.end() ) {
33 typedef typename MapContainer::mapped_type ListType;
34 if( (*oldIt).size() != (*newIt).size() )
return false;
35 typename ListType::const_iterator it1 = (*oldIt).begin();
36 typename ListType::const_iterator it2 = (*newIt).begin();
38 while( it1 != (*oldIt).end() ) {
39 if( !(*it1)->canUpdate( *it2 ) )
return false;
49 template<
class MapContainer>
50 void eachUpdate( MapContainer& old,
const MapContainer& newMap ) {
51 if( old.size() != newMap.size() ) kdError( 9007 ) <<
"error in eachUpdate(...) 1" << endl;
52 typename MapContainer::iterator oldIt = old.begin();
53 typename MapContainer::const_iterator newIt = newMap.begin();
54 while( oldIt != old.end() ) {
55 if( (*oldIt).size() != (*newIt).size() ) kdError( 9007 ) <<
"error in eachUpdate(...) 2" << endl;
56 typedef typename MapContainer::mapped_type ListType;
57 typename ListType::iterator it1 = (*oldIt).begin();
58 typename ListType::const_iterator it2 = (*newIt).begin();
59 while( it1 != (*oldIt).end() ) {
60 (*it1)->update( *it2 );
70 template<
class MapContainer>
71 bool eachCanUpdateSingle(
const MapContainer& old,
const MapContainer& newMap ) {
72 if( old.size() != newMap.size() )
return false;
74 typename MapContainer::const_iterator oldIt = old.begin();
75 typename MapContainer::const_iterator newIt = newMap.begin();
76 while( oldIt != old.end() ) {
77 if( !(*oldIt)->canUpdate( *newIt ) )
return false;
84 template<
class MapContainer>
85 void eachUpdateSingle( MapContainer& old,
const MapContainer& newMap ) {
86 if( old.size() != newMap.size() ) kdError( 9007 ) <<
"error in eachUpdate(...) 1" << endl;
87 typename MapContainer::iterator oldIt = old.begin();
88 typename MapContainer::const_iterator newIt = newMap.begin();
89 while( oldIt != old.end() ) {
90 (*oldIt)->update( *newIt );
102 CodeModel::~ CodeModel( )
106 int CodeModel::newGroupId() {
107 return (m_currentGroupId++) * 2;
110 inline bool isSingleGroup(
const int group ) {
111 return (group % 2) == 0;
116 for(TQMap<TQString, FileDom>::ConstIterator it = m_files.begin(); it != m_files.end(); ++it) {
117 if((*it)->groupId() == gid) ret.append( (*it)-> name() );
125 for(TQMap<TQString, FileDom>::ConstIterator it = m_files.begin(); it != m_files.end(); ++it) {
126 if((*it)->groupId() == gid) ret.append(*it);
136 if( !g1 || !g2 )
return 0;
137 if( g1 == g2 )
return g1;
138 int ng = isSingleGroup( g1 ) ? g2 : g1;
139 if( isSingleGroup( ng ) )
140 ng = newGroupId() + 1;
142 for( TQMap<TQString, FileDom>::iterator it = m_files.begin(); it != m_files.end(); ++it ) {
143 if( (*it)->groupId() == g2 || (*it)->groupId() == g1 ) (*it)->setGroupId( ng );
148 template<
class Type>
static void dumpMap( std::ostream& file, TQMap<TQString, Type>& map ) {
149 typename TQMap<TQString, Type>::Iterator it = map.begin();
150 for( ; it != map.end(); ++it) {
151 typename Type::Iterator it2 = (*it).begin();
152 for( ; it2 != (*it).end(); ++it2) {
153 (*it2) ->
dump( file,
true );
158 template<
class Type>
static void dumpMapDirect( std::ostream& file, TQMap<TQString, Type>& map ) {
159 typename TQMap<TQString, Type>::Iterator it = map.begin();
160 for( ; it != map.end(); ++it) {
161 (*it) ->
dump( file,
true );
167 ostringstream str( ostringstream::out );
169 str <<
"name: " << name().ascii() <<
"\n";
170 str <<
"kind: " << m_kind <<
" ";
172 if( isFile() ) str <<
"isFile ";
173 if( isNamespace() ) str <<
"isNamespace ";
174 if( isClass() ) str <<
"isClass ";
175 if( isFunction() ) str <<
"isFunction ";
176 if( isFunctionDefinition() ) str <<
"isFunctionDefinition ";
177 if( isVariable() ) str <<
"isVariable ";
178 if( isArgument() ) str <<
"isArgument ";
179 if( isEnum() ) str <<
"isEnum ";
180 if( isEnumerator() ) str <<
"isEnumerator ";
181 if( isTypeAlias() ) str <<
"isTypeAlias ";
182 if( isCustom() ) str <<
"isCustom ";
184 str <<
"File: " << fileName().ascii() <<
" ";
186 getStartPosition( &line, &col );
187 str <<
"s:(" << line <<
", " << col <<
") ";
188 getEndPosition( &line, &col );
189 str <<
"e:(" << line <<
", " << col <<
")\n";
192 Info.prepend( str.str().c_str() );
194 file << Info.ascii() <<
"\n";
198 void ClassModel::dump( std::ostream& file,
bool recurse, TQString Info )
200 ostringstream str( ostringstream::out );
203 str <<
"scope: " << m_scope.join(
"::").ascii() <<
"\n";
204 str <<
"bases: " << m_baseClassList.join(
" ").ascii() <<
"\n";
206 Info.prepend( str.str().c_str() );
211 dumpMap( file, m_classes );
215 void NamespaceAliasModel::read( TQDataStream& stream ) {
216 TQString tempFileName;
217 stream >> m_name >> m_aliasName >> tempFileName;
221 void NamespaceAliasModel::write( TQDataStream& stream )
const {
222 stream << m_name << m_aliasName << m_fileName.str();
225 void NamespaceImportModel::read( TQDataStream& stream ) {
226 TQString tempFileName;
227 stream >> m_name >> tempFileName;
231 void NamespaceImportModel::write( TQDataStream& stream )
const {
232 stream << m_name << m_fileName.str();
235 void NamespaceModel::dump( std::ostream& file,
bool recurse, TQString Info )
237 ostringstream str( ostringstream::out );
239 Info.prepend( str.str().c_str() );
241 ClassModel::dump( file,
false, Info );
244 dumpMapDirect( file, m_namespaces );
250 ostringstream str( ostringstream::out );
252 str <<
"type: " << m_type.ascii() <<
" default: " << m_defaultValue.ascii() <<
"\n";
254 Info.prepend( str.str().c_str() );
261 void FunctionModel::dump( std::ostream& file,
bool recurse, TQString Info )
263 ostringstream str( ostringstream::out );
265 str <<
"access: " << m_access;
267 str <<
" scope: " << m_scope.join(
"::").ascii() <<
"\n";
269 if(isAbstract()) str <<
"isAbstract ";
270 if(isConstant()) str <<
"isConstant ";
271 if(isFunction()) str <<
"isFunction ";
272 if(isInline()) str <<
"isInline ";
273 if(isSignal()) str <<
"isSignal ";
274 if(isSlot()) str <<
"isSlot ";
275 if(isStatic()) str <<
"isStatic ";
276 if(isVirtual()) str <<
"isVirtual ";
279 str <<
"result-type: " << resultType().ascii() <<
"\n";
281 Info.prepend( str.str().c_str() );
286 for( ArgumentList::iterator it = m_arguments.begin(); it != m_arguments.end(); ++it) {
287 (*it) ->
dump( file,
true );
294 ostringstream str( ostringstream::out );
296 str <<
"access: " << m_access <<
"type: " << m_type.ascii() <<
"\n";
298 if(isStatic()) str <<
"isStatic ";
302 Info.prepend( str.str().c_str() );
310 ostringstream str(ostringstream::out);
312 Info.prepend( str.str().c_str() );
314 file << Info.ascii() <<
"\n";
316 TQMap<TQString, FileDom>::iterator it = m_files.begin();
317 for(; it != m_files.end(); ++it) {
318 (*it) ->
dump( file,
true );
324 ostringstream str( ostringstream::out );
326 str <<
"access: " << m_access <<
"\n";
328 Info.prepend( str.str().c_str() );
333 dumpMapDirect( file, m_enumerators );
339 ostringstream str( ostringstream::out );
341 str <<
"value: " << m_value.ascii() <<
"\n";
343 Info.prepend( str.str().c_str() );
351 ostringstream str( ostringstream::out );
353 str <<
"type: " << m_type.ascii() <<
"\n";
355 Info.prepend( str.str().c_str() );
368 m_globalNamespace = ns;
373 return m_files.values();
378 return m_files.values();
383 return m_files.contains( name );
388 TQMap<TQString, FileDom>::const_iterator it = m_files.find( name );
389 if( it != m_files.end() ) {
398 TQMap<TQString, FileDom>::const_iterator it = m_files.find( name );
399 if( it != m_files.end() ) {
408 if( source->name().isEmpty() ){
410 }
else if( !target->hasNamespace(source->name()) ){
412 ns->setName( source->name() );
413 ns->setFileName( source->fileName() );
414 ns->setScope( source->scope() );
415 target->addNamespace( ns );
418 NamespaceDom ns = target->namespaceByName( source->name() );
421 ClassList classList = source->classList();
425 EnumList enumList = source->enumList();
427 const NamespaceModel::NamespaceAliasModelList& namespaceAliases = source->namespaceAliases();
430 for( NamespaceList::Iterator it=namespaceList.begin(); it!=namespaceList.end(); ++it )
431 addNamespace( ns, *it );
432 for( ClassList::Iterator it=classList.begin(); it!=classList.end(); ++it )
434 for( FunctionList::Iterator it=functionList.begin(); it!=functionList.end(); ++it )
435 ns->addFunction( *it );
436 for( FunctionDefinitionList::Iterator it=functionDefinitionList.begin(); it!=functionDefinitionList.end(); ++it )
437 ns->addFunctionDefinition( *it );
438 for( VariableList::Iterator it=variableList.begin(); it!=variableList.end(); ++it )
439 ns->addVariable( *it );
440 for( EnumList::Iterator it=enumList.begin(); it!=enumList.end(); ++it )
442 for( TypeAliasList::Iterator it=typeAliasList.begin(); it!=typeAliasList.end(); ++it )
443 ns->addTypeAlias( *it );
444 for( NamespaceModel::NamespaceAliasModelList::const_iterator it=namespaceAliases.begin(); it != namespaceAliases.end(); ++it )
445 ns->addNamespaceAlias( *it );
446 for( NamespaceModel::NamespaceImportModelList::const_iterator it=namespaceImports.begin(); it != namespaceImports.end(); ++it )
447 ns->addNamespaceImport( *it );
452 if( source->name().isEmpty() || !target->hasNamespace(source->name()) )
455 NamespaceDom ns = target->namespaceByName( source->name() );
458 ClassList classList = source->classList();
462 EnumList enumList = source->enumList();
464 const NamespaceModel::NamespaceAliasModelList& namespaceAliases = source->namespaceAliases();
467 for( NamespaceList::Iterator it=namespaceList.begin(); it!=namespaceList.end(); ++it )
468 removeNamespace( ns, *it );
469 for( ClassList::Iterator it=classList.begin(); it!=classList.end(); ++it )
470 ns->removeClass( *it );
471 for( FunctionList::Iterator it=functionList.begin(); it!=functionList.end(); ++it )
472 ns->removeFunction( *it );
473 for( FunctionDefinitionList::Iterator it=functionDefinitionList.begin(); it!=functionDefinitionList.end(); ++it )
474 ns->removeFunctionDefinition( *it );
475 for( VariableList::Iterator it=variableList.begin(); it!=variableList.end(); ++it )
476 ns->removeVariable( *it );
477 for( EnumList::Iterator it=enumList.begin(); it!=enumList.end(); ++it )
478 ns->removeEnum( *it );
479 for( TypeAliasList::Iterator it=typeAliasList.begin(); it!=typeAliasList.end(); ++it )
480 ns->removeTypeAlias( *it );
481 for( NamespaceModel::NamespaceAliasModelList::const_iterator it=namespaceAliases.begin(); it != namespaceAliases.end(); ++it )
482 ns->removeNamespaceAlias( *it );
483 for( NamespaceModel::NamespaceImportModelList::const_iterator it=namespaceImports.begin(); it != namespaceImports.end(); ++it )
484 ns->removeNamespaceImport( *it );
486 if( ns->namespaceList().isEmpty() &&
487 ns->classList().isEmpty() &&
488 ns->functionList().isEmpty() &&
489 ns->functionDefinitionList().isEmpty() &&
490 ns->variableList().isEmpty() &&
491 ns->enumList().isEmpty() &&
492 ns->typeAliasList().isEmpty() &&
493 ns->namespaceImports().empty() &&
494 ns->namespaceAliases().empty() )
496 target->removeNamespace( ns );
502 if( file->name().isEmpty() )
505 if( m_files.find( file->name() ) != m_files.end() ) {
507 kdDebug(9007) <<
"file " << file->name() <<
" was added to code-model without removing it before! \n" << kdBacktrace() << endl;
517 EnumList enumList = file->enumList();
519 const NamespaceModel::NamespaceAliasModelList& namespaceAliases = file->namespaceAliases();
522 for( NamespaceList::Iterator it=namespaceList.begin(); it!=namespaceList.end(); ++it )
523 addNamespace( m_globalNamespace, *it );
524 for( ClassList::Iterator it=classList.begin(); it!=classList.end(); ++it )
525 m_globalNamespace->addClass( *it );
526 for( FunctionList::Iterator it=functionList.begin(); it!=functionList.end(); ++it )
527 m_globalNamespace->addFunction( *it );
528 for( FunctionDefinitionList::Iterator it=functionDefinitionList.begin(); it!=functionDefinitionList.end(); ++it )
529 m_globalNamespace->addFunctionDefinition( *it );
530 for( VariableList::Iterator it=variableList.begin(); it!=variableList.end(); ++it )
531 m_globalNamespace->addVariable( *it );
532 for( EnumList::Iterator it=enumList.begin(); it!=enumList.end(); ++it )
533 m_globalNamespace->addEnum( *it );
534 for( TypeAliasList::Iterator it=typeAliasList.begin(); it!=typeAliasList.end(); ++it )
535 m_globalNamespace->addTypeAlias( *it );
536 for( NamespaceModel::NamespaceAliasModelList::const_iterator it=namespaceAliases.begin(); it != namespaceAliases.end(); ++it )
537 m_globalNamespace->addNamespaceAlias( *it );
538 for( NamespaceModel::NamespaceImportModelList::const_iterator it=namespaceImports.begin(); it != namespaceImports.end(); ++it )
539 m_globalNamespace->addNamespaceImport( *it );
541 m_files.insert( file->name(), file );
553 EnumList enumList = file->enumList();
555 const NamespaceModel::NamespaceAliasModelList& namespaceAliases = file->namespaceAliases();
558 for( NamespaceList::Iterator it=namespaceList.begin(); it!=namespaceList.end(); ++it )
559 removeNamespace( m_globalNamespace, *it );
560 for( ClassList::Iterator it=classList.begin(); it!=classList.end(); ++it )
561 m_globalNamespace->removeClass( *it );
562 for( FunctionList::Iterator it=functionList.begin(); it!=functionList.end(); ++it )
563 m_globalNamespace->removeFunction( *it );
564 for( FunctionDefinitionList::Iterator it=functionDefinitionList.begin(); it!=functionDefinitionList.end(); ++it )
565 m_globalNamespace->removeFunctionDefinition( *it );
566 for( VariableList::Iterator it=variableList.begin(); it!=variableList.end(); ++it )
567 m_globalNamespace->removeVariable( *it );
568 for( EnumList::Iterator it=enumList.begin(); it!=enumList.end(); ++it )
569 m_globalNamespace->removeEnum( *it );
570 for( TypeAliasList::Iterator it=typeAliasList.begin(); it!=typeAliasList.end(); ++it )
571 m_globalNamespace->removeTypeAlias( *it );
572 for( NamespaceModel::NamespaceAliasModelList::const_iterator it=namespaceAliases.begin(); it != namespaceAliases.end(); ++it )
573 m_globalNamespace->removeNamespaceAlias( *it );
574 for( NamespaceModel::NamespaceImportModelList::const_iterator it=namespaceImports.begin(); it != namespaceImports.end(); ++it )
575 m_globalNamespace->removeNamespaceImport( *it );
577 m_files.remove( file->name() );
582 : m_kind( kind ), m_model( model )
591 CodeModelItem::~ CodeModelItem( )
627 if( line ) *line = m_startLine;
628 if( column ) *column = m_startColumn;
634 m_startColumn = column;
639 if( line ) *line = m_endLine;
640 if( column ) *column = m_endColumn;
646 m_endColumn = column;
650 m_startLine = i->m_startLine;
651 m_startColumn = i->m_startColumn;
652 m_endLine = i->m_endLine;
653 m_endColumn = i->m_endColumn;
656 bool CodeModelItem::canUpdate(
const CodeModelItem* i )
const {
657 if( i->m_kind != m_kind || i->m_name != m_name )
672 return m_namespaces.values();
677 return m_namespaces.values();
682 return m_namespaces.contains( name ) ? m_namespaces[
name ] :
NamespaceDom();
687 return m_namespaces.contains( name ) ? m_namespaces[
name ] :
NamespaceDom();
692 return m_namespaces.contains( name );
697 if( ns->name().isEmpty() )
700 m_namespaces[ ns->name() ] = ns;
706 m_namespaces.remove( ns->name() );
711 :
NamespaceModel( model ), m_groupId( model->newGroupId() ), m_parseResult( 0 )
723 return m_baseClassList;
728 m_baseClassList.push_back( baseClass );
734 m_baseClassList.remove( baseClass );
740 TQMap<TQString, ClassList>::Iterator it = m_classes.begin();
741 while( it != m_classes.end() ){
752 TQMap<TQString, ClassList>::ConstIterator it = m_classes.begin();
753 while( it != m_classes.end() ){
763 return m_classes.contains( name );
768 return m_classes.contains( name ) ? m_classes[
name ] :
ClassList();
773 return m_classes.contains( name ) ? m_classes[
name ] :
ClassList();
778 if( klass->name().isEmpty() )
781 m_classes[ klass->name() ].push_back( klass );
787 m_classes[ klass->name() ].remove( klass );
789 if( m_classes[klass->name()].isEmpty() )
790 m_classes.remove( klass->name() );
796 TQMap<TQString, FunctionList>::Iterator it = m_functions.begin();
797 while( it != m_functions.end() ){
808 TQMap<TQString, FunctionList>::ConstIterator it = m_functions.begin();
809 while( it != m_functions.end() ){
819 return m_functions.contains( name );
834 if( fun->name().isEmpty() )
837 m_functions[ fun->name() ].push_back( fun );
843 m_functions[ fun->name() ].remove( fun );
845 if( m_functions[fun->name()].isEmpty() )
846 m_functions.remove( fun->name() );
852 TQMap<TQString, FunctionDefinitionList>::Iterator it = m_functionDefinitions.begin();
853 while( it != m_functionDefinitions.end() ){
864 TQMap<TQString, FunctionDefinitionList>::ConstIterator it = m_functionDefinitions.begin();
865 while( it != m_functionDefinitions.end() ){
875 return m_functionDefinitions.contains( name );
890 if( fun->name().isEmpty() )
893 m_functionDefinitions[ fun->name() ].push_back( fun );
899 m_functionDefinitions[ fun->name() ].remove( fun );
901 if( m_functionDefinitions[fun->name()].isEmpty() )
902 m_functionDefinitions.remove( fun->name() );
907 return m_variables.values();
912 return m_variables.values();
917 return m_variables.contains( name ) ? m_variables[
name ] :
VariableDom();
922 return m_variables.contains( name ) ? m_variables[
name ] :
VariableDom();
927 return m_variables.contains( name );
932 if( var->name().isEmpty() )
935 m_variables.insert( var->name(), var );
941 m_variables.remove( var->name() );
946 return m_enumerators.values();
951 return m_enumerators.values();
956 return m_enumerators.contains( name ) ? m_enumerators[
name ] :
EnumDom();
961 return m_enumerators.contains( name ) ? m_enumerators[
name ] :
EnumDom();
966 return m_enumerators.contains( name );
971 if( e->name().isEmpty() )
974 m_enumerators.insert( e->name(), e );
978 void ClassModel::update(
const ClassModel* klass ) {
979 CodeModelItem::update( klass );
980 eachUpdate( m_classes, klass->m_classes ) ;
981 eachUpdate( m_functions, klass->m_functions ) ;
982 eachUpdate( m_functionDefinitions, klass->m_functionDefinitions ) ;
983 eachUpdateSingle( m_variables, klass->m_variables ) ;
984 eachUpdateSingle( m_enumerators, klass->m_enumerators ) ;
985 eachUpdate( m_typeAliases, klass->m_typeAliases );
988 bool ClassModel::canUpdate(
const ClassModel* klass )
const {
989 if( !CodeModelItem::canUpdate( klass ) )
992 return eachCanUpdate( m_classes, klass->m_classes ) &&
993 eachCanUpdate( m_functions, klass->m_functions ) &&
994 eachCanUpdate( m_functionDefinitions, klass->m_functionDefinitions ) &&
995 eachCanUpdateSingle( m_variables, klass->m_variables ) &&
996 eachCanUpdateSingle( m_enumerators, klass->m_enumerators ) &&
997 eachCanUpdate( m_typeAliases, klass->m_typeAliases );
1002 m_enumerators.remove( e->name() );
1008 TQMap<TQString, TypeAliasList>::Iterator it = m_typeAliases.begin();
1009 while( it != m_typeAliases.end() ){
1020 TQMap<TQString, TypeAliasList>::ConstIterator it = m_typeAliases.begin();
1021 while( it != m_typeAliases.end() ){
1031 return m_typeAliases.contains( name );
1036 return m_typeAliases.contains( name ) ? m_typeAliases[
name ] :
TypeAliasList();
1041 return m_typeAliases.contains( name ) ? m_typeAliases[
name ] :
TypeAliasList();
1046 if( typeAlias->name().isEmpty() )
1049 m_typeAliases[ typeAlias->name() ].push_back( typeAlias );
1055 m_typeAliases[ typeAlias->name() ].remove( typeAlias );
1057 if( m_typeAliases[typeAlias->name()].isEmpty() )
1058 m_typeAliases.remove( typeAlias->name() );
1064 ArgumentModel::ArgumentModel(
CodeModel* model )
1081 return m_defaultValue;
1086 m_defaultValue = defaultValue;
1094 d.v.m_signal =
false;
1096 d.v.m_virtual =
false;
1097 d.v.m_static =
false;
1098 d.v.m_inline =
false;
1099 d.v.m_constant =
false;
1100 d.v.m_abstract =
false;
1105 return d.v.m_virtual;
1115 return d.v.m_static;
1125 return d.v.m_inline;
1135 return d.v.m_constant;
1145 return d.v.m_abstract;
1155 return m_resultType;
1160 m_resultType = type;
1175 m_arguments.push_back( arg );
1181 m_arguments.remove( arg );
1185 m_access = i->m_access;
1186 CodeModelItem::update( i );
1189 bool FunctionModel::canUpdate(
const FunctionModel* i )
const {
1190 if( !CodeModelItem::canUpdate( i ) )
1192 if( m_resultType != i->m_resultType || m_arguments.count() != i->m_arguments.count() || m_scope != i->m_scope )
1204 m_isEnumeratorVariable =
false;
1228 return m_isEnumeratorVariable;
1231 void VariableModel::setEnumeratorVariable(
bool b) {
1232 m_isEnumeratorVariable = b;
1247 return d.v.m_signal;
1252 d.v.m_signal = isSignal;
1262 d.v.m_slot = isSlot;
1282 return m_globalNamespace;
1297 if( isTemplateable() ) {
1298 TemplateModelItem* t = (TemplateModelItem*)(
this );
1316 if( isTemplateable() ) {
1317 TemplateModelItem* t = (TemplateModelItem*)(
this );
1318 t->
write( stream );
1326 TemplateModelItem::read( stream );
1328 stream >> m_scope >> m_baseClassList;
1334 for(
int i=0; i<n; ++i ){
1336 klass->read( stream );
1340 m_functions.clear();
1342 for(
int i=0; i<n; ++i ){
1344 fun->read( stream );
1348 m_functionDefinitions.clear();
1350 for(
int i=0; i<n; ++i ){
1352 fun->read( stream );
1353 addFunctionDefinition( fun );
1356 m_variables.clear();
1358 for(
int i=0; i<n; ++i ){
1360 var->read( stream );
1364 m_enumerators.clear();
1366 for(
int i=0; i<n; ++i ){
1372 m_typeAliases.clear();
1374 for(
int i=0; i<n; ++i ){
1376 typeAlias->read( stream );
1377 addTypeAlias( typeAlias );
1385 TemplateModelItem::write( stream );
1387 stream << m_scope << m_baseClassList;
1389 const ClassList class_list = classList();
1390 stream << int( class_list.size() );
1391 for( ClassList::ConstIterator it = class_list.begin(); it!=class_list.end(); ++it )
1392 (*it)->write( stream );
1395 stream << int( function_list.size() );
1396 for( FunctionList::ConstIterator it = function_list.begin(); it!=function_list.end(); ++it )
1397 (*it)->write( stream );
1400 stream << int( function_definition_list.size() );
1401 for( FunctionDefinitionList::ConstIterator it = function_definition_list.begin(); it!=function_definition_list.end(); ++it )
1402 (*it)->write( stream );
1405 stream << int( variable_list.size() );
1406 for( VariableList::ConstIterator it = variable_list.begin(); it!=variable_list.end(); ++it )
1407 (*it)->write( stream );
1409 const EnumList enum_list = enumList();
1410 stream << int( enum_list.size() );
1411 for( EnumList::ConstIterator it = enum_list.begin(); it!=enum_list.end(); ++it )
1412 (*it)->write( stream );
1415 stream << int( type_alias_list.size() );
1416 for( TypeAliasList::ConstIterator it = type_alias_list.begin(); it!=type_alias_list.end(); ++it )
1417 (*it)->write( stream );
1427 m_namespaces.clear(); m_namespaceAliases.clear(); m_namespaceImports.clear();
1429 for(
int i=0; i<n; ++i ){
1436 for(
int a = 0; a < n; a++ ) {
1437 NamespaceAliasModel m;
1439 m_namespaceAliases.insert( m );
1442 for(
int a = 0; a < n; a++ ) {
1443 NamespaceImportModel m;
1445 m_namespaceImports.insert( m );
1449 void NamespaceModel::addNamespaceImport(
const NamespaceImportModel&
import ) {
1450 m_namespaceImports.insert(
import );
1453 void NamespaceModel::addNamespaceAlias(
const NamespaceAliasModel& alias ) {
1454 m_namespaceAliases.insert( alias );
1457 void NamespaceModel::removeNamespaceImport(
const NamespaceImportModel&
import ) {
1458 m_namespaceImports.erase(
import );
1461 void NamespaceModel::removeNamespaceAlias(
const NamespaceAliasModel& alias ) {
1462 m_namespaceAliases.erase( alias );
1470 stream << int( namespace_list.size() );
1471 for( NamespaceList::ConstIterator it = namespace_list.begin(); it!=namespace_list.end(); ++it )
1472 (*it)->write( stream );
1474 stream << int( m_namespaceAliases.size() );
1475 for( NamespaceAliasModelList::const_iterator it = m_namespaceAliases.begin(); it != m_namespaceAliases.end(); ++it )
1476 (*it).write( stream );
1477 stream << int( m_namespaceImports.size() );
1478 for( NamespaceImportModelList::const_iterator it = m_namespaceImports.begin(); it != m_namespaceImports.end(); ++it )
1479 (*it).write( stream );
1483 if( !ClassModel::canUpdate( ns ) )
1486 const NamespaceAliasModelList& aliases = namespaceAliases();
1491 if( aliases.size() != aliases2.size() )
return false;
1492 if( imports.size() != imports2.size() )
return false;
1495 NamespaceModel::NamespaceAliasModelList::const_iterator it_al1 = aliases.begin();
1496 NamespaceModel::NamespaceAliasModelList::const_iterator it_al2 = aliases2.begin();
1497 while( it_al1 != aliases.end() ) {
1498 if( !(*it_al1 == *it_al2) )
1506 NamespaceModel::NamespaceImportModelList::const_iterator it_ip1 = imports.begin();
1507 NamespaceModel::NamespaceImportModelList::const_iterator it_ip2 = imports2.begin();
1508 while( it_ip1 != imports.end() ) {
1509 if( !(*it_ip1 == *it_ip2) )
1516 return eachCanUpdateSingle( m_namespaces, ns->m_namespaces );
1521 ClassModel::update( ns );
1523 eachUpdateSingle( m_namespaces, ns->m_namespaces );
1528 stream >> m_groupId;
1534 ParsedFileType t( (ParsedFileType) i );
1537 m_parseResult = (AbstractParseResult*)(
new ParsedFile( stream ));
1547 stream << m_groupId;
1548 bool b = m_parseResult;
1551 int i = m_parseResult->type();
1553 m_parseResult->
write( stream );
1564 stream >> m_type >> m_defaultValue;
1571 stream << m_type << m_defaultValue;
1577 TemplateModelItem::read( stream );
1584 m_arguments.clear();
1586 for(
int i=0; i<n; ++i ){
1588 arg->read( stream );
1599 TemplateModelItem::write( stream );
1605 stream << int( argument_list.size() );
1606 for( ArgumentList::ConstIterator it = argument_list.begin(); it!=argument_list.end(); ++it )
1607 (*it)->write( stream );
1620 for(
int i=0; i<n; ++i ){
1621 FileDom file = this->create<FileModel>();
1622 file->read( stream );
1629 const FileList file_list = fileList();
1630 stream << int( file_list.size() );
1631 for( FileList::ConstIterator it = file_list.begin(); it!=file_list.end(); ++it )
1632 (*it)->write( stream );
1638 stream >> m_access >> m_static >> m_type >> m_isEnumeratorVariable;
1644 stream << m_access << m_static << m_type << m_isEnumeratorVariable;
1648 m_access = i->m_access;
1649 CodeModelItem::update( i );
1652 bool VariableModel::canUpdate(
const VariableModel* i )
const {
1653 if( !CodeModelItem::canUpdate( i ) )
1655 if( m_access != i->m_access || m_static != i->m_static || m_type != i->m_type || m_isEnumeratorVariable != i->m_isEnumeratorVariable )
1678 return m_enumerators.values();
1683 return m_enumerators.values();
1688 m_enumerators.insert( enumerator->name(), enumerator );
1698 for(
int i=0; i<n; ++i ){
1711 stream << int( enumerator_list.size() );
1712 for( EnumeratorList::ConstIterator it = enumerator_list.begin(); it!=enumerator_list.end(); ++it )
1713 (*it)->write( stream );
1745 m_enumerators.remove( e->name() );
1748 void EnumModel::update(
const EnumModel* i ) {
1749 m_access = i->m_access;
1750 CodeModelItem::update( i );
1754 if( !CodeModelItem::canUpdate( i ) )
1757 if( m_access != i->m_access || m_enumerators.count() != i->m_enumerators.count() )
1793 CodeModelItem::update( i );
1796 bool TypeAliasModel::canUpdate(
const TypeAliasModel* i )
const {
1797 if( !CodeModelItem::canUpdate( i ) )
1799 return m_type == i->m_type;
1802 void FileModel::update(
const FileModel* file ) {
1803 m_parseResult = file->m_parseResult;
1808 if( isSingleGroup( m_groupId ) )
return (
FileList() <<
FileDom(
this) );
1812 TQStringList FileModel::wholeGroupStrings()
const {
1813 if( isSingleGroup( m_groupId ) )
return (TQStringList() <<
name() );
1817 ParseResultPointer FileModel::parseResult()
const {
1818 return m_parseResult;
1821 void FileModel::setParseResult(
const ParseResultPointer& result ) {
1822 m_parseResult = result;
ClassModel(CodeModel *model)
Constructor.
bool hasNamespace(const TQString &name) const
Checks if the namespace referenced by name is in the model.
void setVirtual(bool isVirtual)
Sets the function to be a virtual function.
void removeFunction(FunctionDom fun)
Removes a function from the class model.
virtual void write(TQDataStream &stream) const
Writes an item to the stream.
TQString defaultValue() const
Safe pointer to the EnumeratorModel.
The list of code model arguments.
NamespaceDom namespaceByName(const TQString &name)
Gets the namespace specified by name.
void setDefaultValue(const TQString &defaultValue)
Sets the default value of this argument.
virtual void read(TQDataStream &stream)
Reads an item from the stream.
bool hasTypeAlias(const TQString &name) const
Checks if the type alias specified by name is in the model.
The list of code model enums.
bool addBaseClass(const TQString &baseClass)
Adds a base class to the list of base classes.
virtual void read(TQDataStream &stream)
Reads an item from the stream.
TQStringList baseClassList() const
TypeAliasModel(CodeModel *model)
Constructor.
virtual void write(TQDataStream &stream) const
This function additionally does version-checking and should be used instead of read when read should ...
CodeModelItem(int kind, CodeModel *model)
Constructor.
void setName(const TQString &name)
Sets the name of the item.
void setInline(bool isInline)
Sets the function to be an inline function.
FunctionDefinitionList functionDefinitionByName(const TQString &name)
Gets the list of functions that match the name given by name.
bool addEnum(EnumDom e)
Adds an enum to the model.
FileDom file()
Gets the file of the item.
FileDom fileByName(const TQString &name)
Gets the FileDom object for a file.
virtual void write(TQDataStream &stream) const
Writes an item to the stream.
Code Model - a memory symbol store.
virtual void read(TQDataStream &stream)
Reads an item from the stream.
EnumModel(CodeModel *model)
Constructor.
bool addArgument(ArgumentDom arg)
Adds an argument to the function.
FunctionDefinitionList functionDefinitionList()
void removeFile(FileDom file)
Removes a file from the store.
void addEnumerator(EnumeratorDom e)
Adds an enumerator to the model.
FunctionDefinitionModel(CodeModel *model)
Constructor.
EnumeratorModel(CodeModel *model)
Constructor.
virtual void dump(std::ostream &file, bool recurse=false, TQString Info="")
bool addFunction(FunctionDom fun)
Adds a function to the class model.
void removeClass(ClassDom klass)
Removes a class from the model.
ArgumentList argumentList()
Gets the list of arguments being passed to the function.
TypeAliasList typeAliasList()
TQString fileName() const
virtual void write(TQDataStream &stream) const
Writes an item to the stream.
void setStatic(bool isStatic)
Sets the function to be a static function.
virtual void read(TQDataStream &stream)
Reads an item from the stream.
void removeTypeAlias(TypeAliasDom typeAlias)
Removes a type alias from the model.
void removeEnumerator(EnumeratorDom e)
Removes an enumerator from the model.
virtual void dump(std::ostream &file, bool recurse=false, TQString Info="")
virtual void dump(std::ostream &file, bool recurse=false, TQString Info="")
The dump-function is not ready yet.
virtual void read(TQDataStream &stream)
Reads an item from the stream.
The list of code model namespaces.
NamespaceModel(CodeModel *model)
Constructor.
Safe pointer to the VariableModel.
std::set< NamespaceImportModel > NamespaceImportModelList
I'm using std-sets here, because TQt-3 has no appropriate replacement.
bool addTypeAlias(TypeAliasDom typeAlias)
Adds a type alias to the model.
void wipeout()
Resets the CodeModel.
bool hasFile(const TQString &name) const
Checks to see if a file is in the store.
void setFileName(const TQString &fileName)
Sets the filename of the item.
virtual void read(TQDataStream &stream)
Reads the model from a stream.
void setType(const TQString &type)
Sets the type of an alias.
The list of code model variables.
bool canUpdate(const NamespaceModel *ns) const
bool hasFunction(const TQString &name) const
Check if the function specified by name is in the model.
void setValue(const TQString &value)
Sets the value of an enumerator.
virtual void read(TQDataStream &stream)
Reads an item from the stream.
void removeFunctionDefinition(FunctionDefinitionDom fun)
Removes a function definition from the model.
bool hasClass(const TQString &name) const
Checks if the class specified by name is in this model.
FileList getGroup(int gid) const
Returns all files within the given group it should be preferred calling FileModel::wholeGroup and Fil...
The list of code model function definitions.
Safe pointer to the TypeAliasModel.
ClassList classByName(const TQString &name)
virtual void dump(std::ostream &file, bool recurse=false, TQString Info="")
void update(const NamespaceModel *ns)
Updates this model so it has the same content as the other one.
void setStartPosition(int line, int col)
Sets the start position of the item.
virtual void read(TQDataStream &stream)
Reads an item from the stream.
virtual void read(TQDataStream &stream)
Reads an item from the stream.
virtual void write(TQDataStream &stream) const
Writes an item to the stream.
Safe pointer to the EnumModel.
virtual void dump(std::ostream &file, bool recurse=false, TQString Info="")
void setSlot(bool isSlot)
Sets the function to be a slot.
Enumerator - a member of an Enum (example:
int mergeGroups(int g1, int g2)
Merges two groups, by changing the group-ids of the files.
bool hasVariable(const TQString &name) const
Checks if the variable specified by name is in the model.
virtual void dump(std::ostream &file, bool recurse=false, TQString Info="")
FileList fileList()
Gets the list of files in the store.
virtual TQStringList getGroupStrings(int gid) const
Same as above, but returns the names instead of the objects.
virtual void write(TQDataStream &stream) const
Writes an item to the stream.
VariableModel(CodeModel *model)
Constructor.
virtual void write(TQDataStream &stream) const
Writes an item to the stream.
The list of code model classes.
Function or class method.
virtual void read(TQDataStream &stream)
Reads an item from the stream.
Safe pointer to the ArgumentModel.
void removeEnum(EnumDom e)
Removes an enum from the model.
const NamespaceDom globalNamespace() const
Gets the global namespace.
TypeAliasList typeAliasByName(const TQString &name)
Gets the list of type aliases that match name.
Item in code model (symbol store).
void setStatic(bool isStatic)
Sets the variable to be a static variable.
bool hasEnum(const TQString &name) const
Checks if the enum specified by name is in the model.
void setType(const TQString &type)
Sets the type of this argument.
void getStartPosition(int *line, int *col) const
Gets the start position of the item.
bool addFunctionDefinition(FunctionDefinitionDom fun)
Adds a function definition to the model.
void setEndPosition(int line, int col)
Set the end position of the item.
bool addFile(FileDom file)
Adds a file to the store.
Safe pointer to the FunctionModel.
bool canUpdate(const EnumModel *i) const
virtual void write(TQDataStream &stream) const
Writes an item to the stream.
FunctionModel(CodeModel *model)
Constructor.
A simple class that stores a string together with it's appropriate hash-key.
Safe pointer to the ClassModel.
void removeNamespace(NamespaceDom ns)
Removes the namespace from the model.
Code Model - a memory symbol store.
const NamespaceAliasModelList & namespaceAliases() const
Must not be called on temporary objects because a reference is returned(for performance-reasons) ...
Function or method parameter.
EnumDom enumByName(const TQString &name)
Gets the enum specified by name.
The list of code model files.
void removeVariable(VariableDom var)
Removes a variable from the model.
void setKind(int kind)
Sets the type (kind) of item.
void setAccess(int access)
Sets the access level of the function.
bool hasFunctionDefinition(const TQString &name) const
Checks if the function definition specified by name is in the model.
Safe pointer to the FunctionDefinitionModel.
FunctionList functionByName(const TQString &name)
bool addVariable(VariableDom var)
Adds a variable to the model.
void removeArgument(ArgumentDom arg)
Removes an argument from the function.
T::Ptr create()
Creates a code model item.
void removeBaseClass(const TQString &baseClass)
Removes a base class from the list of base classes.
VariableList variableList()
void setSignal(bool isSignal)
Sets the function to be a signal.
Type alias (aka typedef in c++).
Safe pointer to the FileModel.
VariableDom variableByName(const TQString &name)
Gets the variable specified by name.
The list of code model type aliases.
bool addNamespace(NamespaceDom ns)
Adds a namespace to the model.
TQString resultType() const
void setType(const TQString &type)
Sets the type of the variable.
Function (procedure) argument model.
Safe pointer to the NamespaceModel.
virtual void write(TQDataStream &stream) const
Writes an item to the stream.
EnumeratorList enumeratorList()
virtual void write(TQDataStream &stream) const
Writes the model to a stream.
The list of code model functions.
The list of code model enumerators.
void setAbstract(bool isAbstract)
Sets the function to be an inline function.
bool addClass(ClassDom klass)
Adds a class to the model.
const NamespaceImportModelList & namespaceImports() const
Must not be called on temporary objects because a reference is returned(for performance-reasons) ...
void setResultType(const TQString &type)
Sets the result type of a function.
void setConstant(bool isConstant)
Sets the function to be a constant function.
bool isEnumeratorVariable() const
void setAccess(int access)
Sets the access level of the variable.
virtual void write(TQDataStream &stream) const
Writes an item to the stream.
virtual void read(TQDataStream &stream)
Reads an item from the stream.
virtual void dump(std::ostream &file, TQString Info="")
this will dump the whole tree into dot-file-format so it can be inspected, not ready yet ...
FunctionList functionList()
NamespaceList namespaceList()
void setAccess(int access)
Sets the access level of the enum.
void getEndPosition(int *line, int *col) const
Get the end position of the item.
FileModel(CodeModel *model)
Constructor.