Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

PALADIN / PROGRAMS / GDSII / GDSII

.CPP
Скачиваний:
4
Добавлен:
16.04.2013
Размер:
2.42 Кб
Скачать
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
#pragma hdrstop
#include "gdsii.h"

char* Record::RecNames[] =	// Contains records name
			{ "Header", "BgnLib", "LibName","Units", "EndLib", "BgnStr", "StrName",
		"EndStr", "Boundary", "Path", "SRef", "ARef", "Text", "Layer",
		"DataType", "Width", "XY", "EndEl", "SName", "ColRow",
		"TextNode", "Node", "TextType", "Presentation", "Spacing",
		"String", "StrAns", "Mag", "Angle", "UInteger", "UString",
		"RefLibs", "Fonts", "PathType", "Generations", "AttrTable",
		"STypTable", "StrType", "ElFlags", "ElKey", "LinkType",
		"LinkKeys", "NodeType", "PropAttr", "PropValue", "Box",
		"BoxType", "Plex", "BgnExtn", "EndExtn", "TapeNum", "TapeCode",
		"StrClass", "Reserved", "Format", "Mask", "EndMask", "LibDirSize",
		"SRfName", "LibSecur"};


// Reading from stream one record
istream& operator>>(istream& is, Record& rec)
{
// read header
	byte Temp[2];					// temporary buffer for convert GDS-int
										// to Borland C++ int
	is.read(Temp, 2);
	rec.Length = Temp[0]*256 + Temp[1];
	is.read(&rec.RecType, 1);
	is.read(&rec.DataType, 1);
// read Data
	s_int2 LenOfData = rec.Length - 4;	// Because Length include header
	if (LenOfData>0)	{
		rec.Data = new byte[LenOfData];
		is.read(rec.Data, LenOfData);
	}
	else
		rec.Data = 0;
	return is;
}


//
ostream& operator<<(ostream& os, Record& rec)
{
	PointToFunc func = Record::ProcNames[rec.RecType];
	os << (rec.*func)() << endl;
	return os;
}


//
GDSFile::~GDSFile()
{
	RecordsList* temp;

	Reset();
	for(int i=0; i<TotalRecs; i++) {
		temp = Current->NextRec;
		delete Current->Rec;   			// release record
		delete Current;               // release list element
		Current = temp;               // next list element
	}
}


//
void GDSFile::Open()
{
	ifstream ifs(FileName.c_str(), ios::in | ios::binary);
	RecordsList *rl;
//	const int NumRec = 5;

	if (!ifs)
		cout << "error open file: " << FileName << endl;
	else {
		while(!ifs.eof()) {
//		for(int i=0; i<NumRec; i++) {
			rl = new RecordsList;		// Create list element
			rl->Rec = new Record;      // Create record in element
			ifs >> *(rl->Rec);         // Read record from input stream
			rl->NextRec = 0;
			if (!List)
				List = rl;
			else
				Current->NextRec = rl;
			Current = rl;
			TotalRecs++;
			cout << TotalRecs << endl;
		}
	}
}



Соседние файлы в папке GDSII
  • #
    16.04.201324.58 Кб4BUS.GDS
  • #
    16.04.20134.26 Кб5GDSFUNCS.CPP
  • #
    16.04.20132.42 Кб4GDSII.CPP
  • #
    16.04.20134.27 Кб4GDSII.DSW
  • #
    16.04.20133.96 Кб4GDSII.H
  • #
    16.04.201331.86 Кб4GDSII.IDE
  • #
    16.04.20138.05 Кб5GDSII.MBT
  • #
    16.04.20137.73 Кб4GDSII.MRT