104 while ((pos =
nnn.find_first_of(
"- []<>#:&?/\'\"\\")) != std::string::npos)
105 nnn.replace(pos, 1,
"_");
126 prnt->BuildFullName(buf);
227 "When member specified, pointer on object (not member) should be provided; use SetFoundResult");
255 while (rec->fParent) {
347 if (
super.ScanOnlyFields())
361 while (*
separ ==
'/') {
534 return find ? 2 : -1;
560 const char *options =
nullptr;
563 while (
auto obj = iter()) {
564 const char *title = obj->GetTitle();
567 options = title +
pattern1.Length();
571 options = title +
pattern2.Length();
580 url.SetOptions(options);
594 const char *
methods =
url.GetValueFromOptions(
"allow_method");
610 if (!cl || !ptr || rec.Done())
619 while (
auto obj = iter()) {
648 const char *title =
member->GetTitle();
652 if (
member->GetTypeName())
655 if (
member->GetArrayDim() > 0) {
665 }
else if (
member->GetArrayIndex() != 0) {
676 if (
chld.CanExpandItem()) {
715 const char *
pos0 = pos;
716 while (*pos && (*pos !=
'='))
727 while (*pos && (*pos != (
quotes ?
'\"' :
' ')))
744 if (rec.fLevel == 0) {
752 rec.fHasMore =
kTRUE;
768 }
else if (rec.CanExpandItem()) {
808 if (!
chld.GoInside(
master, obj,
nullptr,
this)) {
813 if (
chld.SetResult(obj, obj->
IsA()))
820 while ((next = iter()) !=
nullptr) {
823 if ((next->
GetName() !=
nullptr) && ((*(next->
GetName()) ==
'_') ||
chld.ScanOnlyFields())) {
840 if (
chld.SetResult(obj, obj->
IsA()))
848 while (
auto kobj = iter()) {
881 if (
chld.SetResult(obj, obj->
IsA()))
920 fTopFolder = std::make_unique<TFolder>(
"http",
"Dedicated instance");
939 Error(
"RegisterObject",
"Not found top ROOT folder!!!");
980 if (
chld.GoInside(rec,
nullptr,
"StreamerInfo",
this)) {
984 chld.SetField(
"_module",
"hierarchy");
985 chld.SetField(
"_after_request",
"markAsStreamerInfo");
1005 rec.fSearchPath = path;
1006 if (rec.fSearchPath) {
1007 while (*rec.fSearchPath ==
'/')
1009 if (*rec.fSearchPath == 0)
1010 rec.fSearchPath =
nullptr;
1022 if (!rec.fSearchPath)
1046 rec.fSearchPath = path;
1048 if (*rec.fSearchPath ==
'/')
1050 rec.fStore = &store;
1062 res = (
char *)res +
rdata->GetThisOffset();
1064 res = *((
char **)res);
1137 const char *
path_ = path.c_str();
1142 url.SetOptions(options.c_str());
1145 if (
url.GetValueFromOptions(
"compact"))
1146 compact =
url.GetIntValueFromOptions(
"compact");
1158 return !res.empty();
1170 if ((kind == 0) || (
strcmp(kind,
"Command") != 0)) {
1172 Info(
"ExecuteCmd",
"Entry %s is not a command", path.c_str());
1180 Info(
"ExecuteCmd",
"Entry %s do not defines method for execution", path.c_str());
1190 Info(
"ExecuteCmd",
"Entry %s not allowed for specified user", path.c_str());
1202 url.SetOptions(options.c_str());
1210 Info(
"ExecuteCmd",
"For command %s argument %s not specified in options %s", path.c_str(),
argname.Data(),
1223 Info(
"ExecuteCmd",
"Executing command %s method:%s", path.c_str(),
method.Data());
1228 if (
method.Index(
"this->") == 0) {
1239 Info(
"ExecuteCmd",
"Executing %s",
method.Data());
1244 res = std::to_string(
v);
1265 return !res.empty();
1299 (res[0] == res[res.
Length() - 1])) {
1349 url.SetOptions(options.c_str());
1352 if (
url.GetValueFromOptions(
"number"))
1353 number =
url.GetIntValueFromOptions(
"number");
1356 std::vector<std::string>
mem;
1361 for (
Int_t n = 0;
n < number;
n++) {
1362 const char *next = args;
1363 while ((next <
ends) && (*next !=
'\n'))
1366 Error(
"ProduceMulti",
"Not enough arguments in POST block");
1370 std::string
file1(args, next - args);
1376 std::size_t pos =
file1.find_first_of(
'?');
1377 if (pos != std::string::npos) {
1383 pos =
file1.find_last_of(
'/');
1384 if (pos != std::string::npos) {
1386 file1.erase(0, pos + 1);
1405 mem.emplace_back(std::move(
res1));
1413 for (
unsigned n = 0;
n <
mem.size();
n++)
1416 char *
curr = (
char *)str.data();
1417 for (
unsigned n = 0;
n <
mem.size();
n++) {
1419 *
curr++ = (char)(
l & 0xff);
1421 *
curr++ = (char)(
l & 0xff);
1423 *
curr++ = (char)(
l & 0xff);
1425 *
curr++ = (char)(
l & 0xff);
1426 if (!
mem[
n].empty())
1520 if (file ==
"root.bin")
1523 if (file ==
"root.png")
1526 if (file ==
"root.jpeg")
1529 if (file ==
"root.gif")
1532 if (file ==
"exe.bin")
1535 if (file ==
"root.xml")
1538 if (file ==
"root.json")
1541 if (file ==
"file.root")
1545 if (file ==
"exe.txt")
1548 if (file ==
"exe.json")
1551 if (file ==
"cmd.json")
1554 if (file ==
"item.json")
1557 if (file ==
"item.xml")
1560 if (file ==
"multi.bin")
1563 if (file ==
"multi.json")
1592 if (
tok.Length() == 0)
1600 while ((obj = iter()) !=
nullptr) {
1610 obj =
fold->AddFolder(
tok,
"sub-folder");
1680 Error(
"UnregisterObject",
"Not found top folder");
1685 topf->RecursiveRemove(obj);
1726 Info(
"AccessField",
"Should be special case for top folder, support later");
1738 while (
auto obj = iter()) {
1757 return curr !=
nullptr;
1782 Error(
"AccessField",
"Fail cast to TList");
1799 if (!fullname || !
name)
1805 if (!parent || !obj)
1824 if (!parent || !obj || !
name)
1891 if (
strncmp(icon,
"button;", 7) == 0) {
#define ROOT_VERSION_CODE
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
R__EXTERN TVirtualMutex * gROOTMutex
const char * item_prop_typename
const char * item_prop_realname
const char * item_prop_user
const char * item_prop_autoload
const char * item_prop_more
const char * item_prop_kind
const char * item_prop_arraydim
const char * item_prop_title
const char * item_prop_rootversion
const char * item_prop_hidden
#define R__LOCKGUARD(mutex)
static TString ConvertToJSON(const TObject *obj, Int_t compact=0, const char *member_name=nullptr)
Converts object, inherited from TObject class, to JSON string Lower digit of compact parameter define...
TClass instances represent classes, structs and namespaces in the ROOT type system.
void BuildRealData(void *pointer=nullptr, Bool_t isTransient=kFALSE)
Build a full list of persistent data members.
TList * GetListOfRealData() const
Int_t GetBaseClassOffset(const TClass *toBase, void *address=nullptr, bool isDerivedObject=true)
Long_t Property() const override
Returns the properties of the TClass as a bit field stored as a Long_t value.
TRealData * GetRealData(const char *name) const
Return pointer to TRealData element with name "name".
Collection abstract base class.
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
All ROOT classes may have RTTI (run time type identification) support added.
Describe directory structure in memory.
virtual TList * GetList() const
virtual TList * GetListOfKeys() const
<div class="legacybox"><h2>Legacy Code</h2> TFolder is a legacy interface: there will be no bug fixes...
TCollection * GetListOfFolders() const
virtual void Add(TObject *obj)
Add object to this folder. obj must be a TObject or a TFolder.
virtual void Remove(TObject *obj)
Remove object from this folder. obj must be a TObject or a TFolder.
Contains arguments for single HTTP call.
const char * GetUserName() const
return authenticated user name (0 - when no authentication)
const void * GetPostData() const
return pointer on posted with request data
Long_t GetPostDataLength() const
return length of posted with request data
Book space in a file, create I/O buffers, to fill them, (un)compress them.
T * ReadObject()
To read an object (non deriving from TObject) from the file.
virtual const char * GetClassName() const
Short_t GetCycle() const
Return cycle number associated to this key.
virtual TObject * ReadObj()
To read a TObject* from the file.
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
void Add(TObject *obj) override
The TNamed class is the base class for all named ROOT classes.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title of object.
Collectable string class.
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual const char * ClassName() const
Returns name of class to which the object belongs.
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual const char * GetTitle() const
Returns title of object.
virtual TClass * IsA() const
@ kCanDelete
if object in a list can be deleted
@ kMustCleanup
if object destructor must call RecursiveRemove()
The TRealData class manages the effective list of all data members for a given class.
Structure used to scan hierarchies of ROOT objects.
TString fItemName
! name of current item
Int_t fLevel
! current level of hierarchy
Int_t fRestriction
! restriction 0 - default, 1 - read-only, 2 - full access
Bool_t CanExpandItem()
Returns true when item can be expanded.
TRootSnifferStore * fStore
! object to store results
virtual ~TRootSnifferScanRec()
destructor
void SetField(const char *name, const char *value, Bool_t with_quotes=kTRUE)
Set item field only when creating is specified.
void CloseNode()
Close started node.
Bool_t CanSetFields() const
return true when fields could be set to the hierarchy item
UInt_t fMask
! defines operation kind
void MakeItemName(const char *objname, TString &itemname)
Construct item name, using object name as basis.
Bool_t IsReadyForResult() const
Checks if result will be accepted.
Bool_t SetResult(void *obj, TClass *cl, TDataMember *member=nullptr)
Obsolete, use SetFoundResult instead.
Bool_t fHasMore
! indicates that potentially there are more items can be found
Bool_t IsReadOnly(Bool_t dflt=kTRUE)
Returns read-only flag for current item.
Bool_t GoInside(TRootSnifferScanRec &super, TObject *obj, const char *obj_name=nullptr, TRootSniffer *sniffer=nullptr)
Method verifies if new level of hierarchy should be started with provided object.
void BeforeNextChild()
Indicates that new child for current element will be started.
TRootSnifferScanRec * fParent
! pointer on parent record
void SetRootClass(TClass *cl)
Mark item with ROOT class and correspondent streamer info.
void CreateNode(const char *_node_name)
Starts new node, must be closed at the end.
Int_t fNumChilds
! number of childs
Int_t fNumFields
! number of fields
Bool_t fNodeStarted
! indicate if node was started
Bool_t SetFoundResult(void *obj, TClass *cl, TDataMember *member=nullptr)
Set found element with class and datamember (optional)
const char * fSearchPath
! current path searched
@ kSearch
search for specified item (only objects and collections)
@ kOnlyFields
if set, only fields for specified item will be set (but all fields)
@ kExpand
expand of specified item - allowed to scan object members
@ kCheckChilds
check if there childs, very similar to search
@ kScan
normal scan of hierarchy
@ kActions
mask for actions, only actions copied to child rec
Int_t Depth() const
Returns depth of hierarchy.
TList fItemsNames
! list of created items names, need to avoid duplication
Bool_t Done() const
Method indicates that scanning can be interrupted while result is set.
void BuildFullName(TString &buf, TRootSnifferScanRec *prnt=nullptr)
Produces full name for the current item.
TRootSnifferScanRec()
constructor
Storage of hierarchy scan in TRootSniffer in JSON format.
Storage of hierarchy scan in TRootSniffer in XML format.
Abstract interface for storage of hierarchy scan in TRootSniffer.
Int_t GetResNumChilds() const
TDataMember * GetResMember() const
virtual void CreateNode(Int_t, const char *)
void SetResult(void *_res, TClass *_rescl, TDataMember *_resmemb, Int_t _res_chld, Int_t restr=0)
set pointer on found element, class and number of childs
virtual void CloseNode(Int_t, Int_t)
TClass * GetResClass() const
virtual void BeforeNextChild(Int_t, Int_t, Int_t)
Int_t GetResRestrict() const
virtual void SetField(Int_t, const char *, const char *, Bool_t)
Sniffer of ROOT objects, data provider for THttpServer.
void ScanObjectMembers(TRootSnifferScanRec &rec, TClass *cl, char *ptr)
scan object data members some members like enum or static members will be excluded
const char * GetAutoLoad() const
return name of configured autoload scripts (or 0)
TString fObjectsPath
! default path for registered objects
void ScanHierarchy(const char *topname, const char *path, TRootSnifferStore *store, Bool_t only_fields=kFALSE)
Method scans normal objects, registered in ROOT.
TRootSniffer(const char *name="sniff", const char *objpath="Objects")
constructor
TList fRestrictions
! list of restrictions for different locations
Bool_t RegisterObject(const char *subfolder, TObject *obj)
Register object in subfolder structure.
virtual void ScanObjectChilds(TRootSnifferScanRec &rec, TObject *obj)
scans object childs (if any) here one scans collection, branches, trees and so on
TString fCurrentAllowedMethods
! list of allowed methods, extracted when analyzed object restrictions
virtual Bool_t HasStreamerInfo() const
Bool_t UnregisterObject(TObject *obj)
Unregister (remove) object from folders structures.
virtual void ScanKeyProperties(TRootSnifferScanRec &rec, TKey *key, TObject *&obj, TClass *&obj_class)
Scans TKey properties in special cases load objects from the file.
Bool_t CreateItem(const char *fullname, const char *title)
Create item element.
virtual Bool_t ExecuteCmd(const std::string &path, const std::string &options, std::string &res)
Execute command marked as _kind=='Command'.
Bool_t HasRestriction(const char *item_name)
Made fast check if item with specified name is in restriction list If returns true,...
virtual void ScanObjectProperties(TRootSnifferScanRec &rec, TObject *obj)
Scans object properties here such fields as _autoload or _icon properties depending on class or objec...
virtual void ScanRoot(TRootSnifferScanRec &rec)
scan complete ROOT objects hierarchy For the moment it includes objects in gROOT directory and list o...
Bool_t Produce(const std::string &path, const std::string &file, const std::string &options, std::string &res)
Method produce different kind of data out of object.
virtual Bool_t ProduceJson(const std::string &path, const std::string &options, std::string &res)
Produce JSON data for specified item For object conversion TBufferJSON is used.
void CreateOwnTopFolder()
Create own TFolder structures independent from gROOT This allows to have many independent TRootSniffe...
virtual Bool_t ProduceExe(const std::string &path, const std::string &options, Int_t reskind, std::string &res)
Execute command for specified object.
virtual Bool_t ProduceXml(const std::string &path, const std::string &options, std::string &res)
Produce XML data for specified item.
TString DecodeUrlOptionValue(const char *value, Bool_t remove_quotes=kTRUE)
Method replaces all kind of special symbols, which could appear in URL options.
THttpCallArg * SetCurrentCallArg(THttpCallArg *arg)
set current http arguments, which then used in different process methods For instance,...
void Restrict(const char *path, const char *options)
Restrict access to the specified location.
virtual ULong_t GetItemHash(const char *itemname)
Get hash function for specified item used to detect any changes in the specified object.
Bool_t fReadOnly
! indicate if sniffer allowed to change ROOT structures - like read objects from file
void SetScanGlobalDir(Bool_t on=kTRUE)
When enabled (default), sniffer scans gROOT for files, canvases, histograms.
TObject * GetItem(const char *fullname, TFolder *&parent, Bool_t force=kFALSE, Bool_t within_objects=kTRUE)
Return item from the subfolders structure.
THttpCallArg * fCurrentArg
! current http arguments (if any)
virtual Bool_t ProduceImage(Int_t kind, const std::string &path, const std::string &options, std::string &res)
Method to produce image from specified object.
TObject * FindTObjectInHierarchy(const char *path)
Search element in hierarchy, derived from TObject.
void SetAutoLoad(const char *scripts="")
When specified, _autoload attribute will be always add to top element of h.json/h....
virtual void * FindInHierarchy(const char *path, TClass **cl=nullptr, TDataMember **member=nullptr, Int_t *chld=nullptr)
Search element with specified path Returns pointer on element Optionally one could obtain element cla...
virtual Bool_t ProduceItem(const std::string &path, const std::string &options, std::string &res, Bool_t asjson=kTRUE)
Produce JSON/XML for specified item.
Int_t CheckRestriction(const char *item_name)
Checked if restriction is applied to the item full_item_name should have full path to the item.
virtual Bool_t CallProduceImage(const std::string &kind, const std::string &path, const std::string &options, std::string &res)
Invokes TRootSniffer::ProduceIamge, converting kind into TImage::EImageFileTypes type.
Bool_t IsItemField(TObject *obj) const
Return true when object is TNamed with kItemField bit set.
virtual ~TRootSniffer()
destructor
virtual Bool_t CanDrawClass(TClass *)
Int_t fCurrentRestrict
! current restriction for last-found object
TFolder * GetTopFolder(Bool_t force=kFALSE)
Returns top TFolder instance for the sniffer.
const char * GetItemField(TFolder *parent, TObject *item, const char *name)
Return field for specified item.
std::unique_ptr< TFolder > fTopFolder
! own top TFolder object, used for registering objects
Bool_t CanExploreItem(const char *path)
Method returns true when object has childs or one could try to expand item.
Bool_t SetItemField(const char *fullname, const char *name, const char *value)
Set field for specified item.
Int_t WithCurrentUserName(const char *option)
return 2 when option match to current user name return 1 when option==all return 0 when option does n...
Bool_t RegisterCommand(const char *cmdname, const char *method, const char *icon)
Register command which can be executed from web interface.
TString fAutoLoad
! scripts names, which are add as _autoload parameter to h.json request
Bool_t IsScanGlobalDir() const
Returns true when sniffer allowed to scan global directories.
virtual Bool_t ProduceBinary(const std::string &path, const std::string &options, std::string &res)
Produce binary data for specified item.
TFolder * GetSubFolder(const char *foldername, Bool_t force=kFALSE)
Creates subfolder where objects can be registered.
virtual Bool_t ProduceRootFile(const std::string &path, const std::string &options, std::string &res)
Produce ROOT file for specified item.
void ScanCollection(TRootSnifferScanRec &rec, TCollection *lst, const char *foldername=nullptr, TCollection *keys_lst=nullptr)
Scan collection content.
Bool_t AccessField(TFolder *parent, TObject *item, const char *name, const char *value, TNamed **only_get=nullptr)
Set or get field for the child.
virtual Bool_t ProduceMulti(const std::string &path, const std::string &options, std::string &res, Bool_t asjson=kTRUE)
Process several requests, packing all results into binary or JSON buffer.
Bool_t CanDrawItem(const char *path)
Method verifies if object can be drawn.
virtual Int_t GetLast() const
Returns index of last object in collection.
Int_t Atoi() const
Return integer value of string.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
TObjArray * Tokenize(const TString &delim) const
This function is used to isolate sequential tokens in a TString.
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.
TString & Remove(Ssiz_t pos)
TString & Append(const char *cs)
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
This class represents a WWW compatible URL.