Source
// get the parameter set from a line of <src>text</src>. <src>preamble</src> is prepended to exception messages.
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//# Internet email: aips2-request@nrao.edu.
//# Postal address: AIPS++ Project Office
//# National Radio Astronomy Observatory
//# 520 Edgemont Road
//# Charlottesville, VA 22903-2475 USA
//#
namespace casa {
// <summary>
// Parse and store regions and annotations from an ascii region file
// </summary>
// <author>Dave Mehringer</author>
// <use visibility=export>
// <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
// </reviewed>
// <prerequisite>
// </prerequisite>
// <etymology>
// This is a class designed to parse and store regions and annotations from an ascii region file
// </etymology>
// <synopsis>
// This class is for parsing and storing regions and annotations from an ascii region (CRTF) file.
// The format spec can be found at
// https://casa.nrao.edu/casadocs-devel/stable/imaging/image-analysis/region-file-format
// </synopsis>
class RegionTextParser {
public:
static const casacore::Int CURRENT_VERSION;
static const casacore::Regex MAGIC;
// because of nonstandard access patterns, be careful when using ParamValue and ParamSet
// outside this class. These should probably be made into full fledged classes at some
// point.
struct ParamValue {
casacore::Double doubleVal;
casacore::Int intVal;
casacore::String stringVal;
casacore::Bool boolVal;
AnnotationBase::LineStyle lineStyleVal;
AnnotationBase::FontStyle fontStyleVal;
std::shared_ptr<std::pair<casacore::MFrequency, casacore::MFrequency> > freqRange;
casacore::Vector<casacore::Stokes::StokesTypes> stokes;
AnnotationBase::RGB color;
std::vector<casacore::Int> intVec;
};
using ParamSet = std::map<AnnotationBase::Keyword, ParamValue>;
RegionTextParser() = delete;
// <group>
// differentiating between the filename and simple text constructors
// <src>globalOverrideChans</src> override all spectral selections in the file
// or text by using this channel selection<src>
// <src>globalOverrideStokes</src> override all correlation selections in the file
// or text by using this polarization selection<src>
// <src>prependRegion</src> allows one to specify region(s) that will be prepended to
// any text in <src>filename</src> or <src>text</src>
// <src>requireLCRegion</src> forces the parser to create AsciiAnnotationFileLines