15#ifndef _GDSPARSER_GDSDRIVER_H
16#define _GDSPARSER_GDSDRIVER_H
22using std::ostringstream;
30typedef unsigned int uint32_t;
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);
176template <
typename ContainerType>
179 if (ascii_record_type ==
"HEADER")
183 else if (ascii_record_type ==
"BGNLIB")
187 else if (ascii_record_type ==
"LIBNAME")
189 m_lib.lib_name.assign(vData.begin(), vData.end());
191 else if (ascii_record_type ==
"UNITS")
193 m_lib.unit[0] = vData[0];
194 m_lib.unit[1] = vData[1];
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")
208 limboAssertMsg(!
m_lib.vCell.empty(),
"%s block must be in a BGNSTR block", ascii_record_type.c_str());
211 else if (ascii_record_type ==
"TEXT")
214 limboAssertMsg(!
m_lib.vCell.empty(),
"%s block must be in a BGNSTR block", ascii_record_type.c_str());
217 else if (ascii_record_type ==
"SREF")
220 limboAssertMsg(!
m_lib.vCell.empty(),
"%s block must be in a BGNSTR block", ascii_record_type.c_str());
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 limboAssertMsg((vData.size() % 2) == 0 && vData.size() > 4,
"invalid size of data array: %lu", 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 limboAssertMsg(vData.size() == 2,
"invalid size of data array for %s: %lu",
277 m_lib.vCell.back().vText.back().position.assign(vData.begin(), vData.end());
281 limboAssertMsg(vData.size() == 2,
"invalid size of data array for %s: %lu",
283 m_lib.vCell.back().vSref.back().position.assign(vData.begin(), vData.end());
285 else limboAssertMsg(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 limboAssertMsg(0,
"unsupported record type: %s", ascii_record_type.c_str());
#define limboAssertMsg(condition, args...)
custom assertion with message
GdsDataBase redirects callbacks of GdsDataBaseKernel to ascii callbacks.
virtual void add_gds_lib(GdsLib const &)=0
required callback function
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
bool operator()(string const &filename)
Top function for GdsDriver.
string m_current
it can be HEADER, LIBRARY, CELL, BOUNDARY, BOX, TEXT, SREF
virtual void begin_end_cbk(const char *ascii_record_type)
begin or end indicator of a block
virtual void bit_array_cbk(const char *ascii_record_type, const char *ascii_data_type, vector< int > const &vBitArray)
bit array callback
GdsLib m_lib
when parsed a lib, pass it using add_gds_lib function
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 integer_4_cbk(const char *ascii_record_type, const char *ascii_data_type, vector< int > const &vInteger)
4-byte integer callback
virtual void string_cbk(const char *ascii_record_type, const char *ascii_data_type, string const &str)
string callback
GdsDriver(database_type &)
constructor
database_type & m_db
database type
void general_cbk(string const &ascii_record_type, string const &ascii_data_type, ContainerType const &vData)
Generalized callback for all cases.
virtual void integer_2_cbk(const char *ascii_record_type, const char *ascii_data_type, vector< int > const &vInteger)
2-byte integer callback
namespace for Limbo.GdsParser
bool read(GdsDriverDataBase &db, string const &filename)
API function for GdsDriver.
internal structure to store gds information
int32_t datatype
data type
vector< vector< int32_t > > vPoint
void reset()
reset all data members
vector< GdsText > vText
array of texts
string cell_name
cell name
vector< GdsBoundary > vBoundary
array of boundaries
void reset()
reset all data members
vector< double > unit
unit
void reset()
reset all data members
string lib_name
library name
void reset()
reset all data members
string sname
reference name
vector< int32_t > position
int32_t presentation
presentation
void reset()
reset all data members
int32_t texttype
text type
vector< int32_t > position
position