64 if (optlist.length() > 0 &&
65 (optlist.length()<2 ||
66 optlist[0]!=
'|' || optlist[optlist.length()-1]!=
'|') ) {
67 emsg.
Init(
"RparseUrl::Set()",
string(
"optlist \"") + optlist +
68 "\" not enclosed in '|'");
73 if (pdel == 0 && url.length()>0 && url[0] !=
':') pdel = -1;
74 size_t odel = url.find_first_of(
'?',
fScheme.length());
76 if (odel == string::npos) {
77 if (url.length() > pdel+1)
fPath = url.substr(pdel+1);
80 fPath = url.substr(pdel+1,odel-(pdel+1));
85 for (
size_t i=odel+1; i<url.length(); i++) {
88 if (!
AddOpt(key, val, hasval, optlist, emsg))
return false;
100 if (i+1 >= url.length()) {
101 emsg.
Init(
"RparseUrl::Set()",
102 string(
"invalid trailing \\ in url '") + url +
"'");
107 case '\\' : c =
'\\';
break;
108 case ';' : c =
';';
break;
109 default : emsg.
Init(
"RparseUrl::Set()",
110 string(
"invalid \\ escape in url '") +
119 if (key.length() || hasval) {
120 if (!
AddOpt(key, val, hasval, optlist, emsg))
return false;
131 const std::string& scheme,
RerrMsg& emsg)
133 if (
FindScheme(url).length() == 0 && scheme.length() > 0) {
134 string url1 = scheme + string(
":") + url;
135 return Set(url1, optlist, emsg);
138 return Set(url, optlist, emsg);
158 size_t ddel =
fPath.find_last_of(
'/');
159 return (ddel == string::npos) ?
"." :
fPath.substr(0,ddel);
167 size_t ddel =
fPath.find_last_of(
'/');
168 return (ddel != string::npos && ddel+1 <=
fPath.length()) ?
178 size_t ddel = fname.find_last_of(
'.');
179 return (ddel == string::npos) ?
"" : fname.substr(0,ddel);
188 size_t ddel = fname.find_last_of(
'.');
189 return (ddel != string::npos && ddel+1 <= fname.length()) ?
190 fname.substr(ddel+1) :
"";
199 if (it ==
fOptMap.end())
return false;
209 if (it ==
fOptMap.end())
return false;
222 os << bl << (text?text:
"--") <<
"RparseUrl @ " <<
this << endl;
224 os << bl <<
" fUrl: " <<
fUrl << endl;
225 os << bl <<
" fScheme: " <<
fScheme << endl;
226 os << bl <<
" fPath: " <<
fPath << endl;
227 os << bl <<
" fOptMap: " << endl;
229 os << bl <<
" " <<
RosPrintf(o.first.c_str(),
"-s",8)
230 <<
" : " << o.second << endl;
239 const std::string& def)
241 size_t pdel = url.find_first_of(
':');
242 if (pdel == string::npos) {
246 size_t odel = url.find_first_of(
'?');
247 if (odel != string::npos && odel < pdel) {
251 return url.substr(0, pdel);
258 bool hasval,
const std::string& optlist,
RerrMsg& emsg)
262 if (hasval) lkey +=
"=";
264 if (optlist.find(lkey) == string::npos) {
265 emsg.
Init(
"RparseUrl::AddOpt()",
266 string(
"invalid field name '") + lkey +
"'; allowed: '" +
271 fOptMap.emplace(make_pair(key, hasval ? val :
"1"));
void Init(const std::string &meth, const std::string &text)
FIXME_docs.
I/O appicator to generate fill characters.
static std::string FindScheme(const std::string &url, const std::string &def="")
FIXME_docs.
bool FindOpt(const std::string &name) const
FIXME_docs.
bool Set(const std::string &url, const std::string &optlist, RerrMsg &emsg)
FIXME_docs.
std::string FileName() const
FIXME_docs.
bool AddOpt(const std::string &key, const std::string &val, bool hasval, const std::string &optlist, RerrMsg &emsg)
FIXME_docs.
std::string fPath
url path part
RparseUrl()
Default constructor.
std::string FileType() const
FIXME_docs.
std::string fUrl
full url given with open
std::string DirName() const
FIXME_docs.
std::string FileStem() const
FIXME_docs.
virtual ~RparseUrl()
Destructor.
std::string fScheme
url scheme part
virtual void Dump(std::ostream &os, int ind=0, const char *text=0) const
FIXME_docs.
RosPrintfS< bool > RosPrintf(bool value, const char *form=0, int width=0, int prec=0)
Creates a print object for the formatted output of a bool value.
Declaration of class ReventLoop.