bes  Updated for version 3.20.6
BESTokenizer.h
1 // BESTokenizer.h
2 
3 // This file is part of bes, A C++ back-end server implementation framework
4 // for the OPeNDAP Data Access Protocol.
5 
6 // Copyright (c) 2004-2009 University Corporation for Atmospheric Research
7 // Author: Patrick West <pwest@ucar.edu> and Jose Garcia <jgarcia@ucar.edu>
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 //
23 // You can contact University Corporation for Atmospheric Research at
24 // 3080 Center Green Drive, Boulder, CO 80301
25 
26 // (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005
27 // Please read the full copyright statement in the file COPYRIGHT_UCAR.
28 //
29 // Authors:
30 // pwest Patrick West <pwest@ucar.edu>
31 // jgarcia Jose Garcia <jgarcia@ucar.edu>
32 
33 #ifndef BESTokenizer_h_
34 #define BESTokenizer_h_ 1
35 
36 #include <vector>
37 #include <string>
38 
39 #include "BESObj.h"
40 
67 class BESTokenizer: public BESObj {
68 private:
69  std::vector<std::string> tokens;
70  typedef std::vector<std::string>::iterator tokens_iterator;
71  typedef std::vector<std::string>::const_iterator tokens_citerator;
72  int _counter;
73  unsigned int _number_tokens;
74 
75 public:
76  BESTokenizer();
77  ~BESTokenizer();
78 
79  void tokenize(const char *p);
80  std::string & get_first_token();
81  std::string & get_current_token();
82  std::string & get_next_token();
83  void parse_error(const std::string &s = "");
84  std::string parse_container_name(const std::string &s, unsigned int &type);
85  std::string remove_quotes(const std::string &s);
86 
87  void dump_tokens();
88 
89  virtual void dump(std::ostream &strm) const;
90 };
91 
92 #endif // BESTokenizer_h_
93 
BESTokenizer::dump
virtual void dump(std::ostream &strm) const
dumps information about this object
Definition: BESTokenizer.cc:321
BESTokenizer::parse_container_name
std::string parse_container_name(const std::string &s, unsigned int &type)
parses a container name for constraint and attributes
Definition: BESTokenizer.cc:255
BESTokenizer::tokenize
void tokenize(const char *p)
tokenize the BES request/command string
Definition: BESTokenizer.cc:162
BESTokenizer::dump_tokens
void dump_tokens()
dump the tokens that have been tokenized in the order in which they are parsed.
Definition: BESTokenizer.cc:306
BESObj
top level BES object to house generic methods
Definition: BESObj.h:49
BESTokenizer::get_next_token
std::string & get_next_token()
returns the next token from the token list
Definition: BESTokenizer.cc:123
BESTokenizer
tokenizer for the BES request command string
Definition: BESTokenizer.h:67
BESTokenizer::get_current_token
std::string & get_current_token()
returns the current token from the token list
Definition: BESTokenizer.cc:104
BESTokenizer::get_first_token
std::string & get_first_token()
returns the first token from the token list
Definition: BESTokenizer.cc:88
BESTokenizer::parse_error
void parse_error(const std::string &s="")
throws an exception giving the tokens up to the point of the problem
Definition: BESTokenizer.cc:65
BESTokenizer::remove_quotes
std::string remove_quotes(const std::string &s)
removes quotes from a quoted token
Definition: BESTokenizer.cc:290