XRootD
Loading...
Searching...
No Matches
XrdOucMapP2X.hh
Go to the documentation of this file.
1
#ifndef __XrdOucMAPP2X__
2
#define __XrdOucMAPP2X__
3
/******************************************************************************/
4
/* */
5
/* X r d O u c M a p P 2 X . h h */
6
/* */
7
/* (c) 2021 by the Board of Trustees of the Leland Stanford, Jr., University */
8
/* All Rights Reserved */
9
/* Produced by Andrew Hanushevsky for Stanford University under contract */
10
/* DE-AC02-76-SFO0515 with the Department of Energy */
11
/* */
12
/* This file is part of the XRootD software suite. */
13
/* */
14
/* XRootD is free software: you can redistribute it and/or modify it under */
15
/* the terms of the GNU Lesser General Public License as published by the */
16
/* Free Software Foundation, either version 3 of the License, or (at your */
17
/* option) any later version. */
18
/* */
19
/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22
/* License for more details. */
23
/* */
24
/* You should have received a copy of the GNU Lesser General Public License */
25
/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26
/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27
/* */
28
/* The copyright holder's institutional names and contributor's names may not */
29
/* be used to endorse or promote products derived from this software without */
30
/* specific prior written permission of the institution or contributor. */
31
/******************************************************************************/
32
33
#include <strings.h>
34
#include <cstdlib>
35
36
template
<
class
T>
37
class
XrdOucMapP2X
38
{
39
public
:
40
41
XrdOucMapP2X<T>
*
Find
(
const
char
*path)
42
{
XrdOucMapP2X<T>
*p = Next;
43
int
plen = strlen(path);
44
while
(p && plen <= p->PLen)
45
{
if
(plen == p->PLen && !strcmp(p->Path, path))
46
return
p;
47
p = p->Next;
48
}
49
return
0;
50
}
51
52
void
Insert
(
XrdOucMapP2X<T>
*newp)
53
{
XrdOucMapP2X<T>
*pp = 0, *p = Next;
54
while
(p && newp->PLen < p->PLen)
55
{pp = p; p = p->Next;}
56
newp->Next = p;
57
if
(pp) pp->Next = newp;
58
else
Next = newp;
59
}
60
61
bool
isEmpty
() {
return
Next == 0;}
62
63
const
char
*
theName
() {
return
Name;}
64
65
XrdOucMapP2X<T>
*
theNext
() {
return
Next;}
66
67
const
char
*
thePath
() {
return
Path;}
68
69
T
theValu
() {
return
Valu;}
70
71
void
RepName
(
const
char
*newname)
72
{
if
(Path) {free(Name); Name = strdup(newname);}}
73
74
void
RepValu
(T arg) {Valu = arg;}
75
76
XrdOucMapP2X<T>
*
Match
(
const
char
*pd,
const
int
pl=0)
77
{
int
plen = (pl ? pl : strlen(pd));
78
XrdOucMapP2X<T>
*p = Next;
79
while
(p && plen >= p->PLen)
80
{
if
(!strncmp(pd, p->Path, p->PLen))
return
p;
81
p=p->Next;
82
}
83
return
0;
84
}
85
86
XrdOucMapP2X
() : Next(0), Name(0), Path(0), PLen(0), Valu(0) {}
87
88
XrdOucMapP2X
(
const
char
*path,
const
char
*name, T arg=0)
89
: Next(0), Name(strdup(name)), Path(strdup(path)),
90
PLen(strlen(path)), Valu(arg) {}
91
92
~XrdOucMapP2X
() {
if
(Path) free(Path);
if
(Name) free(Name);}
93
94
private
:
95
XrdOucMapP2X<T>
*Next;
96
char
*Name;
97
char
*
Path
;
98
int
PLen;
99
T Valu;
100
};
101
#endif
Path
XrdOucString Path
Definition
XrdSecpwdSrvAdmin.cc:160
XrdOucMapP2X
Definition
XrdOucMapP2X.hh:38
XrdOucMapP2X::isEmpty
bool isEmpty()
Definition
XrdOucMapP2X.hh:61
XrdOucMapP2X::thePath
const char * thePath()
Definition
XrdOucMapP2X.hh:67
XrdOucMapP2X::RepName
void RepName(const char *newname)
Definition
XrdOucMapP2X.hh:71
XrdOucMapP2X::Insert
void Insert(XrdOucMapP2X< T > *newp)
Definition
XrdOucMapP2X.hh:52
XrdOucMapP2X::~XrdOucMapP2X
~XrdOucMapP2X()
Definition
XrdOucMapP2X.hh:92
XrdOucMapP2X::Match
XrdOucMapP2X< T > * Match(const char *pd, const int pl=0)
Definition
XrdOucMapP2X.hh:76
XrdOucMapP2X::Find
XrdOucMapP2X< T > * Find(const char *path)
Definition
XrdOucMapP2X.hh:41
XrdOucMapP2X::theValu
T theValu()
Definition
XrdOucMapP2X.hh:69
XrdOucMapP2X::theNext
XrdOucMapP2X< T > * theNext()
Definition
XrdOucMapP2X.hh:65
XrdOucMapP2X::XrdOucMapP2X
XrdOucMapP2X()
Definition
XrdOucMapP2X.hh:86
XrdOucMapP2X::XrdOucMapP2X
XrdOucMapP2X(const char *path, const char *name, T arg=0)
Definition
XrdOucMapP2X.hh:88
XrdOucMapP2X::theName
const char * theName()
Definition
XrdOucMapP2X.hh:63
XrdOucMapP2X::RepValu
void RepValu(T arg)
Definition
XrdOucMapP2X.hh:74
XrdOuc
XrdOucMapP2X.hh
Generated by
1.13.1