Logo ROOT   6.16/01
Reference Guide
TTabCom.h
Go to the documentation of this file.
1// @(#)root/rint:$Id$
2// Author: Christian Lacunza <lacunza@cdfsg6.lbl.gov> 27/04/99
3
4// Modified by Artur Szostak <artur@alice.phy.uct.ac.za> : 1 June 2003
5// Added support for namespaces.
6
7/*************************************************************************
8 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
9 * All rights reserved. *
10 * *
11 * For the licensing terms see $ROOTSYS/LICENSE. *
12 * For the list of contributors see $ROOTSYS/README/CREDITS. *
13 *************************************************************************/
14
15#ifndef ROOT_TTabCom
16#define ROOT_TTabCom
17
18
19////////////////////////////////////////////////////////////////////////////
20// //
21// TTabCom //
22// //
23// This class performs basic tab completion. //
24// You should be able to hit [TAB] to complete a partially typed: //
25// //
26// username //
27// environment variable //
28// preprocessor directive //
29// pragma //
30// filename (with a context-sensitive path) //
31// public member function or data member //
32// global variable, function, or class name //
33// //
34// Also, something like gWhatever->Func([TAB] will print the appropriate //
35// list of prototypes. For a list of some limitations see the source. //
36// //
37////////////////////////////////////////////////////////////////////////////
38
39#include "TObjString.h"
40#include "TRegexp.h"
41
42
43#define MAX_LEN_PAT 1024 // maximum length of a pattern
44#define dblquote(x) "\"" << x << "\""
45
46// forward declarations
47class TList;
48class TListIter;
49class TSeqCollection;
50class TClass;
51
52
53class TTabCom {
54
55public: // constructors
56 TTabCom();
57 virtual ~TTabCom();
58
59public: // typedefs
62
63public: // member functions
64 Int_t Hook(char *buf, int *pLoc, std::ostream& out);
65
68 const TSeqCollection* GetListOfFilesInPath( const char path[] );
75
76 void ClearClasses();
77 void ClearCppDirectives();
78 void ClearEnvVars();
79 void ClearFiles();
81 void ClearGlobals();
82 void ClearPragmas();
83 void ClearSysIncFiles();
84 void ClearUsers();
85
86 void ClearAll();
87
88 void RehashClasses();
90 void RehashEnvVars();
91 void RehashFiles();
93 void RehashGlobals();
94 void RehashPragmas();
95 void RehashSysIncFiles();
96 void RehashUsers();
97
98 void RehashAll();
99
100public: // static utility functions
101 static Char_t AllAgreeOnChar( int i, const TSeqCollection* pList, Int_t& nGoodStrings );
102 static void AppendListOfFilesInDirectory( const char dirName[], TSeqCollection* pList );
103 static TString DetermineClass( const char varName[] ); // TROOT
105 static TString GetSysIncludePath(); // TROOT
106 static Bool_t IsDirectory( const char fileName[] ); // TSystem
107 static TSeqCollection* NewListOfFilesInPath( const char path[] );
108 static Bool_t PathIsSpecifiedInFileName( const TString& fileName );
109 static void NoMsg( Int_t errorLevel );
110
111public: // enums
112 enum {kDebug = 17}; // set gDebug==TTabCom::kDebug for debugging output
113
116 // first enum (not counting "kUNKNOWN_CONTEXT") must
117 // cast to zero because these enums will be used to
118 // index arrays of size "kNUM_PAT"
119 // ---------------
120
121 // user names and environment variables should come first
123 kSYS_EnvVar, // environment variables
124
125 // file descriptor redirection should almost come first
126 kCINT_stdout, // stdout
127 kCINT_stderr, // stderr
128 kCINT_stdin, // stdin
129
130 // CINT "." instructions
131 // the position of these guys is irrelevant since each of
132 // these commands will always be the only command on the line.
137
138 // specific preprocessor directives.
140 kCINT_includeSYS, // system files
141 kCINT_includePWD, // local files
142
143 // specific preprocessor directives
144 // must come before general preprocessor directives
145
146 // general preprocessor directives
147 // must come after specific preprocessor directives
149
150 // specific member accessing
151 // should come before general member accessing
153
154 // random files
155 /******************************************************************/
156 /* */
157 /* file names should come before member accessing */
158 /* */
159 /* (because otherwise "/tmp/a.cc" might look like you're trying */
160 /* to access member "cc" of some object "a") */
161 /* */
162 /* but after anything that requires a specific path. */
163 /* */
164 /******************************************************************/
166
167 // time to print prototype
168 kCXX_NewProto, // kCXX_NewProto must come before kCXX_ConstructorProto
169 kCXX_ConstructorProto, // kCXX_ConstructorProto this must come before kCXX_GlobalProto
173
174 // general member access
175 // should come after specific member access
179
180 // arbitrary global identifiers
181 // should really come last
184
185
186 // ------- make additions above this line ---------
187 kNUM_PAT // kNUM_PAT must be last. (to fix array size)
188 };
189
190private: // member functions
191 TTabCom(const TTabCom &); //private and not implemented
192 TTabCom& operator=(const TTabCom&); //private and not implemented
193
194 Int_t Complete(const TRegexp& re, const TSeqCollection* pListOfCandidates,
195 const char appendage[], std::ostream& out, TString::ECaseCompare cmp = TString::kExact);
196 void CopyMatch( char dest[], const char localName[], const char appendage[]=0, const char fullName[]=0 ) const;
198 TString DeterminePath( const TString& fileName, const char defaultPath[] ) const;
199 TString ExtendPath( const char originalPath[], TString newBase ) const;
200 void InitPatterns();
201 TClass* MakeClassFromClassName( const char className[] ) const;
202 TClass* TryMakeClassFromClassName( const char className[] ) const;
203 TClass* MakeClassFromVarName( const char varName[], EContext_t& context,
204 int iter=0);
205 void SetPattern( EContext_t handle, const char regexp[] );
206 int ParseReverse(const char *var_str, int start);
207
208private: // data members
218
219 char* fBuf; // initialized by Hook()
220 int* fpLoc; // initialized by Hook()
221
222 Pattern_t fPat[ kNUM_PAT ][ MAX_LEN_PAT ]; // array of patterns
223 const char* fRegExp[ kNUM_PAT ]; // corresponding regular expression plain text
224 Bool_t fVarIsPointer; // frodo: pointer or not flag
225 Int_t fLastIter; // frodo: iteration counter for recursive MakeClassFromVarName
226
227 ClassDef(TTabCom,0) //Perform command line completion when hitting <TAB>
228};
229
231
232#endif
#define R__EXTERN
Definition: DllImport.h:27
unsigned short Pattern_t
Definition: Match.h:26
int Int_t
Definition: RtypesCore.h:41
char Char_t
Definition: RtypesCore.h:29
bool Bool_t
Definition: RtypesCore.h:59
unsigned long long ULong64_t
Definition: RtypesCore.h:70
#define ClassDef(name, id)
Definition: Rtypes.h:324
R__EXTERN TTabCom * gTabCom
Definition: TTabCom.h:230
#define MAX_LEN_PAT
Definition: TTabCom.h:43
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:75
Collection abstract base class.
Definition: TCollection.h:63
Iterator of linked list.
Definition: TList.h:200
A doubly linked list.
Definition: TList.h:44
Regular expression class.
Definition: TRegexp.h:31
Sequenceable collection abstract base class.
Basic string class.
Definition: TString.h:131
ECaseCompare
Definition: TString.h:263
@ kExact
Definition: TString.h:263
static void NoMsg(Int_t errorLevel)
[static utility function]/////////////////////////////
Definition: TTabCom.cxx:1099
const TSeqCollection * GetListOfCppDirectives()
Return the list of CPP directives.
Definition: TTabCom.cxx:473
Int_t Hook(char *buf, int *pLoc, std::ostream &out)
[private]
Definition: TTabCom.cxx:1557
TSeqCollection * fpGlobals
Definition: TTabCom.h:214
ULong64_t fPrevInterpMarker
Definition: TTabCom.h:210
void ClearFiles()
Close all files.
Definition: TTabCom.cxx:250
static TString DetermineClass(const char varName[])
[static utility function]/////////////////////////////
Definition: TTabCom.cxx:790
static Bool_t ExcludedByFignore(TString s)
[static utility function]/////////////////////////////
Definition: TTabCom.cxx:883
void InitPatterns()
[private]
Definition: TTabCom.cxx:2129
void RehashEnvVars()
Environemnt variables rehashing.
Definition: TTabCom.cxx:349
const TSeqCollection * GetListOfSysIncFiles()
Return the list of system include files.
Definition: TTabCom.cxx:618
void ClearAll()
clears all lists except for user names and system include files.
Definition: TTabCom.cxx:315
TSeqCollection * fpDirectives
Definition: TTabCom.h:211
const TSeqCollection * GetListOfFilesInPath(const char path[])
"path" should be initialized with a colon separated list of system directories
Definition: TTabCom.cxx:499
TSeqCollection * fpClasses
Definition: TTabCom.h:209
TSeqCollection * fpEnvVars
Definition: TTabCom.h:212
void ClearSysIncFiles()
Close system files.
Definition: TTabCom.cxx:290
const TSeqCollection * GetListOfEnvVars()
Uses "env" (Unix) or "set" (Windows) to get list of environment variables.
Definition: TTabCom.cxx:518
int * fpLoc
Definition: TTabCom.h:220
TString DeterminePath(const TString &fileName, const char defaultPath[]) const
[private]
Definition: TTabCom.cxx:1481
void CopyMatch(char dest[], const char localName[], const char appendage[]=0, const char fullName[]=0) const
[private]
Definition: TTabCom.cxx:1405
const TSeqCollection * GetListOfPragmas()
Return the list of pragmas.
Definition: TTabCom.cxx:587
char * fBuf
Definition: TTabCom.h:219
static TSeqCollection * NewListOfFilesInPath(const char path[])
[static utility function]/////////////////////////////
Definition: TTabCom.cxx:1040
TClass * MakeClassFromVarName(const char varName[], EContext_t &context, int iter=0)
private returns a new'd TClass given the name of a variable.
Definition: TTabCom.cxx:2245
Int_t fLastIter
Definition: TTabCom.h:225
const TSeqCollection * GetListOfGlobals()
Return the list of globals.
Definition: TTabCom.cxx:571
Pattern_t fPat[kNUM_PAT][MAX_LEN_PAT]
Definition: TTabCom.h:222
void SetPattern(EContext_t handle, const char regexp[])
[private]
Definition: TTabCom.cxx:2533
TSeqCollection * fpUsers
Definition: TTabCom.h:217
TSeqCollection * fpSysIncFiles
Definition: TTabCom.h:216
TSeqCollection * fpFiles
Definition: TTabCom.h:213
void RehashGlobals()
Reload globals.
Definition: TTabCom.cxx:374
TClass * MakeClassFromClassName(const char className[]) const
private returns a new'd TClass given the name of a class.
Definition: TTabCom.cxx:2196
void RehashGlobalFunctions()
Reload global functions.
Definition: TTabCom.cxx:366
void ClearGlobalFunctions()
Forget all global functions seen so far.
Definition: TTabCom.cxx:263
void ClearPragmas()
Forget all pragmas seen so far.
Definition: TTabCom.cxx:278
static Bool_t PathIsSpecifiedInFileName(const TString &fileName)
[static utility function]/////////////////////////////
Definition: TTabCom.cxx:1079
TString ExtendPath(const char originalPath[], TString newBase) const
[private]
Definition: TTabCom.cxx:1525
TTabCom()
Default constructor.
Definition: TTabCom.cxx:173
TTabCom(const TTabCom &)
void RehashPragmas()
Reload pragmas.
Definition: TTabCom.cxx:383
const TSeqCollection * GetListOfClasses()
Return the list of classes.
Definition: TTabCom.cxx:427
void RehashCppDirectives()
Cpp rehashing.
Definition: TTabCom.cxx:340
void RehashUsers()
Reload users.
Definition: TTabCom.cxx:401
const TSeqCollection * GetListOfUsers()
reads from "/etc/passwd"
Definition: TTabCom.cxx:630
static void AppendListOfFilesInDirectory(const char dirName[], TSeqCollection *pList)
[static utility function]/////////////////////////////
Definition: TTabCom.cxx:741
void ClearClasses()
Clear classes and namespace collections.
Definition: TTabCom.cxx:214
TSeqCollection * fpPragmas
Definition: TTabCom.h:215
EContext_t
Definition: TTabCom.h:114
@ kCXX_Global
Definition: TTabCom.h:182
@ kSYS_UserName
Definition: TTabCom.h:122
@ kNUM_PAT
Definition: TTabCom.h:187
@ kUNKNOWN_CONTEXT
Definition: TTabCom.h:115
@ kCXX_IndirectProto
Definition: TTabCom.h:172
@ kCXX_IndirectMember
Definition: TTabCom.h:178
@ kCINT_Exec
Definition: TTabCom.h:135
@ kCXX_ScopeProto
Definition: TTabCom.h:170
@ kCINT_cpp
Definition: TTabCom.h:148
@ kSYS_EnvVar
Definition: TTabCom.h:123
@ kCXX_ScopeMember
Definition: TTabCom.h:176
@ kCXX_GlobalProto
Definition: TTabCom.h:183
@ kSYS_FileName
Definition: TTabCom.h:165
@ kCXX_DirectMember
Definition: TTabCom.h:177
@ kCINT_includeSYS
Definition: TTabCom.h:140
@ kCINT_Load
Definition: TTabCom.h:134
@ kCXX_ConstructorProto
Definition: TTabCom.h:169
@ kCINT_pragma
Definition: TTabCom.h:139
@ kCINT_includePWD
Definition: TTabCom.h:141
@ kCXX_DirectProto
Definition: TTabCom.h:171
@ kCINT_Edit
Definition: TTabCom.h:133
@ kCXX_NewProto
Definition: TTabCom.h:168
@ kCINT_stdin
Definition: TTabCom.h:128
@ kROOT_Load
Definition: TTabCom.h:152
@ kCINT_stdout
Definition: TTabCom.h:126
@ kCINT_stderr
Definition: TTabCom.h:127
@ kCINT_EXec
Definition: TTabCom.h:136
Int_t Complete(const TRegexp &re, const TSeqCollection *pListOfCandidates, const char appendage[], std::ostream &out, TString::ECaseCompare cmp=TString::kExact)
[private]
Definition: TTabCom.cxx:1154
const char * fRegExp[kNUM_PAT]
Definition: TTabCom.h:223
int ParseReverse(const char *var_str, int start)
Returns the place in the string where to put the \0, starting the search from "start".
Definition: TTabCom.cxx:2555
virtual ~TTabCom()
Definition: TTabCom.cxx:196
TTabCom & operator=(const TTabCom &)
TCollection * GetListOfGlobalFunctions()
Return the list of global functions.
Definition: TTabCom.cxx:579
void RehashSysIncFiles()
Reload system include files.
Definition: TTabCom.cxx:392
static Bool_t IsDirectory(const char fileName[])
[static utility function]/////////////////////////////
Definition: TTabCom.cxx:1020
EContext_t DetermineContext() const
[private]
Definition: TTabCom.cxx:1457
static TString GetSysIncludePath()
[static utility function]/////////////////////////////
Definition: TTabCom.cxx:919
void ClearEnvVars()
Forget all environment variables seen so far.
Definition: TTabCom.cxx:238
void ClearCppDirectives()
Forget all Cpp directives seen so far.
Definition: TTabCom.cxx:226
void ClearGlobals()
Forget all global variables seen so far.
Definition: TTabCom.cxx:271
void ClearUsers()
Forget all user seen so far.
Definition: TTabCom.cxx:302
TList TContainer
Definition: TTabCom.h:60
void RehashAll()
clears and then rebuilds all lists except for user names and system include files.
Definition: TTabCom.cxx:411
void RehashFiles()
Close files.
Definition: TTabCom.cxx:358
TClass * TryMakeClassFromClassName(const char className[]) const
Same as above but does not print the error message.
Definition: TTabCom.cxx:2225
void RehashClasses()
Do the class rehash.
Definition: TTabCom.cxx:331
@ kDebug
Definition: TTabCom.h:112
TListIter TContIter
Definition: TTabCom.h:61
static Char_t AllAgreeOnChar(int i, const TSeqCollection *pList, Int_t &nGoodStrings)
[static utility function]///////////////////////////////////////////
Definition: TTabCom.cxx:676
Bool_t fVarIsPointer
Definition: TTabCom.h:224
static constexpr double s
#define dest(otri, vertexptr)
Definition: triangle.c:1040