Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
103 static Bool_t ExcludedByFignore( TString s );
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 &) = delete;
191 TTabCom& operator=(const TTabCom&) = delete;
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, int dest_len, const char *localName, const char *appendage = nullptr, const char *fullName = nullptr) 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:26
unsigned short Pattern_t
Definition Match.h:24
char Char_t
Definition RtypesCore.h:37
unsigned long long ULong64_t
Definition RtypesCore.h:70
#define ClassDef(name, id)
Definition Rtypes.h:342
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t dest
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:81
Collection abstract base class.
Definition TCollection.h:65
Iterator of linked list.
Definition TList.h:191
A doubly linked list.
Definition TList.h:38
Regular expression class.
Definition TRegexp.h:31
Sequenceable collection abstract base class.
Basic string class.
Definition TString.h:139
ECaseCompare
Definition TString.h:277
@ kExact
Definition TString.h:277
static void NoMsg(Int_t errorLevel)
[static utility function]/////////////////////////////
Definition TTabCom.cxx:1114
const TSeqCollection * GetListOfCppDirectives()
Return the list of CPP directives.
Definition TTabCom.cxx:482
Int_t Hook(char *buf, int *pLoc, std::ostream &out)
[private]
Definition TTabCom.cxx:1573
TSeqCollection * fpGlobals
Definition TTabCom.h:213
ULong64_t fPrevInterpMarker
Definition TTabCom.h:209
void ClearFiles()
Close all files.
Definition TTabCom.cxx:254
static TString DetermineClass(const char varName[])
[static utility function]/////////////////////////////
Definition TTabCom.cxx:799
static Bool_t ExcludedByFignore(TString s)
[static utility function]/////////////////////////////
Definition TTabCom.cxx:898
void InitPatterns()
[private]
Definition TTabCom.cxx:2145
void CopyMatch(char *dest, int dest_len, const char *localName, const char *appendage=nullptr, const char *fullName=nullptr) const
[private]
Definition TTabCom.cxx:1421
void RehashEnvVars()
Environemnt variables rehashing.
Definition TTabCom.cxx:353
const TSeqCollection * GetListOfSysIncFiles()
Return the list of system include files.
Definition TTabCom.cxx:627
void ClearAll()
clears all lists except for user names and system include files.
Definition TTabCom.cxx:319
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:508
TSeqCollection * fpClasses
Definition TTabCom.h:208
TSeqCollection * fpEnvVars
Definition TTabCom.h:211
void ClearSysIncFiles()
Close system files.
Definition TTabCom.cxx:294
const TSeqCollection * GetListOfEnvVars()
Uses "env" (Unix) or "set" (Windows) to get list of environment variables.
Definition TTabCom.cxx:527
TTabCom & operator=(const TTabCom &)=delete
int * fpLoc
Definition TTabCom.h:219
TString DeterminePath(const TString &fileName, const char defaultPath[]) const
[private]
Definition TTabCom.cxx:1498
const TSeqCollection * GetListOfPragmas()
Return the list of pragmas.
Definition TTabCom.cxx:596
char * fBuf
Definition TTabCom.h:218
static TSeqCollection * NewListOfFilesInPath(const char path[])
[static utility function]/////////////////////////////
Definition TTabCom.cxx:1055
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:2261
Int_t fLastIter
Definition TTabCom.h:224
const TSeqCollection * GetListOfGlobals()
Return the list of globals.
Definition TTabCom.cxx:580
void SetPattern(EContext_t handle, const char regexp[])
[private]
Definition TTabCom.cxx:2549
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:378
TTabCom(const TTabCom &)=delete
TClass * MakeClassFromClassName(const char className[]) const
[private] (does some specific error handling that makes the function unsuitable for general use....
Definition TTabCom.cxx:2212
void RehashGlobalFunctions()
Reload global functions.
Definition TTabCom.cxx:370
void ClearGlobalFunctions()
Forget all global functions seen so far.
Definition TTabCom.cxx:267
void ClearPragmas()
Forget all pragmas seen so far.
Definition TTabCom.cxx:282
static Bool_t PathIsSpecifiedInFileName(const TString &fileName)
[static utility function]/////////////////////////////
Definition TTabCom.cxx:1094
TString ExtendPath(const char originalPath[], TString newBase) const
[private]
Definition TTabCom.cxx:1541
TTabCom()
Default constructor.
Definition TTabCom.cxx:177
void RehashPragmas()
Reload pragmas.
Definition TTabCom.cxx:387
const TSeqCollection * GetListOfClasses()
Return the list of classes.
Definition TTabCom.cxx:431
void RehashCppDirectives()
Cpp rehashing.
Definition TTabCom.cxx:344
void RehashUsers()
Reload users.
Definition TTabCom.cxx:405
const TSeqCollection * GetListOfUsers()
reads from "/etc/passwd"
Definition TTabCom.cxx:639
static void AppendListOfFilesInDirectory(const char dirName[], TSeqCollection *pList)
[static utility function]/////////////////////////////
Definition TTabCom.cxx:750
void ClearClasses()
Clear classes and namespace collections.
Definition TTabCom.cxx:218
TSeqCollection * fpPragmas
Definition TTabCom.h:214
@ 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:1169
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:2571
virtual ~TTabCom()
Definition TTabCom.cxx:200
TCollection * GetListOfGlobalFunctions()
Return the list of global functions.
Definition TTabCom.cxx:588
@ kDebug
Definition TTabCom.h:111
void RehashSysIncFiles()
Reload system include files.
Definition TTabCom.cxx:396
static Bool_t IsDirectory(const char fileName[])
[static utility function]/////////////////////////////
Definition TTabCom.cxx:1035
EContext_t DetermineContext() const
[private]
Definition TTabCom.cxx:1474
static TString GetSysIncludePath()
[static utility function]/////////////////////////////
Definition TTabCom.cxx:934
void ClearEnvVars()
Forget all environment variables seen so far.
Definition TTabCom.cxx:242
void ClearCppDirectives()
Forget all Cpp directives seen so far.
Definition TTabCom.cxx:230
void ClearGlobals()
Forget all global variables seen so far.
Definition TTabCom.cxx:275
void ClearUsers()
Forget all user seen so far.
Definition TTabCom.cxx:306
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:415
void RehashFiles()
Close files.
Definition TTabCom.cxx:362
TClass * TryMakeClassFromClassName(const char className[]) const
Same as above but does not print the error message.
Definition TTabCom.cxx:2241
Pattern_t fPat[kNUM_PAT][1024]
Definition TTabCom.h:221
void RehashClasses()
Do the class rehash.
Definition TTabCom.cxx:335
TListIter TContIter
Definition TTabCom.h:60
static Char_t AllAgreeOnChar(int i, const TSeqCollection *pList, Int_t &nGoodStrings)
[static utility function]///////////////////////////////////////////
Definition TTabCom.cxx:685
Bool_t fVarIsPointer
Definition TTabCom.h:223