XRootD
XrdPfc::SplitParser Struct Reference

#include <XrdPfcPathParseTools.hh>

+ Inheritance diagram for XrdPfc::SplitParser:
+ Collaboration diagram for XrdPfc::SplitParser:

Public Member Functions

 SplitParser (const std::string &s, const char *d)
 
 ~SplitParser ()
 
int fill_argv (std::vector< char * > &argv)
 
char * get_reminder ()
 
char * get_reminder_with_delim ()
 
char * get_token ()
 
std::string get_token_as_string ()
 
bool has_reminder ()
 

Public Attributes

const char * f_delim
 
bool f_first
 
char * f_state
 
char * f_str
 

Detailed Description

Definition at line 12 of file XrdPfcPathParseTools.hh.

Constructor & Destructor Documentation

◆ SplitParser()

XrdPfc::SplitParser::SplitParser ( const std::string &  s,
const char *  d 
)
inline

Definition at line 19 of file XrdPfcPathParseTools.hh.

19  :
20  f_str(strdup(s.c_str())), f_delim(d), f_state(0), f_first(true)
21  {}

◆ ~SplitParser()

XrdPfc::SplitParser::~SplitParser ( )
inline

Definition at line 22 of file XrdPfcPathParseTools.hh.

22 { free(f_str); }

References f_str.

Member Function Documentation

◆ fill_argv()

int XrdPfc::SplitParser::fill_argv ( std::vector< char * > &  argv)
inline

Definition at line 53 of file XrdPfcPathParseTools.hh.

54  {
55  if (!f_first) return 0;
56  int dcnt = 0; { char *p = f_str; while (*p) { if (*(p++) == f_delim[0]) ++dcnt; } }
57  argv.reserve(dcnt + 1);
58  int argc = 0;
59  char *i = strtok_r(f_str, f_delim, &f_state);
60  while (i)
61  {
62  ++argc;
63  argv.push_back(i);
64  // printf(" arg %d : '%s'\n", argc, i);
65  i = strtok_r(0, f_delim, &f_state);
66  }
67  return argc;
68  }

References f_delim, f_first, f_state, and f_str.

◆ get_reminder()

char* XrdPfc::SplitParser::get_reminder ( )
inline

Definition at line 42 of file XrdPfcPathParseTools.hh.

43  {
44  return f_first ? f_str : f_state;
45  }

References f_first, f_state, and f_str.

Referenced by XrdPfc::PathTokenizer::PathTokenizer(), XrdPfc::Cache::ExecuteCommandUrl(), and has_reminder().

+ Here is the caller graph for this function:

◆ get_reminder_with_delim()

char* XrdPfc::SplitParser::get_reminder_with_delim ( )
inline

Definition at line 36 of file XrdPfcPathParseTools.hh.

37  {
38  if (f_first) { return f_str; }
39  else { *(f_state - 1) = f_delim[0]; return f_state - 1; }
40  }

References f_delim, f_first, f_state, and f_str.

Referenced by XrdPfc::Cache::ExecuteCommandUrl().

+ Here is the caller graph for this function:

◆ get_token()

char* XrdPfc::SplitParser::get_token ( )
inline

Definition at line 24 of file XrdPfcPathParseTools.hh.

25  {
26  if (f_first) { f_first = false; return strtok_r(f_str, f_delim, &f_state); }
27  else { return strtok_r(0, f_delim, &f_state); }
28  }

References f_delim, f_first, f_state, and f_str.

Referenced by XrdPfc::PathTokenizer::PathTokenizer(), XrdPfc::Cache::ExecuteCommandUrl(), and get_token_as_string().

+ Here is the caller graph for this function:

◆ get_token_as_string()

std::string XrdPfc::SplitParser::get_token_as_string ( )
inline

Definition at line 30 of file XrdPfcPathParseTools.hh.

31  {
32  char *t = get_token();
33  return std::string(t ? t : "");
34  }

References get_token().

Referenced by XrdPfc::Cache::ExecuteCommandUrl().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ has_reminder()

bool XrdPfc::SplitParser::has_reminder ( )
inline

Definition at line 47 of file XrdPfcPathParseTools.hh.

48  {
49  char *r = get_reminder();
50  return r && r[0] != 0;
51  }

References get_reminder().

Referenced by XrdPfc::Cache::ExecuteCommandUrl().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ f_delim

const char* XrdPfc::SplitParser::f_delim

Definition at line 15 of file XrdPfcPathParseTools.hh.

Referenced by fill_argv(), get_reminder_with_delim(), and get_token().

◆ f_first

bool XrdPfc::SplitParser::f_first

◆ f_state

char* XrdPfc::SplitParser::f_state

◆ f_str

char* XrdPfc::SplitParser::f_str

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