tokenizer.h

Go to the documentation of this file.
00001 #ifndef TOKENIZER_CLASS
00002 #define TOKENIZER_CLASS
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : tokenizer                                                         *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 1997-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00018 #include "textual_dll.h"
00019 
00020 #include <basis/object_base.h>
00021 
00022 // forward.
00023 class string_table;
00024 
00026 
00036 class TEXTUAL_CLASS_STYLE tokenizer : public virtual object_base
00037 {
00038 public:
00039   enum constraints { DEFAULT_MAX_BITS = 7 };
00040 
00041   tokenizer(int max_bits = DEFAULT_MAX_BITS);
00043 
00048   tokenizer(const istring &separator, const istring &assignment,
00049           int max_bits = DEFAULT_MAX_BITS);
00051 
00057   tokenizer(const istring &separator, const istring &assignment,
00058           const istring &quotes, bool nesting = true,
00059           int max_bits = DEFAULT_MAX_BITS);
00061 
00067   tokenizer(const tokenizer &to_copy);
00069 
00070   virtual ~tokenizer();
00071 
00072   IMPLEMENT_CLASS_NAME("tokenizer");
00073 
00074   void set_comment_chars(const istring &comments);
00076 
00080   tokenizer &operator =(const tokenizer &to_copy);
00082 
00083   int symbols() const;
00085 
00086   void reset();
00088 
00089   const string_table &table() const;
00091   string_table &table();
00093 
00094 //fix these docs.
00095   void parse(const istring &to_tokenize);
00097 
00117   istring find(const istring &name) const;
00119 
00129   bool exists(const istring &name) const;
00131 
00132   istring text_form() const;
00134 
00137   void text_form(istring &to_fill) const;
00139 
00140   // dictates whether the output will have spaces between the assignment
00141   // character and the key name and value.  default is to not add them.
00142   bool add_spaces() const { return _add_spaces; }
00143   void add_spaces(bool add_them) { _add_spaces = add_them; }
00144 
00145   bool okay_for_variable_name(char to_check) const;
00147 
00149   const istring &assignments() const;
00151   const istring &separators() const;
00153   const istring &quotes() const;
00155 
00156   bool assignment(char to_check) const;
00158 
00159   bool separator(char to_check) const;
00161 
00162   bool comment_char(char to_check) const;
00164 
00165   bool is_eol_a_separator() const;
00167 
00168   bool quote_mark(char to_check) const;
00170 
00171 private:
00172   string_table *_implementation;  
00173   istring *_assignments;  
00174   istring *_separators;  
00175   istring *_quotes;  
00176   bool _nesting;  
00177   istring *_comments;  
00178   int _comment_number;  
00179   bool _add_spaces;  
00180 };
00181 
00182 #endif
00183 

Generated on Fri Nov 21 04:29:59 2008 for HOOPLE Libraries by  doxygen 1.5.1