Limbo 3.5.4
Loading...
Searching...
No Matches
test_reader.cpp
Go to the documentation of this file.
1
7
8#include <iostream>
10using std::cout;
11using std::endl;
12
15{
18 {
19 cout << "constructing AsciiDataBase" << endl;
20 }
21
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 }
31
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 }
40
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 }
49
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 }
58
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 }
67
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 }
76
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 }
123
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 }
133
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 }
142
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 }
151
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 }
160
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 }
169
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 }
178
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/* ===========================================
222example 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
227EnumDataBase edb;
228boost::iostreams::filtering_istream in;
229in.push(boost::iostreams::gzip_decompressor());
230in.push(boost::iostreams::file_source(argv[1]));
231
232cout << "test enum api\n" << GdsParser::read(edb, in) << endl;
233=========================================== */
234
239int 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}
read GDSII file
GdsDataBase redirects callbacks of GdsDataBaseKernel to ascii callbacks.
Definition GdsReader.h:82
Kernel callbacks for GdsReader. These callbacks use enum for record_type and data_type,...
Definition GdsReader.h:40
bool read(GdsDriverDataBase &db, string const &filename)
API function for GdsDriver.
const char * gds_record_ascii(int record_type)
Definition GdsRecords.h:329
const char * gds_data_ascii(int data_type)
Definition GdsRecords.h:347
test ascii callbacks
virtual void begin_end_cbk(const char *ascii_record_type)
begin or end indicator of a block
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
virtual void bit_array_cbk(const char *ascii_record_type, const char *ascii_data_type, vector< int > const &vBitArray)
bit array callback
virtual void string_cbk(const char *ascii_record_type, const char *ascii_data_type, string const &str)
string 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
virtual void integer_2_cbk(const char *ascii_record_type, const char *ascii_data_type, vector< int > const &vInteger)
2-byte integer callback
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 ...
AsciiDataBase()
constructor
virtual void integer_4_cbk(const char *ascii_record_type, const char *ascii_data_type, vector< int > const &vInteger)
4-byte integer callback
test enum callbacks
virtual void integer_4_cbk(GdsParser::GdsRecords::EnumType record_type, GdsParser::GdsData::EnumType data_type, vector< int > const &vInteger)
4-byte integer callback
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 begin_end_cbk(GdsParser::GdsRecords::EnumType record_type)
begin or end indicator of a block
virtual void string_cbk(GdsParser::GdsRecords::EnumType record_type, GdsParser::GdsData::EnumType data_type, string const &str)
string callback
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
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 ...
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
EnumDataBase()
constructor
EnumType
enum type of data type
Definition GdsRecords.h:222
EnumType
enum type of GDSII records
Definition GdsRecords.h:23
int main()