feisty meow concerns codebase 2.140
variable_tokenizer.h
Go to the documentation of this file.
1#ifndef TOKENIZER_CLASS
2#define TOKENIZER_CLASS
3
4/*
5* Name : variable_tokenizer
6* Author : Chris Koeritz
7**
8* Copyright (c) 1997-$now By Author. This program is free software; you can *
9* redistribute it and/or modify it under the terms of the GNU General Public *
10* License as published by the Free Software Foundation; either version 2 of *
11* the License or (at your option) any later version. This is online at: *
12* http://www.fsf.org/copyleft/gpl.html *
13* Please send any updates to: fred@gruntose.com *
14*/
15
16#include <basis/contracts.h>
18
19namespace configuration {
20
22
32class variable_tokenizer : public virtual basis::root_object
33{
34public:
36
39
45 int max_bits = DEFAULT_MAX_BITS);
47
54 const basis::astring &quotes, bool nesting = true,
55 int max_bits = DEFAULT_MAX_BITS);
57
65
66 virtual ~variable_tokenizer();
67
68 DEFINE_CLASS_NAME("variable_tokenizer");
69
70 void set_comment_chars(const basis::astring &comments);
72
78
79 int symbols() const;
81
82 void reset();
84
85 const structures::string_table &table() const;
89
90//fix these docs.
91 bool parse(const basis::astring &to_tokenize);
93
113 basis::astring find(const basis::astring &name) const;
115
125 bool exists(const basis::astring &name) const;
127
130
133 void text_form(basis::astring &to_fill) const;
135
136 // dictates whether the output will have spaces between the assignment
137 // character and the key name and value. default is to not add them.
138 bool add_spaces() const { return _add_spaces; }
139 void add_spaces(bool add_them) { _add_spaces = add_them; }
140
141 bool okay_for_variable_name(char to_check) const;
143
145 const basis::astring &assignments() const;
147 const basis::astring &separators() const;
149 const basis::astring &quotes() const;
151
152 bool assignment(char to_check) const;
154
155 bool separator(char to_check) const;
157
158 bool comment_char(char to_check) const;
160
161 bool is_eol_a_separator() const;
163
164 bool quote_mark(char to_check) const;
166
167private:
168 structures::string_table *_implementation;
169 basis::astring *_assignments;
170 basis::astring *_separators;
171 basis::astring *_quotes;
172 bool _nesting;
173 basis::astring *_comments;
174 int _comment_number;
175 bool _add_spaces;
176};
177
178} //namespace.
179
180#endif
181
Provides a dynamically resizable ASCII character string.
Definition astring.h:35
Manages a bank of textual definitions of variables.
variable_tokenizer & operator=(const variable_tokenizer &to_copy)
makes this variable_tokenizer identical to "to_copy".
bool okay_for_variable_name(char to_check) const
true if "to_check" is a valid variable name character.
bool comment_char(char to_check) const
true if "to_check" is a registered comment character.
bool is_eol_a_separator() const
reports whether any of the separators are an EOL character.
const structures::string_table & table() const
provides a constant peek at the string_table holding the values.
bool exists(const basis::astring &name) const
returns true if the "name" exists in the variable_tokenizer.
void reset()
clears all of the entries out.
bool assignment(char to_check) const
true if "to_check" is a valid assignment operator.
const basis::astring & separators() const
provides a peek at the separators list.
const basis::astring & assignments() const
provides a peek at the assignments list.
basis::astring find(const basis::astring &name) const
locates the value for a variable named "name" if it exists.
bool separator(char to_check) const
true if "to_check" is a valid separator.
int symbols() const
returns the number of entries in the variable_tokenizer.
bool quote_mark(char to_check) const
true if "to_check" is a member of the quotes list.
basis::astring text_form() const
creates a new token list as a string of text.
void set_comment_chars(const basis::astring &comments)
establishes a set of characters in "comments" as the comment items.
const basis::astring & quotes() const
provides a peek at the quotes list.
DEFINE_CLASS_NAME("variable_tokenizer")
bool parse(const basis::astring &to_tokenize)
parses the string using our established sentinel characters.
Provides a symbol_table that holds strings as the content.