XRootD
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 59 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 65 of file XrdPfcPathParseTools.hh.

65  :
66  SplitParser(path, "/"),
67  m_reminder (0),
68  m_n_dirs (0)
69  {
70  // max_depth - maximum number of directories to extract. If < 0, all path elements
71  // are extracted (well, up to 4096). The rest is in m_reminder.
72  // If parse_as_lfn is true store final token into m_reminder, regardless of maxdepth.
73  // This assumes the last token is a file name (and full path is lfn, including the file name).
74 
75  if (max_depth < 0)
76  max_depth = 4096;
77  m_dirs.reserve(std::min(8, max_depth));
78 
79  char *t = 0;
80  for (int i = 0; i < max_depth; ++i)
81  {
82  t = get_token();
83  if (t == 0) break;
84  m_dirs.emplace_back(t);
85  }
86  if (parse_as_lfn && *get_reminder() == 0 && ! m_dirs.empty())
87  {
88  m_reminder = m_dirs.back();
89  m_dirs.pop_back();
90  }
91  else
92  {
94  }
95  m_n_dirs = (int) m_dirs.size();
96  }
std::vector< const char * > m_dirs
SplitParser(const std::string &s, const char *d)

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

+ 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 103 of file XrdPfcPathParseTools.hh.

104  {
105  if (pos >= m_n_dirs) return 0;
106  return m_dirs[pos];
107  }

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 98 of file XrdPfcPathParseTools.hh.

99  {
100  return m_n_dirs;
101  }

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 109 of file XrdPfcPathParseTools.hh.

110  {
111  std::string res;
112  for (std::vector<const char*>::iterator i = m_dirs.begin(); i != m_dirs.end(); ++i)
113  {
114  res += "/";
115  res += *i;
116  }
117  if (m_reminder != 0)
118  {
119  res += "/";
120  res += m_reminder;
121  }
122  return res;
123  }

References m_dirs, and m_reminder.

◆ print_debug()

void XrdPfc::PathTokenizer::print_debug ( )
inline

Definition at line 125 of file XrdPfcPathParseTools.hh.

126  {
127  printf("PathTokenizer::print_debug size=%d\n", m_n_dirs);
128  for (int i = 0; i < m_n_dirs; ++i)
129  {
130  printf(" %2d: %s\n", i, m_dirs[i]);
131  }
132  printf(" rem: %s\n", m_reminder);
133  }

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 63 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 62 of file XrdPfcPathParseTools.hh.

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


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