srecord  1.65.0
ti_txt.h
Go to the documentation of this file.
1 //
2 // srecord - manipulate eprom load files
3 // Copyright (C) 2007, 2008, 2010, 2011, 2013 Peter Miller
4 //
5 // This program is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or (at your
8 // option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
13 // License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 //
18 
19 #ifndef SRECORD_INPUT_FILE_ti_txt_H
20 #define SRECORD_INPUT_FILE_ti_txt_H
21 
22 #include <srecord/input/file.h>
23 
24 namespace srecord {
25 
26 /**
27  * The srecord::input_file_ti_txt class is used to repesent the parse
28  * state when reading a ti_txt (MSP430) format input file.
29  */
31  public input_file
32 {
33 public:
34  /**
35  * The destructor.
36  */
37  virtual ~input_file_ti_txt();
38 
39  /**
40  * The create class method is used to create new dynamically
41  * allocated instances of this class.
42  *
43  * @param file_name
44  * The name of the file to be read.
45  * @returns
46  * smart pointer to new instance
47  */
48  static pointer create(const std::string &file_name);
49 
50 protected:
51  // See base class for documentation.
52  bool read(record &record);
53 
54  // See base class for documentation.
55  const char *get_file_format_name(void) const;
56 
57  // See base class for documentation.
58  int format_option_number(void) const;
59 
60 private:
61  /**
62  * The constructor.
63  *
64  * @param file_name
65  * The name of the file to be read.
66  */
67  input_file_ti_txt(const std::string &file_name);
68 
69  /**
70  * The garbage_warning instance variable is used to remember whether
71  * a warning has already been issued if the file contains garbage.
72  */
73  bool garbage_warning;
74 
75  /**
76  * The seen_some_input instance variable is used to remember whether
77  * any data has been seen in the input to date.
78  */
79  bool seen_some_input;
80 
81  /**
82  * The address instance variable is used to remember where we are
83  * up to in the input file, so it may be associated with data bytes.
84  */
85  unsigned long address;
86 
87  enum token_t
88  {
89  token_start_up,
90  token_at,
91  token_end_of_file,
92  token_junk,
93  token_number,
94  token_q
95  };
96 
97  /**
98  * the token instance variable is used to remember the type of the
99  * most recent token, as determined by the get_next_token method.
100  */
101  token_t token;
102 
103  /**
104  * the token_value instance variable is used to remember the value
105  * of the most recent token, as determined by the get_next_token
106  * method. Only meaningful for token_number, zero otherwise.
107  */
108  unsigned long token_value;
109 
110  /**
111  * The address_warning instance variable is used to remember
112  * whether or not we have already warned about addresses which are
113  * too large.
114  */
115  bool address_warning;
116 
117  /**
118  * The get_next_token method is used to partition the input into
119  * the next symbol. All the digits of a hexadecimal number are
120  * considered a single symbol.
121  */
122  void get_next_token(void);
123 
124  /**
125  * The default constructor. Do not use.
126  */
128 
129  /**
130  * The copy constructor. Do not use.
131  */
133 
134  /**
135  * The assignment operator. Do not use.
136  */
137  input_file_ti_txt &operator=(const input_file_ti_txt &);
138 };
139 
140 };
141 
142 #endif // SRECORD_INPUT_FILE_ti_txt_H
143 // vim: set ts=8 sw=4 et :
The srecord::input_file_ti_txt class is used to repesent the parse state when reading a ti_txt (MSP43...
Definition: ti_txt.h:32
virtual ~input_file_ti_txt()
The destructor.
static pointer create(const std::string &file_name)
The create class method is used to create new dynamically allocated instances of this class.
bool read(record &record)
The read method is used to read one record from the input.
const char * get_file_format_name(void) const
The get_file_format_name method is used to find out the name of the file format being read.
int format_option_number(void) const
The format_option_number method is used to obtain the option number, which can then be turned into te...
The srecord::input_file class is used to represent an generic input file.
Definition: file.h:37
std::shared_ptr< input > pointer
Definition: input.h:41
The srecord::record class is used to represent a data record read from a file.
Definition: record.h:35