51 string stripPrefixes(
string urn,
bool strict) {
61 transform(lowered.begin(), lowered.end(), lowered.begin(), ::tolower);
67 if (strict && (numAts > 1 || !hasPrefix))
68 throw LSST_EXCEPT(BadNameError, (
"URN must start with \"urn:eupspkg:\" or \"@urn:eupspkg:\""));
83 void splitAndValidate(
const string& urn, vector<string>& a,
bool strict) {
85 string stripped = stripPrefixes(urn, strict);
89 size_t i = stripped.find(
":");
90 if (i == string::npos) {
91 if (stripped.length() > 0) a.push_back(stripped);
95 a.push_back(stripped.substr(0, i));
96 stripped = stripped.substr(i + 1);
103 if (a.size() < 2 || a.size() > 3)
106 "Wrong number of terms in policy file urn \"" + urn +
"\". "
107 +
"The expected form is "
108 +
"@urn:eupspkg:<product>:[<repository>:]<file> or "
109 +
"@@<product>:[<repository>:]<file>. "
110 +
"Is there a typo in the urn?");
120 vector<string> split;
121 splitAndValidate(urn, split, strictUrn);
132 vector<string> split;
133 splitAndValidate(urn, split, strictUrn);
144 vector<string> split;
145 splitAndValidate(urn, split, strictUrn);
146 if (split.size() == 3)
return split[1];
160 transform(lc.begin(), lc.end(), lc.begin(), ::tolower);
161 while (lc[0] ==
'@') lc = lc.substr(1);
164 const string& stripped = stripPrefixes(s, strict);
165 return s.length() != stripped.length() && s.find(
":") != s.npos;
static std::string productNameFromUrn(const std::string &urn, bool strictUrn=false)
static std::string reposFromUrn(const std::string &urn, bool strictUrn=false)
static bool looksLikeUrn(const std::string &s, bool strict=false)
static const std::string URN_PREFIX
static std::string filePathFromUrn(const std::string &urn, bool strictUrn=false)
static const std::string URN_PREFIX_ABBREV
#define LSST_EXCEPT(type,...)
the definition of the UrnPolicyFile class
Include files required for standard LSST Exception handling.