Limbo 3.5.4
Loading...
Searching...
No Matches
GdsWriter.h
Go to the documentation of this file.
1
7
8#ifndef _GDSPARSER_GDSWRITER_H
9#define _GDSPARSER_GDSWRITER_H
10
11#include <stdio.h>
12#include <math.h>
13#include <stdlib.h>
14#include <string.h>
15#include <sys/stat.h>
16#include <fcntl.h>
17#include <unistd.h>
18#include <time.h>
19#include <assert.h>
20#include <vector>
21#include <iostream>
22#include <fstream>
23
26#define BYTESWAP 1
27//#define BYTE unsigned char
28
29//#define BOOL int
30//#define TRUE 1
31//#define FALSE 0
32
33//extern BYTE gdsswap;
34//extern short gdsword;
35
37namespace GdsParser
38{
39
41typedef int BOOL;
43typedef unsigned char BYTE;
44
75
78{
79 char *name;
82};
83
84// forward declaration of a writer class
85// which is flexiable to choose std::ofstream or gzstream
86class GdsStream;
87
91{
92 public:
95 GdsWriter(const char* filename);
98
99 /**************** high level interfaces *****************/
102
111 void write_boundary(int layer, int datatype, std::vector<int> const& vx, std::vector<int> const& vy, bool has_last = true);
116 void write_box(int layer, int datatype, int xl, int yl, int xh, int yh);
122 void create_lib(const char* libname, double dbu_uu, double dbu_m);
123
125
126 /**************** low level interfaces *****************/
129
130 void gds_make_next_item( struct gds_itemtype **ci );
131 /* dump one byte in binary format */
132 void gds_bindump( BYTE x );
133 /* Write 8 bytes after converting back to wacky GDS float format. */
134 void gds_write_float( double x );
137 void gds_swap4bytes( BYTE *four );
140 void gds_swap2bytes( BYTE *two );
153 void gds_write_libname( const char *name );
156 void gds_write_strname( const char *name );
159 void gds_write_string( const char *s );
162 void gds_write_sname( const char *s );
169 void gds_write_boxtype( short int dt );
182 void gds_write_layer( short int layer );
185 void gds_write_width( int width );
188 void gds_write_datatype( short int dt );
191 void gds_write_texttype( short int dt );
194 void gds_write_generations( short int gens );
197 void gds_write_pathtype( short int pt );
202 void gds_write_presentation( int font, int vp, int hp );
207 void gds_write_strans( BOOL reflect, BOOL abs_angle, BOOL abs_mag );
215 void gds_write_xy( const int *x, const int *y, int n, bool has_last = true);
219 void gds_write_colrow( int ncols, int nrows );
222 void gds_write_bgnextn( int bgnextn );
225 void gds_write_endextn( int endextn );
229 void gds_write_units( double dbu_uu, double dbu_m );
232 void gds_write_mag( double mag );
235 void gds_write_angle( double angle );
239 void gds_create_lib( const char *libname, double dbu_um );
246 void gds_create_text( const char *str, int x, int y, int layer, int size );
247
249
250 // add by Yibo Lin
256 char* gds_adjust_string(const char* input, int *output_length);
257
258 protected:
259
263 int gds_write(const char* b, std::size_t n);
265 void gds_flush();
266
267 GdsStream* m_os;
268 //int out; // output gds file descriptor
270 short gdsword;
271
272 std::size_t m_capacity;
273 std::size_t m_size;
274 char* m_buffer;
275};
276
277} // namespace GdsParser
278
279#endif
mathematical utilities such as abs
Check string is integer, floating point, number... Convert string to upper/lower cases.
namespace for Limbo.GdsParser
Definition GdsIO.h:20
int BOOL
use integer as bool
Definition GdsWriter.h:41
unsigned char BYTE
use unsigned char as byte
Definition GdsWriter.h:43
void gds_create_text(const char *str, int x, int y, int layer, int size)
wrapper to create text
void gds_write_bgnextn(int bgnextn)
write BGNEXTN
void gds_write_layer(short int layer)
write LAYER
void gds_write_libname(const char *name)
write LIBNAME
void gds_swap2bytes(BYTE *two)
swap bytes
void gds_write_angle(double angle)
write ANGLE
void gds_write_texttype(short int dt)
write TEXTTYPE
void gds_write_units(double dbu_uu, double dbu_m)
write UNITS
void gds_write_strans(BOOL reflect, BOOL abs_angle, BOOL abs_mag)
write STRANS
void gds_write_width(int width)
write WIDTH
void gds_write_endextn(int endextn)
write ENDEXTN
void gds_write_bgnstr()
write BGNSTR
void gds_write_colrow(int ncols, int nrows)
write COLROW
void gds_write_endlib()
write ENDLIB
void gds_create_lib(const char *libname, double dbu_um)
create library with name and unit
void gds_write_sname(const char *s)
write SNAME
std::size_t m_size
output buffer size
Definition GdsWriter.h:273
void gds_write_generations(short int gens)
write GENERATIONS
GdsStream * m_os
output stream
Definition GdsWriter.h:267
void gds_write_bgnlib()
write BGNLIB
void gds_write_strname(const char *name)
write STRNAME
void gds_write_box()
write BOX
void gds_write_datatype(short int dt)
write DATATYPE
void gds_write_string(const char *s)
write STRING
void create_lib(const char *libname, double dbu_uu, double dbu_m)
create GDSII library
void gds_write_endstr()
write ENDSTR
~GdsWriter()
destructor
int gds_write(const char *b, std::size_t n)
void gds_swap4bytes(BYTE *four)
swap bytes
BYTE gdsswap
moved from global variables
Definition GdsWriter.h:269
std::size_t m_capacity
output buffer capacity
Definition GdsWriter.h:272
void write_box(int layer, int datatype, int xl, int yl, int xh, int yh)
write a box object
void gds_write_text()
write TEXT
void write_boundary(int layer, int datatype, std::vector< int > const &vx, std::vector< int > const &vy, bool has_last=true)
write a boundary object
void gds_write_boxtype(short int dt)
write BOXTYPE
void gds_write_aref()
write AREF
char * gds_adjust_string(const char *input, int *output_length)
char * m_buffer
output buffer
Definition GdsWriter.h:274
void gds_write_sref()
write SREF
void gds_flush()
flush all contents in the buffer
void gds_write_path()
write PATH
void gds_write_endel()
write ENDEL
void gds_write_pathtype(short int pt)
write PATHTYPE
GdsWriter(const char *filename)
constructor
short gdsword
move from global variables
Definition GdsWriter.h:270
void gds_write_presentation(int font, int vp, int hp)
write PRESENTATION
void gds_write_header()
write HEADER
void gds_write_xy(const int *x, const int *y, int n, bool has_last=true)
write XY
void gds_write_boundary()
write BOUNDARY
void gds_write_mag(double mag)
write MAG
struct gds_itemtype * item
Definition GdsWriter.h:80
struct gds_celltype * nextcell
Definition GdsWriter.h:81
GDSII item type.
Definition GdsWriter.h:47
struct gds_itemtype * nextitem
Definition GdsWriter.h:73