|
Packit |
a4aae4 |
// -*- mode: c++; c-basic-offset:4 -*-
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// This file is part of libdap, A C++ implementation of the OPeNDAP Data
|
|
Packit |
a4aae4 |
// Access Protocol.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// Copyright (c) 2011 OPeNDAP, Inc.
|
|
Packit |
a4aae4 |
// Author: James Gallagher <jgallagher@opendap.org>
|
|
Packit |
a4aae4 |
//
|
|
Packit |
a4aae4 |
// This library is free software; you can redistribute it and/or
|
|
Packit |
a4aae4 |
// modify it under the terms of the GNU Lesser General Public
|
|
Packit |
a4aae4 |
// License as published by the Free Software Foundation; either
|
|
Packit |
a4aae4 |
// version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
a4aae4 |
//
|
|
Packit |
a4aae4 |
// This library is distributed in the hope that it will be useful,
|
|
Packit |
a4aae4 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
a4aae4 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
a4aae4 |
// Lesser General Public License for more details.
|
|
Packit |
a4aae4 |
//
|
|
Packit |
a4aae4 |
// You should have received a copy of the GNU Lesser General Public
|
|
Packit |
a4aae4 |
// License along with this library; if not, write to the Free Software
|
|
Packit |
a4aae4 |
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
Packit |
a4aae4 |
//
|
|
Packit |
a4aae4 |
// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
#ifndef KEYWORDS_H_
|
|
Packit |
a4aae4 |
#define KEYWORDS_H_
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
#include <string>
|
|
Packit |
a4aae4 |
#include <set>
|
|
Packit |
a4aae4 |
#include <map>
|
|
Packit |
a4aae4 |
#include <list>
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
using namespace std;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
namespace libdap {
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
/**
|
|
Packit |
a4aae4 |
* Manage keywords for libdap. These are passed in to the library using the
|
|
Packit |
a4aae4 |
* constraint expression - in fact they are an extension of the CE and this
|
|
Packit |
a4aae4 |
* class implements the parsing needed to remove them from the CE so that
|
|
Packit |
a4aae4 |
* the ConstraintExpression evaluator can parse it (because the keywords are
|
|
Packit |
a4aae4 |
* not identifiers in the DDS, they will cause a parse error.
|
|
Packit |
a4aae4 |
*
|
|
Packit |
a4aae4 |
* @note If pointers are added to this code, modify DDS so copying still works!
|
|
Packit |
a4aae4 |
*
|
|
Packit |
a4aae4 |
* @note The keywords are used to specify the DAP version(s) that the client
|
|
Packit |
a4aae4 |
* can understand.
|
|
Packit |
a4aae4 |
*
|
|
Packit |
a4aae4 |
* @note Keywords are parsed and used by the BES in Hyrax - libdap never makes
|
|
Packit |
a4aae4 |
* calls to these methods.
|
|
Packit |
a4aae4 |
*/
|
|
Packit |
a4aae4 |
class Keywords {
|
|
Packit |
a4aae4 |
public:
|
|
Packit |
a4aae4 |
// convenience types
|
|
Packit |
a4aae4 |
typedef string keyword;
|
|
Packit |
a4aae4 |
typedef string keyword_value;
|
|
Packit |
a4aae4 |
typedef set<keyword_value> value_set_t;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
private:
|
|
Packit |
a4aae4 |
/// Holds the keywords and value of the keywords passed in the CE
|
|
Packit |
a4aae4 |
map<keyword, keyword_value> d_parsed_keywords;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
/// Holds all of the keywords
|
|
Packit |
a4aae4 |
map<keyword, value_set_t> d_known_keywords;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual void m_add_keyword(const keyword &word, const keyword_value &value);
|
|
Packit |
a4aae4 |
virtual bool m_is_valid_keyword(const keyword &word, const keyword_value &value) const;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
public:
|
|
Packit |
a4aae4 |
Keywords();
|
|
Packit |
a4aae4 |
virtual ~Keywords();
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual string parse_keywords(const string &ce);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// Is this keyword in the dictionary?
|
|
Packit |
a4aae4 |
virtual bool is_known_keyword(const string &s) const;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// Get a list of all of the keywords parsed
|
|
Packit |
a4aae4 |
virtual list<keyword> get_keywords() const;
|
|
Packit |
a4aae4 |
// Has a particular keyword been parsed
|
|
Packit |
a4aae4 |
virtual bool has_keyword(const keyword &kw) const;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// Get the parsed keyword (and it's dictionary value) of a particular kind
|
|
Packit |
a4aae4 |
virtual keyword_value get_keyword_value(const keyword &kw) const;
|
|
Packit |
a4aae4 |
};
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
}
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
#endif /* KEYWORDS_H_ */
|