47 _myos =
new std::ostringstream();
58 : _myos(new std::ofstream(file.c_str(), append ? std::ios_base::app
59 : std::ios_base::trunc)),
62 _myos->exceptions(std::ofstream::failbit | std::ofstream::badbit);
75 std::ostringstream *ss =
dynamic_cast<std::ostringstream*
>(
_os);
76 if (ss)
return ss->str();
85 std::ofstream *fs =
dynamic_cast<std::ofstream*
>(
_os);
96 (*_os) <<
"#<?cfg paf policy ?>" << std::endl;
99 Policy::StringArray::const_iterator ni;
100 for(ni=names.begin(); ni != names.end(); ++ni) {
102 const std::type_info& tp = policy.typeOf(*ni);
103 if (tp ==
typeid(
bool)) {
106 else if (tp ==
typeid(
int)) {
109 else if (tp ==
typeid(
double)) {
112 else if (tp ==
typeid(std::string)) {
118 else if (tp ==
typeid(Persistable::Ptr)) {
122 throw LSST_EXCEPT(pexExcept::LogicError,
"Policy: unexpected type for name=" + *ni);
125 catch (NameNotFound&) {
134 std::vector<bool> vals;
135 vals.push_back(value);
140 std::vector<int> vals;
141 vals.push_back(value);
146 std::vector<double> vals;
147 vals.push_back(value);
152 const std::string& value)
154 std::vector<std::string> vals;
155 vals.push_back(value);
160 std::vector<Policy::Ptr> vals;
166 const PolicyFile& value)
168 std::vector<Policy::FilePtr> vals;
virtual void writeBool(const std::string &name, bool value)
definition of the PolicyFile class
table::Key< std::string > name
boost::shared_ptr< PolicyFile > FilePtr
virtual void writeInts(const std::string &name, const Policy::IntArray &values)=0
boost::shared_ptr< PropertySet > Ptr
boost::shared_ptr< Policy > Ptr
the definition of the PolicyWriter class
virtual void writeFiles(const std::string &name, const Policy::FilePtrArray &values)=0
virtual void write(const Policy &policy, bool doDecl=false)
lsst::daf::base::PropertySet PropertySet
virtual void writeBools(const std::string &name, const Policy::BoolArray &values)=0
virtual void writeDoubles(const std::string &name, const Policy::DoubleArray &values)=0
std::vector< std::string > StringArray
virtual void writeFile(const std::string &name, const PolicyFile &value)
virtual void writeString(const std::string &name, const std::string &value)
virtual void writeStrings(const std::string &name, const Policy::StringArray &values)=0
virtual void writeDouble(const std::string &name, double value)
virtual void writeInt(const std::string &name, int value)
#define LSST_EXCEPT(type,...)
virtual void writePolicy(const std::string &name, const Policy &value)
Base class for all persistable classes.
PolicyWriter(std::ostream *out=0)
virtual void writePolicies(const std::string &name, const Policy::PolicyPtrArray &values)=0