Logo ROOT  
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 "TString.h"
40#include "TRegexp.h"
41
42#define MAX_LEN_PAT 1024 // maximum length of a pattern
43#define dblquote(x) "\"" << x << "\""
44
45// forward declarations
46class TList;
47class TListIter;
48class TSeqCollection;
49class TClass;
50
51
52class TTabCom {
53
54public: // constructors
55 TTabCom();
56 virtual ~TTabCom();
57
58public: // typedefs
61
62public: // member functions
63 Int_t Hook(char *buf, int *pLoc, std::ostream& out);
64
67 const TSeqCollection* GetListOfFilesInPath( const char path[] );
74
75 void ClearClasses();
76 void ClearCppDirectives();
77 void ClearEnvVars();
78 void ClearFiles();
80 void ClearGlobals();
81 void ClearPragmas();
82 void ClearSysIncFiles();
83 void ClearUsers();
84
85 void ClearAll();
86
87 void RehashClasses();
89 void RehashEnvVars();
90 void RehashFiles();
92 void RehashGlobals();
93 void RehashPragmas();
94 void RehashSysIncFiles();
95 void RehashUsers();
96
97 void RehashAll();
98
99public: // static utility functions
100 static Char_t AllAgreeOnChar( int i, const TSeqCollection* pList, Int_t& nGoodStrings );
101 static void AppendListOfFilesInDirectory( const char dirName[], TSeqCollection* pList );
102 static TString DetermineClass( const char varName[] ); // TROOT
104 static TString GetSysIncludePath(); // TROOT
105 static Bool_t IsDirectory( const char fileName[] ); // TSystem
106 static TSeqCollection* NewListOfFilesInPath( const char path[] );
107 static Bool_t PathIsSpecifiedInFileName( const TString& fileName );
108 static void NoMsg( Int_t errorLevel );
109
110public: // enums
111 enum {kDebug = 17}; // set gDebug==TTabCom::kDebug for debugging output
112
115 // first enum (not counting "kUNKNOWN_CONTEXT") must
116 // cast to zero because these enums will be used to
117 // index arrays of size "kNUM_PAT"
118 // ---------------
119
120 // user names and environment variables should come first
122 kSYS_EnvVar, // environment variables
123
124 // file descriptor redirection should almost come first
125 kCINT_stdout, // stdout
126 kCINT_stderr, // stderr
127 kCINT_stdin, // stdin
128
129 // CINT "." instructions
130 // the position of these guys is irrelevant since each of
131 // these commands will always be the only command on the line.
136
137 // specific preprocessor directives.
139 kCINT_includeSYS, // system files
140 kCINT_includePWD, // local files
141
142 // specific preprocessor directives
143 // must come before general preprocessor directives
144
145 // general preprocessor directives
146 // must come after specific preprocessor directives
148
149 // specific member accessing
150 // should come before general member accessing
152
153 // random files
154 /******************************************************************/
155 /* */
156 /* file names should come before member accessing */
157 /* */
158 /* (because otherwise "/tmp/a.cc" might look like you're trying */
159 /* to access member "cc" of some object "a") */
160 /* */
161 /* but after anything that requires a specific path. */
162 /* */
163 /******************************************************************/
165
166 // time to print prototype
167 kCXX_NewProto, // kCXX_NewProto must come before kCXX_ConstructorProto
168 kCXX_ConstructorProto, // kCXX_ConstructorProto this must come before kCXX_GlobalProto
172
173 // general member access
174 // should come after specific member access
178
179 // arbitrary global identifiers
180 // should really come last
183
184
185 // ------- make additions above this line ---------
186 kNUM_PAT // kNUM_PAT must be last. (to fix array size)
187 };
188
189private: // member functions
190 TTabCom(const TTabCom &); //private and not implemented
191 TTabCom& operator=(const TTabCom&); //private and not implemented
192
193 Int_t Complete(const TRegexp& re, const TSeqCollection* pListOfCandidates,
194 const char appendage[], std::ostream& out, TString::ECaseCompare cmp = TString::kExact);
195 void CopyMatch( char dest[], const char localName[], const char appendage[]=0, const char fullName[]=0 ) const;
197 TString DeterminePath( const TString& fileName, const char defaultPath[] ) const;
198 TString ExtendPath( const char originalPath[], TString newBase ) const;
199 void InitPatterns();
200 TClass* MakeClassFromClassName( const char className[] ) const;
201 TClass* TryMakeClassFromClassName( const char className[] ) const;
202 TClass* MakeClassFromVarName( const char varName[], EContext_t& context,
203 int iter=0);
204 void SetPattern( EContext_t handle, const char regexp[] );
205 int ParseReverse(const char *var_str, int start);
206
207private: // data members
217
218 char* fBuf; // initialized by Hook()
219 int* fpLoc; // initialized by Hook()
220
221 Pattern_t fPat[ kNUM_PAT ][ MAX_LEN_PAT ]; // array of patterns
222 const char* fRegExp[ kNUM_PAT ]; // corresponding regular expression plain text
223 Bool_t fVarIsPointer; // frodo: pointer or not flag
224 Int_t fLastIter; // frodo: iteration counter for recursive MakeClassFromVarName
225
226 ClassDef(TTabCom,0) //Perform command line completion when hitting <TAB>
227};
228
230
231#endif
#define R__EXTERN
Definition: DllImport.h:27
unsigned short Pattern_t
Definition: Match.h:26
char Char_t
Definition: RtypesCore.h:31
unsigned long long ULong64_t
Definition: RtypesCore.h:72
#define ClassDef(name, id)
Definition: Rtypes.h:322
R__EXTERN TTabCom * gTabCom
Definition: TTabCom.h:229
#define MAX_LEN_PAT
Definition: TTabCom.h:42
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition: TClass.h:80
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:1101
const TSeqCollection * GetListOfCppDirectives()
Return the list of CPP directives.
Definition: TTabCom.cxx:475
Int_t Hook(char *buf, int *pLoc, std::ostream &out)
[private]
Definition: TTabCom.cxx:1558
TSeqCollection * fpGlobals
Definition: TTabCom.h:213
ULong64_t fPrevInterpMarker
Definition: TTabCom.h:209
void ClearFiles()
Close all files.
Definition: TTabCom.cxx:252
static TString DetermineClass(const char varName[])
[static utility function]/////////////////////////////
Definition: TTabCom.cxx:792
static Bool_t ExcludedByFignore(TString s)
[static utility function]/////////////////////////////
Definition: TTabCom.cxx:885
void InitPatterns()
[private]
Definition: TTabCom.cxx:2130
void RehashEnvVars()
Environemnt variables rehashing.
Definition: TTabCom.cxx:351
const TSeqCollection * GetListOfSysIncFiles()
Return the list of system include files.
Definition: TTabCom.cxx:620
void ClearAll()
clears all lists except for user names and system include files.
Definition: TTabCom.cxx:317
TSeqCollection * fpDirectives
Definition: TTabCom.h:210
const TSeqCollection * GetListOfFilesInPath(const char path[])
"path" should be initialized with a colon separated list of system directories
Definition: TTabCom.cxx:501
TSeqCollection * fpClasses
Definition: TTabCom.h:208
TSeqCollection * fpEnvVars
Definition: TTabCom.h:211
void ClearSysIncFiles()
Close system files.
Definition: TTabCom.cxx:292
const TSeqCollection * GetListOfEnvVars()
Uses "env" (Unix) or "set" (Windows) to get list of environment variables.
Definition: TTabCom.cxx:520
int * fpLoc
Definition: TTabCom.h:219
TString DeterminePath(const TString &fileName, const char defaultPath[]) const
[private]
Definition: TTabCom.cxx:1483
void CopyMatch(char dest[], const char localName[], const char appendage[]=0, const char fullName[]=0) const
[private]
Definition: TTabCom.cxx:1407
const TSeqCollection * GetListOfPragmas()
Return the list of pragmas.
Definition: TTabCom.cxx:589
char * fBuf
Definition: TTabCom.h:218
static TSeqCollection * NewListOfFilesInPath(const char path[])
[static utility function]/////////////////////////////
Definition: TTabCom.cxx:1042
TClass * MakeClassFromVarName(const char varName[], EContext_t &context, int iter=0)
[private] (does some specific error handling that makes the function unsuitable for general use....
Definition: TTabCom.cxx:2246
Int_t fLastIter
Definition: TTabCom.h:224
const TSeqCollection * GetListOfGlobals()
Return the list of globals.
Definition: TTabCom.cxx:573
Pattern_t fPat[kNUM_PAT][MAX_LEN_PAT]
Definition: TTabCom.h:221
void SetPattern(EContext_t handle, const char regexp[])
[private]
Definition: TTabCom.cxx:2534
TSeqCollection * fpUsers
Definition: TTabCom.h:216
TSeqCollection * fpSysIncFiles
Definition: TTabCom.h:215
TSeqCollection * fpFiles
Definition: TTabCom.h:212
void RehashGlobals()
Reload globals.
Definition: TTabCom.cxx:376
TClass * MakeClassFromClassName(const char className[]) const
[private] (does some specific error handling that makes the function unsuitable for general use....
Definition: TTabCom.cxx:2197
void RehashGlobalFunctions()
Reload global functions.
Definition: TTabCom.cxx:368
void ClearGlobalFunctions()
Forget all global functions seen so far.
Definition: TTabCom.cxx:265
void ClearPragmas()
Forget all pragmas seen so far.
Definition: TTabCom.cxx:280
static Bool_t PathIsSpecifiedInFileName(const TString &fileName)
[static utility function]/////////////////////////////
Definition: TTabCom.cxx:1081
TString ExtendPath(const char originalPath[], TString newBase) const
[private]
Definition: TTabCom.cxx:1526
TTabCom()
Default constructor.
Definition: TTabCom.cxx:175
TTabCom(const TTabCom &)
void RehashPragmas()
Reload pragmas.
Definition: TTabCom.cxx:385
const TSeqCollection * GetListOfClasses()
Return the list of classes.
Definition: TTabCom.cxx:429
void RehashCppDirectives()
Cpp rehashing.
Definition: TTabCom.cxx:342
void RehashUsers()
Reload users.
Definition: TTabCom.cxx:403
const TSeqCollection * GetListOfUsers()
reads from "/etc/passwd"
Definition: TTabCom.cxx:632
static void AppendListOfFilesInDirectory(const char dirName[], TSeqCollection *pList)
[static utility function]/////////////////////////////
Definition: TTabCom.cxx:743
void ClearClasses()
Clear classes and namespace collections.
Definition: TTabCom.cxx:216
TSeqCollection * fpPragmas
Definition: TTabCom.h:214
EContext_t
Definition: TTabCom.h:113
@ kCXX_Global
Definition: TTabCom.h:181
@ kSYS_UserName
Definition: TTabCom.h:121
@ kNUM_PAT
Definition: TTabCom.h:186
@ kUNKNOWN_CONTEXT
Definition: TTabCom.h:114
@ kCXX_IndirectProto
Definition: TTabCom.h:171
@ kCXX_IndirectMember
Definition: TTabCom.h:177
@ kCINT_Exec
Definition: TTabCom.h:134
@ kCXX_ScopeProto
Definition: TTabCom.h:169
@ kCINT_cpp
Definition: TTabCom.h:147
@ kSYS_EnvVar
Definition: TTabCom.h:122
@ kCXX_ScopeMember
Definition: TTabCom.h:175
@ kCXX_GlobalProto
Definition: TTabCom.h:182
@ kSYS_FileName
Definition: TTabCom.h:164
@ kCXX_DirectMember
Definition: TTabCom.h:176
@ kCINT_includeSYS
Definition: TTabCom.h:139
@ kCINT_Load
Definition: TTabCom.h:133
@ kCXX_ConstructorProto
Definition: TTabCom.h:168
@ kCINT_pragma
Definition: TTabCom.h:138
@ kCINT_includePWD
Definition: TTabCom.h:140
@ kCXX_DirectProto
Definition: TTabCom.h:170
@ kCINT_Edit
Definition: TTabCom.h:132
@ kCXX_NewProto
Definition: TTabCom.h:167
@ kCINT_stdin
Definition: TTabCom.h:127
@ kROOT_Load
Definition: TTabCom.h:151
@ kCINT_stdout
Definition: TTabCom.h:125
@ kCINT_stderr
Definition: TTabCom.h:126
@ kCINT_EXec
Definition: TTabCom.h:135
Int_t Complete(const TRegexp &re, const TSeqCollection *pListOfCandidates, const char appendage[], std::ostream &out, TString::ECaseCompare cmp=TString::kExact)
[private]
Definition: TTabCom.cxx:1156
const char * fRegExp[kNUM_PAT]
Definition: TTabCom.h:222
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:2556
virtual ~TTabCom()
Definition: TTabCom.cxx:198
TTabCom & operator=(const TTabCom &)
TCollection * GetListOfGlobalFunctions()
Return the list of global functions.
Definition: TTabCom.cxx:581
void RehashSysIncFiles()
Reload system include files.
Definition: TTabCom.cxx:394
static Bool_t IsDirectory(const char fileName[])
[static utility function]/////////////////////////////
Definition: TTabCom.cxx:1022
EContext_t DetermineContext() const
[private]
Definition: TTabCom.cxx:1459
static TString GetSysIncludePath()
[static utility function]/////////////////////////////
Definition: TTabCom.cxx:921
void ClearEnvVars()
Forget all environment variables seen so far.
Definition: TTabCom.cxx:240
void ClearCppDirectives()
Forget all Cpp directives seen so far.
Definition: TTabCom.cxx:228
void ClearGlobals()
Forget all global variables seen so far.
Definition: TTabCom.cxx:273
void ClearUsers()
Forget all user seen so far.
Definition: TTabCom.cxx:304
TList TContainer
Definition: TTabCom.h:59
void RehashAll()
clears and then rebuilds all lists except for user names and system include files.
Definition: TTabCom.cxx:413
void RehashFiles()
Close files.
Definition: TTabCom.cxx:360
TClass * TryMakeClassFromClassName(const char className[]) const
Same as above but does not print the error message.
Definition: TTabCom.cxx:2226
@ kDebug
Definition: TTabCom.h:111
void RehashClasses()
Do the class rehash.
Definition: TTabCom.cxx:333
TListIter TContIter
Definition: TTabCom.h:60
static Char_t AllAgreeOnChar(int i, const TSeqCollection *pList, Int_t &nGoodStrings)
[static utility function]///////////////////////////////////////////
Definition: TTabCom.cxx:678
Bool_t fVarIsPointer
Definition: TTabCom.h:223
static constexpr double s
#define dest(otri, vertexptr)
Definition: triangle.c:1040