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) {
96 stripped = stripped.
substr(i + 1);
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?");
121 splitAndValidate(urn, split, strictUrn);
133 splitAndValidate(urn, split, strictUrn);
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);
static std::string reposFromUrn(const std::string &urn, bool strictUrn=false)
Extract the repository name from a URN, or "" if none.
static const std::string URN_PREFIX_ABBREV
The prefix that a Policy URN starts with.
static std::string filePathFromUrn(const std::string &urn, bool strictUrn=false)
Extract the local file path from a URN.
A base class for image defects.
static const std::string URN_PREFIX
The prefix that a Policy URN starts with.
static bool looksLikeUrn(const std::string &s, bool strict=false)
Does s look like a URN? That is, does it start with URN_PREFIX or URN_PREFIX_ABBREV?
static std::string productNameFromUrn(const std::string &urn, bool strictUrn=false)
Extract the product name from a URN.
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
the definition of the UrnPolicyFile class