Limbo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
test_reader.cpp
Go to the documentation of this file.
1 
8 #include <iostream>
10 using std::cout;
11 using std::endl;
12 
15 {
18  {
19  cout << "constructing AsciiDataBase" << endl;
20  }
26  virtual void bit_array_cbk(const char* ascii_record_type, const char* ascii_data_type, vector<int> const& vBitArray)
27  {
28  cout << __func__ << endl;
29  this->general_cbk(ascii_record_type, ascii_data_type, vBitArray);
30  }
35  virtual void integer_2_cbk(const char* ascii_record_type, const char* ascii_data_type, vector<int> const& vInteger)
36  {
37  cout << __func__ << endl;
38  this->general_cbk(ascii_record_type, ascii_data_type, vInteger);
39  }
44  virtual void integer_4_cbk(const char* ascii_record_type, const char* ascii_data_type, vector<int> const& vInteger)
45  {
46  cout << __func__ << endl;
47  this->general_cbk(ascii_record_type, ascii_data_type, vInteger);
48  }
53  virtual void real_4_cbk(const char* ascii_record_type, const char* ascii_data_type, vector<double> const& vFloat)
54  {
55  cout << __func__ << endl;
56  this->general_cbk(ascii_record_type, ascii_data_type, vFloat);
57  }
62  virtual void real_8_cbk(const char* ascii_record_type, const char* ascii_data_type, vector<double> const& vFloat)
63  {
64  cout << __func__ << endl;
65  this->general_cbk(ascii_record_type, ascii_data_type, vFloat);
66  }
71  virtual void string_cbk(const char* ascii_record_type, const char* ascii_data_type, string const& str)
72  {
73  cout << __func__ << endl;
74  this->general_cbk(ascii_record_type, ascii_data_type, str);
75  }
78  virtual void begin_end_cbk(const char* ascii_record_type)
79  {
80  cout << __func__ << endl;
81  this->general_cbk(ascii_record_type, "", vector<int>(0));
82  }
83 
90  template <typename ContainerType>
91  void general_cbk(string const& ascii_record_type, string const& ascii_data_type, ContainerType const& data)
92  {
93  cout << "ascii_record_type: " << ascii_record_type << endl
94  << "ascii_data_type: " << ascii_data_type << endl
95  << "data size: " << data.size() << endl;
96  if (ascii_record_type == "UNITS")
97  {
98  }
99  else if (ascii_record_type == "BOUNDARY")
100  {
101  }
102  else if (ascii_record_type == "LAYER")
103  {
104  }
105  else if (ascii_record_type == "XY")
106  {
107  cout << data.size() << endl;
108  }
109  else if (ascii_record_type == "ENDEL")
110  {
111  }
112  }
113 };
114 
117 {
120  {
121  cout << "constructing EnumDataBase" << endl;
122  }
128  virtual void bit_array_cbk(GdsParser::GdsRecords::EnumType record_type, GdsParser::GdsData::EnumType data_type, vector<int> const& vBitArray)
129  {
130  cout << __func__ << endl;
131  this->general_cbk(record_type, data_type, vBitArray);
132  }
137  virtual void integer_2_cbk(GdsParser::GdsRecords::EnumType record_type, GdsParser::GdsData::EnumType data_type, vector<int> const& vInteger)
138  {
139  cout << __func__ << endl;
140  this->general_cbk(record_type, data_type, vInteger);
141  }
146  virtual void integer_4_cbk(GdsParser::GdsRecords::EnumType record_type, GdsParser::GdsData::EnumType data_type, vector<int> const& vInteger)
147  {
148  cout << __func__ << endl;
149  this->general_cbk(record_type, data_type, vInteger);
150  }
155  virtual void real_4_cbk(GdsParser::GdsRecords::EnumType record_type, GdsParser::GdsData::EnumType data_type, vector<double> const& vFloat)
156  {
157  cout << __func__ << endl;
158  this->general_cbk(record_type, data_type, vFloat);
159  }
164  virtual void real_8_cbk(GdsParser::GdsRecords::EnumType record_type, GdsParser::GdsData::EnumType data_type, vector<double> const& vFloat)
165  {
166  cout << __func__ << endl;
167  this->general_cbk(record_type, data_type, vFloat);
168  }
173  virtual void string_cbk(GdsParser::GdsRecords::EnumType record_type, GdsParser::GdsData::EnumType data_type, string const& str)
174  {
175  cout << __func__ << endl;
176  this->general_cbk(record_type, data_type, str);
177  }
181  {
182  cout << __func__ << endl;
183  this->general_cbk(record_type, GdsParser::GdsData::NO_DATA, vector<int>(0));
184  }
185 
192  template <typename ContainerType>
193  void general_cbk(GdsParser::GdsRecords::EnumType record_type, GdsParser::GdsData::EnumType data_type, ContainerType const& data)
194  {
195  cout << "ascii_record_type: " << GdsParser::gds_record_ascii(record_type) << endl
196  << "ascii_data_type: " << GdsParser::gds_data_ascii(data_type) << endl
197  << "data size: " << data.size() << endl;
198  switch (record_type)
199  {
200  case GdsParser::GdsRecords::UNITS:
201  break;
202  case GdsParser::GdsRecords::BOUNDARY:
203  break;
204  case GdsParser::GdsRecords::LAYER:
205  cout << "LAYER = " << data[0] << endl;
206  break;
207  case GdsParser::GdsRecords::XY:
208  for (typename ContainerType::const_iterator it = data.begin(); it != data.end(); ++it)
209  cout << *it << " ";
210  cout << endl;
211  cout << data.size() << endl;
212  break;
213  case GdsParser::GdsRecords::ENDEL:
214  break;
215  default:
216  break;
217  }
218  }
219 };
220 
221 /* ===========================================
222 example to read .gds.gz
223 #include <boost/iostreams/filter/gzip.hpp>
224 #include <boost/iostreams/device/file.hpp>
225 #include <boost/iostreams/filtering_stream.hpp>
226 
227 EnumDataBase edb;
228 boost::iostreams::filtering_istream in;
229 in.push(boost::iostreams::gzip_decompressor());
230 in.push(boost::iostreams::file_source(argv[1]));
231 
232 cout << "test enum api\n" << GdsParser::read(edb, in) << endl;
233 =========================================== */
234 
239 int main(int argc, char** argv)
240 {
241  if (argc > 1)
242  {
243  AsciiDataBase adb;
244  cout << "test ascii api\n" << GdsParser::read(adb, argv[1]) << endl;
245  EnumDataBase edb;
246  cout << "test enum api\n" << GdsParser::read(edb, argv[1]) << endl;
247  }
248  else cout << "at least 1 argument is required" << endl;
249 
250  return 0;
251 }
AsciiDataBase()
constructor
Definition: test_reader.cpp:17
virtual void real_8_cbk(GdsParser::GdsRecords::EnumType record_type, GdsParser::GdsData::EnumType data_type, vector< double > const &vFloat)
8-byte floating point number callback
virtual void real_8_cbk(const char *ascii_record_type, const char *ascii_data_type, vector< double > const &vFloat)
8-byte floating point number callback
Definition: test_reader.cpp:62
void general_cbk(string const &ascii_record_type, string const &ascii_data_type, ContainerType const &data)
A generic callback function handles all other callback functions. It is not efficient but concise as ...
Definition: test_reader.cpp:91
EnumType
enum type of data type
Definition: GdsRecords.h:222
virtual void real_4_cbk(GdsParser::GdsRecords::EnumType record_type, GdsParser::GdsData::EnumType data_type, vector< double > const &vFloat)
4-byte floating point number callback
virtual void integer_2_cbk(GdsParser::GdsRecords::EnumType record_type, GdsParser::GdsData::EnumType data_type, vector< int > const &vInteger)
2-byte integer callback
virtual void bit_array_cbk(GdsParser::GdsRecords::EnumType record_type, GdsParser::GdsData::EnumType data_type, vector< int > const &vBitArray)
bit array callback
const char * gds_data_ascii(int data_type)
Definition: GdsRecords.h:347
GdsDataBase redirects callbacks of GdsDataBaseKernel to ascii callbacks
Definition: GdsReader.h:81
virtual void bit_array_cbk(const char *ascii_record_type, const char *ascii_data_type, vector< int > const &vBitArray)
bit array callback
Definition: test_reader.cpp:26
virtual void begin_end_cbk(const char *ascii_record_type)
begin or end indicator of a block
Definition: test_reader.cpp:78
virtual void begin_end_cbk(GdsParser::GdsRecords::EnumType record_type)
begin or end indicator of a block
void general_cbk(GdsParser::GdsRecords::EnumType record_type, GdsParser::GdsData::EnumType data_type, ContainerType const &data)
A generic callback function handles all other callback functions. It is not efficient but concise as ...
int main(int argc, char **argv)
main function
virtual void integer_2_cbk(const char *ascii_record_type, const char *ascii_data_type, vector< int > const &vInteger)
2-byte integer callback
Definition: test_reader.cpp:35
Kernel callbacks for GdsReader. These callbacks use enum for record_type and data_type, which is faster than ascii callbacks.
Definition: GdsReader.h:39
virtual void real_4_cbk(const char *ascii_record_type, const char *ascii_data_type, vector< double > const &vFloat)
4-byte floating point number callback
Definition: test_reader.cpp:53
const char * gds_record_ascii(int record_type)
Definition: GdsRecords.h:329
virtual void integer_4_cbk(const char *ascii_record_type, const char *ascii_data_type, vector< int > const &vInteger)
4-byte integer callback
Definition: test_reader.cpp:44
virtual void string_cbk(GdsParser::GdsRecords::EnumType record_type, GdsParser::GdsData::EnumType data_type, string const &str)
string callback
test enum callbacks
read GDSII file
virtual void integer_4_cbk(GdsParser::GdsRecords::EnumType record_type, GdsParser::GdsData::EnumType data_type, vector< int > const &vInteger)
4-byte integer callback
EnumType
enum type of GDSII records
Definition: GdsRecords.h:23
virtual void string_cbk(const char *ascii_record_type, const char *ascii_data_type, string const &str)
string callback
Definition: test_reader.cpp:71
test ascii callbacks
Definition: test_reader.cpp:14
EnumDataBase()
constructor
bool read(GdsDriverDataBase &db, string const &filename)
API function for GdsDriver.