15 #ifndef _GDSPARSER_GDSDRIVER_H
16 #define _GDSPARSER_GDSDRIVER_H
22 using std::ostringstream;
30 typedef unsigned int uint32_t;
60 position.resize(2, 0);
65 layer = texttype = presentation = strans = 0;
67 position.resize(2, 0);
81 position.resize(2, 0);
87 position.resize(2, 0);
153 virtual void bit_array_cbk(
const char* ascii_record_type,
const char* ascii_data_type, vector<int>
const& vBitArray);
154 virtual void integer_2_cbk(
const char* ascii_record_type,
const char* ascii_data_type, vector<int>
const& vInteger);
155 virtual void integer_4_cbk(
const char* ascii_record_type,
const char* ascii_data_type, vector<int>
const& vInteger);
156 virtual void real_4_cbk(
const char* ascii_record_type,
const char* ascii_data_type, vector<double>
const& vFloat);
157 virtual void real_8_cbk(
const char* ascii_record_type,
const char* ascii_data_type, vector<double>
const& vFloat);
158 virtual void string_cbk(
const char* ascii_record_type,
const char* ascii_data_type,
string const& str);
166 template <
typename ContainerType>
167 void general_cbk(
string const& ascii_record_type,
string const& ascii_data_type, ContainerType
const& vData);
176 template <
typename ContainerType>
179 if (ascii_record_type ==
"HEADER")
183 else if (ascii_record_type ==
"BGNLIB")
187 else if (ascii_record_type ==
"LIBNAME")
191 else if (ascii_record_type ==
"UNITS")
196 else if (ascii_record_type ==
"BGNSTR")
201 else if (ascii_record_type ==
"STRNAME")
203 m_lib.
vCell.back().cell_name.assign(vData.begin(), vData.end());
205 else if (ascii_record_type ==
"BOUNDARY" || ascii_record_type ==
"BOX")
211 else if (ascii_record_type ==
"TEXT")
217 else if (ascii_record_type ==
"SREF")
223 else if (ascii_record_type ==
"LAYER")
226 m_lib.
vCell.back().vBoundary.back().layer = vData[0];
228 m_lib.
vCell.back().vText.back().layer = vData[0];
230 else if (ascii_record_type ==
"DATATYPE")
233 m_lib.
vCell.back().vBoundary.back().datatype = vData[0];
235 else if (ascii_record_type ==
"TEXTTYPE")
238 m_lib.
vCell.back().vText.back().texttype = vData[0];
240 else if (ascii_record_type ==
"PRESENTATION")
243 m_lib.
vCell.back().vText.back().presentation = vData[0];
245 else if (ascii_record_type ==
"STRANS")
248 m_lib.
vCell.back().vText.back().strans = vData[0];
250 else if (ascii_record_type ==
"MAG")
253 m_lib.
vCell.back().vText.back().mag = vData[0];
255 else if (ascii_record_type ==
"SNAME")
258 m_lib.
vCell.back().vSref.back().sname.assign(vData.begin(), vData.end());
260 else if (ascii_record_type ==
"XY")
264 assert_msg((vData.size() % 2) == 0 && vData.size() > 4,
"invalid size of data array: " << vData.size());
265 for (uint32_t i = 0; i < vData.size(); i += 2)
267 vector<int32_t> point (2);
269 point[1] = vData[i+1];
270 m_lib.
vCell.back().vBoundary.back().vPoint.push_back(point);
275 assert_msg(vData.size() == 2,
"invalid size of data array for "
277 m_lib.
vCell.back().vText.back().position.assign(vData.begin(), vData.end());
281 assert_msg(vData.size() == 2,
"invalid size of data array for "
283 m_lib.
vCell.back().vSref.back().position.assign(vData.begin(), vData.end());
285 else assert_msg(0,
"record XY should only appear in BOUNDARY, BOX, TEXT, SREF");
287 else if (ascii_record_type ==
"STRING")
290 m_lib.
vCell.back().vText.back().content.assign(vData.begin(), vData.end());
292 else if (ascii_record_type ==
"ENDEL")
296 "currently only support BOUNDARY, BOX, and TEXT");
299 else if (ascii_record_type ==
"ENDSTR")
304 else if (ascii_record_type ==
"ENDLIB")
312 else assert_msg(0,
"unsupported record type: " << ascii_record_type);
string m_current
it can be HEADER, LIBRARY, CELL, BOUNDARY, BOX, TEXT, SREF
GdsLib m_lib
when parsed a lib, pass it using add_gds_lib function
void general_cbk(string const &ascii_record_type, string const &ascii_data_type, ContainerType const &vData)
Generalized callback for all cases.
vector< GdsBoundary > vBoundary
array of boundaries
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 real_4_cbk(const char *ascii_record_type, const char *ascii_data_type, vector< double > const &vFloat)
4-byte floating point number callback
void reset()
reset all data members
virtual void bit_array_cbk(const char *ascii_record_type, const char *ascii_data_type, vector< int > const &vBitArray)
bit array callback
string cell_name
cell name
void reset()
reset all data members
int32_t texttype
text type
void reset()
reset all data members
vector< int32_t > position
virtual void string_cbk(const char *ascii_record_type, const char *ascii_data_type, string const &str)
string callback
GdsDataBase redirects callbacks of GdsDataBaseKernel to ascii callbacks
void reset()
reset all data members
virtual void integer_2_cbk(const char *ascii_record_type, const char *ascii_data_type, vector< int > const &vInteger)
2-byte integer callback
string lib_name
library name
string sname
reference name
vector< double > unit
unit
database_type & m_db
database type
int32_t presentation
presentation
namespace for Limbo.GdsParser
vector< vector< int32_t > > vPoint
virtual void integer_4_cbk(const char *ascii_record_type, const char *ascii_data_type, vector< int > const &vInteger)
4-byte integer callback
bool operator()(string const &filename)
Top function for GdsDriver.
int32_t datatype
data type
vector< int32_t > position
position
High-level wrapper class for GdsReader. Everything is saved in an internal data structure and users o...
void reset()
reset all data members
virtual void begin_end_cbk(const char *ascii_record_type)
begin or end indicator of a block
internal structure to store gds information
virtual void add_gds_lib(GdsLib const &)=0
required callback function
GdsDriver(database_type &)
constructor
#define assert_msg(condition, message)
assertion with message
bool read(GdsDriverDataBase &db, string const &filename)
API function for GdsDriver.
vector< GdsText > vText
array of texts