31 #include <tqstringlist.h> 32 #include <ksharedptr.h> 33 #include <tqvaluevector.h> 34 #include "hashedstring.h" 46 class AbstractParseResult :
public TDEShared {
48 virtual void read( TQDataStream& stream ) = 0;
50 virtual void write( TQDataStream& stream )
const = 0;
52 virtual ParsedFileType type()
const = 0;
55 typedef TDESharedPtr<AbstractParseResult> ParseResultPointer;
78 typedef TDESharedPtr<CodeModelItem>
ItemDom;
86 typedef TDESharedPtr<FileModel>
FileDom;
102 typedef TDESharedPtr<ClassModel>
ClassDom;
142 typedef TDESharedPtr<EnumModel>
EnumDom;
166 typedef TQValueList<ItemDom>
ItemList;
174 typedef TQValueList<FileDom>
FileList;
230 typedef TQValueList<EnumDom>
EnumList;
257 template <
class ItemList>
260 TQStringList nameList;
262 typename ItemList::ConstIterator it = lst.begin();
263 while( it != lst.end() ){
264 if( !(*it)->name().isEmpty() )
265 nameList << (*it)->name();
284 template <
class Result,
class T>
287 Result r( static_cast<T*>(x) );
302 template <
class Result,
class T>
305 Result r( static_cast<T*>(x) );
343 template <
class T>
typename T::Ptr
create()
345 typename T::Ptr ptr(
new T(
this) );
363 bool hasFile(
const TQString& name )
const;
367 FileDom fileByName(
const TQString& name );
372 const FileDom fileByName(
const TQString& name )
const;
381 void removeFile(
FileDom file );
394 virtual void read( TQDataStream& stream );
401 virtual void write( TQDataStream& stream )
const;
404 virtual void dump( std::ostream& file, TQString Info=
"" );
410 int mergeGroups(
int g1,
int g2 );
421 virtual TQStringList getGroupStrings(
int gid )
const;
435 TQMap<TQString, FileDom> m_files;
438 virtual int newGroupId();
442 int m_currentGroupId;
446 void operator = (
const CodeModel& source );
506 int kind()
const {
return m_kind; }
513 TQString name()
const;
515 TQString comment()
const {
519 void setComment( TQString comment ) {
525 void setName(
const TQString& name );
537 TQString fileName()
const;
541 void setFileName(
const TQString& fileName );
546 void getStartPosition(
int* line,
int* col )
const;
551 void setStartPosition(
int line,
int col );
556 void getEndPosition(
int* line,
int* col )
const;
561 void setEndPosition(
int line,
int col );
564 virtual bool isFile()
const {
return false; }
568 virtual bool isClass()
const {
return false; }
578 virtual bool isEnum()
const {
return false; }
586 virtual bool isTemplateable()
const {
return false; }
590 virtual void read( TQDataStream& stream );
593 virtual void write( TQDataStream& stream )
const;
595 virtual void dump( std::ostream& file,
bool recurse=
false, TQString Info=
"" );
610 int m_startLine, m_startColumn;
611 int m_endLine, m_endColumn;
620 class TemplateModelItem {
622 typedef TQPair< TQString, TQString > ParamPair;
623 typedef TQValueVector< ParamPair > ParamMap;
625 virtual const ParamMap& getTemplateParams() {
629 virtual void addTemplateParam( TQString name, TQString def =
"" ) {
630 m_params.push_back( ParamPair( name, def ) );
633 virtual void clearTemplateParams() {
637 bool hasSpecializationDeclaration()
const {
638 return !m_specialization.isEmpty();
641 virtual TQString getSpecializationDeclaration()
const {
642 return m_specialization;
645 void setSpecializationDeclaration(
const TQString& str ) {
646 m_specialization = str;
650 virtual int findTemplateParam(
const TQString& name )
const {
651 for(
unsigned int a = 0; a< m_params.size(); a++)
652 if( m_params[a].first == name )
return a;
656 const ParamPair getParam(
int index )
const {
657 return m_params[index];
660 virtual bool isTemplateable()
const {
return true; }
662 void write( TQDataStream & stream )
const {
663 stream << m_specialization;
664 stream << (int)m_params.size();
665 for( ParamMap::const_iterator it = m_params.begin(); it != m_params.end(); ++it ) {
666 stream << (*it).first;
667 stream << (*it).second;
671 void read( TQDataStream & stream ) {
673 stream >> m_specialization;
675 for(
int a = 0; a < count; a++ ) {
678 stream >> tmp.second;
679 m_params.push_back( tmp );
685 TQString m_specialization;
710 TQStringList
scope()
const {
return m_scope; }
713 void setScope(
const TQStringList& scope ) { m_scope = scope; }
716 TQStringList baseClassList()
const;
720 bool addBaseClass(
const TQString& baseClass );
724 void removeBaseClass(
const TQString& baseClass );
736 bool hasClass(
const TQString& name )
const;
740 ClassList classByName(
const TQString& name );
745 const ClassList classByName(
const TQString& name )
const;
766 bool hasFunction(
const TQString& name )
const;
775 const FunctionList functionByName(
const TQString& name )
const;
796 bool hasFunctionDefinition(
const TQString& name )
const;
830 bool hasVariable(
const TQString& name )
const;
836 VariableDom variableByName(
const TQString& name );
843 const VariableDom variableByName(
const TQString& name )
const;
864 bool hasTypeAlias(
const TQString& name )
const;
877 const TypeAliasList typeAliasByName(
const TQString& name )
const;
898 bool hasEnum(
const TQString& name )
const;
904 EnumDom enumByName(
const TQString& name );
910 const EnumDom enumByName(
const TQString& name )
const;
924 virtual void read( TQDataStream& stream );
925 virtual void write( TQDataStream& stream )
const;
927 virtual void dump( std::ostream& file,
bool recurse=
false, TQString Info=
"" );
930 TQStringList m_scope;
931 TQStringList m_baseClassList;
932 TQMap<TQString, ClassList> m_classes;
933 TQMap<TQString, FunctionList> m_functions;
934 TQMap<TQString, FunctionDefinitionList> m_functionDefinitions;
935 TQMap<TQString, VariableDom> m_variables;
936 TQMap<TQString, TypeAliasList> m_typeAliases;
937 TQMap<TQString, EnumDom> m_enumerators;
945 class NamespaceAliasModel {
947 virtual void read( TQDataStream& stream );
948 virtual void write( TQDataStream& stream )
const;
950 TQString name()
const {
954 void setName(
const TQString& name ) {
958 void setAliasName(
const TQString& theValue ) {
959 m_aliasName = theValue;
962 TQString aliasName()
const {
967 m_fileName = theValue;
974 bool operator < (
const NamespaceAliasModel& rhs )
const {
975 if( m_name < rhs.m_name )
return true;
976 if( m_name == rhs.m_name ) {
977 if( m_aliasName < rhs.m_aliasName )
return true;
978 if( m_aliasName == rhs.m_aliasName && m_fileName < rhs.m_fileName )
return true;
983 bool operator == (
const NamespaceAliasModel& rhs )
const {
984 return m_name == rhs.m_name && m_aliasName == rhs.m_aliasName && m_fileName == rhs.m_fileName;
989 TQString m_aliasName;
993 class NamespaceImportModel {
995 virtual void read( TQDataStream& stream );
996 virtual void write( TQDataStream& stream )
const;
998 TQString name()
const {
1006 void setName(
const TQString& name ) {
1014 bool operator < (
const NamespaceImportModel& rhs )
const {
1015 if( m_name < rhs.m_name )
return true;
1016 if( m_name == rhs.m_name )
1017 if( m_fileName < rhs.m_fileName )
return true;
1022 bool operator == (
const NamespaceImportModel& rhs )
const {
1023 return m_name == rhs.m_name && m_fileName == rhs.m_fileName;
1047 typedef std::set<NamespaceAliasModel> NamespaceAliasModelList;
1066 bool hasNamespace(
const TQString& name )
const;
1079 const NamespaceDom namespaceByName(
const TQString& name )
const;
1096 virtual void read( TQDataStream& stream );
1097 virtual void write( TQDataStream& stream )
const;
1099 virtual void dump( std::ostream& file,
bool recurse=
false, TQString Info=
"" );
1101 void addNamespaceImport(
const NamespaceImportModel&
import );
1102 void addNamespaceAlias(
const NamespaceAliasModel& alias );
1103 void removeNamespaceImport(
const NamespaceImportModel&
import );
1104 void removeNamespaceAlias(
const NamespaceAliasModel& alias );
1108 return m_namespaceAliases;
1113 return m_namespaceImports;
1116 TQMap<TQString, NamespaceDom> m_namespaces;
1117 NamespaceAliasModelList m_namespaceAliases;
1118 NamespaceImportModelList m_namespaceImports;
1151 virtual int groupId()
const {
1155 virtual void setGroupId(
int newId) {
1164 virtual void write( TQDataStream& stream )
const;
1168 TQStringList wholeGroupStrings()
const;
1170 virtual void read( TQDataStream& stream );
1172 ParseResultPointer parseResult()
const;
1173 void setParseResult(
const ParseResultPointer& result );
1178 ParseResultPointer m_parseResult;
1203 TQString type()
const;
1207 void setType(
const TQString& type );
1210 TQString defaultValue()
const;
1214 void setDefaultValue(
const TQString& defaultValue );
1216 virtual void read( TQDataStream& stream );
1217 virtual void write( TQDataStream& stream )
const;
1219 virtual void dump( std::ostream& file,
bool recurse=
false, TQString Info=
"" );
1223 TQString m_defaultValue;
1260 TQStringList
scope()
const {
return m_scope; }
1264 void setScope(
const TQStringList& scope ) { m_scope = scope; }
1273 void setAccess(
int access );
1276 bool isSignal()
const;
1279 void setSignal(
bool isSignal );
1282 bool isSlot()
const;
1285 void setSlot(
bool isSlot );
1288 bool isVirtual()
const;
1291 void setVirtual(
bool isVirtual );
1294 bool isStatic()
const;
1297 void setStatic(
bool isStatic );
1300 bool isInline()
const;
1303 void setInline(
bool isInline );
1306 bool isConstant()
const;
1309 void setConstant(
bool isConstant );
1312 bool isAbstract()
const;
1315 void setAbstract(
bool isAbstract );
1318 TQString resultType()
const;
1321 void setResultType(
const TQString& type );
1343 virtual void read( TQDataStream& stream );
1344 virtual void write( TQDataStream& stream )
const;
1346 virtual void dump( std::ostream& file,
bool recurse=
false, TQString Info=
"" );
1352 TQStringList m_scope;
1368 TQString m_resultType;
1428 void setAccess(
int access );
1431 bool isStatic()
const;
1434 void setStatic(
bool isStatic );
1437 TQString type()
const;
1440 void setType(
const TQString& type );
1443 bool isEnumeratorVariable()
const;
1445 void setEnumeratorVariable(
bool b );
1447 virtual void read( TQDataStream& stream );
1448 virtual void write( TQDataStream& stream )
const;
1450 virtual void dump( std::ostream& file,
bool recurse=
false, TQString Info=
"" );
1459 int m_isEnumeratorVariable;
1492 void setAccess(
int access );
1506 virtual void read( TQDataStream& stream );
1507 virtual void write( TQDataStream& stream )
const;
1510 virtual void dump( std::ostream& file,
bool recurse=
false, TQString Info=
"" );
1513 bool canUpdate(
const EnumModel* i )
const;
1517 TQMap<TQString, EnumeratorDom> m_enumerators;
1521 void operator = (
const EnumModel& source );
1551 TQString value()
const;
1554 void setValue(
const TQString& value );
1556 virtual void read( TQDataStream& stream );
1557 virtual void write( TQDataStream& stream )
const;
1559 virtual void dump( std::ostream& file,
bool recurse=
false, TQString Info=
"" );
1589 TQString type()
const;
1592 void setType(
const TQString& type );
1594 virtual void read( TQDataStream& stream );
1595 virtual void write( TQDataStream& stream )
const;
1598 virtual void dump( std::ostream& file,
bool recurse=
false, TQString Info=
"" );
Safe pointer to the EnumeratorModel.
The list of code model arguments.
virtual bool isClass() const
The list of code model enums.
virtual bool isFunctionDefinition() const
void setScope(const TQStringList &scope)
Sets the scope of the function.
virtual bool isClass() const
EnumeratorDom Ptr
A definition of safe pointer to the enumerator model.
virtual bool isEnumerator() const
virtual bool isArgument() const
virtual bool isFunction() const
virtual bool isEnumerator() const
FileDom Ptr
A definition of safe pointer to the file model.
TQStringList scope() const
TQStringList scope() const
Result model_cast(TDESharedPtr< T > x)
Casts safe code model pointers (TDESharedPtr<T> objects like FileDom, NamespaceDom, etc.) to the Result type.
The list of code model namespaces.
virtual bool isFunctionDefinition() const
Safe pointer to the VariableModel.
std::set< NamespaceImportModel > NamespaceImportModelList
I'm using std-sets here, because TQt-3 has no appropriate replacement.
Kind
A type of a code model item.
The list of code model variables.
virtual bool isFile() const
void setScope(const TQStringList &scope)
Sets the scope of this class.
The list of code model function definitions.
Safe pointer to the TypeAliasModel.
TQStringList sortedNameList(const ItemList &lst)
Iterates through lst and creates sorted list of code model item names.
Safe pointer to the EnumModel.
Safe pointer to the CodeModelItem.
virtual bool isFile() const
The list of code model classes.
Function or class method.
ArgumentDom Ptr
A definition of safe pointer to the argument model.
Safe pointer to the ArgumentModel.
Item in code model (symbol store).
virtual bool isTypeAlias() const
NamespaceDom Ptr
A definition of safe pointer to the namespace model.
virtual bool isVariable() const
Safe pointer to the FunctionModel.
virtual bool isClass() const
Access
An access to the code model item.
A simple class that stores a string together with it's appropriate hash-key.
virtual bool isNamespace() const
virtual bool isCustom() const
Safe pointer to the ClassModel.
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.
The list of code model files.
ClassDom Ptr
A definition of safe pointer to the class model.
void setKind(int kind)
Sets the type (kind) of item.
FunctionDefinitionDom Ptr
A definition of safe pointer to the function definition model.
FunctionDom Ptr
A definition of safe pointer to the function model.
Safe pointer to the FunctionDefinitionModel.
virtual bool isEnum() const
T::Ptr create()
Creates a code model item.
Type alias (aka typedef in c++).
Safe pointer to the FileModel.
The list of code model type aliases.
virtual bool isVariable() const
virtual bool isArgument() const
virtual bool isFunction() const
The list of code model items.
VariableDom Ptr
A definition of safe pointer to the variable model.
TypeAliasDom Ptr
A definition of safe pointer to the type alias model.
Function (procedure) argument model.
Safe pointer to the NamespaceModel.
virtual bool isEnum() const
EnumDom Ptr
A definition of safe pointer to the enum model.
The list of code model functions.
The list of code model enumerators.
const CodeModel * codeModel() const
const NamespaceImportModelList & namespaceImports() const
Must not be called on temporary objects because a reference is returned(for performance-reasons) ...
virtual bool isTypeAlias() const
virtual bool isNamespace() const
ItemDom Ptr
A definition of safe pointer to the code model item.