46 using boost::regex_match;
47 using boost::regex_search;
48 using std::unique_ptr;
51 namespace pexExcept = lsst::pex::exceptions;
65 : PolicySource(fmts), Persistable(), _data(), _pfact()
75 : PolicySource(fmts), Persistable(), _data(data), _pfact()
78 #define PolStr_ERROR_MSG(use, msg, input) \
79 std::ostringstream use; \
80 use << msg << ": '"; \
81 if (input.length() > 40) \
84 use << input.substr(0,40) << "..."; \
96 std::istringstream is(
_data);
98 PolStr_ERROR_MSG(msg,
"failure opening input Policy string",
_data);
99 throw LSST_EXCEPT(pexExcept::IoError, msg.str());
111 PolStr_ERROR_MSG(msg,
"failure reading input Policy string",
_data);
112 throw LSST_EXCEPT(pexExcept::IoError, msg.str());
121 return cacheName(
_formats->recognizeType(line));
134 if (! pfactory.get()) {
136 if (fmtname.empty()) {
137 PolStr_ERROR_MSG(ms,
"Unknown Policy format for string data",
_data);
138 throw LSST_EXCEPT(pexExcept::IoError, ms.str());
140 pfactory =
_formats->getFactory(fmtname);
143 std::unique_ptr<PolicyParser> parser(pfactory->createParser(policy));
145 std::istringstream is(
_data);
147 PolStr_ERROR_MSG(msg,
"failure opening Policy string",
_data);
148 throw LSST_EXCEPT(pexExcept::IoError, msg.str());
definition of the PolicyParser class
definition of the PolicyFile class
virtual void load(Policy &policy)
load the data from this Policy source into a Policy object
a class for creating PAFParser objects
definition of Policy parsing exceptions
static const boost::regex COMMENT
reg-exp for an empty line
virtual const std::string & getFormatName()
return the name of the format that the data is stored in.
SupportedFormats::Ptr _formats
std::shared_ptr< PolicyParserFactory > Ptr
definition of the PAFParserFactory class
definition of Policy-specific exceptions classes
PolicyString(const std::string &data, const SupportedFormats::Ptr &fmts=defaultFormats)
create a PolicyString that's wrapped around a given string.
static const boost::regex CONTENTID
reg-exp for the start of a comment
static const boost::regex SPACE_RE
std::string _data
the policy data
static const std::string FORMAT_NAME
a name for the format
definition of the PolicyString class