Exemplo n.º 1
0
 void skip_data(word_t offs)
 {
     if (static_cast<word_t>(end_ - cur_) < offs)
     {
         set_file_ptr(get_file_ptr() - (end_ - cur_) + offs);
         fill_buffer();
     }
     else
         cur_ += offs;
 }
Exemplo n.º 2
0
 void drop_back(word_t offs)
 {
     if (static_cast<word_t>(cur_ - buf_) < offs)
     {
         set_file_ptr(get_file_ptr() - (end_ - cur_) - offs);
         fill_buffer();
     }
     else
         cur_ -= offs;
 }
Exemplo n.º 3
0
void 
mexFunction(int nlhs, mxArray *plhs[], 
	    int nrhs, const mxArray *prhs[])
{
   FILE *fob;          /* file object pointer */
   date_t cdate;       /* creation date */
   date_t mdate;       /* modification date */
   char sname[NLEN];   /* structure name */
   int slen;           /* string length */

   /* check argument number */
   if (nrhs != 3) {
      mexErrMsgTxt("3 input arguments expected.");
   }
   
   /* get file handle argument */
   fob = get_file_ptr((mxArray *)prhs[0]);

   /* BGNSTR record */
   if ( write_record_hdr(fob, BGNSTR, 2*sizeof(date_t)) )
      mexErrMsgTxt("failed to write BGNSTR record.");

   /* BGNSTR creation date */
   now(cdate);
   if ( write_word_n(fob, cdate, 6) ) /* NOTE: changes byte order in cdate */
      mexErrMsgTxt("failed to write BGNSTR record (cdate).");

   /* BGNSTR modification date */
   now(mdate);
   if ( write_word_n(fob, mdate, 6) ) /* same as cdate */
      mexErrMsgTxt("failed to write BGNSTR record (mdate).");
   
   /* STRNAME record */
   mxGetString(prhs[1], sname, NLEN-2);
   slen = mxGetN(prhs[1]);  /* string length */
   if (slen > 32) {
      mexPrintf("\nStructure name %s exceeds 32 characters\n\n", sname);
      mexErrMsgTxt("structure name too long.");     
   }
   if (slen % 2)          /* string length is odd */
      slen += 1;
   if ( write_record_hdr(fob, STRNAME, slen) )
      mexErrMsgTxt("failed to write STRNAME record.");
   if ( write_string(fob, sname, slen) )
      mexErrMsgTxt("failed to write STRNAME record (sname).");
}
Exemplo n.º 4
0
void
mexFunction(int nlhs, mxArray *plhs[],
            int nrhs, const mxArray *prhs[])
{
   FILE *fob;
   mxArray *internal;
   element_t *pe;
   double *pd;
   int compound;
   double uu_to_dbu;

   /* check argument number */
   if (nrhs != 4) {
      mexErrMsgTxt("gds_write_element :  4 input arguments expected.");
   }
   
   /* get file handle argument */
   fob = get_file_ptr((mxArray *)prhs[0]);

   /* get unit conversion factor user units --> database units */
   pd = (double *)mxGetData(prhs[2]);
   uu_to_dbu = pd[0];

   /* decide what to do */
   if ( !get_field_ptr((mxArray *)prhs[1], "internal", &internal) )
      mexErrMsgTxt("gds_write_element :  missing internal data field.");
   pe = (element_t *)mxGetData(internal);

   switch (pe->kind) {
     
      case GDS_BOUNDARY:
	 pd = (double *)mxGetData(prhs[3]); /* compound */
	 compound = (int)pd[0];
	 if ( compound )
	    write_compound_boundary(fob, (mxArray *)prhs[1], uu_to_dbu);
	 else
	    write_boundary(fob, (mxArray *)prhs[1], uu_to_dbu);
	 break;

      case GDS_PATH:
	 pd = (double *)mxGetData(prhs[3]); /* compound */
	 compound = (int)pd[0];
	 if ( compound )
	    write_compound_path(fob, (mxArray *)prhs[1], uu_to_dbu);
	 else
	    write_path(fob, (mxArray *)prhs[1], uu_to_dbu);
	 break;

      case GDS_SREF:
	 pd = (double *)mxGetData(prhs[3]); /* compound */
	 compound = (int)pd[0];
	 if ( compound )
	    write_compound_sref(fob, (mxArray *)prhs[1], uu_to_dbu);
	 else
	    write_sref(fob, (mxArray *)prhs[1], uu_to_dbu);
	 break;

      case GDS_AREF:
	 write_aref(fob, (mxArray *)prhs[1], uu_to_dbu);
	 break;

      case GDS_TEXT:
	 write_text(fob, (mxArray *)prhs[1], uu_to_dbu);
	 break;

      case GDS_NODE:
	 write_node(fob, (mxArray *)prhs[1], uu_to_dbu);
	 break;

      case GDS_BOX:
	 write_box(fob, (mxArray *)prhs[1], uu_to_dbu);
	 break;

      default:
	 mexErrMsgTxt("gds_write_element :  unknown element type.");
   }
}
Exemplo n.º 5
0
void
mexFunction(int nlhs, mxArray *plhs[],
            int nrhs, const mxArray *prhs[])
{
   mxArray *data;  /* element data in a structure */
   FILE *fob;
   double *pd;
   double dbu_to_uu;
   int etype;

   /* check argument number */
   if (nrhs != 3) {
      mexErrMsgTxt("3 input arguments expected.");
   }
   if (nlhs != 1) {
      mexErrMsgTxt("one output argument expected.");
   }
   
   /* get file handle argument */
   fob = get_file_ptr((mxArray *)prhs[0]);

   /* get type argument */
   pd = mxGetData(prhs[1]);
   etype = pd[0];

   /* get unit conversion factor: database units --> user units */
   pd = mxGetData(prhs[2]);
   dbu_to_uu = pd[0];

   /* decide what to do */
   switch (etype) {
     
      case BOUNDARY:
	 read_boundary(fob, &data, dbu_to_uu);
	 break;

      case PATH:
	 read_path(fob, &data, dbu_to_uu);
	 break;

      case SREF:
	 read_sref(fob, &data, dbu_to_uu);
	 break;

      case AREF:
	 read_aref(fob, &data, dbu_to_uu);
	 break;

      case TEXT:
	 read_text(fob, &data, dbu_to_uu);
	 break;

      case NODE:
	 read_node(fob, &data, dbu_to_uu);
	 break;

      case BOX:
	 read_box(fob, &data, dbu_to_uu);
	 break;

      default:
         mexErrMsgTxt("gds_read_element :  unknown element type.");
   }

   plhs[0] = data;
}
Exemplo n.º 6
0
 void move_offset(sword_t offs)
 {
     flush_buffer();
     set_file_ptr(get_file_ptr() + offs);
 }