1 #ifndef ctags_cxx_scope_h_ 2 #define ctags_cxx_scope_h_ 3 /* 4 * Copyright (c) 2016, Szymon Tomasz Stefanek 5 * 6 * This source code is released for free distribution under the terms of the 7 * GNU General Public License version 2 or (at your option) any later version. 8 * 9 * This module contains functions for parsing and scanning C++ source files 10 */ 11 12 #include "general.h" 13 14 #include "cxx_token.h" 15 16 enum CXXScopeAccess 17 { 18 CXXScopeAccessUnknown, 19 CXXScopeAccessPublic, 20 CXXScopeAccessPrivate, 21 CXXScopeAccessProtected 22 }; 23 24 enum CXXScopeType 25 { 26 CXXScopeTypeFunction, 27 CXXScopeTypeNamespace, 28 CXXScopeTypeClass, 29 CXXScopeTypeEnum, 30 CXXScopeTypeUnion, 31 CXXScopeTypeStruct, 32 CXXScopeTypeVariable, // template variables, mainly 33 CXXScopeTypePrototype, 34 CXXScopeTypeTypedef, // template variables used in "using A = B<T>" 35 CXXScopeTypeLAST 36 }; 37 38 void cxxScopeInit(void); 39 void cxxScopeDone(void); 40 void cxxScopeClear(void); 41 42 // Returns the full current scope name or NULL if there 43 // is no scope currently. 44 const char * cxxScopeGetFullName(void); 45 46 // Returns the current scope name of NULL if there is no 47 // scope currently. This name does not include namespaces so 48 // it is always a single identifier. 49 const char * cxxScopeGetName(void); 50 51 // Return the number of components of the scope name. 52 int cxxScopeGetSize(void); 53 54 // Returns the current scope name or NULL if there is no scope 55 // currently. Ownership of the string is transferred. 56 vString * cxxScopeGetFullNameAsString(void); 57 58 // Returns the current scope name with the exception of the 59 // last component or NULL if there is either no scope or there 60 // are less than two components. Ownership of the string is transferred. 61 vString * cxxScopeGetFullNameExceptLastComponentAsString(void); 62 63 enum CXXScopeType cxxScopeGetType(void); 64 // Returns the current scope kind 65 unsigned int cxxScopeGetKind(void); 66 unsigned int cxxScopeGetVariableKind(void); 67 enum CXXScopeAccess cxxScopeGetAccess(void); 68 // Are we in global scope? 69 bool cxxScopeIsGlobal(void); 70 71 // Add a token to the scope chain. The token ownership is transferred. 72 void cxxScopePush( 73 CXXToken * t, 74 enum CXXScopeType eScopeType, 75 enum CXXScopeAccess eInitialAccess 76 ); 77 void cxxScopeSetAccess(enum CXXScopeAccess eAccess); 78 // Remove the last token from the scope chain 79 void cxxScopePop(void); 80 81 // Special management: pop one scope level but keep it so it can be pushed back 82 CXXToken * cxxScopeTakeTop(void); 83 // Special management: push back a scope taken earlier via cxxScopeTakeTop() 84 void cxxScopePushTop(CXXToken * t); 85 86 #endif //!ctags_cxx_scope_h_ 87