LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
PAFParser.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008, 2009, 2010 LSST Corporation.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <http://www.lsstcorp.org/LegalNotices/>.
23  */
24 
35 #ifndef LSST_PEX_POLICY_PAF_TOKENIZER_H
36 #define LSST_PEX_POLICY_PAF_TOKENIZER_H
37 
38 #include <iostream>
39 
40 #include "lsst/daf/base/Citizen.h"
42 #include "lsst/pex/policy/Policy.h"
43 
44 #include <boost/regex.hpp>
45 
46 namespace lsst {
47 namespace pex {
48 namespace policy {
49 namespace paf {
50 
54 class PAFParser : public PolicyParser {
55 public:
56 
61  PAFParser(Policy& policy);
62 
71  PAFParser(Policy& policy, bool strict);
72 
76  virtual ~PAFParser();
77 
84  virtual int parse(std::istream& is);
85 
86 private:
87  // read next line from stream into the line string
88  std::ios::iostate _nextLine(std::istream& is, std::string& line);
89 
90  // push a line back onto the stream
91  void _pushBackLine(const std::string& line);
92 
93  int _parseIntoPolicy(std::istream& is, Policy& policy);
94  int _addValue(const std::string& propname, std::string& value,
95  Policy& policy, std::istream& is);
96 
97  static const boost::regex COMMENT_LINE;
98  static const boost::regex EMPTY_LINE;
99  static const boost::regex SPACE_SRCH;
100  static const boost::regex PARAM_SRCH;
101  static const boost::regex NAME_MTCH;
102  static const boost::regex OPEN_SRCH;
103  static const boost::regex CLOSE_SRCH;
104  static const boost::regex DOUBLE_VALUE;
105  static const boost::regex INT_VALUE;
106  static const boost::regex ATRUE_VALUE;
107  static const boost::regex AFALSE_VALUE;
108  static const boost::regex QQSTRING_VALUE;
109  static const boost::regex QSTRING_VALUE;
110  static const boost::regex QQSTRING_START;
111  static const boost::regex QSTRING_START;
112  static const boost::regex QQSTRING_EMPTYSTART;
113  static const boost::regex QSTRING_EMPTYSTART;
114  static const boost::regex QQSTRING_END;
115  static const boost::regex QSTRING_END;
116  static const boost::regex BARE_STRING_LINE;
117  static const boost::regex BARE_STRING;
118  static const boost::regex URN_VALUE;
119  static const boost::regex FILE_VALUE;
120 
121  // the policy reference, Policy& _pol, is a member of the parent class
122  std::list<std::string> _buffer;
123  int _lineno;
124  int _depth;
125 };
126 
127 
128 }}}} // end lsst::pex::policy::paf
129 #endif // LSST_PEX_POLICY_PAF_PAFPARSER_H
static const boost::regex SPACE_SRCH
Definition: PAFParser.h:99
an abstract class for parsing serialized Policy data and loading it into a Policy object...
Definition: PolicyParser.h:47
definition of the PolicyParser class
static const boost::regex QQSTRING_END
Definition: PAFParser.h:114
static const boost::regex PARAM_SRCH
Definition: PAFParser.h:100
static const boost::regex QSTRING_END
Definition: PAFParser.h:115
static const boost::regex AFALSE_VALUE
Definition: PAFParser.h:107
a container for holding hierarchical configuration data in memory.
Definition: Policy.h:169
static const boost::regex BARE_STRING
Definition: PAFParser.h:117
std::ios::iostate _nextLine(std::istream &is, std::string &line)
static const boost::regex EMPTY_LINE
Definition: PAFParser.h:98
int _addValue(const std::string &propname, std::string &value, Policy &policy, std::istream &is)
static const boost::regex OPEN_SRCH
Definition: PAFParser.h:102
static const boost::regex QQSTRING_EMPTYSTART
Definition: PAFParser.h:112
static const boost::regex BARE_STRING_LINE
Definition: PAFParser.h:116
static const boost::regex DOUBLE_VALUE
Definition: PAFParser.h:104
virtual int parse(std::istream &is)
void _pushBackLine(const std::string &line)
static const boost::regex QQSTRING_VALUE
Definition: PAFParser.h:108
static const boost::regex NAME_MTCH
Definition: PAFParser.h:101
static const boost::regex FILE_VALUE
Definition: PAFParser.h:119
static const boost::regex COMMENT_LINE
Definition: PAFParser.h:97
a parser for reading PAF-formatted data into a Policy object
Definition: PAFParser.h:54
static const boost::regex ATRUE_VALUE
Definition: PAFParser.h:106
static const boost::regex CLOSE_SRCH
Definition: PAFParser.h:103
static const boost::regex QSTRING_START
Definition: PAFParser.h:111
int _parseIntoPolicy(std::istream &is, Policy &policy)
static const boost::regex URN_VALUE
Definition: PAFParser.h:118
static const boost::regex QSTRING_VALUE
Definition: PAFParser.h:109
static const boost::regex QQSTRING_START
Definition: PAFParser.h:110
std::list< std::string > _buffer
Definition: PAFParser.h:122
static const boost::regex QSTRING_EMPTYSTART
Definition: PAFParser.h:113
static const boost::regex INT_VALUE
Definition: PAFParser.h:105