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

77  :
78  SplitParser(path, "/"),
79  m_reminder (0),
80  m_n_dirs (0)
81  {
82  // max_depth - maximum number of directories to extract. If < 0, all path elements
83  // are extracted (well, up to 4096). The rest is in m_reminder.
84  // If parse_as_lfn is true store final token into m_reminder, regardless of maxdepth.
85  // This assumes the last token is a file name (and full path is lfn, including the file name).
86 
87  if (max_depth < 0)
88  max_depth = 4096;
89  m_dirs.reserve(std::min(8, max_depth));
90 
91  char *t = 0;
92  for (int i = 0; i < max_depth; ++i)
93  {
94  t = get_token();
95  if (t == 0) break;
96  m_dirs.emplace_back(t);
97  }
98  if (parse_as_lfn && (get_reminder() == 0 || *get_reminder() == 0) && ! m_dirs.empty())
99  {
100  m_reminder = m_dirs.back();
101  m_dirs.pop_back();
102  }
103  else
104  {
106  }
107  m_n_dirs = (int) m_dirs.size();
108  }
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 115 of file XrdPfcPathParseTools.hh.

116  {
117  if (pos >= m_n_dirs) return 0;
118  return m_dirs[pos];
119  }

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

111  {
112  return m_n_dirs;
113  }

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

122  {
123  std::string res;
124  for (std::vector<const char*>::iterator i = m_dirs.begin(); i != m_dirs.end(); ++i)
125  {
126  res += "/";
127  res += *i;
128  }
129  if (m_reminder != 0)
130  {
131  res += "/";
132  res += m_reminder;
133  }
134  return res;
135  }

References m_dirs, and m_reminder.

◆ print_debug()

void XrdPfc::PathTokenizer::print_debug ( )
inline

Definition at line 137 of file XrdPfcPathParseTools.hh.

138  {
139  printf("PathTokenizer::print_debug size=%d\n", m_n_dirs);
140  for (int i = 0; i < m_n_dirs; ++i)
141  {
142  printf(" %2d: %s\n", i, m_dirs[i]);
143  }
144  printf(" rem: %s\n", m_reminder);
145  }

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

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


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