XRootD
Loading...
Searching...
No Matches
XrdPfc::PathTokenizer Struct Reference

#include <XrdPfcPathParseTools.hh>

+ Inheritance diagram for XrdPfc::PathTokenizer:
+ Collaboration diagram for XrdPfc::PathTokenizer:

Public Member Functions

 PathTokenizer (const std::string &path, int max_depth, bool parse_as_lfn)
 
const char * get_dir (int pos)
 
int get_n_dirs ()
 
std::string make_path ()
 
void print_debug ()
 

Public Attributes

std::vector< const char * > m_dirs
 
int m_n_dirs
 
const char * m_reminder
 

Detailed Description

Definition at line 79 of file XrdPfcPathParseTools.hh.

Constructor & Destructor Documentation

◆ PathTokenizer()

XrdPfc::PathTokenizer::PathTokenizer ( const std::string &  path,
int  max_depth,
bool  parse_as_lfn 
)
inline

Definition at line 85 of file XrdPfcPathParseTools.hh.

85 :
86 SplitParser(path, "/"),
87 m_reminder (0),
88 m_n_dirs (0)
89 {
90 // max_depth - maximum number of directories to extract. If < 0, all path elements
91 // are extracted (well, up to 4096). The rest is in m_reminder.
92 // If parse_as_lfn is true store final token into m_reminder, regardless of maxdepth.
93 // This assumes the last token is a file name (and full path is lfn, including the file name).
94
95 if (max_depth < 0)
96 max_depth = 4096;
97 m_dirs.reserve(std::min(pre_count_n_tokens(), max_depth));
98
99 const char *t = 0;
100 for (int i = 0; i < max_depth; ++i)
101 {
102 t = get_token();
103 if (t == 0) break;
104 m_dirs.emplace_back(t);
105 }
106 if (parse_as_lfn && ! has_reminder() && ! m_dirs.empty())
107 {
108 m_reminder = m_dirs.back();
109 m_dirs.pop_back();
110 }
111 else
112 {
114 }
115 m_n_dirs = (int) m_dirs.size();
116 }
std::vector< const char * > m_dirs

References XrdPfc::SplitParser::get_reminder(), XrdPfc::SplitParser::get_token(), XrdPfc::SplitParser::has_reminder(), m_dirs, m_n_dirs, m_reminder, and XrdPfc::SplitParser::pre_count_n_tokens().

+ Here is the call graph for this function:

Member Function Documentation

◆ get_dir()

const char * XrdPfc::PathTokenizer::get_dir ( int  pos)
inline

Definition at line 123 of file XrdPfcPathParseTools.hh.

124 {
125 if (pos >= m_n_dirs) return 0;
126 return m_dirs[pos];
127 }

References m_dirs, and m_n_dirs.

Referenced by XrdPfc::DataFsPurgeshot::find_dir_entry_from_tok().

+ Here is the caller graph for this function:

◆ get_n_dirs()

int XrdPfc::PathTokenizer::get_n_dirs ( )
inline

Definition at line 118 of file XrdPfcPathParseTools.hh.

119 {
120 return m_n_dirs;
121 }

References m_n_dirs.

Referenced by XrdPfc::DataFsPurgeshot::find_dir_entry_from_tok(), and XrdPfc::DirState::find_path_tok().

+ Here is the caller graph for this function:

◆ make_path()

std::string XrdPfc::PathTokenizer::make_path ( )
inline

Definition at line 129 of file XrdPfcPathParseTools.hh.

130 {
131 std::string res;
132 for (std::vector<const char*>::iterator i = m_dirs.begin(); i != m_dirs.end(); ++i)
133 {
134 res += "/";
135 res += *i;
136 }
137 if (m_reminder != 0)
138 {
139 res += "/";
140 res += m_reminder;
141 }
142 return res;
143 }

References m_dirs, and m_reminder.

◆ print_debug()

void XrdPfc::PathTokenizer::print_debug ( )
inline

Definition at line 145 of file XrdPfcPathParseTools.hh.

146 {
147 printf("PathTokenizer::print_debug size=%d\n", m_n_dirs);
148 for (int i = 0; i < m_n_dirs; ++i)
149 {
150 printf(" %2d: %s\n", i, m_dirs[i]);
151 }
152 printf(" rem: %s\n", m_reminder);
153 }

References m_dirs, m_n_dirs, and m_reminder.

Member Data Documentation

◆ m_dirs

std::vector<const char*> XrdPfc::PathTokenizer::m_dirs

◆ m_n_dirs

int XrdPfc::PathTokenizer::m_n_dirs

Definition at line 83 of file XrdPfcPathParseTools.hh.

Referenced by PathTokenizer(), get_dir(), get_n_dirs(), and print_debug().

◆ m_reminder

const char* XrdPfc::PathTokenizer::m_reminder

Definition at line 82 of file XrdPfcPathParseTools.hh.

Referenced by PathTokenizer(), make_path(), and print_debug().


The documentation for this struct was generated from the following file: