Пример #1
0
        public int mWriteMap(RecordSetMD aRecordSetMD)
        //throws com.WDataSci.WDS.WDSException
        {
            try {
                if (this.Header.Buffer == null)
                {
                    throw new com.WDataSci.WDS.WDSException("Error, Header buffer not set before WriteMap!");
                }

                long nColumns = aRecordSetMD.nColumns();
                int  nColumnNameMaxByteLength = (int)(this.Header.MaxStringByteLength);

                DBB buf = this.Header.Buffer;
                buf.cAsUsualLayout("WDSH", nColumns, 40, 2 * nColumnNameMaxByteLength);
                buf.position(0, 0, 0);

                int bptr = 0;

                //write leading data
                buf.PutLayerFLenString(0, "WDSH", 8, 0);
                buf.PutLayerLong(0, buf.nDBBRequiredBytes);
                buf.PutLayerLong(0, buf.nDBBLeadingBytes);
                buf.PutLayerLong(0, buf.nDBBFLenBytes);
                buf.PutLayerLong(0, buf.nDBBVLenBytes);
                buf.PutLayerLong(0, buf.nRecords);
                buf.PutLayerLong(0, buf.nRecordFLenBytes);
                buf.PutLayerLong(0, buf.nRecordVLenBytes);

                buf.position(buf.ptr, 0, 0);
                //here bptr is relative only to layer 1
                bptr = 0;

                for (int jj = 0; jj < nColumns; jj++, bptr += (int)buf.nRecordFLenBytes)
                {
                    aRecordSetMD.Column[jj].Consistency();
                    buf.position(buf.ptr, bptr, buf.vlenptr);
                    buf.PutLayerVLenString(1, aRecordSetMD.Column[jj].Name, nColumnNameMaxByteLength, 2);
                    if (aRecordSetMD.Column[jj].MapKey != null)
                    {
                        buf.PutLayerVLenString(1, aRecordSetMD.Column[jj].MapKey.getValue(), nColumnNameMaxByteLength, 2);
                    }
                    else
                    {
                        buf.PutLayerVLenString(1, "", nColumnNameMaxByteLength, 2);
                    }
                    buf.PutLayerInt(1, aRecordSetMD.Column[jj].DTyp.AsInt());
                    buf.PutLayerLong(1, aRecordSetMD.Column[jj].ByteMemLength);
                    buf.PutLayerLong(1, aRecordSetMD.Column[jj].ByteMaxLength);
                }

                return(0);
            }
            catch (Exception e) {
                throw new com.WDataSci.WDS.WDSException("Error in writing output map to DBB", e);
            }
        }