lsst.pex.policy  13.0-1-g47a359c+10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
lsst::pex::policy::PolicyString Class Reference

a representation of a string containing Policy parameter data More...

#include <PolicyString.h>

Inheritance diagram for lsst::pex::policy::PolicyString:
lsst::pex::policy::PolicySource

Public Member Functions

 PolicyString (const std::string &data, const SupportedFormats::Ptr &fmts=defaultFormats)
 create a PolicyString that's wrapped around a given string. More...
 
 PolicyString (const SupportedFormats::Ptr &fmts=defaultFormats)
 create a "null" Policy formed from an empty string. More...
 
const std::string & getData () const
 return the wrapped policy data as a string More...
 
virtual const std::string & getFormatName ()
 return the name of the format that the data is stored in. More...
 
const std::string & getFormatName () const
 return the name of the format that the data is stored in. More...
 
virtual void load (Policy &policy)
 load the data from this Policy source into a Policy object More...
 
void load (Policy &policy) const
 load the data from this Policy source into a Policy object More...
 
- Public Member Functions inherited from lsst::pex::policy::PolicySource
 PolicySource (SupportedFormats::Ptr fmts=defaultFormats)
 create a Policy file that points a file with given path. More...
 
virtual ~PolicySource ()
 destroy the source More...
 

Static Public Attributes

static const boost::regex SPACE_RE
 
static const boost::regex COMMENT
 reg-exp for an empty line More...
 
static const boost::regex CONTENTID
 reg-exp for the start of a comment More...
 
- Static Public Attributes inherited from lsst::pex::policy::PolicySource
static SupportedFormats::Ptr defaultFormats
 returns true if the given string containing a content identifier indicates that it contains dictionary data. More...
 

Protected Attributes

std::string _data
 the policy data More...
 
- Protected Attributes inherited from lsst::pex::policy::PolicySource
SupportedFormats::Ptr _formats
 

Detailed Description

a representation of a string containing Policy parameter data

This class facilitates reading data from a string. This class is especially useful for supporting string I/O from Python. The data is encoded in a supported format (just like the contents of a policy file).

Definition at line 52 of file PolicyString.h.

Constructor & Destructor Documentation

lsst::pex::policy::PolicyString::PolicyString ( const std::string &  data,
const SupportedFormats::Ptr fmts = defaultFormats 
)
explicit

create a PolicyString that's wrapped around a given string.

Parameters
datathe path to the file, either as a string or a boost::filesystem::path instance
fmtsa SupportedFormats object to use. An instance encapsulates a configured set of known formats.
lsst::pex::policy::PolicyString::PolicyString ( const SupportedFormats::Ptr fmts = defaultFormats)

create a "null" Policy formed from an empty string.

Parameters
fmtsa SupportedFormats object to use. An instance encapsulates a configured set of known formats.

Member Function Documentation

const std::string& lsst::pex::policy::PolicyString::getData ( ) const
inline

return the wrapped policy data as a string

Definition at line 75 of file PolicyString.h.

virtual const std::string& lsst::pex::policy::PolicyString::getFormatName ( )
virtual

return the name of the format that the data is stored in.

This may cause the first few records of the source to be read. In this implementation, once the format is definitely determined, the format name is cached internally, preventing re-determination on the next call to this function.

Exceptions
IOErrorif an error occurs while reading the first few characters of the source stream.

Implements lsst::pex::policy::PolicySource.

const std::string& lsst::pex::policy::PolicyString::getFormatName ( ) const
inline

return the name of the format that the data is stored in.

This may cause the first few records of the source to be read. In this implementation, once the format is definitely determined, the format name is cached internally, preventing re-determination on the next call to this function.

Exceptions
IOErrorif an error occurs while reading the first few characters of the source stream.

Definition at line 88 of file PolicyString.h.

virtual void lsst::pex::policy::PolicyString::load ( Policy policy)
virtual

load the data from this Policy source into a Policy object

Parameters
policythe policy object to load the data into
Exceptions
ParserExceptionif an error occurs while parsing the data
IOErrorif an I/O error occurs while reading from the source stream.

Implements lsst::pex::policy::PolicySource.

void lsst::pex::policy::PolicyString::load ( Policy policy) const
inlinevirtual

load the data from this Policy source into a Policy object

Parameters
policythe policy object to load the data into
Exceptions
ParserExceptionif an error occurs while parsing the data
IOErrorif an I/O error occurs while reading from the source stream.

Implements lsst::pex::policy::PolicySource.

Definition at line 102 of file PolicyString.h.

Member Data Documentation

std::string lsst::pex::policy::PolicyString::_data
protected

the policy data

Definition at line 118 of file PolicyString.h.

const boost::regex lsst::pex::policy::PolicyString::COMMENT
static

reg-exp for an empty line

Definition at line 108 of file PolicyString.h.

const boost::regex lsst::pex::policy::PolicyString::CONTENTID
static

reg-exp for the start of a comment

reg-exp for a Policy content identifier, "<?cfg [format] [content] ?>"

Definition at line 112 of file PolicyString.h.

const boost::regex lsst::pex::policy::PolicyString::SPACE_RE
static

Definition at line 107 of file PolicyString.h.


The documentation for this class was generated from the following file: