0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Tokenizer.h
Go to the documentation of this file.
1 /* -*- c++ -*-
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; version 3 of the
9  * License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
26 
27 #ifndef Common_ClusterDefinition_Tokenizer_h
28 #define Common_ClusterDefinition_Tokenizer_h
29 
30 #include "Token.h"
31 
32 #include <memory>
33 #include <string>
34 
35 namespace Hypertable { namespace ClusterDefinitionFile {
36 
37  using namespace std;
38 
41 
43  class Tokenizer {
44 
45  public:
46 
52  Tokenizer(const string &fname);
53 
60  Tokenizer(const string &fname, const string &content);
61 
66  string dirname();
67 
77  bool next(Token &token);
78 
79  private:
80 
88  int identify_line_type(const char *base, const char *end);
89 
110  bool accumulate(const char **basep, const char *end, int type, Token &token);
111 
113  string m_fname;
115  string m_content;
117  const char *m_next {};
119  size_t m_line {};
120  };
121 
123  typedef shared_ptr<Tokenizer> TokenizerPtr;
124 
126 
127 }}
128 
129 #endif // Common_ClusterDefinition_Tokenizer_h
STL namespace.
Cluster definition file token.
Definition: Token.h:43
shared_ptr< Tokenizer > TokenizerPtr
Smart pointer to Tokenizer.
Definition: Tokenizer.h:123
Splits cluster definition file into tokens.
Definition: Tokenizer.h:43
Hypertable definitions
string m_fname
Pathname of cluster definition file.
Definition: Tokenizer.h:113
Declarations for Token.
string m_content
Content of cluster definition file.
Definition: Tokenizer.h:115